Skip to content

Commit 97079be

Browse files
committed
Adding the compton profile block
1 parent 27c6a49 commit 97079be

11 files changed

Lines changed: 926 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ if(ACEtk.python)
154154
python/src/block/CoherentFormFactorBlock.python.cpp
155155
python/src/block/PhotoAtomicHeatingNumbersBlock.python.cpp
156156
python/src/block/PhotoAtomicComptonProfile.python.cpp
157+
python/src/block/PhotoAtomicComptonProfileBlock.python.cpp
157158
python/src/ContinuousEnergyTable.python.cpp
158159
python/src/DosimetryTable.python.cpp
159160
python/src/ThermalScatteringTable.python.cpp

‎cmake/unit_testing.cmake‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ add_subdirectory( src/ACEtk/block/IncoherentScatteringFunctionBlock/test )
8383
add_subdirectory( src/ACEtk/block/CoherentFormFactorBlock/test )
8484
add_subdirectory( src/ACEtk/block/PhotoAtomicHeatingNumbersBlock/test )
8585
add_subdirectory( src/ACEtk/block/PhotoAtomicComptonProfile/test )
86+
add_subdirectory( src/ACEtk/block/PhotoAtomicComptonProfileBlock/test )
8687
add_subdirectory( src/ACEtk/details/verify/CDF/test )
8788
add_subdirectory( src/ACEtk/details/verify/Positive/test )
8889
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
@@ -96,6 +96,7 @@ namespace block {
9696
void wrapCoherentFormFactorBlock( python::module&, python::module& );
9797
void wrapPhotoAtomicHeatingNumbersBlock( python::module&, python::module& );
9898
void wrapPhotoAtomicComptonProfile( python::module&, python::module& );
99+
void wrapPhotoAtomicComptonProfileBlock( python::module&, python::module& );
99100
}
100101

101102
// declarations - ACE table types
@@ -217,6 +218,7 @@ PYBIND11_MODULE( ACEtk, module ) {
217218
block::wrapIncoherentScatteringFunctionBlock( module, viewmodule );
218219
block::wrapCoherentFormFactorBlock( module, viewmodule );
219220
block::wrapPhotoAtomicHeatingNumbersBlock( module, viewmodule );
221+
block::wrapPhotoAtomicComptonProfileBlock( module, viewmodule );
220222

221223
// wrap ACE table types
222224
wrapContinuousEnergyTable( module, viewmodule );
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
#include "ACEtk/block/PhotoAtomicComptonProfileBlock.hpp"
7+
#include "views.hpp"
8+
#include "definitions.hpp"
9+
10+
// namespace aliases
11+
namespace python = pybind11;
12+
13+
namespace block {
14+
15+
void wrapPhotoAtomicComptonProfileBlock( python::module& module, python::module& ) {
16+
17+
// type aliases
18+
using Block = njoy::ACEtk::block::PhotoAtomicComptonProfileBlock;
19+
using PhotoAtomicComptonProfile = njoy::ACEtk::block::PhotoAtomicComptonProfile;
20+
21+
// wrap views created by this block
22+
23+
// create the block
24+
python::class_< Block > block(
25+
26+
module,
27+
"PhotoAtomicComptonProfileBlock",
28+
"The photoatomic LSWD and SWD block with the compton profile data\n\n"
29+
"The PhotoAtomicComptonProfileBlock class contains NXS(5) sets of compton\n"
30+
"profiles, one for each electron shell."
31+
);
32+
33+
// wrap the block
34+
block
35+
.def(
36+
37+
python::init< std::vector< PhotoAtomicComptonProfile > >(),
38+
python::arg( "profiles" ),
39+
"Initialise the block\n\n"
40+
"Arguments:\n"
41+
" self the block\n"
42+
" profiles the compton profile data"
43+
)
44+
.def_property_readonly(
45+
46+
"NSH",
47+
&Block::NSH,
48+
"The number of electron shelld"
49+
)
50+
.def_property_readonly(
51+
52+
"number_electron_shells",
53+
&Block::numberElectronShells,
54+
"The number of electron shelld"
55+
)
56+
.def(
57+
58+
"LSWD",
59+
&Block::LSWD,
60+
python::arg( "index" ),
61+
"Return the relative compton profile locator for an electron shell index\n\n"
62+
"When the index is out of range an out of range exception is thrown\n"
63+
"(debug mode only).\n\n"
64+
" self the block\n"
65+
" index the index (one-based)"
66+
)
67+
.def(
68+
69+
"compton_profile_locator",
70+
&Block::comptonProfileLocator,
71+
python::arg( "index" ),
72+
"Return the relative compton profile locator for an electron shell index\n\n"
73+
"When the index is out of range an out of range exception is thrown\n"
74+
"(debug mode only).\n\n"
75+
" self the block\n"
76+
" index the index (one-based)"
77+
)
78+
.def_property_readonly(
79+
80+
"data",
81+
&Block::data,
82+
"The compton profiles"
83+
)
84+
.def(
85+
86+
"compton_profile",
87+
&Block::comptonProfile,
88+
python::arg( "index" ),
89+
"Return the compton profile for an electron shell index\n\n"
90+
"When the index is out of range an out of range exception is thrown\n"
91+
"(debug mode only).\n\n"
92+
" self the block\n"
93+
" index the index (one-based)"
94+
);
95+
96+
// add standard block definitions
97+
addStandardBlockDefinitions< Block >( block );
98+
}
99+
100+
} // block namespace

‎python/test/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ add_test( NAME ACEtk.python.block.IncoherentScatteringFunctionBlock COMMAND ${PY
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 )
6767
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 )
68+
add_test( NAME ACEtk.python.block.PhotoAtomicComptonProfileBlock COMMAND ${PYTHON_EXECUTABLE} -m unittest -v test/block/Test_ACEtk_PhotoAtomicComptonProfileBlock.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python )
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# standard imports
2+
import unittest
3+
4+
# third party imports
5+
6+
# local imports
7+
from ACEtk import PhotoAtomicComptonProfileBlock
8+
from ACEtk import PhotoAtomicComptonProfile
9+
10+
class Test_ACEtk_PhotoAtomicComptonProfileBlock( unittest.TestCase ) :
11+
"""Unit test for the PhotoAtomicComptonProfileBlock class."""
12+
13+
chunk = [ 1, 96, 2,
14+
31, 0.000000000000e+00, 5.000000000000e-02, 1.000000000000e-01,
15+
1.500000000000e-01, 2.000000000000e-01, 3.000000000000e-01, 4.000000000000e-01,
16+
5.000000000000e-01, 6.000000000000e-01, 7.000000000000e-01, 8.000000000000e-01,
17+
1.000000000000e+00, 1.200000000000e+00, 1.400000000000e+00, 1.600000000000e+00,
18+
1.800000000000e+00, 2.000000000000e+00, 2.400000000000e+00, 3.000000000000e+00,
19+
4.000000000000e+00, 5.000000000000e+00, 6.000000000000e+00, 7.000000000000e+00,
20+
8.000000000000e+00, 1.000000000000e+01, 1.500000000000e+01, 2.000000000000e+01,
21+
3.000000000000e+01, 4.000000000000e+01, 6.000000000000e+01, 1.000000000000e+02,
22+
6.527863344596e-01, 6.508021814673e-01, 6.488180284750e-01, 6.448497224905e-01,
23+
6.388972635137e-01, 6.250081925677e-01, 6.051666626449e-01, 5.813568267376e-01,
24+
5.535786848457e-01, 5.218322369692e-01, 4.900857890928e-01, 4.226245873553e-01,
25+
3.571475386101e-01, 2.956387958495e-01, 2.420666650580e-01, 1.964311462356e-01,
26+
1.583354087838e-01, 1.017870485039e-01, 5.277846959461e-02, 1.871056271719e-02,
27+
7.361207601353e-03, 3.194486317568e-03, 1.515892886101e-03, 7.718355139963e-04,
28+
2.380983590734e-04, 2.380983590734e-05, 4.761967181468e-06, 4.365136583013e-07,
29+
7.738196669886e-08, 6.944535472975e-09, 3.571475386101e-10, 0.000000000000e+00,
30+
3.258971289817e-02, 6.508021814673e-02, 9.742191192087e-02, 1.295155865710e-01,
31+
1.927108593750e-01, 2.542196021357e-01, 3.135457766048e-01, 3.702925521840e-01,
32+
4.240630982747e-01, 4.746589995778e-01, 5.659300372226e-01, 6.439072498192e-01,
33+
7.091858832651e-01, 7.629564293559e-01, 8.068062104852e-01, 8.422828659872e-01,
34+
8.943073574447e-01, 9.406770128742e-01, 9.764215290301e-01, 9.894574141894e-01,
35+
9.947352611489e-01, 9.970904507507e-01, 9.982343149508e-01, 9.992442488238e-01,
36+
9.998990193113e-01, 9.999704488190e-01, 9.999964412232e-01, 9.999990107013e-01,
37+
9.999998539663e-01, 1.000000000000e+00, 2, 31,
38+
0.000000000000e+00, 5.000000000000e-02, 1.000000000000e-01, 1.500000000000e-01,
39+
2.000000000000e-01, 3.000000000000e-01, 4.000000000000e-01, 5.000000000000e-01,
40+
6.000000000000e-01, 7.000000000000e-01, 8.000000000000e-01, 1.000000000000e+00,
41+
1.200000000000e+00, 1.400000000000e+00, 1.600000000000e+00, 1.800000000000e+00,
42+
2.000000000000e+00, 2.400000000000e+00, 3.000000000000e+00, 4.000000000000e+00,
43+
5.000000000000e+00, 6.000000000000e+00, 7.000000000000e+00, 8.000000000000e+00,
44+
1.000000000000e+01, 1.500000000000e+01, 2.000000000000e+01, 3.000000000000e+01,
45+
4.000000000000e+01, 6.000000000000e+01, 1.000000000000e+02, 3.848272047027e+00,
46+
3.709416870073e+00, 3.352360700761e+00, 2.836612900644e+00, 2.261355738975e+00,
47+
1.213990975660e+00, 5.435188355080e-01, 2.142337015871e-01, 8.152782532619e-02,
48+
3.848272047027e-02, 2.796939992942e-02, 2.658084815988e-02, 2.380374462079e-02,
49+
1.900332278893e-02, 1.436159258787e-02, 1.063233926395e-02, 7.835399271009e-03,
50+
4.324346939443e-03, 1.908266860433e-03, 5.851753885943e-04, 2.142337015871e-04,
51+
8.886731325094e-05, 4.086309493235e-05, 2.043154746618e-05, 6.149300693703e-06,
52+
6.149300693703e-07, 1.170350777189e-07, 1.071168507935e-08, 1.904299569663e-09,
53+
1.705935031156e-10, 8.728039694288e-12, 0.000000000000e+00, 1.889422229275e-01,
54+
3.654866621983e-01, 5.202110022334e-01, 6.476602182239e-01, 8.214275539556e-01,
55+
9.093030445140e-01, 9.471906713688e-01, 9.619787477145e-01, 9.679792750043e-01,
56+
9.713018810243e-01, 9.767569058332e-01, 9.817953651113e-01, 9.860760718522e-01,
57+
9.894125633899e-01, 9.919119565751e-01, 9.937587304286e-01, 9.961906796707e-01,
58+
9.980604638107e-01, 9.993071849352e-01, 9.997068894803e-01, 9.998584399877e-01,
59+
9.999233051918e-01, 9.999539525130e-01, 9.999805333611e-01, 9.999974439380e-01,
60+
9.999992738509e-01, 9.999999125847e-01, 9.999999756646e-01, 9.999999964136e-01,
61+
1.000000000000e+00 ]
62+
63+
def test_component( self ) :
64+
65+
def verify_chunk( self, chunk ) :
66+
67+
# verify content
68+
self.assertEqual( False, chunk.empty )
69+
self.assertEqual( 192, chunk.length )
70+
self.assertEqual( "SWD", chunk.name )
71+
72+
self.assertEqual( 2, chunk.NSH )
73+
self.assertEqual( 2, chunk.number_electron_shells )
74+
self.assertEqual( 2, len( chunk.data ) )
75+
76+
self.assertEqual( 1, chunk.LSWD(1) )
77+
self.assertEqual( 96, chunk.LSWD(2) )
78+
self.assertEqual( 1, chunk.compton_profile_locator(1) )
79+
self.assertEqual( 96, chunk.compton_profile_locator(2) )
80+
81+
profile = chunk.compton_profile(1)
82+
self.assertEqual( 2, profile.interpolation )
83+
self.assertEqual( 31, profile.number_values )
84+
self.assertEqual( 31, len( profile.momentum ) )
85+
self.assertAlmostEqual( 0., profile.momentum[0] )
86+
self.assertAlmostEqual( 100., profile.momentum[-1] )
87+
self.assertEqual( 31, len( profile.pdf ) )
88+
self.assertAlmostEqual( 6.527863344596e-01, profile.pdf[0] )
89+
self.assertAlmostEqual( 3.571475386101e-10, profile.pdf[-1] )
90+
self.assertEqual( 31, len( profile.cdf ) )
91+
self.assertAlmostEqual( 0., profile.cdf[0] )
92+
self.assertAlmostEqual( 1., profile.cdf[-1] )
93+
94+
profile = chunk.compton_profile(2)
95+
self.assertEqual( 2, profile.interpolation )
96+
self.assertEqual( 31, profile.number_values )
97+
self.assertEqual( 31, len( profile.momentum ) )
98+
self.assertAlmostEqual( 0., profile.momentum[0] )
99+
self.assertAlmostEqual( 100., profile.momentum[-1] )
100+
self.assertEqual( 31, len( profile.pdf ) )
101+
self.assertAlmostEqual( 3.848272047027e+00, profile.pdf[0] )
102+
self.assertAlmostEqual( 8.728039694288e-12, profile.pdf[-1] )
103+
self.assertEqual( 31, len( profile.cdf ) )
104+
self.assertAlmostEqual( 0., profile.cdf[0] )
105+
self.assertAlmostEqual( 1., profile.cdf[-1] )
106+
107+
profile = chunk.data[0]
108+
self.assertEqual( 2, profile.interpolation )
109+
self.assertEqual( 31, profile.number_values )
110+
self.assertEqual( 31, len( profile.momentum ) )
111+
self.assertAlmostEqual( 0., profile.momentum[0] )
112+
self.assertAlmostEqual( 100., profile.momentum[-1] )
113+
self.assertEqual( 31, len( profile.pdf ) )
114+
self.assertAlmostEqual( 6.527863344596e-01, profile.pdf[0] )
115+
self.assertAlmostEqual( 3.571475386101e-10, profile.pdf[-1] )
116+
self.assertEqual( 31, len( profile.cdf ) )
117+
self.assertAlmostEqual( 0., profile.cdf[0] )
118+
self.assertAlmostEqual( 1., profile.cdf[-1] )
119+
120+
profile = chunk.data[1]
121+
self.assertEqual( 2, profile.interpolation )
122+
self.assertEqual( 31, profile.number_values )
123+
self.assertEqual( 31, len( profile.momentum ) )
124+
self.assertAlmostEqual( 0., profile.momentum[0] )
125+
self.assertAlmostEqual( 100., profile.momentum[-1] )
126+
self.assertEqual( 31, len( profile.pdf ) )
127+
self.assertAlmostEqual( 3.848272047027e+00, profile.pdf[0] )
128+
self.assertAlmostEqual( 8.728039694288e-12, profile.pdf[-1] )
129+
self.assertEqual( 31, len( profile.cdf ) )
130+
self.assertAlmostEqual( 0., profile.cdf[0] )
131+
self.assertAlmostEqual( 1., profile.cdf[-1] )
132+
133+
# verify the xss array
134+
xss = chunk.xss_array
135+
for index in range( chunk.length ) :
136+
137+
self.assertAlmostEqual( self.chunk[index], xss[index] )
138+
139+
# the data is given explicitly
140+
chunk = PhotoAtomicComptonProfileBlock(
141+
profiles = [
142+
143+
PhotoAtomicComptonProfile(
144+
2,
145+
[ 0.000000000000e+00, 5.000000000000e-02, 1.000000000000e-01,
146+
1.500000000000e-01, 2.000000000000e-01, 3.000000000000e-01, 4.000000000000e-01,
147+
5.000000000000e-01, 6.000000000000e-01, 7.000000000000e-01, 8.000000000000e-01,
148+
1.000000000000e+00, 1.200000000000e+00, 1.400000000000e+00, 1.600000000000e+00,
149+
1.800000000000e+00, 2.000000000000e+00, 2.400000000000e+00, 3.000000000000e+00,
150+
4.000000000000e+00, 5.000000000000e+00, 6.000000000000e+00, 7.000000000000e+00,
151+
8.000000000000e+00, 1.000000000000e+01, 1.500000000000e+01, 2.000000000000e+01,
152+
3.000000000000e+01, 4.000000000000e+01, 6.000000000000e+01, 1.000000000000e+02 ],
153+
[ 6.527863344596e-01, 6.508021814673e-01, 6.488180284750e-01, 6.448497224905e-01,
154+
6.388972635137e-01, 6.250081925677e-01, 6.051666626449e-01, 5.813568267376e-01,
155+
5.535786848457e-01, 5.218322369692e-01, 4.900857890928e-01, 4.226245873553e-01,
156+
3.571475386101e-01, 2.956387958495e-01, 2.420666650580e-01, 1.964311462356e-01,
157+
1.583354087838e-01, 1.017870485039e-01, 5.277846959461e-02, 1.871056271719e-02,
158+
7.361207601353e-03, 3.194486317568e-03, 1.515892886101e-03, 7.718355139963e-04,
159+
2.380983590734e-04, 2.380983590734e-05, 4.761967181468e-06, 4.365136583013e-07,
160+
7.738196669886e-08, 6.944535472975e-09, 3.571475386101e-10 ],
161+
[ 0.000000000000e+00,
162+
3.258971289817e-02, 6.508021814673e-02, 9.742191192087e-02, 1.295155865710e-01,
163+
1.927108593750e-01, 2.542196021357e-01, 3.135457766048e-01, 3.702925521840e-01,
164+
4.240630982747e-01, 4.746589995778e-01, 5.659300372226e-01, 6.439072498192e-01,
165+
7.091858832651e-01, 7.629564293559e-01, 8.068062104852e-01, 8.422828659872e-01,
166+
8.943073574447e-01, 9.406770128742e-01, 9.764215290301e-01, 9.894574141894e-01,
167+
9.947352611489e-01, 9.970904507507e-01, 9.982343149508e-01, 9.992442488238e-01,
168+
9.998990193113e-01, 9.999704488190e-01, 9.999964412232e-01, 9.999990107013e-01,
169+
9.999998539663e-01, 1.000000000000e+00 ] ),
170+
PhotoAtomicComptonProfile(
171+
2,
172+
[ 0.000000000000e+00, 5.000000000000e-02, 1.000000000000e-01, 1.500000000000e-01,
173+
2.000000000000e-01, 3.000000000000e-01, 4.000000000000e-01, 5.000000000000e-01,
174+
6.000000000000e-01, 7.000000000000e-01, 8.000000000000e-01, 1.000000000000e+00,
175+
1.200000000000e+00, 1.400000000000e+00, 1.600000000000e+00, 1.800000000000e+00,
176+
2.000000000000e+00, 2.400000000000e+00, 3.000000000000e+00, 4.000000000000e+00,
177+
5.000000000000e+00, 6.000000000000e+00, 7.000000000000e+00, 8.000000000000e+00,
178+
1.000000000000e+01, 1.500000000000e+01, 2.000000000000e+01, 3.000000000000e+01,
179+
4.000000000000e+01, 6.000000000000e+01, 1.000000000000e+02 ],
180+
[ 3.848272047027e+00,
181+
3.709416870073e+00, 3.352360700761e+00, 2.836612900644e+00, 2.261355738975e+00,
182+
1.213990975660e+00, 5.435188355080e-01, 2.142337015871e-01, 8.152782532619e-02,
183+
3.848272047027e-02, 2.796939992942e-02, 2.658084815988e-02, 2.380374462079e-02,
184+
1.900332278893e-02, 1.436159258787e-02, 1.063233926395e-02, 7.835399271009e-03,
185+
4.324346939443e-03, 1.908266860433e-03, 5.851753885943e-04, 2.142337015871e-04,
186+
8.886731325094e-05, 4.086309493235e-05, 2.043154746618e-05, 6.149300693703e-06,
187+
6.149300693703e-07, 1.170350777189e-07, 1.071168507935e-08, 1.904299569663e-09,
188+
1.705935031156e-10, 8.728039694288e-12 ],
189+
[ 0.000000000000e+00, 1.889422229275e-01,
190+
3.654866621983e-01, 5.202110022334e-01, 6.476602182239e-01, 8.214275539556e-01,
191+
9.093030445140e-01, 9.471906713688e-01, 9.619787477145e-01, 9.679792750043e-01,
192+
9.713018810243e-01, 9.767569058332e-01, 9.817953651113e-01, 9.860760718522e-01,
193+
9.894125633899e-01, 9.919119565751e-01, 9.937587304286e-01, 9.961906796707e-01,
194+
9.980604638107e-01, 9.993071849352e-01, 9.997068894803e-01, 9.998584399877e-01,
195+
9.999233051918e-01, 9.999539525130e-01, 9.999805333611e-01, 9.999974439380e-01,
196+
9.999992738509e-01, 9.999999125847e-01, 9.999999756646e-01, 9.999999964136e-01,
197+
1.000000000000e+00 ] ) ] )
198+
199+
verify_chunk( self, chunk )
200+
201+
if __name__ == '__main__' :
202+
203+
unittest.main()

0 commit comments

Comments
 (0)