ncrystal-python 4.0.0__tar.gz → 4.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ncrystal_python-4.0.0/src/ncrystal_python.egg-info → ncrystal_python-4.0.2}/PKG-INFO +45 -27
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/README.md +44 -26
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/__init__.py +1 -1
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_common.py +11 -2
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/cifutils.py +21 -1
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2/src/ncrystal_python.egg-info}/PKG-INFO +45 -27
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/LICENSE +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/pyproject.toml +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/setup.cfg +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/__main__.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_chooks.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_cif2ncmat.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_endf2ncmat.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_hfg2ncmat.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_mcstasunion.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_ncmat2cpp.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_ncmat2hkl.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_nctool.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_vdos2ncmat.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cli_verifyatompos.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cliimpl.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_cliwrap_config.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_coreimpl.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_hfgdata.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_hklobjects.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_is_std.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_locatelib.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_miscimpl.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_mmc.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_msg.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_ncmat2cpp_impl.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_ncmatimpl.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_numpy.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/_testimpl.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/api.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/atomdata.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/cfgstr.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/cli.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/constants.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/core.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/datasrc.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/exceptions.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/hfg2ncmat.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/mcstasutils.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/misc.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/mmc.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/ncmat.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/ncmat2cpp.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/obsolete.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/plot.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/plugins.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/test.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/NCrystal/vdos.py +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/ncrystal_python.egg-info/SOURCES.txt +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/ncrystal_python.egg-info/dependency_links.txt +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/ncrystal_python.egg-info/entry_points.txt +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/ncrystal_python.egg-info/requires.txt +0 -0
- {ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/ncrystal_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ncrystal-python
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.2
|
|
4
4
|
Summary: Library for thermal neutron transport in crystals and other materials.
|
|
5
5
|
Author: NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)
|
|
6
6
|
License: The Apache 2.0 license is reproduced in the following. See the NOTICE file for
|
|
@@ -222,6 +222,10 @@ Requires-Dist: numpy>=1.22
|
|
|
222
222
|
NCrystal : A library for thermal neutron transport in crystals and other materials
|
|
223
223
|
----------------------------------------------------------------------------------
|
|
224
224
|
|
|
225
|
+

|
|
226
|
+

|
|
227
|
+

|
|
228
|
+
|
|
225
229
|
This is a source distribution of NCrystal, a library and associated tools which
|
|
226
230
|
enables calculations for Monte Carlo simulations of thermal neutrons in crystals
|
|
227
231
|
and other materials. Supported is a range of physics including both coherent,
|
|
@@ -321,17 +325,21 @@ your compiler's include path, and that the NCrystal library is linked
|
|
|
321
325
|
correctly. Here are some examples of how this could for instance be done, with a
|
|
322
326
|
C and a C++ app respectively:
|
|
323
327
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
```
|
|
329
|
+
export LDFLAGS="${LDFLAGS:-} -Wl,-rpath,$(ncrystal-config --show libdir) $(ncrystal-config --show libpath)"
|
|
330
|
+
export CFLAGS="${CFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
331
|
+
export CXXFLAGS="${CXXFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
332
|
+
cc -std=c11 ${LDFLAGS} ${CFLAGS} my_c_code.c -o my_c_app
|
|
333
|
+
c++ -std=c++17 ${LDFLAGS} ${CXXFLAGS} my_cpp_code.cpp -o my_cpp_app
|
|
334
|
+
```
|
|
329
335
|
|
|
330
336
|
Then, in your code you can access the relevant APIs with with statements like:
|
|
331
337
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
338
|
+
```
|
|
339
|
+
#include "NCrystal/NCrystal.hh" // C++ code, core NCrystal
|
|
340
|
+
#include "NCrystal/ncrystal.h" // C code
|
|
341
|
+
import NCrystal ## Python code
|
|
342
|
+
```
|
|
335
343
|
|
|
336
344
|
In the ./examples/ directory of your NCrystal distribution that you got after
|
|
337
345
|
downloading and unpacking the NCrystal source tar-ball, you will find small
|
|
@@ -339,8 +347,10 @@ examples of code using NCrystal. For C++/C, there is currently no documentation
|
|
|
339
347
|
beyond the header files and examples. In the case of Python, there is integrated
|
|
340
348
|
documentation available via the usual "help" function, accessed with:
|
|
341
349
|
|
|
342
|
-
|
|
343
|
-
|
|
350
|
+
```
|
|
351
|
+
import NCrystal
|
|
352
|
+
help(NCrystal)
|
|
353
|
+
```
|
|
344
354
|
|
|
345
355
|
There are also several jupyter-lab notebooks showcasing the NCrystal python API
|
|
346
356
|
at https://github.com/mctools/ncrystal-notebooks
|
|
@@ -403,13 +413,13 @@ which when used in a complete OpenMC project, results in the following material
|
|
|
403
413
|
entry being added to the `materials.xml` produced:
|
|
404
414
|
|
|
405
415
|
```
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
416
|
+
<material cfg="Polyethylene_CH2.ncmat;temp=50C" id="1" temperature="323.15">
|
|
417
|
+
<density units="g/cm3" value="0.92" />
|
|
418
|
+
<nuclide ao="0.66656284" name="H1" />
|
|
419
|
+
<nuclide ao="0.00010382666666666666" name="H2" />
|
|
420
|
+
<nuclide ao="0.32964066666666664" name="C12" />
|
|
421
|
+
<nuclide ao="0.003692666666666666" name="C13" />
|
|
422
|
+
</material>
|
|
413
423
|
```
|
|
414
424
|
|
|
415
425
|
Temperature, density and material composition were all created automatically
|
|
@@ -439,13 +449,13 @@ A few issues might warrent attention:
|
|
|
439
449
|
|
|
440
450
|
For more information, please consult the user guide at:
|
|
441
451
|
|
|
442
|
-
|
|
452
|
+
* https://docs.openmc.org/
|
|
443
453
|
|
|
444
454
|
In particular note the sections concerning installation and usage of NCrystal in
|
|
445
455
|
the sections:
|
|
446
456
|
|
|
447
|
-
|
|
448
|
-
|
|
457
|
+
* https://docs.openmc.org/en/stable/usersguide/install.html
|
|
458
|
+
* https://docs.openmc.org/en/stable/usersguide/materials.html
|
|
449
459
|
|
|
450
460
|
|
|
451
461
|
|
|
@@ -466,27 +476,35 @@ the correct settings for doing so. Thus, you can always invoke "ncrystal-config
|
|
|
466
476
|
active. Depending on how you installed McStas, NCrystal is most likely already
|
|
467
477
|
available. If not, you can try one of the following ways of enabling it:
|
|
468
478
|
|
|
469
|
-
|
|
470
|
-
|
|
479
|
+
```
|
|
480
|
+
$> conda install conda-forge::ncrystal [if you are in a conda-forge env]
|
|
481
|
+
$> python3 -mpip install ncrystal [for non-conda users]
|
|
482
|
+
```
|
|
471
483
|
|
|
472
484
|
It is beyond the scope for this README to provide a full documentation of
|
|
473
485
|
McStas, or the Union sub-system, but if you are using McStasScript to compose
|
|
474
486
|
your instruments, you can add NCrystal materials into your Union geometry using
|
|
475
487
|
code like:
|
|
476
488
|
|
|
477
|
-
|
|
478
|
-
|
|
489
|
+
```
|
|
490
|
+
from mcstasscript.tools.ncrystal_union import add_ncrystal_union_material
|
|
491
|
+
add_ncrystal_union_material(instr, name="myAl", cfgstr="Al_sg225.ncmat;temp=10C")
|
|
492
|
+
```
|
|
479
493
|
|
|
480
494
|
This creates the material and gives it the name "myAl", which you must later
|
|
481
495
|
attach to a particular Union volume, like for instance:
|
|
482
496
|
|
|
483
|
-
|
|
484
|
-
|
|
497
|
+
```
|
|
498
|
+
myvol.set_parameters(radius=0.01, yheight=0.01,
|
|
499
|
+
material_string='"myAl"', priority=1)
|
|
500
|
+
```
|
|
485
501
|
|
|
486
502
|
If you are instead hand-editing your instrument files, you can generate code
|
|
487
503
|
which defines Union materials from an NCrystal cfg-string by invoking:
|
|
488
504
|
|
|
505
|
+
```
|
|
489
506
|
$> python3 -mNCrystal.mcstasutils --union myAl 'Al_sg225.ncmat;temp=250K'
|
|
507
|
+
```
|
|
490
508
|
|
|
491
509
|
It should be noted that McStas 3.3 also provides a new SHELL syntax which can
|
|
492
510
|
also be used to faciliate this invocation from with a classic .instr file.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
NCrystal : A library for thermal neutron transport in crystals and other materials
|
|
2
2
|
----------------------------------------------------------------------------------
|
|
3
3
|
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
4
8
|
This is a source distribution of NCrystal, a library and associated tools which
|
|
5
9
|
enables calculations for Monte Carlo simulations of thermal neutrons in crystals
|
|
6
10
|
and other materials. Supported is a range of physics including both coherent,
|
|
@@ -100,17 +104,21 @@ your compiler's include path, and that the NCrystal library is linked
|
|
|
100
104
|
correctly. Here are some examples of how this could for instance be done, with a
|
|
101
105
|
C and a C++ app respectively:
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
```
|
|
108
|
+
export LDFLAGS="${LDFLAGS:-} -Wl,-rpath,$(ncrystal-config --show libdir) $(ncrystal-config --show libpath)"
|
|
109
|
+
export CFLAGS="${CFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
110
|
+
export CXXFLAGS="${CXXFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
111
|
+
cc -std=c11 ${LDFLAGS} ${CFLAGS} my_c_code.c -o my_c_app
|
|
112
|
+
c++ -std=c++17 ${LDFLAGS} ${CXXFLAGS} my_cpp_code.cpp -o my_cpp_app
|
|
113
|
+
```
|
|
108
114
|
|
|
109
115
|
Then, in your code you can access the relevant APIs with with statements like:
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
```
|
|
118
|
+
#include "NCrystal/NCrystal.hh" // C++ code, core NCrystal
|
|
119
|
+
#include "NCrystal/ncrystal.h" // C code
|
|
120
|
+
import NCrystal ## Python code
|
|
121
|
+
```
|
|
114
122
|
|
|
115
123
|
In the ./examples/ directory of your NCrystal distribution that you got after
|
|
116
124
|
downloading and unpacking the NCrystal source tar-ball, you will find small
|
|
@@ -118,8 +126,10 @@ examples of code using NCrystal. For C++/C, there is currently no documentation
|
|
|
118
126
|
beyond the header files and examples. In the case of Python, there is integrated
|
|
119
127
|
documentation available via the usual "help" function, accessed with:
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
```
|
|
130
|
+
import NCrystal
|
|
131
|
+
help(NCrystal)
|
|
132
|
+
```
|
|
123
133
|
|
|
124
134
|
There are also several jupyter-lab notebooks showcasing the NCrystal python API
|
|
125
135
|
at https://github.com/mctools/ncrystal-notebooks
|
|
@@ -182,13 +192,13 @@ which when used in a complete OpenMC project, results in the following material
|
|
|
182
192
|
entry being added to the `materials.xml` produced:
|
|
183
193
|
|
|
184
194
|
```
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
<material cfg="Polyethylene_CH2.ncmat;temp=50C" id="1" temperature="323.15">
|
|
196
|
+
<density units="g/cm3" value="0.92" />
|
|
197
|
+
<nuclide ao="0.66656284" name="H1" />
|
|
198
|
+
<nuclide ao="0.00010382666666666666" name="H2" />
|
|
199
|
+
<nuclide ao="0.32964066666666664" name="C12" />
|
|
200
|
+
<nuclide ao="0.003692666666666666" name="C13" />
|
|
201
|
+
</material>
|
|
192
202
|
```
|
|
193
203
|
|
|
194
204
|
Temperature, density and material composition were all created automatically
|
|
@@ -218,13 +228,13 @@ A few issues might warrent attention:
|
|
|
218
228
|
|
|
219
229
|
For more information, please consult the user guide at:
|
|
220
230
|
|
|
221
|
-
|
|
231
|
+
* https://docs.openmc.org/
|
|
222
232
|
|
|
223
233
|
In particular note the sections concerning installation and usage of NCrystal in
|
|
224
234
|
the sections:
|
|
225
235
|
|
|
226
|
-
|
|
227
|
-
|
|
236
|
+
* https://docs.openmc.org/en/stable/usersguide/install.html
|
|
237
|
+
* https://docs.openmc.org/en/stable/usersguide/materials.html
|
|
228
238
|
|
|
229
239
|
|
|
230
240
|
|
|
@@ -245,27 +255,35 @@ the correct settings for doing so. Thus, you can always invoke "ncrystal-config
|
|
|
245
255
|
active. Depending on how you installed McStas, NCrystal is most likely already
|
|
246
256
|
available. If not, you can try one of the following ways of enabling it:
|
|
247
257
|
|
|
248
|
-
|
|
249
|
-
|
|
258
|
+
```
|
|
259
|
+
$> conda install conda-forge::ncrystal [if you are in a conda-forge env]
|
|
260
|
+
$> python3 -mpip install ncrystal [for non-conda users]
|
|
261
|
+
```
|
|
250
262
|
|
|
251
263
|
It is beyond the scope for this README to provide a full documentation of
|
|
252
264
|
McStas, or the Union sub-system, but if you are using McStasScript to compose
|
|
253
265
|
your instruments, you can add NCrystal materials into your Union geometry using
|
|
254
266
|
code like:
|
|
255
267
|
|
|
256
|
-
|
|
257
|
-
|
|
268
|
+
```
|
|
269
|
+
from mcstasscript.tools.ncrystal_union import add_ncrystal_union_material
|
|
270
|
+
add_ncrystal_union_material(instr, name="myAl", cfgstr="Al_sg225.ncmat;temp=10C")
|
|
271
|
+
```
|
|
258
272
|
|
|
259
273
|
This creates the material and gives it the name "myAl", which you must later
|
|
260
274
|
attach to a particular Union volume, like for instance:
|
|
261
275
|
|
|
262
|
-
|
|
263
|
-
|
|
276
|
+
```
|
|
277
|
+
myvol.set_parameters(radius=0.01, yheight=0.01,
|
|
278
|
+
material_string='"myAl"', priority=1)
|
|
279
|
+
```
|
|
264
280
|
|
|
265
281
|
If you are instead hand-editing your instrument files, you can generate code
|
|
266
282
|
which defines Union materials from an NCrystal cfg-string by invoking:
|
|
267
283
|
|
|
284
|
+
```
|
|
268
285
|
$> python3 -mNCrystal.mcstasutils --union myAl 'Al_sg225.ncmat;temp=250K'
|
|
286
|
+
```
|
|
269
287
|
|
|
270
288
|
It should be noted that McStas 3.3 also provides a new SHELL syntax which can
|
|
271
289
|
also be used to faciliate this invocation from with a classic .instr file.
|
|
@@ -55,7 +55,7 @@ For detailed usage conditions and licensing of this open source project, see:
|
|
|
55
55
|
|
|
56
56
|
#NB: Synchronize meta-data below with fields in setup.py+template_setup.py.in meta data:
|
|
57
57
|
__license__ = "Apache 2.0, http://www.apache.org/licenses/LICENSE-2.0"
|
|
58
|
-
__version__ = '4.0.
|
|
58
|
+
__version__ = '4.0.2'
|
|
59
59
|
__status__ = "Production"
|
|
60
60
|
__author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
|
|
61
61
|
__copyright__ = "Copyright 2015-2024 %s"%__author__
|
|
@@ -420,14 +420,23 @@ def extract_path( s ):
|
|
|
420
420
|
return res_try
|
|
421
421
|
return pathlib.Path(s)
|
|
422
422
|
|
|
423
|
-
def download_url( url,
|
|
423
|
+
def download_url( url,
|
|
424
|
+
decode_as_utf8_str = True,
|
|
425
|
+
wrap_exception = True,
|
|
426
|
+
timeout = None,
|
|
427
|
+
quiet_network_fail = False ):
|
|
428
|
+
"""Download the provided url. The timeout value is in seconds if given.
|
|
429
|
+
Returns None on network failure if quiet_network_fail is True.
|
|
430
|
+
"""
|
|
424
431
|
import urllib.request
|
|
425
432
|
import urllib.error
|
|
426
433
|
try:
|
|
427
434
|
req = urllib.request.Request(url)
|
|
428
|
-
with urllib.request.urlopen(req) as response:
|
|
435
|
+
with urllib.request.urlopen(req, timeout = timeout ) as response:
|
|
429
436
|
data = response.read()
|
|
430
437
|
except urllib.error.URLError as e:
|
|
438
|
+
if quiet_network_fail:
|
|
439
|
+
return None
|
|
431
440
|
if wrap_exception:
|
|
432
441
|
from .exceptions import NCException
|
|
433
442
|
raise NCException(f'Error downloading url "{url}": {e}')
|
|
@@ -1239,7 +1239,27 @@ def _cod_get_cifdata( codid, quiet = False ):
|
|
|
1239
1239
|
return c
|
|
1240
1240
|
if not quiet:
|
|
1241
1241
|
_nc_common.print(f"Querying the Crystallography Open Database for entry {codid}")
|
|
1242
|
-
|
|
1242
|
+
|
|
1243
|
+
mirror_urls = [
|
|
1244
|
+
"https://www.crystallography.net/cod/%i.cif",#canonical first
|
|
1245
|
+
'https://qiserver.ugr.es/cod/%i.cif',
|
|
1246
|
+
'http://cod.ibt.lt/cod/%i.cif',
|
|
1247
|
+
]
|
|
1248
|
+
|
|
1249
|
+
result = None
|
|
1250
|
+
while result is None:
|
|
1251
|
+
#Fail gently and try next mirror - except for the last attempt.
|
|
1252
|
+
url = mirror_urls.pop(0)%codid
|
|
1253
|
+
result = _nc_common.download_url( url,
|
|
1254
|
+
timeout = 10.0,
|
|
1255
|
+
quiet_network_fail = bool(mirror_urls) )
|
|
1256
|
+
if result or not mirror_urls:
|
|
1257
|
+
break
|
|
1258
|
+
nextdescr = '/'.join(mirror_urls[0].split('/')[0:-1])+'/'
|
|
1259
|
+
_nc_common.print(f'Retrival failed. Trying mirror at: {nextdescr}')
|
|
1260
|
+
|
|
1261
|
+
assert result is not None
|
|
1262
|
+
|
|
1243
1263
|
if len(_cod_cache)==10:
|
|
1244
1264
|
_cod_cache.pop(0)
|
|
1245
1265
|
_cod_cache.append( (codid, result ) )
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ncrystal-python
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.2
|
|
4
4
|
Summary: Library for thermal neutron transport in crystals and other materials.
|
|
5
5
|
Author: NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)
|
|
6
6
|
License: The Apache 2.0 license is reproduced in the following. See the NOTICE file for
|
|
@@ -222,6 +222,10 @@ Requires-Dist: numpy>=1.22
|
|
|
222
222
|
NCrystal : A library for thermal neutron transport in crystals and other materials
|
|
223
223
|
----------------------------------------------------------------------------------
|
|
224
224
|
|
|
225
|
+

|
|
226
|
+

|
|
227
|
+

|
|
228
|
+
|
|
225
229
|
This is a source distribution of NCrystal, a library and associated tools which
|
|
226
230
|
enables calculations for Monte Carlo simulations of thermal neutrons in crystals
|
|
227
231
|
and other materials. Supported is a range of physics including both coherent,
|
|
@@ -321,17 +325,21 @@ your compiler's include path, and that the NCrystal library is linked
|
|
|
321
325
|
correctly. Here are some examples of how this could for instance be done, with a
|
|
322
326
|
C and a C++ app respectively:
|
|
323
327
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
```
|
|
329
|
+
export LDFLAGS="${LDFLAGS:-} -Wl,-rpath,$(ncrystal-config --show libdir) $(ncrystal-config --show libpath)"
|
|
330
|
+
export CFLAGS="${CFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
331
|
+
export CXXFLAGS="${CXXFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
332
|
+
cc -std=c11 ${LDFLAGS} ${CFLAGS} my_c_code.c -o my_c_app
|
|
333
|
+
c++ -std=c++17 ${LDFLAGS} ${CXXFLAGS} my_cpp_code.cpp -o my_cpp_app
|
|
334
|
+
```
|
|
329
335
|
|
|
330
336
|
Then, in your code you can access the relevant APIs with with statements like:
|
|
331
337
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
338
|
+
```
|
|
339
|
+
#include "NCrystal/NCrystal.hh" // C++ code, core NCrystal
|
|
340
|
+
#include "NCrystal/ncrystal.h" // C code
|
|
341
|
+
import NCrystal ## Python code
|
|
342
|
+
```
|
|
335
343
|
|
|
336
344
|
In the ./examples/ directory of your NCrystal distribution that you got after
|
|
337
345
|
downloading and unpacking the NCrystal source tar-ball, you will find small
|
|
@@ -339,8 +347,10 @@ examples of code using NCrystal. For C++/C, there is currently no documentation
|
|
|
339
347
|
beyond the header files and examples. In the case of Python, there is integrated
|
|
340
348
|
documentation available via the usual "help" function, accessed with:
|
|
341
349
|
|
|
342
|
-
|
|
343
|
-
|
|
350
|
+
```
|
|
351
|
+
import NCrystal
|
|
352
|
+
help(NCrystal)
|
|
353
|
+
```
|
|
344
354
|
|
|
345
355
|
There are also several jupyter-lab notebooks showcasing the NCrystal python API
|
|
346
356
|
at https://github.com/mctools/ncrystal-notebooks
|
|
@@ -403,13 +413,13 @@ which when used in a complete OpenMC project, results in the following material
|
|
|
403
413
|
entry being added to the `materials.xml` produced:
|
|
404
414
|
|
|
405
415
|
```
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
416
|
+
<material cfg="Polyethylene_CH2.ncmat;temp=50C" id="1" temperature="323.15">
|
|
417
|
+
<density units="g/cm3" value="0.92" />
|
|
418
|
+
<nuclide ao="0.66656284" name="H1" />
|
|
419
|
+
<nuclide ao="0.00010382666666666666" name="H2" />
|
|
420
|
+
<nuclide ao="0.32964066666666664" name="C12" />
|
|
421
|
+
<nuclide ao="0.003692666666666666" name="C13" />
|
|
422
|
+
</material>
|
|
413
423
|
```
|
|
414
424
|
|
|
415
425
|
Temperature, density and material composition were all created automatically
|
|
@@ -439,13 +449,13 @@ A few issues might warrent attention:
|
|
|
439
449
|
|
|
440
450
|
For more information, please consult the user guide at:
|
|
441
451
|
|
|
442
|
-
|
|
452
|
+
* https://docs.openmc.org/
|
|
443
453
|
|
|
444
454
|
In particular note the sections concerning installation and usage of NCrystal in
|
|
445
455
|
the sections:
|
|
446
456
|
|
|
447
|
-
|
|
448
|
-
|
|
457
|
+
* https://docs.openmc.org/en/stable/usersguide/install.html
|
|
458
|
+
* https://docs.openmc.org/en/stable/usersguide/materials.html
|
|
449
459
|
|
|
450
460
|
|
|
451
461
|
|
|
@@ -466,27 +476,35 @@ the correct settings for doing so. Thus, you can always invoke "ncrystal-config
|
|
|
466
476
|
active. Depending on how you installed McStas, NCrystal is most likely already
|
|
467
477
|
available. If not, you can try one of the following ways of enabling it:
|
|
468
478
|
|
|
469
|
-
|
|
470
|
-
|
|
479
|
+
```
|
|
480
|
+
$> conda install conda-forge::ncrystal [if you are in a conda-forge env]
|
|
481
|
+
$> python3 -mpip install ncrystal [for non-conda users]
|
|
482
|
+
```
|
|
471
483
|
|
|
472
484
|
It is beyond the scope for this README to provide a full documentation of
|
|
473
485
|
McStas, or the Union sub-system, but if you are using McStasScript to compose
|
|
474
486
|
your instruments, you can add NCrystal materials into your Union geometry using
|
|
475
487
|
code like:
|
|
476
488
|
|
|
477
|
-
|
|
478
|
-
|
|
489
|
+
```
|
|
490
|
+
from mcstasscript.tools.ncrystal_union import add_ncrystal_union_material
|
|
491
|
+
add_ncrystal_union_material(instr, name="myAl", cfgstr="Al_sg225.ncmat;temp=10C")
|
|
492
|
+
```
|
|
479
493
|
|
|
480
494
|
This creates the material and gives it the name "myAl", which you must later
|
|
481
495
|
attach to a particular Union volume, like for instance:
|
|
482
496
|
|
|
483
|
-
|
|
484
|
-
|
|
497
|
+
```
|
|
498
|
+
myvol.set_parameters(radius=0.01, yheight=0.01,
|
|
499
|
+
material_string='"myAl"', priority=1)
|
|
500
|
+
```
|
|
485
501
|
|
|
486
502
|
If you are instead hand-editing your instrument files, you can generate code
|
|
487
503
|
which defines Union materials from an NCrystal cfg-string by invoking:
|
|
488
504
|
|
|
505
|
+
```
|
|
489
506
|
$> python3 -mNCrystal.mcstasutils --union myAl 'Al_sg225.ncmat;temp=250K'
|
|
507
|
+
```
|
|
490
508
|
|
|
491
509
|
It should be noted that McStas 3.3 also provides a new SHELL syntax which can
|
|
492
510
|
also be used to faciliate this invocation from with a classic .instr file.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/ncrystal_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{ncrystal_python-4.0.0 → ncrystal_python-4.0.2}/src/ncrystal_python.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|