-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
181 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
python/src/multigroup/AverageFissionEnergyRelease.python.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// system includes | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
|
||
// local includes | ||
#include "NDItk/multigroup/AverageFissionEnergyRelease.hpp" | ||
#include "tools/views/views-python.hpp" | ||
#include "definitions.hpp" | ||
#include "read.hpp" | ||
|
||
// namespace aliases | ||
namespace python = pybind11; | ||
|
||
namespace multigroup { | ||
|
||
void wrapAverageFissionEnergyRelease( python::module& module, python::module& ) { | ||
|
||
// type aliases | ||
using Record = njoy::NDItk::multigroup::AverageFissionEnergyRelease; | ||
|
||
// wrap views created by this record | ||
|
||
// create the record | ||
python::class_< Record > record( | ||
|
||
module, | ||
"AverageFissionEnergyRelease", | ||
"An average fission energy release record for multigroup neutron and photon data" | ||
); | ||
|
||
// wrap the record | ||
record | ||
.def( | ||
|
||
python::init< double, double, double, | ||
double, double, double >(), | ||
python::arg( "total" ), python::arg( "prompt" ), python::arg( "neutrons" ), | ||
python::arg( "gammas" ), python::arg( "betas" ), python::arg( "fragments" ), | ||
"Initialise the record\n\n" | ||
"Arguments:\n" | ||
" self the table\n" | ||
" total the total energy release (including delayed particles\n" | ||
" and neutrinos)\n" | ||
" prompt the recoverable energy release (total minus delayed\n" | ||
" particles and neutrinos)\n" | ||
" neutrons the energy release through prompt neutrons\n" | ||
" gammas the energy release through prompt gammas\n" | ||
" betas the energy release through delayed betas\n" | ||
" fragments the kinetic energy of fission fragments" | ||
) | ||
.def_property_readonly( | ||
|
||
"prompt_energy_release", | ||
&Record::promptEnergyRelease, | ||
"The prompt energy release (total energy release minus delayed particles\n" | ||
"and neutrinos)" | ||
) | ||
.def_property_readonly( | ||
|
||
"total_energy_release", | ||
&Record::totalEnergyRelease, | ||
"The total energy release (including delayed particles and neutrinos)" | ||
) | ||
.def_property_readonly( | ||
|
||
"delayed_betas", | ||
&Record::delayedBetas, | ||
"The energy release through delayed betas" | ||
) | ||
.def_property_readonly( | ||
|
||
"prompt_gammas", | ||
&Record::promptGammas, | ||
"The energy release through prompt gammas" | ||
) | ||
.def_property_readonly( | ||
|
||
"prompt_neutrons", | ||
&Record::promptNeutrons, | ||
"The kinetic energy of the prompt fission neutrons" | ||
) | ||
.def_property_readonly( | ||
|
||
"fission_fragments", | ||
&Record::fissionFragments, | ||
"The kinetic energy of the fission products" | ||
) | ||
.def_static( | ||
|
||
"from_string", | ||
[] ( const std::string& string ) -> Record | ||
{ return read< Record >( string ); }, | ||
python::arg( "string" ), | ||
"Read the record from a string\n\n" | ||
"An exception is raised if something goes wrong while reading the\n" | ||
"record\n\n" | ||
"Arguments:\n" | ||
" string the string representing the record" | ||
); | ||
|
||
// add standard record definitions | ||
addStandardRecordDefinitions< Record, DoubleRange >( record ); | ||
} | ||
|
||
} // multigroup namespace |
54 changes: 54 additions & 0 deletions
54
python/test/multigroup/Test_NDItk_multigroup_AverageFissionEnergyRelease.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# standard imports | ||
import unittest | ||
|
||
# third party imports | ||
|
||
# local imports | ||
from NDItk.multigroup import AverageFissionEnergyRelease | ||
|
||
class Test_NDItk_multigroup_AverageFissionEnergyRelease( unittest.TestCase ) : | ||
"""Unit test for the AverageFissionEnergyRelease class.""" | ||
|
||
chunk_values = [ 181.238898, 202.827, 6.5, 7.281253, 169.13, 4.827645 ] | ||
chunk_string = ( 'fiss_q\n' | ||
' 181.238898 202.827 6.5 7.281253 169.13\n' | ||
' 4.827645\n' ) | ||
|
||
def test_component( self ) : | ||
|
||
def verify_chunk( self, chunk ) : | ||
|
||
# verify content | ||
self.assertAlmostEqual( 181.238898, chunk.prompt_energy_release ) | ||
self.assertAlmostEqual( 202.827, chunk.total_energy_release ) | ||
self.assertAlmostEqual( 6.5, chunk.delayed_betas ) | ||
self.assertAlmostEqual( 7.281253, chunk.prompt_gammas ) | ||
self.assertAlmostEqual( 169.13, chunk.fission_fragments ) | ||
self.assertAlmostEqual( 4.827645, chunk.prompt_neutrons ) | ||
|
||
self.assertEqual( self.chunk_string, chunk.to_string() ) | ||
|
||
# verify the record | ||
self.assertEqual( 'fiss_q', chunk.keyword ) | ||
self.assertEqual( False, chunk.empty ) | ||
self.assertEqual( 6, chunk.size ) | ||
|
||
values = chunk.values | ||
for index in range( chunk.size ) : | ||
|
||
self.assertAlmostEqual( self.chunk_values[index], values[index] ) | ||
|
||
# the data is given explicitly | ||
chunk = AverageFissionEnergyRelease( total = 202.827, prompt = 181.238898, neutrons = 4.827645, | ||
gammas = 7.281253, betas = 6.5, fragments = 169.13 ) | ||
|
||
verify_chunk( self, chunk ) | ||
|
||
# the data is read from a string | ||
chunk = AverageFissionEnergyRelease.from_string( self.chunk_string ) | ||
|
||
verify_chunk( self, chunk ) | ||
|
||
if __name__ == '__main__' : | ||
|
||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters