Merge pull request #2222 from highness-eu/mixed_ncrystal

Adding support for NCrystal materials in OpenMC
This commit is contained in:
Paul Romano 2023-01-12 09:47:33 +07:00 committed by GitHub
commit a62bb50b27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 861 additions and 45 deletions

View file

@ -0,0 +1,45 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="1" material="1" region="-1" universe="1" />
<cell id="2" material="void" region="1 -2" universe="1" />
<surface coeffs="0.0 0.0 0.0 0.1" id="1" type="sphere" />
<surface boundary="vacuum" coeffs="0.0 0.0 0.0 100" id="2" type="sphere" />
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material cfg="Al_sg225.ncmat" id="1" temperature="293.15">
<density units="g/cm3" value="2.6986455176922477" />
<nuclide ao="1.0" name="Al27" />
</material>
</materials>
<?xml version='1.0' encoding='utf-8'?>
<settings>
<run_mode>fixed source</run_mode>
<particles>100000</particles>
<batches>10</batches>
<source strength="1.0">
<space type="point">
<parameters>0 0 -20</parameters>
</space>
<angle reference_uvw="0.0 0.0 1.0" type="monodirectional" />
<energy type="discrete">
<parameters>0.012 1.0</parameters>
</energy>
</source>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>
<filter id="1" type="surface">
<bins>1</bins>
</filter>
<filter id="2" type="polar">
<bins>0.0 0.017453292519943295 0.03490658503988659 0.05235987755982989 0.06981317007977318 0.08726646259971647 0.10471975511965978 0.12217304763960307 0.13962634015954636 0.15707963267948966 0.17453292519943295 0.19198621771937624 0.20943951023931956 0.22689280275926285 0.24434609527920614 0.2617993877991494 0.2792526803190927 0.29670597283903605 0.3141592653589793 0.33161255787892263 0.3490658503988659 0.3665191429188092 0.3839724354387525 0.4014257279586958 0.4188790204786391 0.4363323129985824 0.4537856055185257 0.47123889803846897 0.4886921905584123 0.5061454830783556 0.5235987755982988 0.5410520681182421 0.5585053606381855 0.5759586531581288 0.5934119456780721 0.6108652381980153 0.6283185307179586 0.6457718232379019 0.6632251157578453 0.6806784082777885 0.6981317007977318 0.7155849933176751 0.7330382858376184 0.7504915783575618 0.767944870877505 0.7853981633974483 0.8028514559173916 0.8203047484373349 0.8377580409572782 0.8552113334772214 0.8726646259971648 0.8901179185171081 0.9075712110370514 0.9250245035569946 0.9424777960769379 0.9599310885968813 0.9773843811168246 0.9948376736367679 1.0122909661567112 1.0297442586766545 1.0471975511965976 1.064650843716541 1.0821041362364843 1.0995574287564276 1.117010721276371 1.1344640137963142 1.1519173063162575 1.1693705988362009 1.1868238913561442 1.2042771838760873 1.2217304763960306 1.239183768915974 1.2566370614359172 1.2740903539558606 1.2915436464758039 1.3089969389957472 1.3264502315156905 1.3439035240356338 1.361356816555577 1.3788101090755203 1.3962634015954636 1.413716694115407 1.4311699866353502 1.4486232791552935 1.4660765716752369 1.4835298641951802 1.5009831567151235 1.5184364492350666 1.53588974175501 1.5533430342749532 1.5707963267948966 1.5882496193148399 1.6057029118347832 1.6231562043547265 1.6406094968746698 1.6580627893946132 1.6755160819145565 1.6929693744344996 1.710422666954443 1.7278759594743862 1.7453292519943295 1.7627825445142729 1.7802358370342162 1.7976891295541595 1.8151424220741028 1.8325957145940461 1.8500490071139892 1.8675022996339325 1.8849555921538759 1.9024088846738192 1.9198621771937625 1.9373154697137058 1.9547687622336491 1.9722220547535925 1.9896753472735358 2.007128639793479 2.0245819323134224 2.0420352248333655 2.059488517353309 2.076941809873252 2.0943951023931953 2.111848394913139 2.129301687433082 2.1467549799530254 2.1642082724729685 2.181661564992912 2.199114857512855 2.2165681500327987 2.234021442552742 2.251474735072685 2.2689280275926285 2.2863813201125716 2.303834612632515 2.321287905152458 2.3387411976724017 2.356194490192345 2.3736477827122884 2.3911010752322315 2.4085543677521746 2.426007660272118 2.443460952792061 2.4609142453120048 2.478367537831948 2.4958208303518914 2.5132741228718345 2.530727415391778 2.548180707911721 2.5656340004316642 2.5830872929516078 2.600540585471551 2.6179938779914944 2.6354471705114375 2.652900463031381 2.670353755551324 2.6878070480712677 2.705260340591211 2.722713633111154 2.7401669256310974 2.7576202181510405 2.775073510670984 2.792526803190927 2.8099800957108707 2.827433388230814 2.8448866807507573 2.8623399732707004 2.8797932657906435 2.897246558310587 2.91469985083053 2.9321531433504737 2.949606435870417 2.9670597283903604 2.9845130209103035 3.001966313430247 3.01941960595019 3.036872898470133 3.0543261909900767 3.07177948351002 3.0892327760299634 3.1066860685499065 3.12413936106985 3.141592653589793</bins>
</filter>
<filter id="3" type="cellfrom">
<bins>1</bins>
</filter>
<tally id="1" name="angular distribution">
<filters>1 2 3</filters>
<scores>current</scores>
</tally>
</tallies>

View file

@ -0,0 +1,181 @@
surface polar low [rad] polar high [rad] cellfrom nuclide score mean std. dev.
0 1 0.00e+00 1.75e-02 1 total current 9.82e-01 1.43e-04
1 1 1.75e-02 3.49e-02 1 total current 0.00e+00 0.00e+00
2 1 3.49e-02 5.24e-02 1 total current 1.00e-06 1.00e-06
3 1 5.24e-02 6.98e-02 1 total current 0.00e+00 0.00e+00
4 1 6.98e-02 8.73e-02 1 total current 0.00e+00 0.00e+00
5 1 8.73e-02 1.05e-01 1 total current 1.00e-06 1.00e-06
6 1 1.05e-01 1.22e-01 1 total current 0.00e+00 0.00e+00
7 1 1.22e-01 1.40e-01 1 total current 1.00e-06 1.00e-06
8 1 1.40e-01 1.57e-01 1 total current 1.00e-06 1.00e-06
9 1 1.57e-01 1.75e-01 1 total current 1.00e-06 1.00e-06
10 1 1.75e-01 1.92e-01 1 total current 0.00e+00 0.00e+00
11 1 1.92e-01 2.09e-01 1 total current 2.00e-06 1.33e-06
12 1 2.09e-01 2.27e-01 1 total current 0.00e+00 0.00e+00
13 1 2.27e-01 2.44e-01 1 total current 1.00e-06 1.00e-06
14 1 2.44e-01 2.62e-01 1 total current 1.00e-06 1.00e-06
15 1 2.62e-01 2.79e-01 1 total current 2.00e-06 1.33e-06
16 1 2.79e-01 2.97e-01 1 total current 0.00e+00 0.00e+00
17 1 2.97e-01 3.14e-01 1 total current 2.00e-06 2.00e-06
18 1 3.14e-01 3.32e-01 1 total current 1.00e-06 1.00e-06
19 1 3.32e-01 3.49e-01 1 total current 1.00e-06 1.00e-06
20 1 3.49e-01 3.67e-01 1 total current 2.00e-06 1.33e-06
21 1 3.67e-01 3.84e-01 1 total current 0.00e+00 0.00e+00
22 1 3.84e-01 4.01e-01 1 total current 2.00e-06 1.33e-06
23 1 4.01e-01 4.19e-01 1 total current 2.00e-06 1.33e-06
24 1 4.19e-01 4.36e-01 1 total current 1.00e-06 1.00e-06
25 1 4.36e-01 4.54e-01 1 total current 2.00e-06 2.00e-06
26 1 4.54e-01 4.71e-01 1 total current 5.00e-06 2.24e-06
27 1 4.71e-01 4.89e-01 1 total current 4.00e-06 1.63e-06
28 1 4.89e-01 5.06e-01 1 total current 3.00e-06 1.53e-06
29 1 5.06e-01 5.24e-01 1 total current 3.00e-06 1.53e-06
30 1 5.24e-01 5.41e-01 1 total current 3.00e-06 1.53e-06
31 1 5.41e-01 5.59e-01 1 total current 7.00e-06 2.13e-06
32 1 5.59e-01 5.76e-01 1 total current 3.00e-06 1.53e-06
33 1 5.76e-01 5.93e-01 1 total current 3.00e-06 1.53e-06
34 1 5.93e-01 6.11e-01 1 total current 2.00e-06 1.33e-06
35 1 6.11e-01 6.28e-01 1 total current 2.00e-06 1.33e-06
36 1 6.28e-01 6.46e-01 1 total current 3.00e-06 2.13e-06
37 1 6.46e-01 6.63e-01 1 total current 3.00e-06 1.53e-06
38 1 6.63e-01 6.81e-01 1 total current 2.00e-06 1.33e-06
39 1 6.81e-01 6.98e-01 1 total current 3.00e-06 1.53e-06
40 1 6.98e-01 7.16e-01 1 total current 1.00e-06 1.00e-06
41 1 7.16e-01 7.33e-01 1 total current 6.00e-06 2.67e-06
42 1 7.33e-01 7.50e-01 1 total current 6.00e-06 2.21e-06
43 1 7.50e-01 7.68e-01 1 total current 7.00e-06 3.35e-06
44 1 7.68e-01 7.85e-01 1 total current 6.00e-06 2.67e-06
45 1 7.85e-01 8.03e-01 1 total current 6.00e-06 2.21e-06
46 1 8.03e-01 8.20e-01 1 total current 7.00e-06 2.13e-06
47 1 8.20e-01 8.38e-01 1 total current 5.00e-06 2.24e-06
48 1 8.38e-01 8.55e-01 1 total current 3.00e-06 1.53e-06
49 1 8.55e-01 8.73e-01 1 total current 8.00e-06 3.27e-06
50 1 8.73e-01 8.90e-01 1 total current 7.00e-06 2.13e-06
51 1 8.90e-01 9.08e-01 1 total current 6.00e-06 2.21e-06
52 1 9.08e-01 9.25e-01 1 total current 4.00e-06 2.21e-06
53 1 9.25e-01 9.42e-01 1 total current 1.20e-05 3.27e-06
54 1 9.42e-01 9.60e-01 1 total current 8.00e-06 3.89e-06
55 1 9.60e-01 9.77e-01 1 total current 1.20e-05 4.42e-06
56 1 9.77e-01 9.95e-01 1 total current 7.00e-06 3.67e-06
57 1 9.95e-01 1.01e+00 1 total current 1.20e-05 3.89e-06
58 1 1.01e+00 1.03e+00 1 total current 9.00e-06 2.33e-06
59 1 1.03e+00 1.05e+00 1 total current 6.00e-06 2.67e-06
60 1 1.05e+00 1.06e+00 1 total current 7.00e-06 2.13e-06
61 1 1.06e+00 1.08e+00 1 total current 5.00e-06 2.24e-06
62 1 1.08e+00 1.10e+00 1 total current 1.20e-05 2.91e-06
63 1 1.10e+00 1.12e+00 1 total current 1.30e-05 3.35e-06
64 1 1.12e+00 1.13e+00 1 total current 9.00e-06 3.14e-06
65 1 1.13e+00 1.15e+00 1 total current 1.20e-05 3.89e-06
66 1 1.15e+00 1.17e+00 1 total current 6.00e-06 2.21e-06
67 1 1.17e+00 1.19e+00 1 total current 5.11e-03 4.20e-05
68 1 1.19e+00 1.20e+00 1 total current 8.00e-06 3.27e-06
69 1 1.20e+00 1.22e+00 1 total current 1.30e-05 4.48e-06
70 1 1.22e+00 1.24e+00 1 total current 1.20e-05 3.89e-06
71 1 1.24e+00 1.26e+00 1 total current 1.50e-05 4.28e-06
72 1 1.26e+00 1.27e+00 1 total current 7.00e-06 3.00e-06
73 1 1.27e+00 1.29e+00 1 total current 1.60e-05 3.71e-06
74 1 1.29e+00 1.31e+00 1 total current 9.00e-06 3.79e-06
75 1 1.31e+00 1.33e+00 1 total current 1.30e-05 2.60e-06
76 1 1.33e+00 1.34e+00 1 total current 1.60e-05 3.06e-06
77 1 1.34e+00 1.36e+00 1 total current 1.40e-05 2.67e-06
78 1 1.36e+00 1.38e+00 1 total current 1.40e-05 6.86e-06
79 1 1.38e+00 1.40e+00 1 total current 1.50e-05 4.28e-06
80 1 1.40e+00 1.41e+00 1 total current 3.26e-03 6.93e-05
81 1 1.41e+00 1.43e+00 1 total current 1.40e-05 3.71e-06
82 1 1.43e+00 1.45e+00 1 total current 1.30e-05 3.00e-06
83 1 1.45e+00 1.47e+00 1 total current 1.30e-05 3.67e-06
84 1 1.47e+00 1.48e+00 1 total current 1.70e-05 5.59e-06
85 1 1.48e+00 1.50e+00 1 total current 1.70e-05 3.67e-06
86 1 1.50e+00 1.52e+00 1 total current 1.40e-05 3.40e-06
87 1 1.52e+00 1.54e+00 1 total current 2.50e-05 4.53e-06
88 1 1.54e+00 1.55e+00 1 total current 1.30e-05 5.39e-06
89 1 1.55e+00 1.57e+00 1 total current 1.80e-05 4.67e-06
90 1 1.57e+00 1.59e+00 1 total current 1.40e-05 4.52e-06
91 1 1.59e+00 1.61e+00 1 total current 1.70e-05 4.23e-06
92 1 1.61e+00 1.62e+00 1 total current 1.40e-05 3.71e-06
93 1 1.62e+00 1.64e+00 1 total current 1.00e-05 2.11e-06
94 1 1.64e+00 1.66e+00 1 total current 2.00e-05 4.22e-06
95 1 1.66e+00 1.68e+00 1 total current 2.30e-05 5.59e-06
96 1 1.68e+00 1.69e+00 1 total current 1.70e-05 6.51e-06
97 1 1.69e+00 1.71e+00 1 total current 1.30e-05 3.00e-06
98 1 1.71e+00 1.73e+00 1 total current 1.50e-05 4.01e-06
99 1 1.73e+00 1.75e+00 1 total current 1.70e-05 3.96e-06
100 1 1.75e+00 1.76e+00 1 total current 1.80e-05 5.12e-06
101 1 1.76e+00 1.78e+00 1 total current 2.50e-05 6.54e-06
102 1 1.78e+00 1.80e+00 1 total current 1.80e-05 3.59e-06
103 1 1.80e+00 1.82e+00 1 total current 1.50e-05 4.01e-06
104 1 1.82e+00 1.83e+00 1 total current 1.10e-05 4.07e-06
105 1 1.83e+00 1.85e+00 1 total current 1.50e-05 4.01e-06
106 1 1.85e+00 1.87e+00 1 total current 1.90e-05 4.82e-06
107 1 1.87e+00 1.88e+00 1 total current 2.20e-05 3.89e-06
108 1 1.88e+00 1.90e+00 1 total current 2.10e-05 3.79e-06
109 1 1.90e+00 1.92e+00 1 total current 1.50e-05 3.42e-06
110 1 1.92e+00 1.94e+00 1 total current 2.20e-05 5.12e-06
111 1 1.94e+00 1.95e+00 1 total current 2.10e-05 5.86e-06
112 1 1.95e+00 1.97e+00 1 total current 2.60e-05 4.27e-06
113 1 1.97e+00 1.99e+00 1 total current 2.20e-05 4.16e-06
114 1 1.99e+00 2.01e+00 1 total current 2.40e-05 5.42e-06
115 1 2.01e+00 2.02e+00 1 total current 1.60e-05 4.52e-06
116 1 2.02e+00 2.04e+00 1 total current 1.30e-05 3.35e-06
117 1 2.04e+00 2.06e+00 1 total current 1.90e-05 4.07e-06
118 1 2.06e+00 2.08e+00 1 total current 1.30e-05 3.00e-06
119 1 2.08e+00 2.09e+00 1 total current 1.40e-05 4.00e-06
120 1 2.09e+00 2.11e+00 1 total current 3.10e-05 5.47e-06
121 1 2.11e+00 2.13e+00 1 total current 2.30e-05 5.39e-06
122 1 2.13e+00 2.15e+00 1 total current 2.20e-05 4.67e-06
123 1 2.15e+00 2.16e+00 1 total current 1.70e-05 4.48e-06
124 1 2.16e+00 2.18e+00 1 total current 1.60e-05 4.00e-06
125 1 2.18e+00 2.20e+00 1 total current 1.80e-05 4.16e-06
126 1 2.20e+00 2.22e+00 1 total current 1.80e-05 4.42e-06
127 1 2.22e+00 2.23e+00 1 total current 1.80e-05 5.54e-06
128 1 2.23e+00 2.25e+00 1 total current 1.90e-05 4.33e-06
129 1 2.25e+00 2.27e+00 1 total current 1.00e-05 3.33e-06
130 1 2.27e+00 2.29e+00 1 total current 1.80e-05 4.42e-06
131 1 2.29e+00 2.30e+00 1 total current 4.15e-03 5.40e-05
132 1 2.30e+00 2.32e+00 1 total current 1.90e-05 2.33e-06
133 1 2.32e+00 2.34e+00 1 total current 2.30e-05 3.96e-06
134 1 2.34e+00 2.36e+00 1 total current 1.90e-05 3.48e-06
135 1 2.36e+00 2.37e+00 1 total current 1.60e-05 3.71e-06
136 1 2.37e+00 2.39e+00 1 total current 1.60e-05 4.27e-06
137 1 2.39e+00 2.41e+00 1 total current 2.30e-05 4.48e-06
138 1 2.41e+00 2.43e+00 1 total current 2.10e-05 3.48e-06
139 1 2.43e+00 2.44e+00 1 total current 1.60e-05 2.21e-06
140 1 2.44e+00 2.46e+00 1 total current 9.00e-06 2.77e-06
141 1 2.46e+00 2.48e+00 1 total current 1.30e-05 3.00e-06
142 1 2.48e+00 2.50e+00 1 total current 2.70e-05 3.67e-06
143 1 2.50e+00 2.51e+00 1 total current 1.90e-05 4.07e-06
144 1 2.51e+00 2.53e+00 1 total current 1.20e-05 4.16e-06
145 1 2.53e+00 2.55e+00 1 total current 1.30e-05 2.13e-06
146 1 2.55e+00 2.57e+00 1 total current 1.10e-05 2.33e-06
147 1 2.57e+00 2.58e+00 1 total current 1.50e-05 3.07e-06
148 1 2.58e+00 2.60e+00 1 total current 1.20e-05 2.49e-06
149 1 2.60e+00 2.62e+00 1 total current 1.80e-05 5.54e-06
150 1 2.62e+00 2.64e+00 1 total current 1.30e-05 3.67e-06
151 1 2.64e+00 2.65e+00 1 total current 1.60e-05 3.40e-06
152 1 2.65e+00 2.67e+00 1 total current 7.00e-06 3.35e-06
153 1 2.67e+00 2.69e+00 1 total current 1.00e-05 2.98e-06
154 1 2.69e+00 2.71e+00 1 total current 7.00e-06 3.35e-06
155 1 2.71e+00 2.72e+00 1 total current 1.20e-05 2.91e-06
156 1 2.72e+00 2.74e+00 1 total current 9.00e-06 2.33e-06
157 1 2.74e+00 2.76e+00 1 total current 1.00e-05 3.33e-06
158 1 2.76e+00 2.78e+00 1 total current 1.10e-05 3.14e-06
159 1 2.78e+00 2.79e+00 1 total current 1.00e-05 3.33e-06
160 1 2.79e+00 2.81e+00 1 total current 1.40e-05 4.76e-06
161 1 2.81e+00 2.83e+00 1 total current 8.00e-06 2.91e-06
162 1 2.83e+00 2.84e+00 1 total current 5.00e-06 2.69e-06
163 1 2.84e+00 2.86e+00 1 total current 6.00e-06 2.21e-06
164 1 2.86e+00 2.88e+00 1 total current 5.00e-06 1.67e-06
165 1 2.88e+00 2.90e+00 1 total current 4.00e-06 2.21e-06
166 1 2.90e+00 2.91e+00 1 total current 7.00e-06 2.13e-06
167 1 2.91e+00 2.93e+00 1 total current 6.00e-06 2.67e-06
168 1 2.93e+00 2.95e+00 1 total current 7.00e-06 2.13e-06
169 1 2.95e+00 2.97e+00 1 total current 5.00e-06 1.67e-06
170 1 2.97e+00 2.98e+00 1 total current 3.00e-06 1.53e-06
171 1 2.98e+00 3.00e+00 1 total current 6.00e-06 2.21e-06
172 1 3.00e+00 3.02e+00 1 total current 3.00e-06 1.53e-06
173 1 3.02e+00 3.04e+00 1 total current 1.00e-05 2.98e-06
174 1 3.04e+00 3.05e+00 1 total current 2.00e-06 1.33e-06
175 1 3.05e+00 3.07e+00 1 total current 1.00e-06 1.00e-06
176 1 3.07e+00 3.09e+00 1 total current 2.00e-06 1.33e-06
177 1 3.09e+00 3.11e+00 1 total current 0.00e+00 0.00e+00
178 1 3.11e+00 3.12e+00 1 total current 1.00e-06 1.00e-06
179 1 3.12e+00 3.14e+00 1 total current 0.00e+00 0.00e+00

View file

@ -0,0 +1,80 @@
from math import pi
import numpy as np
import openmc
import openmc.lib
import pytest
from tests.testing_harness import PyAPITestHarness
pytestmark = pytest.mark.skipif(
not openmc.lib._ncrystal_enabled(),
reason="NCrystal materials are not enabled.")
def pencil_beam_model(cfg, E0, N):
"""Return an openmc.Model() object for a monoenergetic pencil
beam hitting a 1 mm sphere filled with the material defined by
the cfg string, and compute the angular distribution"""
# Material definition
m1 = openmc.Material.from_ncrystal(cfg)
materials = openmc.Materials([m1])
# Geometry definition
sample_sphere = openmc.Sphere(r=0.1)
outer_sphere = openmc.Sphere(r=100, boundary_type="vacuum")
cell1 = openmc.Cell(region=-sample_sphere, fill=m1)
cell2_region = +sample_sphere & -outer_sphere
cell2 = openmc.Cell(region=cell2_region, fill=None)
geometry = openmc.Geometry([cell1, cell2])
# Source definition
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, -20))
source.angle = openmc.stats.Monodirectional(reference_uvw=(0, 0, 1))
source.energy = openmc.stats.Discrete([E0], [1.0])
# Execution settings
settings = openmc.Settings()
settings.source = source
settings.run_mode = "fixed source"
settings.batches = 10
settings.particles = N
# Tally definition
tally1 = openmc.Tally(name="angular distribution")
tally1.scores = ["current"]
filter1 = openmc.SurfaceFilter(sample_sphere)
filter2 = openmc.PolarFilter(np.linspace(0, pi, 180+1))
filter3 = openmc.CellFromFilter(cell1)
tally1.filters = [filter1, filter2, filter3]
tallies = openmc.Tallies([tally1])
return openmc.Model(geometry, materials, settings, tallies)
class NCrystalTest(PyAPITestHarness):
def _get_results(self):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
with openmc.StatePoint(self._sp_name) as sp:
tal = sp.get_tally(name='angular distribution')
df = tal.get_pandas_dataframe()
return df.to_string()
def test_ncrystal():
n_particles = 100000
T = 293.6 # K
E0 = 0.012 # eV
cfg = 'Al_sg225.ncmat'
test = pencil_beam_model(cfg, E0, n_particles)
harness = NCrystalTest('statepoint.10.h5', model=test)
harness.main()