diff --git a/CMakeLists.txt b/CMakeLists.txt index 22ca6db2..a5fc7fb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,10 @@ if(ACEtk.python) python/src/block/DistributionGivenElsewhere.python.cpp python/src/block/AngularDistributionBlock.python.cpp python/src/block/LevelScatteringDistribution.python.cpp + python/src/block/TabulatedOutgoingEnergyDistribution.python.cpp + python/src/block/OutgoingEnergyDistributionData.python.cpp + python/src/block/TabulatedKalbachMannDistribution.python.cpp + python/src/block/KalbachMannDistributionData.python.cpp python/src/ContinuousEnergyTable.python.cpp ) diff --git a/cmake/unit_testing.cmake b/cmake/unit_testing.cmake index d6264720..cadd3e9c 100644 --- a/cmake/unit_testing.cmake +++ b/cmake/unit_testing.cmake @@ -28,6 +28,10 @@ add_subdirectory( src/ACEtk/block/IsotropicAngularDistribution/test ) add_subdirectory( src/ACEtk/block/AngularDistributionData/test ) add_subdirectory( src/ACEtk/block/AngularDistributionBlock/test ) add_subdirectory( src/ACEtk/block/LevelScatteringDistribution/test ) +add_subdirectory( src/ACEtk/block/TabulatedOutgoingEnergyDistribution/test ) +add_subdirectory( src/ACEtk/block/OutgoingEnergyDistributionData/test ) +add_subdirectory( src/ACEtk/block/TabulatedKalbachMannDistribution/test ) +add_subdirectory( src/ACEtk/block/KalbachMannDistributionData/test ) add_subdirectory( src/ACEtk/details/verify/CDF/test ) add_subdirectory( src/ACEtk/details/verify/Positive/test ) add_subdirectory( src/ACEtk/details/verify/Sorted/test ) diff --git a/python/src/ACEtk.python.cpp b/python/src/ACEtk.python.cpp index 05e1aa82..88bf40d0 100644 --- a/python/src/ACEtk.python.cpp +++ b/python/src/ACEtk.python.cpp @@ -34,6 +34,10 @@ namespace block { void wrapFullyIsotropicDistribution( python::module&, python::module& ); void wrapDistributionGivenElsewhere( python::module&, python::module& ); void wrapLevelScatteringDistribution( python::module&, python::module& ); + void wrapTabulatedOutgoingEnergyDistribution( python::module&, python::module& ); + void wrapOutgoingEnergyDistributionData( python::module&, python::module& ); + void wrapTabulatedKalbachMannDistribution( python::module&, python::module& ); + void wrapKalbachMannDistributionData( python::module&, python::module& ); // declarations - ACE table blocks void wrapPrincipalCrossSectionBlock( python::module&, python::module& ); @@ -97,6 +101,10 @@ PYBIND11_MODULE( ACEtk, module ) { block::wrapFullyIsotropicDistribution( module, viewmodule ); block::wrapDistributionGivenElsewhere( module, viewmodule ); block::wrapLevelScatteringDistribution( module, viewmodule ); + block::wrapTabulatedOutgoingEnergyDistribution( module, viewmodule ); + block::wrapOutgoingEnergyDistributionData( module, viewmodule ); + block::wrapTabulatedKalbachMannDistribution( module, viewmodule ); + block::wrapKalbachMannDistributionData( module, viewmodule ); // wrap ACE table blocks block::wrapPrincipalCrossSectionBlock( module, viewmodule ); diff --git a/python/src/block/AngularDistributionData.python.cpp b/python/src/block/AngularDistributionData.python.cpp index 29962722..74606102 100644 --- a/python/src/block/AngularDistributionData.python.cpp +++ b/python/src/block/AngularDistributionData.python.cpp @@ -91,8 +91,8 @@ void wrapAngularDistributionData( python::module& module, python::module& ) { ) .def( - "angular_distribution_locator", - &Block::angularDistributionLocator, + "distribution_locator", + &Block::distributionLocator, python::arg( "index" ), "Return the angular distribution locator for an incident energy index\n\n" "This locator is the value as stored in the XSS array. It is relative to\n" @@ -108,8 +108,8 @@ void wrapAngularDistributionData( python::module& module, python::module& ) { ) .def( - "relative_angular_distribution_locator", - &Block::relativeAngularDistributionLocator, + "relative_distribution_locator", + &Block::relativeDistributionLocator, python::arg( "index" ), "Return the relative angular distribution locator for an incident energy index\n\n" "This is the locator relative to the beginning of the current angular\n" @@ -121,8 +121,8 @@ void wrapAngularDistributionData( python::module& module, python::module& ) { ) .def( - "angular_distribution_type", - &Block::angularDistributionType, + "distribution_type", + &Block::distributionType, python::arg( "index" ), "Return the angular distribution type for an incident energy index\n\n" "When the index is out of range an out of range exception is thrown\n" @@ -132,8 +132,8 @@ void wrapAngularDistributionData( python::module& module, python::module& ) { ) .def( - "angular_distribution_data", - &Block::angularDistributionData, + "distribution", + &Block::distribution, python::arg( "index" ), "Return the angular distribution data for an incident energy index\n\n" "When the index is out of range an out of range exception is thrown\n" diff --git a/python/src/block/KalbachMannDistributionData.python.cpp b/python/src/block/KalbachMannDistributionData.python.cpp new file mode 100644 index 00000000..76586d98 --- /dev/null +++ b/python/src/block/KalbachMannDistributionData.python.cpp @@ -0,0 +1,131 @@ +// system includes +#include +#include + +// local includes +#include "ACEtk/block/KalbachMannDistributionData.hpp" +#include "views.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace block { + +void wrapKalbachMannDistributionData( python::module& module, + python::module& ) { + + // type aliases + using Block = njoy::ACEtk::block::KalbachMannDistributionData; + using Distribution = njoy::ACEtk::block::TabulatedKalbachMannDistribution; + + // wrap views created by this block + + // create the block + python::class_< Block > block( + + module, + "KalbachMannDistributionData", + "Convenience interface for outgoing energy distribution data from the\n" + "DLW block for a single reaction using Kalbach-Mann systematics" + ); + + // wrap the block + block + .def( + + python::init< std::vector< Distribution >&&, std::size_t >(), + python::arg( "distributions" ), python::arg( "locb" ) = 1, + "Initialise the block\n\n" + "Arguments:\n" + " self the block\n" + " distributions the distributions for each incident energy\n" + " locb the starting xss index with respect to the DLW block\n" + " (default = 1, the relative locators get recalculated)" + ) + .def_property_readonly( + + "NE", + &Block::NE, + "The number of incident energy values" + ) + .def_property_readonly( + + "number_incident_energies", + &Block::numberIncidentEnergies, + "The number of incident energy values" + ) + .def_property_readonly( + + "incident_energies", + [] ( const Block& self ) -> DoubleRange + { return self.incidentEnergies(); }, + "The incident energy values" + ) + .def( + + "incident_energy", + &Block::incidentEnergy, + python::arg( "index" ), + "Return the incident energy for a given index\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "LOCC", + &Block::LOCC, + python::arg( "index" ), + "Return the the distribution locator for an incident energy index\n\n" + "This locator is the value as stored in the XSS array. It is relative to\n" + "the beginning of the DLW block.\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "distribution_locator", + &Block::distributionLocator, + python::arg( "index" ), + "Return the the distribution locator for an incident energy index\n\n" + "This locator is the value as stored in the XSS array. It is relative to\n" + "the beginning of the DLW block.\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "relative_distribution_locator", + &Block::relativeDistributionLocator, + python::arg( "index" ), + "Return the relative distribution locator for an incident energy index\n\n" + "This is the locator relative to the beginning of the current angular\n" + "distribution block in the DLW block. It is always positive.\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "distribution", + &Block::distribution, + python::arg( "index" ), + "Return the distribution data for an incident energy index\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ); + + // add standard block definitions + addStandardBlockDefinitions< Block >( block ); +} + +} // block namespace diff --git a/python/src/block/OutgoingEnergyDistributionData.python.cpp b/python/src/block/OutgoingEnergyDistributionData.python.cpp new file mode 100644 index 00000000..7123e50c --- /dev/null +++ b/python/src/block/OutgoingEnergyDistributionData.python.cpp @@ -0,0 +1,131 @@ +// system includes +#include +#include + +// local includes +#include "ACEtk/block/OutgoingEnergyDistributionData.hpp" +#include "views.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace block { + +void wrapOutgoingEnergyDistributionData( python::module& module, + python::module& ) { + + // type aliases + using Block = njoy::ACEtk::block::OutgoingEnergyDistributionData; + using Distribution = njoy::ACEtk::block::TabulatedOutgoingEnergyDistribution; + + // wrap views created by this block + + // create the block + python::class_< Block > block( + + module, + "OutgoingEnergyDistributionData", + "Convenience interface for outgoing energy distribution data from the\n" + "DLW block for a single reaction using tabulated outgoing energy distributions" + ); + + // wrap the block + block + .def( + + python::init< std::vector< Distribution >&&, std::size_t >(), + python::arg( "distributions" ), python::arg( "locb" ) = 1, + "Initialise the block\n\n" + "Arguments:\n" + " self the block\n" + " distributions the distributions for each incident energy\n" + " locb the starting xss index with respect to the DLW block\n" + " (default = 1, the relative locators get recalculated)" + ) + .def_property_readonly( + + "NE", + &Block::NE, + "The number of incident energy values" + ) + .def_property_readonly( + + "number_incident_energies", + &Block::numberIncidentEnergies, + "The number of incident energy values" + ) + .def_property_readonly( + + "incident_energies", + [] ( const Block& self ) -> DoubleRange + { return self.incidentEnergies(); }, + "The incident energy values" + ) + .def( + + "incident_energy", + &Block::incidentEnergy, + python::arg( "index" ), + "Return the incident energy for a given index\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "LOCC", + &Block::LOCC, + python::arg( "index" ), + "Return the the distribution locator for an incident energy index\n\n" + "This locator is the value as stored in the XSS array. It is relative to\n" + "the beginning of the DLW block.\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "distribution_locator", + &Block::distributionLocator, + python::arg( "index" ), + "Return the the distribution locator for an incident energy index\n\n" + "This locator is the value as stored in the XSS array. It is relative to\n" + "the beginning of the DLW block.\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "relative_distribution_locator", + &Block::relativeDistributionLocator, + python::arg( "index" ), + "Return the relative distribution locator for an incident energy index\n\n" + "This is the locator relative to the beginning of the current angular\n" + "distribution block in the DLW block. It is always positive.\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ) + .def( + + "distribution", + &Block::distribution, + python::arg( "index" ), + "Return the distribution data for an incident energy index\n\n" + "When the index is out of range an out of range exception is thrown\n" + "(debug mode only).\n\n" + " self the block\n" + " index the index (one-based)" + ); + + // add standard block definitions + addStandardBlockDefinitions< Block >( block ); +} + +} // block namespace diff --git a/python/src/block/TabulatedKalbachMannDistribution.python.cpp b/python/src/block/TabulatedKalbachMannDistribution.python.cpp new file mode 100644 index 00000000..7772ebb6 --- /dev/null +++ b/python/src/block/TabulatedKalbachMannDistribution.python.cpp @@ -0,0 +1,116 @@ +// system includes +#include +#include + +// local includes +#include "ACEtk/block/TabulatedKalbachMannDistribution.hpp" +#include "views.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace block { + +void wrapTabulatedKalbachMannDistribution( python::module& module, python::module& ) { + + // type aliases + using Block = njoy::ACEtk::block::TabulatedKalbachMannDistribution; + + // wrap views created by this block + + // create the block + python::class_< Block > block( + + module, + "TabulatedKalbachMannDistribution", + "Convenience interface for tabulated Kalbach-Mann distribution data " + "from the DLW block" + ); + + // wrap the block + block + .def( + + python::init< double, int, std::vector< double >&&, std::vector< double >&&, + std::vector< double >&&, std::vector< double >&&, + std::vector< double >&&, std::size_t >(), + python::arg( "incident" ), python::arg( "interpolation" ), + python::arg( "cosines" ), python::arg( "pdf" ), python::arg( "cdf" ), + python::arg( "r" ), python::arg( "a" ), python::arg( "discrete" ) = 0, + "Initialise the block\n\n" + "Arguments:\n" + " self the block\n" + " incident the incident energy value\n" + " cosines the cosine values\n" + " pdf the pdf values\n" + " cdf the cdf values\n" + " r the precompound fraction values values\n" + " a the angular distribution slope values\n" + " discrete the number of discrete photon lines (defaults to 0)" + ) + .def_property_readonly( + + "incident_energy", + &Block::incidentEnergy, + "The incident energy" + ) + .def_property_readonly( + + "interpolation", + &Block::interpolation, + "The interpolation flag" + ) + .def_property_readonly( + + "number_discrete_photon_lines", + &Block::numberDiscretePhotonLines, + "The number of discrete photon lines" + ) + .def_property_readonly( + + "number_outgoing_energies", + &Block::numberOutgoingEnergies, + "The number of outgoing energy values" + ) + .def_property_readonly( + + "outgoing_energies", + [] ( const Block& self ) -> DoubleRange + { return self.outgoingEnergies(); }, + "The outgoing energy values" + ) + .def_property_readonly( + + "pdf", + [] ( const Block& self ) -> DoubleRange + { return self.pdf(); }, + "The pdf values" + ) + .def_property_readonly( + + "cdf", + [] ( const Block& self ) -> DoubleRange + { return self.cdf(); }, + "The cdf values" + ) + .def_property_readonly( + + "precompound_fraction_values", + [] ( const Block& self ) -> DoubleRange + { return self.precompoundFractionValues(); }, + "The precompound fraction values" + ) + .def_property_readonly( + + "angular_distribution_slope_values", + [] ( const Block& self ) -> DoubleRange + { return self.angularDistributionSlopeValues(); }, + "The angular distribution slope values" + ); + + // add standard block definitions + addStandardBlockDefinitions< Block >( block ); +} + +} // block namespace diff --git a/python/src/block/TabulatedOutgoingEnergyDistribution.python.cpp b/python/src/block/TabulatedOutgoingEnergyDistribution.python.cpp new file mode 100644 index 00000000..a077027c --- /dev/null +++ b/python/src/block/TabulatedOutgoingEnergyDistribution.python.cpp @@ -0,0 +1,99 @@ +// system includes +#include +#include + +// local includes +#include "ACEtk/block/TabulatedOutgoingEnergyDistribution.hpp" +#include "views.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace block { + +void wrapTabulatedOutgoingEnergyDistribution( python::module& module, python::module& ) { + + // type aliases + using Block = njoy::ACEtk::block::TabulatedOutgoingEnergyDistribution; + + // wrap views created by this block + + // create the block + python::class_< Block > block( + + module, + "TabulatedOutgoingEnergyDistribution", + "Convenience interface for tabulated outgoing energy distribution data " + "from the DLW block" + ); + + // wrap the block + block + .def( + + python::init< double, int, std::vector< double >&&, std::vector< double >&&, + std::vector< double >&&, std::size_t >(), + python::arg( "incident" ), python::arg( "interpolation" ), + python::arg( "cosines" ), python::arg( "pdf" ), python::arg( "cdf" ), + python::arg( "discrete" ) = 0, + "Initialise the block\n\n" + "Arguments:\n" + " self the block\n" + " incident the incident energy value\n" + " cosines the cosine values\n" + " pdf the pdf values\n" + " cdf the cdf values\n" + " discrete the number of discrete photon lines (defaults to 0)" + ) + .def_property_readonly( + + "incident_energy", + &Block::incidentEnergy, + "The incident energy" + ) + .def_property_readonly( + + "interpolation", + &Block::interpolation, + "The interpolation flag" + ) + .def_property_readonly( + + "number_discrete_photon_lines", + &Block::numberDiscretePhotonLines, + "The number of discrete photon lines" + ) + .def_property_readonly( + + "number_outgoing_energies", + &Block::numberOutgoingEnergies, + "The number of outgoing energy values" + ) + .def_property_readonly( + + "outgoing_energies", + [] ( const Block& self ) -> DoubleRange + { return self.outgoingEnergies(); }, + "The outgoing energy values" + ) + .def_property_readonly( + + "pdf", + [] ( const Block& self ) -> DoubleRange + { return self.pdf(); }, + "The pdf values" + ) + .def_property_readonly( + + "cdf", + [] ( const Block& self ) -> DoubleRange + { return self.cdf(); }, + "The cdf values" + ); + + // add standard block definitions + addStandardBlockDefinitions< Block >( block ); +} + +} // block namespace diff --git a/python/test/CMakeLists.txt b/python/test/CMakeLists.txt index 47ee48f9..52c393d3 100644 --- a/python/test/CMakeLists.txt +++ b/python/test/CMakeLists.txt @@ -15,3 +15,7 @@ add_test( NAME ACEtk.python.block.IsotropicAngularDistribution COMMAND ${PYTHON_ add_test( NAME ACEtk.python.block.AngularDistributionData COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_AngularDistributionData.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python ) add_test( NAME ACEtk.python.block.AngularDistributionBlock COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_AngularDistributionBlock.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python ) add_test( NAME ACEtk.python.block.LevelScatteringDistribution COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_LevelScatteringDistribution.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python ) +add_test( NAME ACEtk.python.block.TabulatedOutgoingEnergyDistribution COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_TabulatedOutgoingEnergyDistribution.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python ) +add_test( NAME ACEtk.python.block.OutgoingEnergyDistributionData COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_OutgoingEnergyDistributionData.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python ) +add_test( NAME ACEtk.python.block.TabulatedKalbachMannDistribution COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_TabulatedKalbachMannDistribution.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python ) +add_test( NAME ACEtk.python.block.KalbachMannDistributionData COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_KalbachMannDistributionData.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python ) diff --git a/python/test/block/Test_ACEtk_AngularDistributionBlock.py b/python/test/block/Test_ACEtk_AngularDistributionBlock.py index ad88e1ff..d0890b29 100644 --- a/python/test/block/Test_ACEtk_AngularDistributionBlock.py +++ b/python/test/block/Test_ACEtk_AngularDistributionBlock.py @@ -13,8 +13,8 @@ from ACEtk import TabulatedAngularDistribution from ACEtk import AngularDistributionType -class Test_ACEtk_TabulatedAngularDistribution( unittest.TestCase ) : - """Unit test for the TabulatedAngularDistribution class.""" +class Test_ACEtk_AngularDistributionBlock( unittest.TestCase ) : + """Unit test for the AngularDistributionBlock class.""" chunk = [ 1, -1, 0, 25, 2, 1.00000000000E-11, 2.00000000000E+01, -6, @@ -77,14 +77,14 @@ def verify_chunk( self, chunk ) : self.assertAlmostEqual( 20., data.incident_energy(2) ) self.assertEqual( -6, data.LOCC(1) ) self.assertEqual( -14, data.LOCC(2) ) - self.assertEqual( -6, data.angular_distribution_locator(1) ) - self.assertEqual( -14, data.angular_distribution_locator(2) ) - self.assertEqual( AngularDistributionType.Tabulated, data.angular_distribution_type(1) ) - self.assertEqual( AngularDistributionType.Tabulated, data.angular_distribution_type(2) ) - self.assertEqual( 6, data.relative_angular_distribution_locator(1) ) - self.assertEqual( 14, data.relative_angular_distribution_locator(2) ) - self.assertEqual( True, isinstance( data.angular_distribution_data(1), TabulatedAngularDistribution ) ) - self.assertEqual( True, isinstance( data.angular_distribution_data(2), TabulatedAngularDistribution ) ) + self.assertEqual( -6, data.distribution_locator(1) ) + self.assertEqual( -14, data.distribution_locator(2) ) + self.assertEqual( AngularDistributionType.Tabulated, data.distribution_type(1) ) + self.assertEqual( AngularDistributionType.Tabulated, data.distribution_type(2) ) + self.assertEqual( 6, data.relative_distribution_locator(1) ) + self.assertEqual( 14, data.relative_distribution_locator(2) ) + self.assertEqual( True, isinstance( data.distribution(1), TabulatedAngularDistribution ) ) + self.assertEqual( True, isinstance( data.distribution(2), TabulatedAngularDistribution ) ) data = chunk.angular_distribution_data(3) self.assertEqual( 3, data.NE ) @@ -99,18 +99,18 @@ def verify_chunk( self, chunk ) : self.assertEqual( -32, data.LOCC(1) ) self.assertEqual( 0, data.LOCC(2) ) self.assertEqual( -43, data.LOCC(3) ) - self.assertEqual( -32, data.angular_distribution_locator(1) ) - self.assertEqual( 0, data.angular_distribution_locator(2) ) - self.assertEqual( -43, data.angular_distribution_locator(3) ) - self.assertEqual( AngularDistributionType.Tabulated, data.angular_distribution_type(1) ) - self.assertEqual( AngularDistributionType.Isotropic, data.angular_distribution_type(2) ) - self.assertEqual( AngularDistributionType.Tabulated, data.angular_distribution_type(3) ) - self.assertEqual( 8, data.relative_angular_distribution_locator(1) ) - self.assertEqual( 0, data.relative_angular_distribution_locator(2) ) - self.assertEqual( 19, data.relative_angular_distribution_locator(3) ) - self.assertEqual( True, isinstance( data.angular_distribution_data(1), TabulatedAngularDistribution ) ) - self.assertEqual( True, isinstance( data.angular_distribution_data(2), IsotropicAngularDistribution ) ) - self.assertEqual( True, isinstance( data.angular_distribution_data(3), TabulatedAngularDistribution ) ) + self.assertEqual( -32, data.distribution_locator(1) ) + self.assertEqual( 0, data.distribution_locator(2) ) + self.assertEqual( -43, data.distribution_locator(3) ) + self.assertEqual( AngularDistributionType.Tabulated, data.distribution_type(1) ) + self.assertEqual( AngularDistributionType.Isotropic, data.distribution_type(2) ) + self.assertEqual( AngularDistributionType.Tabulated, data.distribution_type(3) ) + self.assertEqual( 8, data.relative_distribution_locator(1) ) + self.assertEqual( 0, data.relative_distribution_locator(2) ) + self.assertEqual( 19, data.relative_distribution_locator(3) ) + self.assertEqual( True, isinstance( data.distribution(1), TabulatedAngularDistribution ) ) + self.assertEqual( True, isinstance( data.distribution(2), IsotropicAngularDistribution ) ) + self.assertEqual( True, isinstance( data.distribution(3), TabulatedAngularDistribution ) ) # verify the xss array xss = chunk.xss_array diff --git a/python/test/block/Test_ACEtk_AngularDistributionData.py b/python/test/block/Test_ACEtk_AngularDistributionData.py index cabf19c5..f995cdc1 100644 --- a/python/test/block/Test_ACEtk_AngularDistributionData.py +++ b/python/test/block/Test_ACEtk_AngularDistributionData.py @@ -10,8 +10,8 @@ from ACEtk import TabulatedAngularDistribution from ACEtk import AngularDistributionType -class Test_ACEtk_TabulatedAngularDistribution( unittest.TestCase ) : - """Unit test for the TabulatedAngularDistribution class.""" +class Test_ACEtk_AngularDistributionData( unittest.TestCase ) : + """Unit test for the AngularDistributionData class.""" chunk = [ 3, 1.00000000000E-11, 1.00000000000E+00, 2.00000000000E+01, 0, 13, -46, -1.00000000000E+00, @@ -51,20 +51,20 @@ def verify_chunk( self, chunk ) : self.assertEqual( 0, chunk.LOCC(1) ); self.assertEqual( 13, chunk.LOCC(2) ); self.assertEqual( -46, chunk.LOCC(3) ); - self.assertEqual( 0, chunk.angular_distribution_locator(1) ); - self.assertEqual( 13, chunk.angular_distribution_locator(2) ); - self.assertEqual( -46, chunk.angular_distribution_locator(3) ); - - self.assertEqual( AngularDistributionType.Isotropic, chunk.angular_distribution_type(1) ); - self.assertEqual( AngularDistributionType.Equiprobable, chunk.angular_distribution_type(2) ); - self.assertEqual( AngularDistributionType.Tabulated, chunk.angular_distribution_type(3) ); - self.assertEqual( 0, chunk.relative_angular_distribution_locator(1) ); - self.assertEqual( 8, chunk.relative_angular_distribution_locator(2) ); - self.assertEqual( 41, chunk.relative_angular_distribution_locator(3) ); - - self.assertEqual( True, isinstance( chunk.angular_distribution_data(1), IsotropicAngularDistribution ) ) - self.assertEqual( True, isinstance( chunk.angular_distribution_data(2), EquiprobableAngularBins ) ) - self.assertEqual( True, isinstance( chunk.angular_distribution_data(3), TabulatedAngularDistribution ) ) + self.assertEqual( 0, chunk.distribution_locator(1) ); + self.assertEqual( 13, chunk.distribution_locator(2) ); + self.assertEqual( -46, chunk.distribution_locator(3) ); + + self.assertEqual( AngularDistributionType.Isotropic, chunk.distribution_type(1) ); + self.assertEqual( AngularDistributionType.Equiprobable, chunk.distribution_type(2) ); + self.assertEqual( AngularDistributionType.Tabulated, chunk.distribution_type(3) ); + self.assertEqual( 0, chunk.relative_distribution_locator(1) ); + self.assertEqual( 8, chunk.relative_distribution_locator(2) ); + self.assertEqual( 41, chunk.relative_distribution_locator(3) ); + + self.assertEqual( True, isinstance( chunk.distribution(1), IsotropicAngularDistribution ) ) + self.assertEqual( True, isinstance( chunk.distribution(2), EquiprobableAngularBins ) ) + self.assertEqual( True, isinstance( chunk.distribution(3), TabulatedAngularDistribution ) ) # verify the xss array xss = chunk.xss_array diff --git a/python/test/block/Test_ACEtk_KalbachMannDistributionData.py b/python/test/block/Test_ACEtk_KalbachMannDistributionData.py new file mode 100644 index 00000000..3961ebb6 --- /dev/null +++ b/python/test/block/Test_ACEtk_KalbachMannDistributionData.py @@ -0,0 +1,131 @@ +# standard imports +import unittest + +# third party imports + +# local imports +from ACEtk import KalbachMannDistributionData +from ACEtk import TabulatedKalbachMannDistribution + +class Test_ACEtk_KalbachMannDistributionData( unittest.TestCase ) : + """Unit test for the KalbachMannDistributionData class.""" + + chunk = [ 0, 2, 1.219437E+01, 2.000000E+01, + 27, 39, 1, 2, + 0.000000E+00, 1.866919E-02, 5.356419E+01, 0.000000E+00, + 0.000000E+00, 1.000000E+00, 0.000000E+00, 0.000000E+00, + 2.391154E-01, 2.398743E-01, 2, 3, + 0.000000E+00, 1.120151E+00, 7.592137E+00, 7.738696E-02, + 4.209016E-01, 1.226090E-11, 0.000000E+00, 5.382391E-01, + 1.000000E+00, 2.491475E-03, 1.510768E-02, 9.775367E-01, + 2.391154E-01, 2.847920E-01, 5.592013E-01 ] + + def test_component( self ) : + + def verify_chunk( self, chunk ) : + + # verify content + self.assertEqual( False, chunk.empty ) + self.assertEqual( 35, chunk.length ) + self.assertEqual( "DLW::KalbachMannDistributionData", chunk.name ) + + self.assertEqual( 2, chunk.NE ) + self.assertEqual( 2, chunk.number_incident_energies ) + + self.assertEqual( 2, len( chunk.incident_energies ) ) + self.assertAlmostEqual( 1.219437E+01, chunk.incident_energies[0] ) + self.assertAlmostEqual( 20., chunk.incident_energies[1] ) + + self.assertAlmostEqual( 1.219437E+01, chunk.incident_energy(1) ) + self.assertAlmostEqual( 20., chunk.incident_energy(2) ) + + self.assertEqual( 27, chunk.LOCC(1) ); + self.assertEqual( 39, chunk.LOCC(2) ); + self.assertEqual( 27, chunk.distribution_locator(1) ); + self.assertEqual( 39, chunk.distribution_locator(2) ); + + self.assertEqual( 7, chunk.relative_distribution_locator(1) ); + self.assertEqual( 19, chunk.relative_distribution_locator(2) ); + + self.assertEqual( True, isinstance( chunk.distribution(1), TabulatedKalbachMannDistribution ) ) + self.assertEqual( True, isinstance( chunk.distribution(2), TabulatedKalbachMannDistribution ) ) + + data1 = chunk.distribution(1); + self.assertAlmostEqual( 1.219437E+01, data1.incident_energy ) + self.assertEqual( 1, data1.interpolation ) + self.assertEqual( 0, data1.number_discrete_photon_lines ) + self.assertEqual( 2, data1.number_outgoing_energies ) + + self.assertEqual( 2, len( data1.outgoing_energies ) ) + self.assertAlmostEqual( 0., data1.outgoing_energies[0] ) + self.assertAlmostEqual( 1.866919E-02, data1.outgoing_energies[-1] ) + + self.assertEqual( 2, len( data1.pdf ) ) + self.assertAlmostEqual( 5.356419E+01, data1.pdf[0] ) + self.assertAlmostEqual( 0., data1.pdf[-1] ) + + self.assertEqual( 2, len( data1.cdf ) ) + self.assertAlmostEqual( 0., data1.cdf[0] ) + self.assertAlmostEqual( 1., data1.cdf[-1] ) + + self.assertEqual( 2, len( data1.precompound_fraction_values ) ) + self.assertAlmostEqual( 0., data1.precompound_fraction_values[0] ) + self.assertAlmostEqual( 0., data1.precompound_fraction_values[-1] ) + + self.assertEqual( 2, len( data1.angular_distribution_slope_values ) ) + self.assertAlmostEqual( 2.391154E-01, data1.angular_distribution_slope_values[0] ) + self.assertAlmostEqual( 2.398743E-01, data1.angular_distribution_slope_values[-1] ) + + data2 = chunk.distribution(2); + self.assertAlmostEqual( 20., data2.incident_energy ) + self.assertEqual( 2, data2.interpolation ) + self.assertEqual( 0, data2.number_discrete_photon_lines ) + self.assertEqual( 3, data2.number_outgoing_energies ) + + self.assertEqual( 3, len( data2.outgoing_energies ) ) + self.assertAlmostEqual( 0., data2.outgoing_energies[0] ) + self.assertAlmostEqual( 7.592137E+00, data2.outgoing_energies[-1] ) + + self.assertEqual( 3, len( data2.pdf ) ) + self.assertAlmostEqual( 7.738696E-02, data2.pdf[0] ) + self.assertAlmostEqual( 1.226090E-11, data2.pdf[-1] ) + + self.assertEqual( 3, len( data2.cdf ) ) + self.assertAlmostEqual( 0., data2.cdf[0] ) + self.assertAlmostEqual( 1., data2.cdf[-1] ) + + self.assertEqual( 3, len( data2.precompound_fraction_values ) ) + self.assertAlmostEqual( 2.491475E-03, data2.precompound_fraction_values[0] ) + self.assertAlmostEqual( 9.775367E-01, data2.precompound_fraction_values[-1] ) + + self.assertEqual( 3, len( data2.angular_distribution_slope_values ) ) + self.assertAlmostEqual( 2.391154E-01, data2.angular_distribution_slope_values[0] ) + self.assertAlmostEqual( 5.592013E-01, data2.angular_distribution_slope_values[-1] ) + + # verify the xss array + xss = chunk.xss_array + for index in range( chunk.length ) : + + self.assertAlmostEqual( self.chunk[index], xss[index] ) + + # the data is given explicitly + chunk = KalbachMannDistributionData( + distributions = [ + + TabulatedKalbachMannDistribution( + 1.219437E+01, 1, [ 0.000000E+00, 1.866919E-02 ], + [ 5.356419E+01, 0.000000E+00 ], [ 0., 1. ], [ 0., 0. ], + [ 2.391154E-01, 2.398743E-01 ] ), + TabulatedKalbachMannDistribution( + 20., 2, [ 0.000000E+00, 1.120151E+00, 7.592137E+00 ], + [ 7.738696E-02, 4.209016E-01, 1.226090E-11 ], + [ 0.000000E+00, 5.382391E-01, 1.000000E+00 ], + [ 2.491475E-03, 1.510768E-02, 9.775367E-01 ], + [ 2.391154E-01, 2.847920E-01, 5.592013E-01 ] ) ], + locb = 21 ) + + verify_chunk( self, chunk ) + +if __name__ == '__main__' : + + unittest.main() diff --git a/python/test/block/Test_ACEtk_OutgoingEnergyDistributionData.py b/python/test/block/Test_ACEtk_OutgoingEnergyDistributionData.py new file mode 100644 index 00000000..09bd4de8 --- /dev/null +++ b/python/test/block/Test_ACEtk_OutgoingEnergyDistributionData.py @@ -0,0 +1,108 @@ +# standard imports +import unittest + +# third party imports + +# local imports +from ACEtk import OutgoingEnergyDistributionData +from ACEtk import TabulatedOutgoingEnergyDistribution + +class Test_ACEtk_OutgoingEnergyDistributionData( unittest.TestCase ) : + """Unit test for the OutgoingEnergyDistributionData class.""" + + chunk = [ 0, 2, 1.000000E-11, 2.000000E+01, + 27, 38, 2, 3, + 0.000000E+00, 3.100000E-01, 1.840000E+00, 2.364290E-01, + 1.050191E+00, 0.000000E+00, 0.000000E+00, 4.932501E-01, + 1.000000E+00, 2, 2, 0.000000E+00, + 1.840000E+00, 5.000000E-01, 5.000000E-01, 0.000000E+00, + 1.000000E+00 ] + + def test_component( self ) : + + def verify_chunk( self, chunk ) : + + # verify content + self.assertEqual( False, chunk.empty ) + self.assertEqual( 25, chunk.length ) + self.assertEqual( "DLW::OutgoingEnergyDistributionData", chunk.name ) + + self.assertEqual( 2, chunk.NE ) + self.assertEqual( 2, chunk.number_incident_energies ) + + self.assertEqual( 2, len( chunk.incident_energies ) ) + self.assertAlmostEqual( 1e-11, chunk.incident_energies[0] ) + self.assertAlmostEqual( 20., chunk.incident_energies[1] ) + + self.assertAlmostEqual( 1e-11, chunk.incident_energy(1) ) + self.assertAlmostEqual( 20., chunk.incident_energy(2) ) + + self.assertEqual( 27, chunk.LOCC(1) ); + self.assertEqual( 38, chunk.LOCC(2) ); + self.assertEqual( 27, chunk.distribution_locator(1) ); + self.assertEqual( 38, chunk.distribution_locator(2) ); + + self.assertEqual( 7, chunk.relative_distribution_locator(1) ); + self.assertEqual( 18, chunk.relative_distribution_locator(2) ); + + self.assertEqual( True, isinstance( chunk.distribution(1), TabulatedOutgoingEnergyDistribution ) ) + self.assertEqual( True, isinstance( chunk.distribution(2), TabulatedOutgoingEnergyDistribution ) ) + + data1 = chunk.distribution(1); + self.assertAlmostEqual( 1e-11, data1.incident_energy ) + self.assertEqual( 2, data1.interpolation ) + self.assertEqual( 0, data1.number_discrete_photon_lines ) + self.assertEqual( 3, data1.number_outgoing_energies ) + + self.assertEqual( 3, len( data1.outgoing_energies ) ) + self.assertAlmostEqual( 0., data1.outgoing_energies[0] ) + self.assertAlmostEqual( 1.84, data1.outgoing_energies[-1] ) + + self.assertEqual( 3, len( data1.pdf ) ) + self.assertAlmostEqual( 2.364290E-01, data1.pdf[0] ) + self.assertAlmostEqual( 0., data1.pdf[-1] ) + + self.assertEqual( 3, len( data1.cdf ) ) + self.assertAlmostEqual( 0., data1.cdf[0] ) + self.assertAlmostEqual( 1., data1.cdf[-1] ) + + data2 = chunk.distribution(2); + self.assertAlmostEqual( 20., data2.incident_energy ) + self.assertEqual( 2, data2.interpolation ) + self.assertEqual( 0, data2.number_discrete_photon_lines ) + self.assertEqual( 2, data2.number_outgoing_energies ) + + self.assertEqual( 2, len( data2.outgoing_energies ) ) + self.assertAlmostEqual( 0., data2.outgoing_energies[0] ) + self.assertAlmostEqual( 1.84, data2.outgoing_energies[-1] ) + + self.assertEqual( 2, len( data2.pdf ) ) + self.assertAlmostEqual( 0.5, data2.pdf[0] ) + self.assertAlmostEqual( 0.5, data2.pdf[-1] ) + + self.assertEqual( 2, len( data2.cdf ) ) + self.assertAlmostEqual( 0., data2.cdf[0] ) + self.assertAlmostEqual( 1., data2.cdf[-1] ) + + # verify the xss array + xss = chunk.xss_array + for index in range( chunk.length ) : + + self.assertAlmostEqual( self.chunk[index], xss[index] ) + + # the data is given explicitly + chunk = OutgoingEnergyDistributionData( + distributions = [ + + TabulatedOutgoingEnergyDistribution( + 1e-11, 2, [ 0.0, .31, 1.84 ], + [ 2.364290E-01, 1.050191E+00, 0. ], [ 0., 4.932501E-01, 1. ] ), + TabulatedOutgoingEnergyDistribution( + 20., 2, [ 0.0, 1.84 ], [ .5, .5 ], [ 0., 1. ] ) ], + locb = 21 ) + + verify_chunk( self, chunk ) + +if __name__ == '__main__' : + + unittest.main() diff --git a/python/test/block/Test_ACEtk_TabulatedAngularDistribution.py b/python/test/block/Test_ACEtk_TabulatedAngularDistribution.py index 71745af6..d3b6ea47 100644 --- a/python/test/block/Test_ACEtk_TabulatedAngularDistribution.py +++ b/python/test/block/Test_ACEtk_TabulatedAngularDistribution.py @@ -23,6 +23,7 @@ def verify_chunk( self, chunk ) : self.assertEqual( "AND::TabulatedAngularDistribution", chunk.name ) self.assertEqual( 2.1, chunk.incident_energy ) + self.assertEqual( 2, chunk.interpolation ) self.assertEqual( 3, chunk.number_cosines ) self.assertEqual( 3, len( chunk.cosines ) ) diff --git a/python/test/block/Test_ACEtk_TabulatedKalbachMannDistribution.py b/python/test/block/Test_ACEtk_TabulatedKalbachMannDistribution.py new file mode 100644 index 00000000..2352d0fd --- /dev/null +++ b/python/test/block/Test_ACEtk_TabulatedKalbachMannDistribution.py @@ -0,0 +1,73 @@ +# standard imports +import unittest + +# third party imports + +# local imports +from ACEtk import TabulatedKalbachMannDistribution + +class Test_ACEtk_TabulatedKalbachMannDistribution( unittest.TestCase ) : + """Unit test for the TabulatedKalbachMannDistribution class.""" + + chunk = [ 32, 3, 1.00000000000E-11, 1.00000000000E+00, + 2.00000000000E+01, 0.50000000000E+00, 0.50000000000E+00, 0.50000000000E+00, + 0.00000000000E+00, 0.50000000000E+00, 1.00000000000E+00, 1.00000000000E+00, + 2.00000000000E+00, 3.00000000000E+00, 4.00000000000E+00, 5.00000000000E+00, + 6.00000000000E+00 ] + + def test_component( self ) : + + def verify_chunk( self, chunk ) : + + # verify content + self.assertEqual( False, chunk.empty ) + self.assertEqual( 17, chunk.length ) + self.assertEqual( "DLW::TabulatedKalbachMannDistribution", chunk.name ) + + self.assertEqual( 2.1, chunk.incident_energy ) + self.assertEqual( 2, chunk.interpolation ) + self.assertEqual( 3, chunk.number_discrete_photon_lines ) + self.assertEqual( 3, chunk.number_outgoing_energies ) + + self.assertEqual( 3, len( chunk.outgoing_energies ) ) + self.assertAlmostEqual( 1e-11, chunk.outgoing_energies[0] ) + self.assertAlmostEqual( 20., chunk.outgoing_energies[-1] ) + + self.assertEqual( 3, len( chunk.pdf ) ) + self.assertAlmostEqual( .5, chunk.pdf[0] ) + self.assertAlmostEqual( .5, chunk.pdf[-1] ) + + self.assertEqual( 3, len( chunk.cdf ) ) + self.assertAlmostEqual( 0., chunk.cdf[0] ) + self.assertAlmostEqual( 1., chunk.cdf[-1] ) + + self.assertEqual( 3, len( chunk.precompound_fraction_values ) ) + self.assertAlmostEqual( 1., chunk.precompound_fraction_values[0] ) + self.assertAlmostEqual( 3., chunk.precompound_fraction_values[-1] ) + + self.assertEqual( 3, len( chunk.angular_distribution_slope_values ) ) + self.assertAlmostEqual( 4., chunk.angular_distribution_slope_values[0] ) + self.assertAlmostEqual( 6., chunk.angular_distribution_slope_values[-1] ) + + # verify the xss array + xss = chunk.xss_array + for index in range( chunk.length ) : + + self.assertAlmostEqual( self.chunk[index], xss[index] ) + + # the data is given explicitly + chunk = TabulatedKalbachMannDistribution( + incident = 2.1, + interpolation = 2, + cosines = [ 1e-11, 1., 20. ], + pdf = [ 0.5, 0.5, 0.5 ], + cdf = [ 0.0, 0.5, 1.0 ], + r = [ 1, 2, 3 ], + a = [ 4, 5, 6 ], + discrete = 3 ) + + verify_chunk( self, chunk ) + +if __name__ == '__main__' : + + unittest.main() diff --git a/python/test/block/Test_ACEtk_TabulatedOutgoingEnergyDistribution.py b/python/test/block/Test_ACEtk_TabulatedOutgoingEnergyDistribution.py new file mode 100644 index 00000000..fa05a851 --- /dev/null +++ b/python/test/block/Test_ACEtk_TabulatedOutgoingEnergyDistribution.py @@ -0,0 +1,61 @@ +# standard imports +import unittest + +# third party imports + +# local imports +from ACEtk import TabulatedOutgoingEnergyDistribution + +class Test_ACEtk_TabulatedOutgoingEnergyDistribution( unittest.TestCase ) : + """Unit test for the TabulatedOutgoingEnergyDistribution class.""" + + chunk = [ 32, 3, 1.00000000000E-11, 1.00000000000E+00, + 2.00000000000E+01, 0.50000000000E+00, 0.50000000000E+00, 0.50000000000E+00, + 0.00000000000E+00, 0.50000000000E+00, 1.00000000000E+00 ] + + def test_component( self ) : + + def verify_chunk( self, chunk ) : + + # verify content + self.assertEqual( False, chunk.empty ) + self.assertEqual( 11, chunk.length ) + self.assertEqual( "DLW::TabulatedOutgoingEnergyDistribution", chunk.name ) + + self.assertEqual( 2.1, chunk.incident_energy ) + self.assertEqual( 2, chunk.interpolation ) + self.assertEqual( 3, chunk.number_discrete_photon_lines ) + self.assertEqual( 3, chunk.number_outgoing_energies ) + + self.assertEqual( 3, len( chunk.outgoing_energies ) ) + self.assertAlmostEqual( 1e-11, chunk.outgoing_energies[0] ) + self.assertAlmostEqual( 20., chunk.outgoing_energies[-1] ) + + self.assertEqual( 3, len( chunk.pdf ) ) + self.assertAlmostEqual( .5, chunk.pdf[0] ) + self.assertAlmostEqual( .5, chunk.pdf[-1] ) + + self.assertEqual( 3, len( chunk.cdf ) ) + self.assertAlmostEqual( 0., chunk.cdf[0] ) + self.assertAlmostEqual( 1., chunk.cdf[-1] ) + + # verify the xss array + xss = chunk.xss_array + for index in range( chunk.length ) : + + self.assertAlmostEqual( self.chunk[index], xss[index] ) + + # the data is given explicitly + chunk = TabulatedOutgoingEnergyDistribution( + incident = 2.1, + interpolation = 2, + cosines = [ 1e-11, 1., 20. ], + pdf = [ 0.5, 0.5, 0.5 ], + cdf = [ 0.0, 0.5, 1.0 ], + discrete = 3 ) + + verify_chunk( self, chunk ) + +if __name__ == '__main__' : + + unittest.main() diff --git a/src/ACEtk/block/AngularDistributionBlock/src/generateXSS.hpp b/src/ACEtk/block/AngularDistributionBlock/src/generateXSS.hpp index 2099f029..7ff40fb2 100644 --- a/src/ACEtk/block/AngularDistributionBlock/src/generateXSS.hpp +++ b/src/ACEtk/block/AngularDistributionBlock/src/generateXSS.hpp @@ -35,7 +35,7 @@ generateXSS( std::vector< DistributionData >&& distributions ) { int oldlocator = xss[ locposition ]; int newlocator = oldlocator == 0 ? 0 - : offset + value.relativeAngularDistributionLocator(incident) - 1; + : offset + value.relativeDistributionLocator(incident) - 1; if ( oldlocator < 0 ) { newlocator *= -1; diff --git a/src/ACEtk/block/AngularDistributionBlock/test/AngularDistributionBlock.test.cpp b/src/ACEtk/block/AngularDistributionBlock/test/AngularDistributionBlock.test.cpp index 355ffc0c..81b82d92 100644 --- a/src/ACEtk/block/AngularDistributionBlock/test/AngularDistributionBlock.test.cpp +++ b/src/ACEtk/block/AngularDistributionBlock/test/AngularDistributionBlock.test.cpp @@ -149,14 +149,14 @@ void verifyChunk( const AngularDistributionBlock& chunk ) { CHECK( 20. == Approx( data1.incidentEnergy(2) ) ); CHECK( -6 == data1.LOCC(1) ); CHECK( -14 == data1.LOCC(2) ); - CHECK( -6 == data1.angularDistributionLocator(1) ); - CHECK( -14 == data1.angularDistributionLocator(2) ); - CHECK( AngularDistributionType::Tabulated == data1.angularDistributionType(1) ); - CHECK( AngularDistributionType::Tabulated == data1.angularDistributionType(2) ); - CHECK( 6 == data1.relativeAngularDistributionLocator(1) ); - CHECK( 14 == data1.relativeAngularDistributionLocator(2) ); - CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data1.angularDistributionData(1) ) ); - CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data1.angularDistributionData(2) ) ); + CHECK( -6 == data1.distributionLocator(1) ); + CHECK( -14 == data1.distributionLocator(2) ); + CHECK( AngularDistributionType::Tabulated == data1.distributionType(1) ); + CHECK( AngularDistributionType::Tabulated == data1.distributionType(2) ); + CHECK( 6 == data1.relativeDistributionLocator(1) ); + CHECK( 14 == data1.relativeDistributionLocator(2) ); + CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data1.distribution(1) ) ); + CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data1.distribution(2) ) ); auto data4 = std::get< AngularDistributionData >( chunk.angularDistributionData(3) ); CHECK( 3 == data4.NE() ); @@ -171,16 +171,16 @@ void verifyChunk( const AngularDistributionBlock& chunk ) { CHECK( -32 == data4.LOCC(1) ); CHECK( 0 == data4.LOCC(2) ); CHECK( -43 == data4.LOCC(3) ); - CHECK( -32 == data4.angularDistributionLocator(1) ); - CHECK( 0 == data4.angularDistributionLocator(2) ); - CHECK( -43 == data4.angularDistributionLocator(3) ); - CHECK( AngularDistributionType::Tabulated == data4.angularDistributionType(1) ); - CHECK( AngularDistributionType::Isotropic == data4.angularDistributionType(2) ); - CHECK( AngularDistributionType::Tabulated == data4.angularDistributionType(3) ); - CHECK( 8 == data4.relativeAngularDistributionLocator(1) ); - CHECK( 0 == data4.relativeAngularDistributionLocator(2) ); - CHECK( 19 == data4.relativeAngularDistributionLocator(3) ); - CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data4.angularDistributionData(1) ) ); - CHECK( true == std::holds_alternative< IsotropicAngularDistribution >( data4.angularDistributionData(2) ) ); - CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data4.angularDistributionData(3) ) ); + CHECK( -32 == data4.distributionLocator(1) ); + CHECK( 0 == data4.distributionLocator(2) ); + CHECK( -43 == data4.distributionLocator(3) ); + CHECK( AngularDistributionType::Tabulated == data4.distributionType(1) ); + CHECK( AngularDistributionType::Isotropic == data4.distributionType(2) ); + CHECK( AngularDistributionType::Tabulated == data4.distributionType(3) ); + CHECK( 8 == data4.relativeDistributionLocator(1) ); + CHECK( 0 == data4.relativeDistributionLocator(2) ); + CHECK( 19 == data4.relativeDistributionLocator(3) ); + CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data4.distribution(1) ) ); + CHECK( true == std::holds_alternative< IsotropicAngularDistribution >( data4.distribution(2) ) ); + CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( data4.distribution(3) ) ); } diff --git a/src/ACEtk/block/AngularDistributionData.hpp b/src/ACEtk/block/AngularDistributionData.hpp index fe1b5a09..49ee940a 100644 --- a/src/ACEtk/block/AngularDistributionData.hpp +++ b/src/ACEtk/block/AngularDistributionData.hpp @@ -118,7 +118,7 @@ class AngularDistributionData : protected details::Base { * * @param[in] index the index (one-based) */ - int angularDistributionLocator( std::size_t index ) const { + int distributionLocator( std::size_t index ) const { return this->LOCC( index ); } @@ -135,7 +135,7 @@ class AngularDistributionData : protected details::Base { * * @param[in] index the index (one-based) */ - std::size_t relativeAngularDistributionLocator( std::size_t index ) const { + std::size_t relativeDistributionLocator( std::size_t index ) const { const int locator = this->LOCC( index ); return locator == 0 ? locator : std::abs( locator ) - this->locb_ + 1; @@ -149,9 +149,9 @@ class AngularDistributionData : protected details::Base { * * @param[in] index the index (one-based) */ - AngularDistributionType angularDistributionType( std::size_t index ) const { + AngularDistributionType distributionType( std::size_t index ) const { - const auto locator = this->angularDistributionLocator( index ); + const auto locator = this->distributionLocator( index ); return locator == 0 ? AngularDistributionType::Isotropic : locator < 0 ? AngularDistributionType::Tabulated @@ -166,9 +166,9 @@ class AngularDistributionData : protected details::Base { * * @param[in] index the index (one-based) */ - Distribution angularDistributionData( std::size_t index ) const { + Distribution distribution( std::size_t index ) const { - const auto type = this->angularDistributionType( index ); + const auto type = this->distributionType( index ); const double incident = this->incidentEnergy( index ); if ( type == AngularDistributionType::Isotropic ) { @@ -176,12 +176,12 @@ class AngularDistributionData : protected details::Base { } else { - const auto locator = this->relativeAngularDistributionLocator( index ); + const auto locator = this->relativeDistributionLocator( index ); const auto left = std::next( this->begin(), locator - 1 ); auto right = this->end(); for ( auto next = index + 1; next <= this->numberIncidentEnergies(); ++next ) { - auto nextlocator = this->relativeAngularDistributionLocator( next ); + auto nextlocator = this->relativeDistributionLocator( next ); if ( nextlocator > locator ) { right = std::next( this->begin(), nextlocator - 1 ); diff --git a/src/ACEtk/block/AngularDistributionData/src/ctor.hpp b/src/ACEtk/block/AngularDistributionData/src/ctor.hpp index 364d576d..5908887d 100644 --- a/src/ACEtk/block/AngularDistributionData/src/ctor.hpp +++ b/src/ACEtk/block/AngularDistributionData/src/ctor.hpp @@ -18,7 +18,7 @@ AngularDistributionData( std::vector< Distribution >&& distributions, /** * @brief Constructor * - * @param[in] locb the offset with respect to the beginning of the AND block + * @param[in] locb the starting xss index with respect to the AND block * @param[in] begin the begin iterator of the block in the XSS array * @param[in] end the end iterator of the block in the XSS array */ diff --git a/src/ACEtk/block/AngularDistributionData/src/verifyIncidentEnergyIndex.hpp b/src/ACEtk/block/AngularDistributionData/src/verifyIncidentEnergyIndex.hpp index 6f0cf3aa..9064d7b4 100644 --- a/src/ACEtk/block/AngularDistributionData/src/verifyIncidentEnergyIndex.hpp +++ b/src/ACEtk/block/AngularDistributionData/src/verifyIncidentEnergyIndex.hpp @@ -5,7 +5,7 @@ void verifyIncidentEnergyIndex( const std::size_t index ) const { Log::error( "Illegal incident energy index argument into {} block", this->name() ); Log::info( "Index value: {}", index ); - Log::info( "{} accepts a reaction index between 1 and {} inclusively", + Log::info( "{} accepts an incident energy index between 1 and {} inclusively", this->name(), this->numberIncidentEnergies() ); throw std::out_of_range( this->name() ); } diff --git a/src/ACEtk/block/AngularDistributionData/test/AngularDistributionData.test.cpp b/src/ACEtk/block/AngularDistributionData/test/AngularDistributionData.test.cpp index 2fd16960..b23ed69a 100644 --- a/src/ACEtk/block/AngularDistributionData/test/AngularDistributionData.test.cpp +++ b/src/ACEtk/block/AngularDistributionData/test/AngularDistributionData.test.cpp @@ -122,18 +122,18 @@ void verifyChunk( const AngularDistributionData& chunk ) { CHECK( 0 == chunk.LOCC(1) ); CHECK( 13 == chunk.LOCC(2) ); CHECK( -46 == chunk.LOCC(3) ); - CHECK( 0 == chunk.angularDistributionLocator(1) ); - CHECK( 13 == chunk.angularDistributionLocator(2) ); - CHECK( -46 == chunk.angularDistributionLocator(3) ); - - CHECK( AngularDistributionType::Isotropic == chunk.angularDistributionType(1) ); - CHECK( AngularDistributionType::Equiprobable == chunk.angularDistributionType(2) ); - CHECK( AngularDistributionType::Tabulated == chunk.angularDistributionType(3) ); - CHECK( 0 == chunk.relativeAngularDistributionLocator(1) ); - CHECK( 8 == chunk.relativeAngularDistributionLocator(2) ); - CHECK( 41 == chunk.relativeAngularDistributionLocator(3) ); - - CHECK( true == std::holds_alternative< IsotropicAngularDistribution >( chunk.angularDistributionData(1) ) ); - CHECK( true == std::holds_alternative< EquiprobableAngularBins >( chunk.angularDistributionData(2) ) ); - CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( chunk.angularDistributionData(3) ) ); + CHECK( 0 == chunk.distributionLocator(1) ); + CHECK( 13 == chunk.distributionLocator(2) ); + CHECK( -46 == chunk.distributionLocator(3) ); + + CHECK( AngularDistributionType::Isotropic == chunk.distributionType(1) ); + CHECK( AngularDistributionType::Equiprobable == chunk.distributionType(2) ); + CHECK( AngularDistributionType::Tabulated == chunk.distributionType(3) ); + CHECK( 0 == chunk.relativeDistributionLocator(1) ); + CHECK( 8 == chunk.relativeDistributionLocator(2) ); + CHECK( 41 == chunk.relativeDistributionLocator(3) ); + + CHECK( true == std::holds_alternative< IsotropicAngularDistribution >( chunk.distribution(1) ) ); + CHECK( true == std::holds_alternative< EquiprobableAngularBins >( chunk.distribution(2) ) ); + CHECK( true == std::holds_alternative< TabulatedAngularDistribution >( chunk.distribution(3) ) ); } diff --git a/src/ACEtk/block/KalbachMannDistributionData.hpp b/src/ACEtk/block/KalbachMannDistributionData.hpp new file mode 100644 index 00000000..1ea415cb --- /dev/null +++ b/src/ACEtk/block/KalbachMannDistributionData.hpp @@ -0,0 +1,142 @@ +#ifndef NJOY_ACETK_BLOCK_KALBACHMANNDISTRIBUTIONDATA +#define NJOY_ACETK_BLOCK_KALBACHMANNDISTRIBUTIONDATA + +// system includes +#include + +// other includes +#include "utility/overload.hpp" +#include "ACEtk/block/details/BaseDistributionData.hpp" +#include "ACEtk/block/TabulatedKalbachMannDistribution.hpp" + +namespace njoy { +namespace ACEtk { +namespace block { + +/** + * @class + * @brief Correlated outgoing energy-angle distribution data from the DLW block + * for a single reaction using Kalbach-Mann systematics + */ +class KalbachMannDistributionData : + protected details::BaseDistributionData< TabulatedKalbachMannDistribution > { + + /* fields */ + + /* auxiliary functions */ + +public: + + /* constructor */ + #include "ACEtk/block/KalbachMannDistributionData/src/ctor.hpp" + + /** + * @brief Return the number of incident energy values + */ + std::size_t NE() const { return BaseDistributionData::NE(); } + + /** + * @brief Return the number of incident energy values + */ + std::size_t numberIncidentEnergies() const { + + return BaseDistributionData::numberIncidentEnergies(); + } + + /** + * @brief Return the incident energy values + */ + auto incidentEnergies() const { + + return BaseDistributionData::incidentEnergies(); + } + + /** + * @brief Return the incident energy for a given index + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + double incidentEnergy( std::size_t index ) const { + + return BaseDistributionData::incidentEnergy( index ); + } + + /** + * @brief Return the distribution locator for an incident energy index + * + * This locator is the value as stored in the XSS array. It is relative to + * the beginning of the DLW block. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + int LOCC( std::size_t index ) const { + + return BaseDistributionData::LOCC( index ); + } + + /** + * @brief Return the distribution locator for an incident energy index + * + * This locator is the value as stored in the XSS array. It is relative to + * the beginning of the DLW block. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + int distributionLocator( std::size_t index ) const { + + return BaseDistributionData::distributionLocator( index ); + } + + /** + * @brief Return the relative distribution locator for an incident energy + * index + * + * This is the locator relative to the beginning of the current + * distribution block in the DLW block. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + std::size_t relativeDistributionLocator( std::size_t index ) const { + + return BaseDistributionData::relativeDistributionLocator( index ); + } + + /** + * @brief Return the distribution for an incident energy index + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + TabulatedKalbachMannDistribution + distribution( std::size_t index ) const { + + return BaseDistributionData::distribution( index ); + } + + using Base::empty; + using Base::name; + using Base::length; + using Base::XSS; + using Base::begin; + using Base::end; +}; + +} // block namespace +} // ACEtk namespace +} // njoy namespace + +#endif diff --git a/src/ACEtk/block/KalbachMannDistributionData/src/ctor.hpp b/src/ACEtk/block/KalbachMannDistributionData/src/ctor.hpp new file mode 100644 index 00000000..3f7b0067 --- /dev/null +++ b/src/ACEtk/block/KalbachMannDistributionData/src/ctor.hpp @@ -0,0 +1,46 @@ +KalbachMannDistributionData() = default; + +KalbachMannDistributionData( const KalbachMannDistributionData& ) = default; +KalbachMannDistributionData( KalbachMannDistributionData&& ) = default; + +/** + * @brief Constructor + * + * @param[in] boundaries the interpolation range boundaries + * @param[in] interpolants the interpolation types for each range + * @param[in] distributions the distributions for each incident energy + * @param[in] locb the starting xss index with respect to the superblock + */ +KalbachMannDistributionData( + std::vector< long >&& boundaries, + std::vector< long >&& interpolants, + std::vector< TabulatedKalbachMannDistribution >&& distributions, + std::size_t locb = 1 ) : + BaseDistributionData( "DLW::KalbachMannDistributionData", + std::move( boundaries ), std::move( interpolants ), + std::move( distributions ), locb ) {} + +/** + * @brief Constructor without interpolation data + * + * @param[in] distributions the distributions for each incident energy + * @param[in] locb the starting xss index with respect to the superblock + */ +KalbachMannDistributionData( + std::vector< TabulatedKalbachMannDistribution >&& distributions, + std::size_t locb = 1 ) : + KalbachMannDistributionData( {}, {}, std::move( distributions ), locb ) {} + +/** + * @brief Constructor + * + * @param[in] locb the starting xss index with respect to the superblock + * @param[in] sig the begin iterator of the block in the XSS array + * @param[in] end the end iterator of the block in the XSS array + */ +KalbachMannDistributionData( std::size_t locb, Iterator begin, Iterator end ) : + BaseDistributionData( "DLW::KalbachMannDistributionData", locb, + begin, end ) {} + +KalbachMannDistributionData& operator=( const KalbachMannDistributionData& ) = default; +KalbachMannDistributionData& operator=( KalbachMannDistributionData&& ) = default; diff --git a/src/ACEtk/block/KalbachMannDistributionData/test/CMakeLists.txt b/src/ACEtk/block/KalbachMannDistributionData/test/CMakeLists.txt new file mode 100644 index 00000000..801c2788 --- /dev/null +++ b/src/ACEtk/block/KalbachMannDistributionData/test/CMakeLists.txt @@ -0,0 +1,18 @@ + +add_executable( ACEtk.block.KalbachMannDistributionData.test KalbachMannDistributionData.test.cpp ) +target_compile_options( ACEtk.block.KalbachMannDistributionData.test PRIVATE ${${PREFIX}_common_flags} +$<$:${${PREFIX}_strict_flags}>$<$: +${${PREFIX}_DEBUG_flags} +$<$:${${PREFIX}_coverage_flags}>> +$<$: +${${PREFIX}_RELEASE_flags} +$<$:${${PREFIX}_link_time_optimization_flags}> +$<$:${${PREFIX}_nonportable_optimization_flags}>> + +${CXX_appended_flags} ${ACEtk_appended_flags} ) +target_link_libraries( ACEtk.block.KalbachMannDistributionData.test PUBLIC ACEtk ) +file( GLOB resources "resources/*" ) +foreach( resource ${resources}) + file( COPY "${resource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" ) +endforeach() +add_test( NAME ACEtk.block.KalbachMannDistributionData COMMAND ACEtk.block.KalbachMannDistributionData.test ) diff --git a/src/ACEtk/block/KalbachMannDistributionData/test/KalbachMannDistributionData.test.cpp b/src/ACEtk/block/KalbachMannDistributionData/test/KalbachMannDistributionData.test.cpp new file mode 100644 index 00000000..619e8f7f --- /dev/null +++ b/src/ACEtk/block/KalbachMannDistributionData/test/KalbachMannDistributionData.test.cpp @@ -0,0 +1,166 @@ +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "ACEtk/block/KalbachMannDistributionData.hpp" + +// other includes + +// convenience typedefs +using namespace njoy::ACEtk; +using KalbachMannDistributionData = block::KalbachMannDistributionData; +using TabulatedKalbachMannDistribution = block::TabulatedKalbachMannDistribution; + +std::vector< double > chunk(); +void verifyChunk( const KalbachMannDistributionData& ); + +SCENARIO( "KalbachMannDistributionData" ) { + + GIVEN( "valid data for a KalbachMannDistributionData instance" ) { + + std::vector< double > xss = chunk(); + + WHEN( "the data is given explicitly" ) { + + std::vector< TabulatedKalbachMannDistribution > distributions = { + + TabulatedKalbachMannDistribution( + 1.219437E+01, 1, { 0.000000E+00, 1.866919E-02 }, + { 5.356419E+01, 0.000000E+00 }, { 0., 1. }, { 0., 0. }, + { 2.391154E-01, 2.398743E-01 } ), + TabulatedKalbachMannDistribution( + 20., 2, { 0.000000E+00, 1.120151E+00, 7.592137E+00 }, + { 7.738696E-02, 4.209016E-01, 1.226090E-11 }, + { 0.000000E+00, 5.382391E-01, 1.000000E+00 }, + { 2.491475E-03, 1.510768E-02, 9.775367E-01 }, + { 2.391154E-01, 2.847920E-01, 5.592013E-01 } ) + }; + std::size_t locb = 21; + + KalbachMannDistributionData chunk( std::move( distributions ), locb ); + + THEN( "a KalbachMannDistributionData can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + + WHEN( "the data is defined by iterators" ) { + + KalbachMannDistributionData chunk( 21, xss.begin(), xss.end() ); + + THEN( "a KalbachMannDistributionData can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +std::vector< double > chunk() { + + return { 0, 2, 1.219437E+01, 2.000000E+01, + 27, 39, 1, 2, + 0.000000E+00, 1.866919E-02, 5.356419E+01, 0.000000E+00, + 0.000000E+00, 1.000000E+00, 0.000000E+00, 0.000000E+00, + 2.391154E-01, 2.398743E-01, 2, 3, + 0.000000E+00, 1.120151E+00, 7.592137E+00, 7.738696E-02, + 4.209016E-01, 1.226090E-11, 0.000000E+00, 5.382391E-01, + 1.000000E+00, 2.491475E-03, 1.510768E-02, 9.775367E-01, + 2.391154E-01, 2.847920E-01, 5.592013E-01 };} + +void verifyChunk( const KalbachMannDistributionData& chunk ) { + + CHECK( false == chunk.empty() ); + CHECK( 35 == chunk.length() ); + CHECK( "DLW::KalbachMannDistributionData" == chunk.name() ); + + CHECK( 2 == chunk.NE() ); + CHECK( 2 == chunk.numberIncidentEnergies() ); + + CHECK( 2 == chunk.incidentEnergies().size() ); + CHECK( 1.219437E+01 == Approx( chunk.incidentEnergies()[0] ) ); + CHECK( 20. == Approx( chunk.incidentEnergies()[1] ) ); + + CHECK( 1.219437E+01 == Approx( chunk.incidentEnergy(1) ) ); + CHECK( 20. == Approx( chunk.incidentEnergy(2) ) ); + + CHECK( 27 == chunk.LOCC(1) ); + CHECK( 39 == chunk.LOCC(2) ); + CHECK( 27 == chunk.distributionLocator(1) ); + CHECK( 39 == chunk.distributionLocator(2) ); + + CHECK( 7 == chunk.relativeDistributionLocator(1) ); + CHECK( 19 == chunk.relativeDistributionLocator(2) ); + + auto data1 = chunk.distribution(1); + CHECK( 1.219437E+01 == Approx( data1.incidentEnergy() ) ); + CHECK( 1 == data1.interpolation() ); + CHECK( 0 == data1.numberDiscretePhotonLines() ); + CHECK( 2 == data1.numberOutgoingEnergies() ); + + CHECK( 2 == data1.outgoingEnergies().size() ); + CHECK( 0.0 == Approx( data1.outgoingEnergies().front() ) ); + CHECK( 1.866919E-02 == Approx( data1.outgoingEnergies().back() ) ); + + CHECK( 2 == data1.pdf().size() ); + CHECK( 5.356419E+01 == Approx( data1.pdf().front() ) ); + CHECK( 0. == Approx( data1.pdf().back() ) ); + + CHECK( 2 == data1.cdf().size() ); + CHECK( 0. == Approx( data1.cdf().front() ) ); + CHECK( 1. == Approx( data1.cdf().back() ) ); + + CHECK( 2 == data1.precompoundFractionValues().size() ); + CHECK( 0. == Approx( data1.precompoundFractionValues().front() ) ); + CHECK( 0. == Approx( data1.precompoundFractionValues().back() ) ); + + CHECK( 2 == data1.angularDistributionSlopeValues().size() ); + CHECK( 2.391154E-01 == Approx( data1.angularDistributionSlopeValues().front() ) ); + CHECK( 2.398743E-01 == Approx( data1.angularDistributionSlopeValues().back() ) ); + + auto data2 = chunk.distribution(2); + CHECK( 20. == Approx( data2.incidentEnergy() ) ); + CHECK( 2 == data2.interpolation() ); + CHECK( 0 == data2.numberDiscretePhotonLines() ); + CHECK( 3 == data2.numberOutgoingEnergies() ); + + CHECK( 3 == data2.outgoingEnergies().size() ); + CHECK( 0.0 == Approx( data2.outgoingEnergies().front() ) ); + CHECK( 7.592137E+00 == Approx( data2.outgoingEnergies().back() ) ); + + CHECK( 3 == data2.pdf().size() ); + CHECK( 7.738696E-02 == Approx( data2.pdf().front() ) ); + CHECK( 1.226090E-11 == Approx( data2.pdf().back() ) ); + + CHECK( 3 == data2.cdf().size() ); + CHECK( 0. == Approx( data2.cdf().front() ) ); + CHECK( 1. == Approx( data2.cdf().back() ) ); + + CHECK( 3 == data2.precompoundFractionValues().size() ); + CHECK( 2.491475E-03 == Approx( data2.precompoundFractionValues().front() ) ); + CHECK( 9.775367E-01 == Approx( data2.precompoundFractionValues().back() ) ); + + CHECK( 3 == data2.angularDistributionSlopeValues().size() ); + CHECK( 2.391154E-01 == Approx( data2.angularDistributionSlopeValues().front() ) ); + CHECK( 5.592013E-01 == Approx( data2.angularDistributionSlopeValues().back() ) ); +} diff --git a/src/ACEtk/block/OutgoingEnergyDistributionData.hpp b/src/ACEtk/block/OutgoingEnergyDistributionData.hpp new file mode 100644 index 00000000..835221f6 --- /dev/null +++ b/src/ACEtk/block/OutgoingEnergyDistributionData.hpp @@ -0,0 +1,142 @@ +#ifndef NJOY_ACETK_BLOCK_OUTGOINGENERGYDISTRIBUTIONDATA +#define NJOY_ACETK_BLOCK_OUTGOINGENERGYDISTRIBUTIONDATA + +// system includes +#include + +// other includes +#include "utility/overload.hpp" +#include "ACEtk/block/details/BaseDistributionData.hpp" +#include "ACEtk/block/TabulatedOutgoingEnergyDistribution.hpp" + +namespace njoy { +namespace ACEtk { +namespace block { + +/** + * @class + * @brief Outgoing energy distribution data from the DLW block for a single + * reaction using tabulated outgoing energy distributions + */ +class OutgoingEnergyDistributionData : + protected details::BaseDistributionData< TabulatedOutgoingEnergyDistribution > { + + /* fields */ + + /* auxiliary functions */ + +public: + + /* constructor */ + #include "ACEtk/block/OutgoingEnergyDistributionData/src/ctor.hpp" + + /** + * @brief Return the number of incident energy values + */ + std::size_t NE() const { return BaseDistributionData::NE(); } + + /** + * @brief Return the number of incident energy values + */ + std::size_t numberIncidentEnergies() const { + + return BaseDistributionData::numberIncidentEnergies(); + } + + /** + * @brief Return the incident energy values + */ + auto incidentEnergies() const { + + return BaseDistributionData::incidentEnergies(); + } + + /** + * @brief Return the incident energy for a given index + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + double incidentEnergy( std::size_t index ) const { + + return BaseDistributionData::incidentEnergy( index ); + } + + /** + * @brief Return the distribution locator for an incident energy index + * + * This locator is the value as stored in the XSS array. It is relative to + * the beginning of the DLW block. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + int LOCC( std::size_t index ) const { + + return BaseDistributionData::LOCC( index ); + } + + /** + * @brief Return the distribution locator for an incident energy index + * + * This locator is the value as stored in the XSS array. It is relative to + * the beginning of the DLW block. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + int distributionLocator( std::size_t index ) const { + + return BaseDistributionData::distributionLocator( index ); + } + + /** + * @brief Return the relative distribution locator for an incident energy + * index + * + * This is the locator relative to the beginning of the current + * distribution block in the DLW block. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + std::size_t relativeDistributionLocator( std::size_t index ) const { + + return BaseDistributionData::relativeDistributionLocator( index ); + } + + /** + * @brief Return the distribution for an incident energy index + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + TabulatedOutgoingEnergyDistribution + distribution( std::size_t index ) const { + + return BaseDistributionData::distribution( index ); + } + + using Base::empty; + using Base::name; + using Base::length; + using Base::XSS; + using Base::begin; + using Base::end; +}; + +} // block namespace +} // ACEtk namespace +} // njoy namespace + +#endif diff --git a/src/ACEtk/block/OutgoingEnergyDistributionData/src/ctor.hpp b/src/ACEtk/block/OutgoingEnergyDistributionData/src/ctor.hpp new file mode 100644 index 00000000..dd2bc6e6 --- /dev/null +++ b/src/ACEtk/block/OutgoingEnergyDistributionData/src/ctor.hpp @@ -0,0 +1,44 @@ +OutgoingEnergyDistributionData() = default; + +OutgoingEnergyDistributionData( const OutgoingEnergyDistributionData& ) = default; +OutgoingEnergyDistributionData( OutgoingEnergyDistributionData&& ) = default; + +/** + * @brief Constructor + * + * @param[in] boundaries the interpolation range boundaries + * @param[in] interpolants the interpolation types for each range + * @param[in] distributions the distributions for each incident energy + * @param[in] locb the starting xss index with respect to the superblock + */ +OutgoingEnergyDistributionData( std::vector< long >&& boundaries, + std::vector< long >&& interpolants, + std::vector< TabulatedOutgoingEnergyDistribution >&& distributions, + std::size_t locb = 1 ) : + BaseDistributionData( "DLW::OutgoingEnergyDistributionData", + std::move( boundaries ), std::move( interpolants ), + std::move( distributions ), locb ) {} + +/** + * @brief Constructor without interpolation data + * + * @param[in] distributions the distributions for each incident energy + * @param[in] locb the starting xss index with respect to the superblock + */ +OutgoingEnergyDistributionData( std::vector< TabulatedOutgoingEnergyDistribution >&& distributions, + std::size_t locb = 1 ) : + OutgoingEnergyDistributionData( {}, {}, std::move( distributions ), locb ) {} + +/** + * @brief Constructor + * + * @param[in] locb the starting xss index with respect to the superblock + * @param[in] sig the begin iterator of the block in the XSS array + * @param[in] end the end iterator of the block in the XSS array + */ +OutgoingEnergyDistributionData( std::size_t locb, Iterator begin, Iterator end ) : + BaseDistributionData( "DLW::OutgoingEnergyDistributionData", locb, + begin, end ) {} + +OutgoingEnergyDistributionData& operator=( const OutgoingEnergyDistributionData& ) = default; +OutgoingEnergyDistributionData& operator=( OutgoingEnergyDistributionData&& ) = default; diff --git a/src/ACEtk/block/OutgoingEnergyDistributionData/test/CMakeLists.txt b/src/ACEtk/block/OutgoingEnergyDistributionData/test/CMakeLists.txt new file mode 100644 index 00000000..f519445a --- /dev/null +++ b/src/ACEtk/block/OutgoingEnergyDistributionData/test/CMakeLists.txt @@ -0,0 +1,18 @@ + +add_executable( ACEtk.block.OutgoingEnergyDistributionData.test OutgoingEnergyDistributionData.test.cpp ) +target_compile_options( ACEtk.block.OutgoingEnergyDistributionData.test PRIVATE ${${PREFIX}_common_flags} +$<$:${${PREFIX}_strict_flags}>$<$: +${${PREFIX}_DEBUG_flags} +$<$:${${PREFIX}_coverage_flags}>> +$<$: +${${PREFIX}_RELEASE_flags} +$<$:${${PREFIX}_link_time_optimization_flags}> +$<$:${${PREFIX}_nonportable_optimization_flags}>> + +${CXX_appended_flags} ${ACEtk_appended_flags} ) +target_link_libraries( ACEtk.block.OutgoingEnergyDistributionData.test PUBLIC ACEtk ) +file( GLOB resources "resources/*" ) +foreach( resource ${resources}) + file( COPY "${resource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" ) +endforeach() +add_test( NAME ACEtk.block.OutgoingEnergyDistributionData COMMAND ACEtk.block.OutgoingEnergyDistributionData.test ) diff --git a/src/ACEtk/block/OutgoingEnergyDistributionData/test/OutgoingEnergyDistributionData.test.cpp b/src/ACEtk/block/OutgoingEnergyDistributionData/test/OutgoingEnergyDistributionData.test.cpp new file mode 100644 index 00000000..7d6cd54e --- /dev/null +++ b/src/ACEtk/block/OutgoingEnergyDistributionData/test/OutgoingEnergyDistributionData.test.cpp @@ -0,0 +1,144 @@ +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "ACEtk/block/OutgoingEnergyDistributionData.hpp" + +// other includes + +// convenience typedefs +using namespace njoy::ACEtk; +using OutgoingEnergyDistributionData = block::OutgoingEnergyDistributionData; +using TabulatedOutgoingEnergyDistribution = block::TabulatedOutgoingEnergyDistribution; + +std::vector< double > chunk(); +void verifyChunk( const OutgoingEnergyDistributionData& ); + +SCENARIO( "OutgoingEnergyDistributionData" ) { + + GIVEN( "valid data for an OutgoingEnergyDistributionData instance" ) { + + std::vector< double > xss = chunk(); + + WHEN( "the data is given explicitly" ) { + + std::vector< TabulatedOutgoingEnergyDistribution > distributions = { + + TabulatedOutgoingEnergyDistribution( + 1e-11, 2, { 0.0, .31, 1.84 }, + { 2.364290E-01, 1.050191E+00, 0. }, { 0., 4.932501E-01, 1. } ), + TabulatedOutgoingEnergyDistribution( + 20., 2, { 0.0, 1.84 }, { .5, .5 }, { 0., 1. } ) + }; + std::size_t locb = 21; + + OutgoingEnergyDistributionData chunk( std::move( distributions ), locb ); + + THEN( "an OutgoingEnergyDistributionData can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + + WHEN( "the data is defined by iterators" ) { + + OutgoingEnergyDistributionData chunk( 21, xss.begin(), xss.end() ); + + THEN( "an OutgoingEnergyDistributionData can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +std::vector< double > chunk() { + + return { 0, 2, 1.000000E-11, 2.000000E+01, + 27, 38, 2, 3, + 0.000000E+00, 3.100000E-01, 1.840000E+00, 2.364290E-01, + 1.050191E+00, 0.000000E+00, 0.000000E+00, 4.932501E-01, + 1.000000E+00, 2, 2, 0.000000E+00, + 1.840000E+00, 5.000000E-01, 5.000000E-01, 0.000000E+00, + 1.000000E+00 }; +} + +void verifyChunk( const OutgoingEnergyDistributionData& chunk ) { + + CHECK( false == chunk.empty() ); + CHECK( 25 == chunk.length() ); + CHECK( "DLW::OutgoingEnergyDistributionData" == chunk.name() ); + + CHECK( 2 == chunk.NE() ); + CHECK( 2 == chunk.numberIncidentEnergies() ); + + CHECK( 2 == chunk.incidentEnergies().size() ); + CHECK( 1e-11 == Approx( chunk.incidentEnergies()[0] ) ); + CHECK( 20. == Approx( chunk.incidentEnergies()[1] ) ); + + CHECK( 1e-11 == Approx( chunk.incidentEnergy(1) ) ); + CHECK( 20. == Approx( chunk.incidentEnergy(2) ) ); + + CHECK( 27 == chunk.LOCC(1) ); + CHECK( 38 == chunk.LOCC(2) ); + CHECK( 27 == chunk.distributionLocator(1) ); + CHECK( 38 == chunk.distributionLocator(2) ); + + CHECK( 7 == chunk.relativeDistributionLocator(1) ); + CHECK( 18 == chunk.relativeDistributionLocator(2) ); + + auto data1 = chunk.distribution(1); + CHECK( 1e-11 == Approx( data1.incidentEnergy() ) ); + CHECK( 2 == data1.interpolation() ); + CHECK( 0 == data1.numberDiscretePhotonLines() ); + CHECK( 3 == data1.numberOutgoingEnergies() ); + + CHECK( 3 == data1.outgoingEnergies().size() ); + CHECK( 0.0 == Approx( data1.outgoingEnergies().front() ) ); + CHECK( 1.84 == Approx( data1.outgoingEnergies().back() ) ); + + CHECK( 3 == data1.pdf().size() ); + CHECK( 2.364290E-01 == Approx( data1.pdf().front() ) ); + CHECK( 0. == Approx( data1.pdf().back() ) ); + + CHECK( 3 == data1.cdf().size() ); + CHECK( 0. == Approx( data1.cdf().front() ) ); + CHECK( 1. == Approx( data1.cdf().back() ) ); + + auto data2 = chunk.distribution(2); + CHECK( 20. == Approx( data2.incidentEnergy() ) ); + CHECK( 2 == data2.interpolation() ); + CHECK( 0 == data2.numberDiscretePhotonLines() ); + CHECK( 2 == data2.numberOutgoingEnergies() ); + + CHECK( 2 == data2.outgoingEnergies().size() ); + CHECK( 0.0 == Approx( data2.outgoingEnergies().front() ) ); + CHECK( 1.84 == Approx( data2.outgoingEnergies().back() ) ); + + CHECK( 2 == data2.pdf().size() ); + CHECK( 0.5 == Approx( data2.pdf().front() ) ); + CHECK( 0.5 == Approx( data2.pdf().back() ) ); + + CHECK( 2 == data2.cdf().size() ); + CHECK( 0. == Approx( data2.cdf().front() ) ); + CHECK( 1. == Approx( data2.cdf().back() ) ); +} diff --git a/src/ACEtk/block/TabulatedAngularDistribution/src/ctor.hpp b/src/ACEtk/block/TabulatedAngularDistribution/src/ctor.hpp index f67cd774..2e6bd1fc 100644 --- a/src/ACEtk/block/TabulatedAngularDistribution/src/ctor.hpp +++ b/src/ACEtk/block/TabulatedAngularDistribution/src/ctor.hpp @@ -20,7 +20,7 @@ TabulatedAngularDistribution( double incident, TabulatedProbabilityDistribution( "AND::TabulatedAngularDistribution", interpolation, std::move( cosines ), - std::move( pdf ), std::move( cdf ) ), + std::move( pdf ), std::move( cdf ), {} ), incident_( incident ) {} /** diff --git a/src/ACEtk/block/TabulatedAngularDistribution/src/generateXSS.hpp b/src/ACEtk/block/TabulatedAngularDistribution/src/generateXSS.hpp deleted file mode 100644 index f8cfb237..00000000 --- a/src/ACEtk/block/TabulatedAngularDistribution/src/generateXSS.hpp +++ /dev/null @@ -1,15 +0,0 @@ -static std::vector< double > generateXSS( - int interpolation, - std::vector< double >&& cosines, - std::vector< double >&& pdf, - std::vector< double >&& cdf ) { - - std::vector< double > xss = { static_cast< double >( interpolation ) }; - xss.reserve( 2 + 3 * cosines.size() ); - details::ColumnData data( "AND::TabulatedAngularDistribution", - std::move( cosines ), std::move( pdf ), - std::move( cdf ) ); - xss.insert( xss.end(), data.begin(), data.end() ); - - return xss; -} diff --git a/src/ACEtk/block/TabulatedAngularDistribution/src/verifySize.hpp b/src/ACEtk/block/TabulatedAngularDistribution/src/verifySize.hpp deleted file mode 100644 index cffa45ed..00000000 --- a/src/ACEtk/block/TabulatedAngularDistribution/src/verifySize.hpp +++ /dev/null @@ -1,13 +0,0 @@ -static void verifySize( Iterator begin, Iterator end, - unsigned int numberValues ) { - - auto size = std::distance( begin, end ); - if ( size < 3 * numberValues + 2 ) { - - Log::error( "The size of the XSS subrange in the tabulated angular " - "distribution data should be at least 2 + 3 * XSS(2)" ); - Log::info( "XSS(2) value: {}", numberValues ); - Log::info( "XSS.size(): {}", size ); - throw std::exception(); - } -} diff --git a/src/ACEtk/block/TabulatedKalbachMannDistribution.hpp b/src/ACEtk/block/TabulatedKalbachMannDistribution.hpp new file mode 100644 index 00000000..9ba227a8 --- /dev/null +++ b/src/ACEtk/block/TabulatedKalbachMannDistribution.hpp @@ -0,0 +1,120 @@ +#ifndef NJOY_ACETK_BLOCK_TABULATEDKALBACHMANNDISTRIBUTION +#define NJOY_ACETK_BLOCK_TABULATEDKALBACHMANNDISTRIBUTION + +// system includes + +// other includes +#include "ACEtk/block/details/TabulatedProbabilityDistribution.hpp" + +namespace njoy { +namespace ACEtk { +namespace block { + +/** + * @class + * @brief Tabulated Kalbach-Mann distribution data from the DLW block for + * a single reaction and incident energy + * + * The TabulatedKalbachMannDistribution class contains the probability + * density function (PDF), the cumulative density function (CDF), the + * precompound fraction r and angular distribution slope a as a function + * of the outgoing energy for a single incident energy. + */ +class TabulatedKalbachMannDistribution : + protected details::TabulatedProbabilityDistribution { + + /* fields */ + double incident_; + + /* auxiliary functions */ + +public: + + /* constructor */ + #include "ACEtk/block/TabulatedKalbachMannDistribution/src/ctor.hpp" + + /** + * @brief Return the incident energy value + */ + double incidentEnergy() const { return this->incident_; } + + /** + * @brief Return the interpolation flag + */ + unsigned int interpolation() const { + + // the INTT' value = 10 * ND + INTT + return TabulatedProbabilityDistribution::interpolation() % 10; + } + + /** + * @brief Return the number of discrete photon lines + */ + std::size_t numberDiscretePhotonLines() const { + + // the INTT' value = 10 * ND + INTT + return ( TabulatedProbabilityDistribution::interpolation() - + this->interpolation() ) / 10; + } + + /** + * @brief Return the number of cosine values + */ + std::size_t numberOutgoingEnergies() const { + + return TabulatedProbabilityDistribution::numberValues(); + } + + /** + * @brief Return the outgoing energies values + */ + auto outgoingEnergies() const { + + return TabulatedProbabilityDistribution::values(); + } + + /** + * @brief Return the pdf values + */ + auto pdf() const { + + return TabulatedProbabilityDistribution::pdf(); + } + + /** + * @brief Return the cdf values + */ + auto cdf() const { + + return TabulatedProbabilityDistribution::cdf(); + } + + /** + * @brief Return the precompound fraction values + */ + auto precompoundFractionValues() const { + + return this->column( 0 ); + } + + /** + * @brief Return the angular distribution slope values + */ + auto angularDistributionSlopeValues() const { + + return this->column( 1 ); + } + + using TabulatedProbabilityDistribution::empty; + using TabulatedProbabilityDistribution::name; + using TabulatedProbabilityDistribution::length; + using TabulatedProbabilityDistribution::XSS; + using TabulatedProbabilityDistribution::begin; + using TabulatedProbabilityDistribution::end; +}; + +} // block namespace +} // ACEtk namespace +} // njoy namespace + +#endif diff --git a/src/ACEtk/block/TabulatedKalbachMannDistribution/src/ctor.hpp b/src/ACEtk/block/TabulatedKalbachMannDistribution/src/ctor.hpp new file mode 100644 index 00000000..b2e6e960 --- /dev/null +++ b/src/ACEtk/block/TabulatedKalbachMannDistribution/src/ctor.hpp @@ -0,0 +1,45 @@ +TabulatedKalbachMannDistribution() = default; + +TabulatedKalbachMannDistribution( const TabulatedKalbachMannDistribution& ) = default; +TabulatedKalbachMannDistribution( TabulatedKalbachMannDistribution&& ) = default; + +/** + * @brief Constructor + * + * @param[in] incident the incident energy value + * @param[in] interpolation the interpolation type + * @param[in] cosines the cosine values (N values) + * @param[in] pdf the pdf values (N values) + * @param[in] cdf the cdf values (N values) + * @param[in] r the precompound fraction values (N values) + * @param[in] a the cdf values (N values) + * @param[in] discrete the number discrete photon lines (defaults to 0) + */ +TabulatedKalbachMannDistribution( double incident, + int interpolation, + std::vector< double >&& cosines, + std::vector< double >&& pdf, + std::vector< double >&& cdf, + std::vector< double >&& r, + std::vector< double >&& a, + std::size_t discrete = 0 ) : + TabulatedProbabilityDistribution( + "DLW::TabulatedKalbachMannDistribution", + discrete * 10 + interpolation, std::move( cosines ), + std::move( pdf ), std::move( cdf ), { std::move( r ), std::move( a ) } ), + incident_( incident ) {} + +/** + * @brief Constructor + * + * @param[in] incident the incident energy value + * @param[in] begin the begin iterator of the tabulated distribution data + * @param[in] end the end iterator of the tabulated distribution data + */ +TabulatedKalbachMannDistribution( double incident, Iterator begin, Iterator end ) : + TabulatedProbabilityDistribution( "DLW::TabulatedKalbachMannDistribution", + begin, end ), + incident_( incident ) {} + +TabulatedKalbachMannDistribution& operator=( const TabulatedKalbachMannDistribution& ) = default; +TabulatedKalbachMannDistribution& operator=( TabulatedKalbachMannDistribution&& ) = default; diff --git a/src/ACEtk/block/TabulatedKalbachMannDistribution/test/CMakeLists.txt b/src/ACEtk/block/TabulatedKalbachMannDistribution/test/CMakeLists.txt new file mode 100644 index 00000000..de14664d --- /dev/null +++ b/src/ACEtk/block/TabulatedKalbachMannDistribution/test/CMakeLists.txt @@ -0,0 +1,18 @@ + +add_executable( ACEtk.block.TabulatedKalbachMannDistribution.test TabulatedKalbachMannDistribution.test.cpp ) +target_compile_options( ACEtk.block.TabulatedKalbachMannDistribution.test PRIVATE ${${PREFIX}_common_flags} +$<$:${${PREFIX}_strict_flags}>$<$: +${${PREFIX}_DEBUG_flags} +$<$:${${PREFIX}_coverage_flags}>> +$<$: +${${PREFIX}_RELEASE_flags} +$<$:${${PREFIX}_link_time_optimization_flags}> +$<$:${${PREFIX}_nonportable_optimization_flags}>> + +${CXX_appended_flags} ${ACEtk_appended_flags} ) +target_link_libraries( ACEtk.block.TabulatedKalbachMannDistribution.test PUBLIC ACEtk ) +file( GLOB resources "resources/*" ) +foreach( resource ${resources}) + file( COPY "${resource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" ) +endforeach() +add_test( NAME ACEtk.block.TabulatedKalbachMannDistribution COMMAND ACEtk.block.TabulatedKalbachMannDistribution.test ) diff --git a/src/ACEtk/block/TabulatedKalbachMannDistribution/test/TabulatedKalbachMannDistribution.test.cpp b/src/ACEtk/block/TabulatedKalbachMannDistribution/test/TabulatedKalbachMannDistribution.test.cpp new file mode 100644 index 00000000..4c0444a3 --- /dev/null +++ b/src/ACEtk/block/TabulatedKalbachMannDistribution/test/TabulatedKalbachMannDistribution.test.cpp @@ -0,0 +1,118 @@ +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "ACEtk/block/TabulatedKalbachMannDistribution.hpp" + +// other includes + +// convenience typedefs +using namespace njoy::ACEtk; +using TabulatedKalbachMannDistribution = block::TabulatedKalbachMannDistribution; + +std::vector< double > chunk(); +void verifyChunk( const TabulatedKalbachMannDistribution& ); + +SCENARIO( "TabulatedKalbachMannDistribution" ) { + + GIVEN( "valid data for a TabulatedKalbachMannDistribution instance" ) { + + std::vector< double > xss = chunk(); + + WHEN( "the data is given explicitly" ) { + + double incident = 2.1; + int interpolation = 2; + std::size_t discrete = 3; + std::vector< double > cosines = { 1e-11, 1.0, 20.0 }; + std::vector< double > pdf = { 0.5, 0.5, 0.5 }; + std::vector< double > cdf = { 0.0, 0.5, 1.0 }; + std::vector< double > r = { 1., 2., 3. }; + std::vector< double > a = { 4., 5., 6. }; + + TabulatedKalbachMannDistribution chunk( incident, interpolation, + std::move( cosines ), + std::move( pdf ), + std::move( cdf ), + std::move( r ), + std::move( a ), + discrete ); + + THEN( "a TabulatedKalbachMannDistribution can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + + WHEN( "the data is defined by iterators" ) { + + double incident = 2.1; + TabulatedKalbachMannDistribution chunk( incident, xss.begin(), xss.end() ); + + THEN( "a TabulatedKalbachMannDistribution can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +std::vector< double > chunk() { + + return { 32, 3, 1.00000000000E-11, 1.00000000000E+00, + 2.00000000000E+01, 0.50000000000E+00, 0.50000000000E+00, 0.50000000000E+00, + 0.00000000000E+00, 0.50000000000E+00, 1.00000000000E+00, 1.00000000000E+00, + 2.00000000000E+00, 3.00000000000E+00, 4.00000000000E+00, 5.00000000000E+00, + 6.00000000000E+00 }; +} + +void verifyChunk( const TabulatedKalbachMannDistribution& chunk ) { + + CHECK( false == chunk.empty() ); + CHECK( 17 == chunk.length() ); + CHECK( "DLW::TabulatedKalbachMannDistribution" == chunk.name() ); + + CHECK( 2.1 == Approx( chunk.incidentEnergy() ) ); + CHECK( 2 == chunk.interpolation() ); + CHECK( 3 == chunk.numberDiscretePhotonLines() ); + CHECK( 3 == chunk.numberOutgoingEnergies() ); + + CHECK( 3 == chunk.outgoingEnergies().size() ); + CHECK( 1e-11 == Approx( chunk.outgoingEnergies().front() ) ); + CHECK( 20. == Approx( chunk.outgoingEnergies().back() ) ); + + CHECK( 3 == chunk.pdf().size() ); + CHECK( .5 == Approx( chunk.pdf().front() ) ); + CHECK( .5 == Approx( chunk.pdf().back() ) ); + + CHECK( 3 == chunk.cdf().size() ); + CHECK( 0. == Approx( chunk.cdf().front() ) ); + CHECK( 1. == Approx( chunk.cdf().back() ) ); + + CHECK( 3 == chunk.precompoundFractionValues().size() ); + CHECK( 1. == Approx( chunk.precompoundFractionValues().front() ) ); + CHECK( 3. == Approx( chunk.precompoundFractionValues().back() ) ); + + CHECK( 3 == chunk.cdf().size() ); + CHECK( 4. == Approx( chunk.angularDistributionSlopeValues().front() ) ); + CHECK( 6. == Approx( chunk.angularDistributionSlopeValues().back() ) ); +} diff --git a/src/ACEtk/block/TabulatedOutgoingEnergyDistribution.hpp b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution.hpp new file mode 100644 index 00000000..2500af23 --- /dev/null +++ b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution.hpp @@ -0,0 +1,103 @@ +#ifndef NJOY_ACETK_BLOCK_TABULATEDOUTGOINGENERGYDISTRIBUTION +#define NJOY_ACETK_BLOCK_TABULATEDOUTGOINGENERGYDISTRIBUTION + +// system includes + +// other includes +#include "ACEtk/block/details/TabulatedProbabilityDistribution.hpp" + +namespace njoy { +namespace ACEtk { +namespace block { + +/** + * @class + * @brief Tabulated secondary energy distribution data from the DLW block for + * a single reaction and incident energy + * + * The TabulatedOutgoingEnergyDistribution class contains the probability + * density function (PDF) and cumulative density function (CDF) as a function + * of the outgoing energy for a single incident energy. + */ +class TabulatedOutgoingEnergyDistribution : + protected details::TabulatedProbabilityDistribution { + + /* fields */ + double incident_; + + /* auxiliary functions */ + +public: + + /* constructor */ + #include "ACEtk/block/TabulatedOutgoingEnergyDistribution/src/ctor.hpp" + + /** + * @brief Return the incident energy value + */ + double incidentEnergy() const { return this->incident_; } + + /** + * @brief Return the interpolation flag + */ + unsigned int interpolation() const { + + // the INTT' value = 10 * ND + INTT + return TabulatedProbabilityDistribution::interpolation() % 10; + } + + /** + * @brief Return the number of discrete photon lines + */ + std::size_t numberDiscretePhotonLines() const { + + // the INTT' value = 10 * ND + INTT + return ( TabulatedProbabilityDistribution::interpolation() - + this->interpolation() ) / 10; + } + + /** + * @brief Return the number of cosine values + */ + std::size_t numberOutgoingEnergies() const { + + return TabulatedProbabilityDistribution::numberValues(); + } + + /** + * @brief Return the outgoing energies values + */ + auto outgoingEnergies() const { + + return TabulatedProbabilityDistribution::values(); + } + + /** + * @brief Return the pdf values + */ + auto pdf() const { + + return TabulatedProbabilityDistribution::pdf(); + } + + /** + * @brief Return the cdf values + */ + auto cdf() const { + + return TabulatedProbabilityDistribution::cdf(); + } + + using TabulatedProbabilityDistribution::empty; + using TabulatedProbabilityDistribution::name; + using TabulatedProbabilityDistribution::length; + using TabulatedProbabilityDistribution::XSS; + using TabulatedProbabilityDistribution::begin; + using TabulatedProbabilityDistribution::end; +}; + +} // block namespace +} // ACEtk namespace +} // njoy namespace + +#endif diff --git a/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/src/ctor.hpp b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/src/ctor.hpp new file mode 100644 index 00000000..f0cbe7d9 --- /dev/null +++ b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/src/ctor.hpp @@ -0,0 +1,42 @@ +TabulatedOutgoingEnergyDistribution() = default; + +TabulatedOutgoingEnergyDistribution( const TabulatedOutgoingEnergyDistribution& ) = default; +TabulatedOutgoingEnergyDistribution( TabulatedOutgoingEnergyDistribution&& ) = default; + +/** + * @brief Constructor + * + * @param[in] incident the incident energy value + * @param[in] interpolation the interpolation type + * @param[in] cosines the cosine values (N values) + * @param[in] pdf the pdf values (N values) + * @param[in] cdf the cdf values (N values) + * @param[in] discrete the number discrete photon lines (defaults to 0) + */ +TabulatedOutgoingEnergyDistribution( double incident, + int interpolation, + std::vector< double >&& cosines, + std::vector< double >&& pdf, + std::vector< double >&& cdf, + std::size_t discrete = 0 ) : + TabulatedProbabilityDistribution( + "DLW::TabulatedOutgoingEnergyDistribution", + discrete * 10 + interpolation, std::move( cosines ), + std::move( pdf ), std::move( cdf ), {} ), + incident_( incident ) {} + +/** + * @brief Constructor + * + * @param[in] incident the incident energy value + * @param[in] begin the begin iterator of the tabulated distribution data + * @param[in] end the end iterator of the tabulated distribution data + */ +TabulatedOutgoingEnergyDistribution( double incident, + Iterator begin, Iterator end ) : + TabulatedProbabilityDistribution( "DLW::TabulatedOutgoingEnergyDistribution", + begin, end ), + incident_( incident ) {} + +TabulatedOutgoingEnergyDistribution& operator=( const TabulatedOutgoingEnergyDistribution& ) = default; +TabulatedOutgoingEnergyDistribution& operator=( TabulatedOutgoingEnergyDistribution&& ) = default; diff --git a/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/test/CMakeLists.txt b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/test/CMakeLists.txt new file mode 100644 index 00000000..8f0810db --- /dev/null +++ b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/test/CMakeLists.txt @@ -0,0 +1,18 @@ + +add_executable( ACEtk.block.TabulatedOutgoingEnergyDistribution.test TabulatedOutgoingEnergyDistribution.test.cpp ) +target_compile_options( ACEtk.block.TabulatedOutgoingEnergyDistribution.test PRIVATE ${${PREFIX}_common_flags} +$<$:${${PREFIX}_strict_flags}>$<$: +${${PREFIX}_DEBUG_flags} +$<$:${${PREFIX}_coverage_flags}>> +$<$: +${${PREFIX}_RELEASE_flags} +$<$:${${PREFIX}_link_time_optimization_flags}> +$<$:${${PREFIX}_nonportable_optimization_flags}>> + +${CXX_appended_flags} ${ACEtk_appended_flags} ) +target_link_libraries( ACEtk.block.TabulatedOutgoingEnergyDistribution.test PUBLIC ACEtk ) +file( GLOB resources "resources/*" ) +foreach( resource ${resources}) + file( COPY "${resource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" ) +endforeach() +add_test( NAME ACEtk.block.TabulatedOutgoingEnergyDistribution COMMAND ACEtk.block.TabulatedOutgoingEnergyDistribution.test ) diff --git a/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/test/TabulatedOutgoingEnergyDistribution.test.cpp b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/test/TabulatedOutgoingEnergyDistribution.test.cpp new file mode 100644 index 00000000..c477ce8e --- /dev/null +++ b/src/ACEtk/block/TabulatedOutgoingEnergyDistribution/test/TabulatedOutgoingEnergyDistribution.test.cpp @@ -0,0 +1,104 @@ +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "ACEtk/block/TabulatedOutgoingEnergyDistribution.hpp" + +// other includes + +// convenience typedefs +using namespace njoy::ACEtk; +using TabulatedOutgoingEnergyDistribution = block::TabulatedOutgoingEnergyDistribution; + +std::vector< double > chunk(); +void verifyChunk( const TabulatedOutgoingEnergyDistribution& ); + +SCENARIO( "TabulatedOutgoingEnergyDistribution" ) { + + GIVEN( "valid data for a TabulatedOutgoingEnergyDistribution instance" ) { + + std::vector< double > xss = chunk(); + + WHEN( "the data is given explicitly" ) { + + double incident = 2.1; + int interpolation = 2; + std::size_t discrete = 3; + std::vector< double > cosines = { 1e-11, 1.0, 20.0 }; + std::vector< double > pdf = { 0.5, 0.5, 0.5 }; + std::vector< double > cdf = { 0.0, 0.5, 1.0 }; + + TabulatedOutgoingEnergyDistribution chunk( incident, interpolation, + std::move( cosines ), + std::move( pdf ), + std::move( cdf ), + discrete ); + + THEN( "a TabulatedOutgoingEnergyDistribution can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + + WHEN( "the data is defined by iterators" ) { + + double incident = 2.1; + TabulatedOutgoingEnergyDistribution chunk( incident, xss.begin(), xss.end() ); + + THEN( "a TabulatedOutgoingEnergyDistribution can be constructed and " + "members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "the XSS array is correct" ) { + + auto xss_chunk = chunk.XSS(); + for ( unsigned int i = 0; i < chunk.length(); ++i ) { + + CHECK( xss[i] == Approx( xss_chunk[i] ) ); + } + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +std::vector< double > chunk() { + + return { 32, 3, 1.00000000000E-11, 1.00000000000E+00, + 2.00000000000E+01, 0.50000000000E+00, 0.50000000000E+00, 0.50000000000E+00, + 0.00000000000E+00, 0.50000000000E+00, 1.00000000000E+00 }; +} + +void verifyChunk( const TabulatedOutgoingEnergyDistribution& chunk ) { + + CHECK( false == chunk.empty() ); + CHECK( 11 == chunk.length() ); + CHECK( "DLW::TabulatedOutgoingEnergyDistribution" == chunk.name() ); + + CHECK( 2.1 == Approx( chunk.incidentEnergy() ) ); + CHECK( 2 == chunk.interpolation() ); + CHECK( 3 == chunk.numberDiscretePhotonLines() ); + CHECK( 3 == chunk.numberOutgoingEnergies() ); + + CHECK( 3 == chunk.outgoingEnergies().size() ); + CHECK( 1e-11 == Approx( chunk.outgoingEnergies().front() ) ); + CHECK( 20. == Approx( chunk.outgoingEnergies().back() ) ); + + CHECK( 3 == chunk.pdf().size() ); + CHECK( .5 == Approx( chunk.pdf().front() ) ); + CHECK( .5 == Approx( chunk.pdf().back() ) ); + + CHECK( 3 == chunk.cdf().size() ); + CHECK( 0. == Approx( chunk.cdf().front() ) ); + CHECK( 1. == Approx( chunk.cdf().back() ) ); +} diff --git a/src/ACEtk/block/details/BaseDistributionData.hpp b/src/ACEtk/block/details/BaseDistributionData.hpp new file mode 100644 index 00000000..81b1818d --- /dev/null +++ b/src/ACEtk/block/details/BaseDistributionData.hpp @@ -0,0 +1,193 @@ +#ifndef NJOY_ACETK_BLOCK_DETAILS_DISTRIBUTIONDATABASE +#define NJOY_ACETK_BLOCK_DETAILS_DISTRIBUTIONDATABASE + +// system includes +#include + +// other includes +#include "utility/overload.hpp" +#include "ACEtk/block/details/Base.hpp" +#include "ACEtk/block/details/ColumnData.hpp" +#include "ACEtk/block/InterpolationData.hpp" + +namespace njoy { +namespace ACEtk { +namespace block { +namespace details { + +/** + * @class + * @brief Base class for distribution data as a function of incident energy + */ +template< typename Distribution > +class BaseDistributionData : protected details::Base { + + /* fields */ + std::size_t locb_; + InterpolationData interpolation_; + details::ColumnData data_; + + /* auxiliary functions */ + #include "ACEtk/block/details/BaseDistributionData/src/generateXSS.hpp" + #include "ACEtk/block/details/BaseDistributionData/src/verifyIncidentEnergyIndex.hpp" + #include "ACEtk/block/details/BaseDistributionData/src/generateBlocks.hpp" + #include "ACEtk/block/details/BaseDistributionData/src/verifySize.hpp" + +public: + + /* constructor */ + #include "ACEtk/block/details/BaseDistributionData/src/ctor.hpp" + + /** + * @brief Return the interpolation data + */ + auto interpolationData() const { return this->interpolation_; } + + /** + * @brief Return the number of interpolation regions + */ + std::size_t NB() const { return this->interpolationData().NB(); } + + /** + * @brief Return the number of interpolation regions + */ + std::size_t numberInterpolationRegions() const { return this->NB(); } + + /** + * @brief Return the interpolation boundaries + */ + auto NBT() const { return this->interpolationData().NBT(); } + + /** + * @brief Return the interpolation boundaries + */ + auto boundaries() const { return this->NBT(); } + + /** + * @brief Return the interpolants + */ + auto INT() const { return this->interpolationData().INT(); } + + /** + * @brief Return the interpolants + */ + auto interpolants() const { return this->INT(); } + + /** + * @brief Return the number of incident energy values + */ + std::size_t NE() const { return this->data_.N(); } + + /** + * @brief Return the number of incident energy values + */ + std::size_t numberIncidentEnergies() const { return this->NE(); } + + /** + * @brief Return the incident energy values + */ + auto incidentEnergies() const { return this->data_.column( 1 ); } + + /** + * @brief Return the incident energy for a given index + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + double incidentEnergy( std::size_t index ) const { + + #ifndef NDEBUG + this->verifyIncidentEnergyIndex( index ); + #endif + return this->data_.value( 1, index ); + } + + /** + * @brief Return the angular distribution locator for an incident + * energy index + * + * This locator is the value as stored in the XSS array. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + int LOCC( std::size_t index ) const { + + #ifndef NDEBUG + this->verifyIncidentEnergyIndex( index ); + #endif + return this->data_.value( 2, index ); + } + + /** + * @brief Return the angular distribution locator for an incident + * energy index + * + * This locator is the value as stored in the XSS array. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + int distributionLocator( std::size_t index ) const { + + return this->LOCC( index ); + } + + /** + * @brief Return the relative angular distribution locator for an incident + * energy index + * + * This is the locator relative to the beginning of the current distribution + * block. + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + std::size_t relativeDistributionLocator( std::size_t index ) const { + + const int locator = this->LOCC( index ); + return locator - this->locb_ + 1; + } + + /** + * @brief Return the distribution for an incident energy index + * + * When the index is out of range an std::out_of_range exception is thrown + * (debug mode only). + * + * @param[in] index the index (one-based) + */ + Distribution distribution( std::size_t index ) const { + + const double incident = this->incidentEnergy( index ); + const auto locator = this->relativeDistributionLocator( index ); + const auto left = std::next( this->begin(), locator - 1 ); + const auto right = index == this->numberIncidentEnergies() + ? this->end() + : std::next( this->begin(), + this->relativeDistributionLocator( index + 1 ) - 1 ); + return Distribution( incident, left, right ); + } + + using Base::empty; + using Base::name; + using Base::length; + using Base::XSS; + using Base::begin; + using Base::end; +}; + +} // details namespace +} // block namespace +} // ACEtk namespace +} // njoy namespace + +#endif diff --git a/src/ACEtk/block/details/BaseDistributionData/src/ctor.hpp b/src/ACEtk/block/details/BaseDistributionData/src/ctor.hpp new file mode 100644 index 00000000..ae0d05b0 --- /dev/null +++ b/src/ACEtk/block/details/BaseDistributionData/src/ctor.hpp @@ -0,0 +1,48 @@ +BaseDistributionData() = default; + +BaseDistributionData( const BaseDistributionData& ) = default; +BaseDistributionData( BaseDistributionData&& ) = default; + +/** + * @brief Constructor + * + * @param[in] name the name of the block + * @param[in] boundaries the interpolation range boundaries + * @param[in] interpolants the interpolation types for each range + * @param[in] distributions the distributions for each incident energy + * @param[in] locb the starting xss index with respect to the superblock + */ +BaseDistributionData( std::string&& name, + std::vector< long >&& boundaries, + std::vector< long >&& interpolants, + std::vector< Distribution >&& distributions, + std::size_t locb = 1 ) : + Base( std::move( name ), + generateXSS( std::string( name ), + std::move( boundaries ), std::move( interpolants ), + std::move( distributions ), locb ) ), + locb_( locb ) { + + this->generateBlocks(); +} + +/** + * @brief Constructor + * + * @param[in] name the name of the block + * @param[in] locb the starting xss index with respect to the superblock + * @param[in] sig the begin iterator of the block in the XSS array + * @param[in] end the end iterator of the block in the XSS array + */ +BaseDistributionData( std::string&& name, std::size_t locb, + Iterator begin, Iterator end ) : + Base( std::move( name ), begin, end ), locb_( locb ) { + + std::size_t nr = static_cast< std::size_t >( this->XSS( 1 ) ); + std::size_t ne = static_cast< std::size_t >( this->XSS( 1 + 2 * nr + 1 ) ); + verifySize( this->begin(), this->end(), nr, ne ); + this->generateBlocks(); +} + +BaseDistributionData& operator=( const BaseDistributionData& ) = default; +BaseDistributionData& operator=( BaseDistributionData&& ) = default; diff --git a/src/ACEtk/block/details/BaseDistributionData/src/generateBlocks.hpp b/src/ACEtk/block/details/BaseDistributionData/src/generateBlocks.hpp new file mode 100644 index 00000000..203b5664 --- /dev/null +++ b/src/ACEtk/block/details/BaseDistributionData/src/generateBlocks.hpp @@ -0,0 +1,13 @@ +void generateBlocks() { + + std::size_t nr = static_cast< std::size_t >( this->XSS( 1 ) ); + std::size_t ne = static_cast< std::size_t >( this->XSS( 1 + 2 * nr + 1 ) ); + auto begin = this->begin(); + auto data = begin + 2 * nr + 1; + auto end = data + + 2 * ne + 1; + + this->interpolation_ = block::InterpolationData( std::string( this->name() ), + begin, data ); + this->data_ = block::details::ColumnData( std::string( this->name() ), + data, end, 2 ); +} diff --git a/src/ACEtk/block/details/BaseDistributionData/src/generateXSS.hpp b/src/ACEtk/block/details/BaseDistributionData/src/generateXSS.hpp new file mode 100644 index 00000000..08a6bdd0 --- /dev/null +++ b/src/ACEtk/block/details/BaseDistributionData/src/generateXSS.hpp @@ -0,0 +1,37 @@ +static std::vector< double > +generateXSS( const std::string& name, + std::vector< long >&& boundaries, + std::vector< long >&& interpolants, + std::vector< Distribution >&& distributions, + std::size_t locb ) { + + // add the distribution data to the xss array + std::size_t nr = boundaries.size(); + std::size_t ne = distributions.size(); + std::vector< double > xss( 1 + 2 * ne ); + xss[0] = ne; + std::size_t index = 1; + std::size_t offset = 1 + 2 * nr + locb; + for ( const auto& distribution : distributions ) { + + // set the energy value + xss[index] = distribution.incidentEnergy(); + + // set the locator + xss[index + ne] = xss.size() + offset; + + // insert the xss array + xss.insert( xss.end(), distribution.begin(), distribution.end() ); + + // on to the next distribution + ++index; + } + + // insert the interpolation data in the front + InterpolationData interpolation( std::string( name ), + std::move( boundaries ), + std::move( interpolants ) ); + xss.insert( xss.begin(), interpolation.begin(), interpolation.end() ); + + return xss; +} diff --git a/src/ACEtk/block/details/BaseDistributionData/src/verifyIncidentEnergyIndex.hpp b/src/ACEtk/block/details/BaseDistributionData/src/verifyIncidentEnergyIndex.hpp new file mode 100644 index 00000000..9064d7b4 --- /dev/null +++ b/src/ACEtk/block/details/BaseDistributionData/src/verifyIncidentEnergyIndex.hpp @@ -0,0 +1,12 @@ +void verifyIncidentEnergyIndex( const std::size_t index ) const { + + if ( ( index < 1 ) || ( index > this->numberIncidentEnergies() ) ) { + + Log::error( "Illegal incident energy index argument into {} block", + this->name() ); + Log::info( "Index value: {}", index ); + Log::info( "{} accepts an incident energy index between 1 and {} inclusively", + this->name(), this->numberIncidentEnergies() ); + throw std::out_of_range( this->name() ); + } +} diff --git a/src/ACEtk/block/details/BaseDistributionData/src/verifySize.hpp b/src/ACEtk/block/details/BaseDistributionData/src/verifySize.hpp new file mode 100644 index 00000000..e2e9ac1e --- /dev/null +++ b/src/ACEtk/block/details/BaseDistributionData/src/verifySize.hpp @@ -0,0 +1,15 @@ +static void verifySize( Iterator begin, Iterator end, + unsigned int nr, unsigned int ne ) { + + // there are at least 2 + 2 * nr + 2 * ne values in the distribution data block + auto size = std::distance( begin, end ); + if ( size < 2 + 2 * nr + 2 * ne ) { + + Log::error( "The size of the XSS subrange in the distribution data " + "block should be at least 2 + 2 * NR + 2 * NE" ); + Log::info( "NR value: {}", nr ); + Log::info( "NE value: {}", ne ); + Log::info( "XSS.size(): {}", size ); + throw std::exception(); + } +} diff --git a/src/ACEtk/block/details/ColumnData.hpp b/src/ACEtk/block/details/ColumnData.hpp index 9e40efc6..062a0819 100644 --- a/src/ACEtk/block/details/ColumnData.hpp +++ b/src/ACEtk/block/details/ColumnData.hpp @@ -41,20 +41,32 @@ class ColumnData : protected Base { /** * @brief Return the column * - * @param[in] index the column index (one-based) + * @param[in] column the column index (one-based) */ - auto C( std::size_t index ) const { + auto C( std::size_t column ) const { auto number = this->N(); - return this->XSS( 2 + ( index - 1 ) * number, number ); + return this->XSS( 2 + ( column - 1 ) * number, number ); } /** * @brief Return the column * - * @param[in] index the column index (one-based) + * @param[in] column the column index (one-based) */ - auto column( std::size_t index ) const { return this->C( index ); } + auto column( std::size_t column ) const { return this->C( column ); } + + /** + * @brief Return a value + * + * @param[in] column the column index (one-based) + * @param[in] index the index in the column (one-based) + */ + auto value( std::size_t column, std::size_t index ) const { + + auto number = this->N(); + return this->XSS( 2 + ( column - 1 ) * number + index - 1 ); + } using Base::empty; using Base::name; diff --git a/src/ACEtk/block/details/TabulatedProbabilityDistribution.hpp b/src/ACEtk/block/details/TabulatedProbabilityDistribution.hpp index 5b17d1f0..76cbfc7c 100644 --- a/src/ACEtk/block/details/TabulatedProbabilityDistribution.hpp +++ b/src/ACEtk/block/details/TabulatedProbabilityDistribution.hpp @@ -17,8 +17,9 @@ namespace details { * @brief Tabulated probability distribution data (base class) * * The TabulatedProbabilityDistribution class contains the probability density - * function (PDF) and cumulative density function (CDF) as a function of - * cosine for the given incident energy. + * function (PDF), the cumulative density function (CDF) and any number of + * additional data columns as a function of cosine for the given incident + * energy. */ class TabulatedProbabilityDistribution : protected details::Base { @@ -69,6 +70,15 @@ class TabulatedProbabilityDistribution : protected details::Base { return this->XSS( 3 + 2 * this->numberValues(), this->numberValues() ); } + /** + * @brief Return a column of the additional data + */ + auto column( std::size_t index ) const { + + return this->XSS( 3 + ( 3 + index ) * this->numberValues(), + this->numberValues() ); + } + using Base::empty; using Base::name; using Base::length; diff --git a/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/ctor.hpp b/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/ctor.hpp index ffdb82dd..2cd47faf 100644 --- a/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/ctor.hpp +++ b/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/ctor.hpp @@ -6,7 +6,7 @@ TabulatedProbabilityDistribution( TabulatedProbabilityDistribution&& ) = default /** * @brief Constructor * - * @param[in] incident the incident energy value + * @param[in] name the name of the block * @param[in] interpolation the interpolation type * @param[in] values the values (N values) * @param[in] pdf the pdf values (N values) @@ -16,10 +16,12 @@ TabulatedProbabilityDistribution( std::string&& name, int interpolation, std::vector< double >&& values, std::vector< double >&& pdf, - std::vector< double >&& cdf ) : + std::vector< double >&& cdf, + std::vector< std::vector< double > > data ) : Base( std::move( name ), generateXSS( interpolation, - std::move( values ), std::move( pdf ), std::move( cdf ) ) ) {} + std::move( values ), std::move( pdf ), std::move( cdf ), + std::move( data ) ) ) {} /** * @brief Constructor diff --git a/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/generateXSS.hpp b/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/generateXSS.hpp index 0d9c5246..03577b4e 100644 --- a/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/generateXSS.hpp +++ b/src/ACEtk/block/details/TabulatedProbabilityDistribution/src/generateXSS.hpp @@ -2,14 +2,17 @@ static std::vector< double > generateXSS( int interpolation, std::vector< double >&& values, std::vector< double >&& pdf, - std::vector< double >&& cdf ) { + std::vector< double >&& cdf, + std::vector< std::vector< double > >&& data ) { std::vector< double > xss = { static_cast< double >( interpolation ) }; + data.insert( data.begin(), std::move( cdf ) ); + data.insert( data.begin(), std::move( pdf ) ); + data.insert( data.begin(), std::move( values ) ); xss.reserve( 2 + 3 * values.size() ); - details::ColumnData data( "TabulatedProbabilityDistribution", - std::move( values ), std::move( pdf ), - std::move( cdf ) ); - xss.insert( xss.end(), data.begin(), data.end() ); + details::ColumnData columns( "TabulatedProbabilityDistribution", + std::move( data ) ); + xss.insert( xss.end(), columns.begin(), columns.end() ); return xss; }