Skip to content

Commit 27c6a49

Browse files
committed
Adding the compton profile
1 parent afb12ff commit 27c6a49

11 files changed

Lines changed: 401 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ if(ACEtk.python)
153153
python/src/block/IncoherentScatteringFunctionBlock.python.cpp
154154
python/src/block/CoherentFormFactorBlock.python.cpp
155155
python/src/block/PhotoAtomicHeatingNumbersBlock.python.cpp
156+
python/src/block/PhotoAtomicComptonProfile.python.cpp
156157
python/src/ContinuousEnergyTable.python.cpp
157158
python/src/DosimetryTable.python.cpp
158159
python/src/ThermalScatteringTable.python.cpp

‎cmake/unit_testing.cmake‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ add_subdirectory( src/ACEtk/block/PhotoAtomicPrincipalCrossSectionBlock/test )
8282
add_subdirectory( src/ACEtk/block/IncoherentScatteringFunctionBlock/test )
8383
add_subdirectory( src/ACEtk/block/CoherentFormFactorBlock/test )
8484
add_subdirectory( src/ACEtk/block/PhotoAtomicHeatingNumbersBlock/test )
85+
add_subdirectory( src/ACEtk/block/PhotoAtomicComptonProfile/test )
8586
add_subdirectory( src/ACEtk/details/verify/CDF/test )
8687
add_subdirectory( src/ACEtk/details/verify/Positive/test )
8788
add_subdirectory( src/ACEtk/details/verify/Sorted/test )

‎python/src/ACEtk.python.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ namespace block {
9595
void wrapIncoherentScatteringFunctionBlock( python::module&, python::module& );
9696
void wrapCoherentFormFactorBlock( python::module&, python::module& );
9797
void wrapPhotoAtomicHeatingNumbersBlock( python::module&, python::module& );
98+
void wrapPhotoAtomicComptonProfile( python::module&, python::module& );
9899
}
99100

100101
// declarations - ACE table types
@@ -185,6 +186,7 @@ PYBIND11_MODULE( ACEtk, module ) {
185186
block::wrapProbabilityTable( module, viewmodule );
186187
block::wrapThermalScatteringDiscreteCosines( module, viewmodule );
187188
block::wrapThermalScatteringDiscreteCosinesWithProbability( module, viewmodule );
189+
block::wrapPhotoAtomicComptonProfile( module, viewmodule );
188190

189191
// wrap ACE table blocks
190192
block::wrapPrincipalCrossSectionBlock( module, viewmodule );
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
#include "ACEtk/block/PhotoAtomicComptonProfile.hpp"
7+
#include "views.hpp"
8+
#include "definitions.hpp"
9+
10+
// namespace aliases
11+
namespace python = pybind11;
12+
13+
namespace block {
14+
15+
void wrapPhotoAtomicComptonProfile( python::module& module, python::module& ) {
16+
17+
// type aliases
18+
using Block = njoy::ACEtk::block::PhotoAtomicComptonProfile;
19+
20+
// wrap views created by this block
21+
22+
// create the block
23+
python::class_< Block > block(
24+
25+
module,
26+
"PhotoAtomicComptonProfile",
27+
"Tabulated Compton profile data for a given electron shell\n\n"
28+
"The PhotoAtomicComptonProfile class contains the probability density\n"
29+
"function (PDF) and cumulative density function (CDF) as a function of\n"
30+
"momentum. It is used in the LSWD block."
31+
);
32+
33+
// wrap the block
34+
block
35+
.def(
36+
37+
python::init< int, std::vector< double >, std::vector< double >,
38+
std::vector< double > >(),
39+
python::arg( "interpolation" ), python::arg( "momentum" ),
40+
python::arg( "pdf" ), python::arg( "cdf" ),
41+
"Initialise the block\n\n"
42+
"Arguments:\n"
43+
" self the block\n"
44+
" interpolation the interpolation type\n"
45+
" momentum the cosine values (N values)\n"
46+
" pdf the pdf values (N values)\n"
47+
" cdf the cdf values (N values)"
48+
)
49+
.def_property_readonly(
50+
51+
"interpolation",
52+
&Block::interpolation,
53+
"The interpolation flag"
54+
)
55+
.def_property_readonly(
56+
57+
"number_values",
58+
&Block::numberValues,
59+
"The number of values"
60+
)
61+
.def_property_readonly(
62+
63+
"momentum",
64+
[] ( const Block& self ) -> DoubleRange
65+
{ return self.momentum(); },
66+
"The momentum values"
67+
)
68+
.def_property_readonly(
69+
70+
"pdf",
71+
[] ( const Block& self ) -> DoubleRange
72+
{ return self.pdf(); },
73+
"The pdf values"
74+
)
75+
.def_property_readonly(
76+
77+
"cdf",
78+
[] ( const Block& self ) -> DoubleRange
79+
{ return self.cdf(); },
80+
"The cdf values"
81+
);
82+
83+
// add standard block definitions
84+
addStandardBlockDefinitions< Block >( block );
85+
}
86+
87+
} // block namespace

‎python/test/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ add_test( NAME ACEtk.python.block.PhotoAtomicPrincipalCrossSectionBlock COMMAND
6464
add_test( NAME ACEtk.python.block.IncoherentScatteringFunctionBlock COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_IncoherentScatteringFunctionBlock.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python )
6565
add_test( NAME ACEtk.python.block.CoherentFormFactorBlock COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_CoherentFormFactorBlock.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python )
6666
add_test( NAME ACEtk.python.block.PhotoAtomicHeatingNumbersBlock COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_PhotoAtomicHeatingNumbersBlock.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python )
67+
add_test( NAME ACEtk.python.block.PhotoAtomicComptonProfile COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_PhotoAtomicComptonProfile.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python )
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# standard imports
2+
import unittest
3+
4+
# third party imports
5+
6+
# local imports
7+
from ACEtk import PhotoAtomicComptonProfile
8+
9+
class Test_ACEtk_PhotoAtomicComptonProfile( unittest.TestCase ) :
10+
"""Unit test for the PhotoAtomicComptonProfile class."""
11+
12+
chunk = [ 2, 3, 1.00000000000E-11, 1.00000000000E+00,
13+
2.00000000000E+01, 0.50000000000E+00, 0.50000000000E+00, 0.50000000000E+00,
14+
0.00000000000E+00, 0.50000000000E+00, 1.00000000000E+00 ]
15+
16+
def test_component( self ) :
17+
18+
def verify_chunk( self, chunk ) :
19+
20+
# verify content
21+
self.assertEqual( False, chunk.empty )
22+
self.assertEqual( 11, chunk.length )
23+
self.assertEqual( "PhotoAtomicComptonProfile", chunk.name )
24+
25+
self.assertEqual( 2, chunk.interpolation )
26+
self.assertEqual( 3, chunk.number_values )
27+
28+
self.assertEqual( 3, len( chunk.momentum ) )
29+
self.assertAlmostEqual( 1e-11, chunk.momentum[0] )
30+
self.assertAlmostEqual( 20., chunk.momentum[-1] )
31+
32+
self.assertEqual( 3, len( chunk.pdf ) )
33+
self.assertAlmostEqual( .5, chunk.pdf[0] )
34+
self.assertAlmostEqual( .5, chunk.pdf[-1] )
35+
36+
self.assertEqual( 3, len( chunk.cdf ) )
37+
self.assertAlmostEqual( 0., chunk.cdf[0] )
38+
self.assertAlmostEqual( 1., chunk.cdf[-1] )
39+
40+
# verify the xss array
41+
xss = chunk.xss_array
42+
for index in range( chunk.length ) :
43+
44+
self.assertAlmostEqual( self.chunk[index], xss[index] )
45+
46+
# the data is given explicitly
47+
chunk = PhotoAtomicComptonProfile(
48+
interpolation = 2,
49+
momentum = [ 1e-11, 1., 20. ],
50+
pdf = [ 0.5, 0.5, 0.5 ],
51+
cdf = [ 0.0, 0.5, 1.0 ] )
52+
53+
verify_chunk( self, chunk )
54+
55+
if __name__ == '__main__' :
56+
57+
unittest.main()
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#ifndef NJOY_ACETK_BLOCK_PHOTOATOMICCOMPTONPROFILE
2+
#define NJOY_ACETK_BLOCK_PHOTOATOMICCOMPTONPROFILE
3+
4+
// system includes
5+
6+
// other includes
7+
#include "ACEtk/block/details/TabulatedProbabilityDistribution.hpp"
8+
9+
namespace njoy {
10+
namespace ACEtk {
11+
namespace block {
12+
13+
/**
14+
* @class
15+
* @brief Tabulated Compton profile data for a given electron shell
16+
*
17+
* The PhotoAtomicComptonProfile class contains the probability density
18+
* function (PDF) and cumulative density function (CDF) as a function of
19+
* momentum. It is used in the LSWD block.
20+
*/
21+
class PhotoAtomicComptonProfile :
22+
protected details::TabulatedProbabilityDistribution {
23+
24+
/* fields */
25+
26+
/* auxiliary functions */
27+
28+
public:
29+
30+
/* constructor */
31+
#include "ACEtk/block/PhotoAtomicComptonProfile/src/ctor.hpp"
32+
33+
/**
34+
* @brief Return the interpolation flag
35+
*/
36+
int interpolation() const {
37+
38+
return TabulatedProbabilityDistribution::interpolation();
39+
}
40+
41+
/**
42+
* @brief Return the number of values
43+
*/
44+
std::size_t numberValues() const {
45+
46+
return TabulatedProbabilityDistribution::numberValues();
47+
}
48+
49+
/**
50+
* @brief Return the momentum values
51+
*/
52+
auto momentum() const {
53+
54+
return TabulatedProbabilityDistribution::values();
55+
}
56+
57+
/**
58+
* @brief Return the pdf values
59+
*/
60+
auto pdf() const {
61+
62+
return TabulatedProbabilityDistribution::pdf();
63+
}
64+
65+
/**
66+
* @brief Return the cdf values
67+
*/
68+
auto cdf() const {
69+
70+
return TabulatedProbabilityDistribution::cdf();
71+
}
72+
73+
using TabulatedProbabilityDistribution::empty;
74+
using TabulatedProbabilityDistribution::name;
75+
using TabulatedProbabilityDistribution::length;
76+
using TabulatedProbabilityDistribution::XSS;
77+
using TabulatedProbabilityDistribution::begin;
78+
using TabulatedProbabilityDistribution::end;
79+
};
80+
81+
} // block namespace
82+
} // ACEtk namespace
83+
} // njoy namespace
84+
85+
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
PhotoAtomicComptonProfile() = default;
2+
3+
PhotoAtomicComptonProfile( const PhotoAtomicComptonProfile& ) = default;
4+
PhotoAtomicComptonProfile( PhotoAtomicComptonProfile&& ) = default;
5+
6+
/**
7+
* @brief Constructor
8+
*
9+
* @param[in] interpolation the interpolation type
10+
* @param[in] momentum the cosine values (N values)
11+
* @param[in] pdf the pdf values (N values)
12+
* @param[in] cdf the cdf values (N values)
13+
*/
14+
PhotoAtomicComptonProfile( int interpolation,
15+
std::vector< double > momentum,
16+
std::vector< double > pdf,
17+
std::vector< double > cdf ) :
18+
TabulatedProbabilityDistribution(
19+
"PhotoAtomicComptonProfile", interpolation, std::move( momentum ),
20+
std::move( pdf ), std::move( cdf ) ) {}
21+
22+
/**
23+
* @brief Constructor
24+
*
25+
* @param[in] begin the begin iterator of the tabulated distribution data
26+
* @param[in] end the end iterator of the tabulated distribution data
27+
*/
28+
PhotoAtomicComptonProfile( Iterator begin, Iterator end ) :
29+
TabulatedProbabilityDistribution( "PhotoAtomicComptonProfile", begin, end ) {}
30+
31+
PhotoAtomicComptonProfile& operator=( const PhotoAtomicComptonProfile& ) = default;
32+
PhotoAtomicComptonProfile& operator=( PhotoAtomicComptonProfile&& ) = default;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
add_executable( ACEtk.block.PhotoAtomicComptonProfile.test PhotoAtomicComptonProfile.test.cpp )
3+
target_compile_options( ACEtk.block.PhotoAtomicComptonProfile.test PRIVATE ${${PREFIX}_common_flags}
4+
$<$<BOOL:${strict}>:${${PREFIX}_strict_flags}>$<$<CONFIG:DEBUG>:
5+
${${PREFIX}_DEBUG_flags}
6+
$<$<BOOL:${coverage}>:${${PREFIX}_coverage_flags}>>
7+
$<$<CONFIG:RELEASE>:
8+
${${PREFIX}_RELEASE_flags}
9+
$<$<BOOL:${link_time_optimization}>:${${PREFIX}_link_time_optimization_flags}>
10+
$<$<BOOL:${nonportable_optimization}>:${${PREFIX}_nonportable_optimization_flags}>>
11+
12+
${CXX_appended_flags} ${ACEtk_appended_flags} )
13+
target_link_libraries( ACEtk.block.PhotoAtomicComptonProfile.test PUBLIC ACEtk )
14+
file( GLOB resources "resources/*" )
15+
foreach( resource ${resources})
16+
file( COPY "${resource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" )
17+
endforeach()
18+
add_test( NAME ACEtk.block.PhotoAtomicComptonProfile COMMAND ACEtk.block.PhotoAtomicComptonProfile.test )

0 commit comments

Comments
 (0)