ncrystal-python 3.9.81__py3-none-any.whl
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/__init__.py +85 -0
- NCrystal/__main__.py +98 -0
- NCrystal/_chooks.py +854 -0
- NCrystal/_cli_cif2ncmat.py +269 -0
- NCrystal/_cli_endf2ncmat.py +503 -0
- NCrystal/_cli_hfg2ncmat.py +144 -0
- NCrystal/_cli_mcstasunion.py +74 -0
- NCrystal/_cli_ncmat2cpp.py +31 -0
- NCrystal/_cli_ncmat2hkl.py +180 -0
- NCrystal/_cli_nctool.py +1018 -0
- NCrystal/_cli_vdos2ncmat.py +463 -0
- NCrystal/_cli_verifyatompos.py +257 -0
- NCrystal/_cliimpl.py +307 -0
- NCrystal/_cliwrap_config.py +36 -0
- NCrystal/_common.py +499 -0
- NCrystal/_coreimpl.py +114 -0
- NCrystal/_hfgdata.py +546 -0
- NCrystal/_hklobjects.py +136 -0
- NCrystal/_is_std.py +0 -0
- NCrystal/_locatelib.py +210 -0
- NCrystal/_miscimpl.py +354 -0
- NCrystal/_mmc.py +757 -0
- NCrystal/_msg.py +60 -0
- NCrystal/_ncmat2cpp_impl.py +445 -0
- NCrystal/_ncmatimpl.py +2131 -0
- NCrystal/_numpy.py +76 -0
- NCrystal/_testimpl.py +579 -0
- NCrystal/api.py +56 -0
- NCrystal/atomdata.py +177 -0
- NCrystal/cfgstr.py +77 -0
- NCrystal/cifutils.py +1795 -0
- NCrystal/cli.py +96 -0
- NCrystal/constants.py +134 -0
- NCrystal/core.py +1910 -0
- NCrystal/datasrc.py +226 -0
- NCrystal/exceptions.py +66 -0
- NCrystal/hfg2ncmat.py +270 -0
- NCrystal/mcstasutils.py +438 -0
- NCrystal/misc.py +317 -0
- NCrystal/mmc.py +35 -0
- NCrystal/ncmat.py +778 -0
- NCrystal/ncmat2cpp.py +80 -0
- NCrystal/obsolete.py +67 -0
- NCrystal/plot.py +484 -0
- NCrystal/plugins.py +49 -0
- NCrystal/test.py +76 -0
- NCrystal/vdos.py +1034 -0
- ncrystal_python-3.9.81.dist-info/LICENSE +206 -0
- ncrystal_python-3.9.81.dist-info/METADATA +515 -0
- ncrystal_python-3.9.81.dist-info/RECORD +53 -0
- ncrystal_python-3.9.81.dist-info/WHEEL +5 -0
- ncrystal_python-3.9.81.dist-info/entry_points.txt +10 -0
- ncrystal_python-3.9.81.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: ncrystal-python
|
|
3
|
+
Version: 3.9.81
|
|
4
|
+
Summary: Library for thermal neutron transport in crystals and other materials.
|
|
5
|
+
Author: NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)
|
|
6
|
+
License: The Apache 2.0 license is reproduced in the following. See the NOTICE file for
|
|
7
|
+
important details of how it applies to the distributed NCrystal code.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Apache License
|
|
12
|
+
Version 2.0, January 2004
|
|
13
|
+
http://www.apache.org/licenses/
|
|
14
|
+
|
|
15
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
16
|
+
|
|
17
|
+
1. Definitions.
|
|
18
|
+
|
|
19
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
20
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
21
|
+
|
|
22
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
23
|
+
the copyright owner that is granting the License.
|
|
24
|
+
|
|
25
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
26
|
+
other entities that control, are controlled by, or are under common
|
|
27
|
+
control with that entity. For the purposes of this definition,
|
|
28
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
29
|
+
direction or management of such entity, whether by contract or
|
|
30
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
31
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
32
|
+
|
|
33
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
34
|
+
exercising permissions granted by this License.
|
|
35
|
+
|
|
36
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
37
|
+
including but not limited to software source code, documentation
|
|
38
|
+
source, and configuration files.
|
|
39
|
+
|
|
40
|
+
"Object" form shall mean any form resulting from mechanical
|
|
41
|
+
transformation or translation of a Source form, including but
|
|
42
|
+
not limited to compiled object code, generated documentation,
|
|
43
|
+
and conversions to other media types.
|
|
44
|
+
|
|
45
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
46
|
+
Object form, made available under the License, as indicated by a
|
|
47
|
+
copyright notice that is included in or attached to the work
|
|
48
|
+
(an example is provided in the Appendix below).
|
|
49
|
+
|
|
50
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
51
|
+
form, that is based on (or derived from) the Work and for which the
|
|
52
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
53
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
54
|
+
of this License, Derivative Works shall not include works that remain
|
|
55
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
56
|
+
the Work and Derivative Works thereof.
|
|
57
|
+
|
|
58
|
+
"Contribution" shall mean any work of authorship, including
|
|
59
|
+
the original version of the Work and any modifications or additions
|
|
60
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
61
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
62
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
63
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
64
|
+
means any form of electronic, verbal, or written communication sent
|
|
65
|
+
to the Licensor or its representatives, including but not limited to
|
|
66
|
+
communication on electronic mailing lists, source code control systems,
|
|
67
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
68
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
69
|
+
excluding communication that is conspicuously marked or otherwise
|
|
70
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
71
|
+
|
|
72
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
73
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
74
|
+
subsequently incorporated within the Work.
|
|
75
|
+
|
|
76
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
77
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
78
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
79
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
80
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
81
|
+
Work and such Derivative Works in Source or Object form.
|
|
82
|
+
|
|
83
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
84
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
85
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
86
|
+
(except as stated in this section) patent license to make, have made,
|
|
87
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
88
|
+
where such license applies only to those patent claims licensable
|
|
89
|
+
by such Contributor that are necessarily infringed by their
|
|
90
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
91
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
92
|
+
institute patent litigation against any entity (including a
|
|
93
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
94
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
95
|
+
or contributory patent infringement, then any patent licenses
|
|
96
|
+
granted to You under this License for that Work shall terminate
|
|
97
|
+
as of the date such litigation is filed.
|
|
98
|
+
|
|
99
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
100
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
101
|
+
modifications, and in Source or Object form, provided that You
|
|
102
|
+
meet the following conditions:
|
|
103
|
+
|
|
104
|
+
(a) You must give any other recipients of the Work or
|
|
105
|
+
Derivative Works a copy of this License; and
|
|
106
|
+
|
|
107
|
+
(b) You must cause any modified files to carry prominent notices
|
|
108
|
+
stating that You changed the files; and
|
|
109
|
+
|
|
110
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
111
|
+
that You distribute, all copyright, patent, trademark, and
|
|
112
|
+
attribution notices from the Source form of the Work,
|
|
113
|
+
excluding those notices that do not pertain to any part of
|
|
114
|
+
the Derivative Works; and
|
|
115
|
+
|
|
116
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
117
|
+
distribution, then any Derivative Works that You distribute must
|
|
118
|
+
include a readable copy of the attribution notices contained
|
|
119
|
+
within such NOTICE file, excluding those notices that do not
|
|
120
|
+
pertain to any part of the Derivative Works, in at least one
|
|
121
|
+
of the following places: within a NOTICE text file distributed
|
|
122
|
+
as part of the Derivative Works; within the Source form or
|
|
123
|
+
documentation, if provided along with the Derivative Works; or,
|
|
124
|
+
within a display generated by the Derivative Works, if and
|
|
125
|
+
wherever such third-party notices normally appear. The contents
|
|
126
|
+
of the NOTICE file are for informational purposes only and
|
|
127
|
+
do not modify the License. You may add Your own attribution
|
|
128
|
+
notices within Derivative Works that You distribute, alongside
|
|
129
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
130
|
+
that such additional attribution notices cannot be construed
|
|
131
|
+
as modifying the License.
|
|
132
|
+
|
|
133
|
+
You may add Your own copyright statement to Your modifications and
|
|
134
|
+
may provide additional or different license terms and conditions
|
|
135
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
136
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
137
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
138
|
+
the conditions stated in this License.
|
|
139
|
+
|
|
140
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
141
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
142
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
143
|
+
this License, without any additional terms or conditions.
|
|
144
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
145
|
+
the terms of any separate license agreement you may have executed
|
|
146
|
+
with Licensor regarding such Contributions.
|
|
147
|
+
|
|
148
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
149
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
150
|
+
except as required for reasonable and customary use in describing the
|
|
151
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
152
|
+
|
|
153
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
154
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
155
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
156
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
157
|
+
implied, including, without limitation, any warranties or conditions
|
|
158
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
159
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
160
|
+
appropriateness of using or redistributing the Work and assume any
|
|
161
|
+
risks associated with Your exercise of permissions under this License.
|
|
162
|
+
|
|
163
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
164
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
165
|
+
unless required by applicable law (such as deliberate and grossly
|
|
166
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
167
|
+
liable to You for damages, including any direct, indirect, special,
|
|
168
|
+
incidental, or consequential damages of any character arising as a
|
|
169
|
+
result of this License or out of the use or inability to use the
|
|
170
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
171
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
172
|
+
other commercial damages or losses), even if such Contributor
|
|
173
|
+
has been advised of the possibility of such damages.
|
|
174
|
+
|
|
175
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
176
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
177
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
178
|
+
or other liability obligations and/or rights consistent with this
|
|
179
|
+
License. However, in accepting such obligations, You may act only
|
|
180
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
181
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
182
|
+
defend, and hold each Contributor harmless for any liability
|
|
183
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
184
|
+
of your accepting any such warranty or additional liability.
|
|
185
|
+
|
|
186
|
+
END OF TERMS AND CONDITIONS
|
|
187
|
+
|
|
188
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
189
|
+
|
|
190
|
+
To apply the Apache License to your work, attach the following
|
|
191
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
192
|
+
replaced with your own identifying information. (Don't include
|
|
193
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
194
|
+
comment syntax for the file format. We also recommend that a
|
|
195
|
+
file or class name and description of purpose be included on the
|
|
196
|
+
same "printed page" as the copyright notice for easier
|
|
197
|
+
identification within third-party archives.
|
|
198
|
+
|
|
199
|
+
Copyright [yyyy] [name of copyright owner]
|
|
200
|
+
|
|
201
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
202
|
+
you may not use this file except in compliance with the License.
|
|
203
|
+
You may obtain a copy of the License at
|
|
204
|
+
|
|
205
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
206
|
+
|
|
207
|
+
Unless required by applicable law or agreed to in writing, software
|
|
208
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
209
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
210
|
+
See the License for the specific language governing permissions and
|
|
211
|
+
limitations under the License.
|
|
212
|
+
|
|
213
|
+
Project-URL: Homepage, https://mctools.github.io/ncrystal/
|
|
214
|
+
Project-URL: Bug Tracker, https://github.com/mctools/ncrystal/issues
|
|
215
|
+
Classifier: Programming Language :: Python :: 3
|
|
216
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
217
|
+
Classifier: Operating System :: Unix
|
|
218
|
+
Requires-Python: >=3.8
|
|
219
|
+
Description-Content-Type: text/markdown
|
|
220
|
+
License-File: LICENSE
|
|
221
|
+
Requires-Dist: numpy
|
|
222
|
+
|
|
223
|
+
NCrystal : A library for thermal neutron transport in crystals and other materials
|
|
224
|
+
----------------------------------------------------------------------------------
|
|
225
|
+
|
|
226
|
+
This is a source distribution of NCrystal, a library and associated tools which
|
|
227
|
+
enables calculations for Monte Carlo simulations of thermal neutrons in crystals
|
|
228
|
+
and other materials. Supported is a range of physics including both coherent,
|
|
229
|
+
incoherent, elastic and inelastic scatterings in a wide range of materials,
|
|
230
|
+
including crystal powders, mosaic single crystals, layered single crystals,
|
|
231
|
+
amorphous solids, and liquids. Multiphase materials or isotopically enriched
|
|
232
|
+
material are supported as well, and the framework furthermore supports
|
|
233
|
+
phase-contrast (SANS) physics. Written in C++, interfaces and infrastructure
|
|
234
|
+
facilitate integration into existing simulation frameworks such as OpenMC
|
|
235
|
+
(https://docs.openmc.org/), Geant4 (https://geant4.web.cern.ch/) or McStas
|
|
236
|
+
(http://mcstas.org/), as well as allowing direct usage from C++, C or Python
|
|
237
|
+
code or via command-line tools. While the C++ library is designed with a high
|
|
238
|
+
degree of flexibility in mind for developers, typical end-user configuration is
|
|
239
|
+
deliberately kept simple and uniform across various applications and APIs - this
|
|
240
|
+
for instance allows tuning and validation of a particular crystal setup to be
|
|
241
|
+
performed in one tool before it is then deployed in another.
|
|
242
|
+
|
|
243
|
+
In addition to code and tools, the NCrystal distribution also includes a set of
|
|
244
|
+
validated data files, covering many crystals important at neutron scattering
|
|
245
|
+
facilities. For more information about the properties and validity of each file,
|
|
246
|
+
users are referred to the dedicated page at:
|
|
247
|
+
|
|
248
|
+
https://github.com/mctools/ncrystal/wiki/Data-library
|
|
249
|
+
|
|
250
|
+
Supporting compilation with all modern C++ standards (C++11 and later), the code
|
|
251
|
+
has no third-party dependencies and is available under the highly liberal open
|
|
252
|
+
source Apache 2.0 license (see NOTICE and LICENSE files for usage conditions and
|
|
253
|
+
the INSTALL file for build and installation instructions). NCrystal was
|
|
254
|
+
developed in close collaboration by Xiao Xiao Cai (DTU, ESS) and Thomas
|
|
255
|
+
Kittelmann (ESS) and was supported in part by the European Union's Horizon 2020
|
|
256
|
+
research and innovation programme under grant agreement No 676548 (the
|
|
257
|
+
BrightnESS project) and 951782 (the HighNESS project).
|
|
258
|
+
|
|
259
|
+
A very substantial effort went into developing NCrystal. If you use it for your
|
|
260
|
+
work, we would appreciate it if you would use the following primary reference in
|
|
261
|
+
your work:
|
|
262
|
+
|
|
263
|
+
X.-X. Cai and T. Kittelmann, NCrystal: A library for thermal neutron
|
|
264
|
+
transport, Computer Physics Communications 246 (2020) 106851,
|
|
265
|
+
https://doi.org/10.1016/j.cpc.2019.07.015
|
|
266
|
+
|
|
267
|
+
For work benefitting from elastic physics (e.g. Bragg diffraction), we
|
|
268
|
+
furthermore request that you additionally also use the following reference in
|
|
269
|
+
your work:
|
|
270
|
+
|
|
271
|
+
T. Kittelmann and X.-X. Cai, Elastic neutron scattering models
|
|
272
|
+
for NCrystal, Computer Physics Communications 267 (2021) 108082,
|
|
273
|
+
https://doi.org/10.1016/j.cpc.2021.108082
|
|
274
|
+
|
|
275
|
+
For work benefitting from our inelastic physics, we furthermore request that you
|
|
276
|
+
additionally also use the following reference in your work:
|
|
277
|
+
|
|
278
|
+
X.-X. Cai, T. Kittelmann, et. al., "Rejection-based sampling of inelastic
|
|
279
|
+
neutron scattering", Journal of Computational Physics 380 (2019) 400-407,
|
|
280
|
+
https://doi.org/10.1016/j.jcp.2018.11.043
|
|
281
|
+
|
|
282
|
+
The rest of this file gives a brief overview of the manners in which NCrystal
|
|
283
|
+
capabilities can be utilised. Further instructions and documentation, along with
|
|
284
|
+
the latest version of NCrystal, can be found at https://mctools.github.io/ncrystal/
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
Using the NCrystal installation from the command-line
|
|
289
|
+
-----------------------------------------------------
|
|
290
|
+
|
|
291
|
+
After installing NCrystal and having sourced the setup.sh script mentioned in
|
|
292
|
+
the INSTALL file, you can run any of the commands from the $NCRYSTALDIR/bin
|
|
293
|
+
directory, which includes example code as well as the "nctool" command. Start by
|
|
294
|
+
reading the usage instructions:
|
|
295
|
+
|
|
296
|
+
$> nctool --help
|
|
297
|
+
|
|
298
|
+
Assuming you chose to install data files, you can try to let NCrystal load one
|
|
299
|
+
of the data files found in $NCRYSTALDIR/data/ (or provide the absolute path to a
|
|
300
|
+
data file downloaded from https://github.com/mctools/ncrystal/wiki/Data-library)
|
|
301
|
+
and either dump the derived information to the terminal...:
|
|
302
|
+
|
|
303
|
+
$> nctool --dump 'Al_sg225.ncmat;temp=10C'
|
|
304
|
+
|
|
305
|
+
Note that this included a choice of temperature. If you leave it out, it will
|
|
306
|
+
usually default to room temperature (20C). You can also plot (powder)
|
|
307
|
+
cross-sections and sampled scatter angles with:
|
|
308
|
+
|
|
309
|
+
$> nctool 'Al_sg225.ncmat;temp=10C'
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
Using the NCrystal installation from C++ (including Geant4), C or Python code
|
|
314
|
+
-----------------------------------------------------------------------------
|
|
315
|
+
|
|
316
|
+
If you wish to use NCrystal from Python code, there is no special setup
|
|
317
|
+
needed. If you on the other hand wish to use NCrystal from your compiled C++ or
|
|
318
|
+
C code, you must put appropriate build flags. The recommended way is using CMake
|
|
319
|
+
to do this (see next section), but otherwise you must ensure that the NCrystal
|
|
320
|
+
header files are in your compiler's include path, and that the NCrystal library
|
|
321
|
+
is linked correctly. Here are some examples of how this could for instance be
|
|
322
|
+
done, with a C and a C++ app respectively:
|
|
323
|
+
|
|
324
|
+
export LDFLAGS="${LDFLAGS:-} -Wl,-rpath,$(ncrystal-config --show libdir) $(ncrystal-config --show libpath)"
|
|
325
|
+
export CFLAGS="${CFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
326
|
+
export CXXFLAGS="${CXXFLAGS:-} -I$(ncrystal-config --show includedir)"
|
|
327
|
+
cc -std=c11 ${LDFLAGS} ${CFLAGS} my_c_code.c -o my_c_app
|
|
328
|
+
c++ -std=c++17 ${LDFLAGS} ${CXXFLAGS} my_cpp_code.cpp -o my_cpp_app
|
|
329
|
+
|
|
330
|
+
If using the NCrystal-Geant4 interfaces, you should also add "-lG4NCrystal" to
|
|
331
|
+
the link flags.
|
|
332
|
+
|
|
333
|
+
Then, in your code you can access the relevant APIs with with statements like:
|
|
334
|
+
|
|
335
|
+
#include "NCrystal/NCrystal.hh" // C++ code, core NCrystal
|
|
336
|
+
#include "G4NCrystal/G4NCrystal.hh" // C++ code, for Geant4 users
|
|
337
|
+
#include "NCrystal/ncrystal.h" // C code
|
|
338
|
+
import NCrystal ## Python code
|
|
339
|
+
|
|
340
|
+
In the ./examples/ directory of your NCrystal distribution that you got after
|
|
341
|
+
downloading and unpacking the NCrystal source tar-ball, you will find small
|
|
342
|
+
examples of code using NCrystal. For C++/C and Geant4, there is currently no
|
|
343
|
+
documentation beyond the header files and examples. In the case of Python, there
|
|
344
|
+
is integrated documentation available via the usual "help" function, accessed
|
|
345
|
+
with:
|
|
346
|
+
|
|
347
|
+
import NCrystal
|
|
348
|
+
help(NCrystal)
|
|
349
|
+
|
|
350
|
+
There are also several jupyter-lab notebooks showcasing the NCrystal python API
|
|
351
|
+
at https://github.com/mctools/ncrystal-notebooks
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
Configuring CMake-based projects to use NCrystal
|
|
356
|
+
------------------------------------------------
|
|
357
|
+
|
|
358
|
+
Assuming NCrystal was built and installed via CMake, it is possible and
|
|
359
|
+
recommended for client projects to simply use NCrystal as a CMake package in
|
|
360
|
+
order to correctly build their C/C++ code which depends on the NCrystal C++ or C
|
|
361
|
+
APIs.
|
|
362
|
+
|
|
363
|
+
Depending on where NCrystal was installed on the system, it might be necessary
|
|
364
|
+
to let CMake know about it via the usual mechanisms (for instance passing
|
|
365
|
+
-DNCrystal_DIR=/path/to/ncrystalinstall as an argument to cmake on the command
|
|
366
|
+
line).
|
|
367
|
+
|
|
368
|
+
CMake code for a small project using NCrystal might look like the following
|
|
369
|
+
(assume that exampleapp.cc below includes the NCrystal/NCrystal.hh header):
|
|
370
|
+
|
|
371
|
+
cmake_minimum_required(VERSION 3.10...3.26)
|
|
372
|
+
project(MyExampleProject LANGUAGES CXX)
|
|
373
|
+
execute_process( COMMAND ncrystal-config --show cmakedir
|
|
374
|
+
OUTPUT_VARIABLE NCrystal_DIR
|
|
375
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
|
376
|
+
find_package(NCrystal REQUIRED)
|
|
377
|
+
add_executable(exampleapp "${PROJECT_SOURCE_DIR}/exampleapp.cc")
|
|
378
|
+
target_link_libraries( exampleapp NCrystal::NCrystal )
|
|
379
|
+
install( TARGETS exampleapp DESTINATION bin )
|
|
380
|
+
|
|
381
|
+
Note that the "execute_process( ... )" command above is optional, but is
|
|
382
|
+
required before the code can work in an environment where the NCrystal CMake
|
|
383
|
+
modules are not automatically injected into the CMake package search path (this
|
|
384
|
+
notably includes NCrystal installed via "pip install ncrystal").
|
|
385
|
+
|
|
386
|
+
If the NCrystal-Geant4 bindings are needed, they must be explicitly requested,
|
|
387
|
+
and the NCrystal::G4NCrystal target added as a dependency for downstream code:
|
|
388
|
+
|
|
389
|
+
find_package(NCrystal REQUIRED COMPONENTS GEANT4BINDINGS )
|
|
390
|
+
target_link_libraries( exampleapp NCrystal::G4NCrystal )
|
|
391
|
+
|
|
392
|
+
This will of course fail if NCrystal was not build with Geant4 support
|
|
393
|
+
(i.e. configured with -DNCRYSTAL_ENABLE_GEANT4=ON). Note: currently (August
|
|
394
|
+
2024), NCrystal conda and pip packages are built *without* Geant4 support.
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
Using the NCrystal installation from OpenMC
|
|
399
|
+
-----------------------------------------------------------------------------
|
|
400
|
+
|
|
401
|
+
Using NCrystal materials in openmc is supported since OpenMC release 13.3, and
|
|
402
|
+
uses a nice simple syntax in the Python API:
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
mat = openmc.Material.from_ncrystal('Polyethylene_CH2.ncmat;temp=50C')
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
which when used in a complete OpenMC project, results in the following material
|
|
409
|
+
entry being added to the `materials.xml` produced:
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
<material cfg="Polyethylene_CH2.ncmat;temp=50C" id="1" temperature="323.15">
|
|
413
|
+
<density units="g/cm3" value="0.92" />
|
|
414
|
+
<nuclide ao="0.66656284" name="H1" />
|
|
415
|
+
<nuclide ao="0.00010382666666666666" name="H2" />
|
|
416
|
+
<nuclide ao="0.32964066666666664" name="C12" />
|
|
417
|
+
<nuclide ao="0.003692666666666666" name="C13" />
|
|
418
|
+
</material>
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Temperature, density and material composition were all created automatically
|
|
422
|
+
from the cfg-string, and the cfg-string itself was also encoded. Upon launching
|
|
423
|
+
the simulation with the OpenMC binary executable `openmc`, it will handle the
|
|
424
|
+
material as usual, except that low-energy neutron scattering physics (currently
|
|
425
|
+
defined as ($E<5eV$) will be provided by the algorithms in NCrystal.
|
|
426
|
+
|
|
427
|
+
A few issues might warrent attention:
|
|
428
|
+
|
|
429
|
+
1. If you try to assemble the above xml manually, it is rather unlikely that you
|
|
430
|
+
will get the base densities and compositions right. It is safest to stick to
|
|
431
|
+
let the Python API compose the xml for you.
|
|
432
|
+
2. After creation with `mat=openmc.Material.from_ncrystal(..)`, you can not use
|
|
433
|
+
the usual OpenMC API to modify the material density, temperature, or
|
|
434
|
+
composition. So be sure to reflect the final desired material inside the
|
|
435
|
+
NCrystal cfg-string.
|
|
436
|
+
3. The OpenMC binaries must have been built with NCrystal support, or your job
|
|
437
|
+
will fail once you launch the simulation (you can check for this by running
|
|
438
|
+
the command `openmc -v`). Specifically (as documented on
|
|
439
|
+
https://docs.openmc.org/en/stable/usersguide/install.html) you must supply
|
|
440
|
+
the CMake flag `cmake -DOPENMC_USE_NCRYSTAL=on ..` (and make sure NCrystal is
|
|
441
|
+
available already). Note: we have agreement from OpenMC developers to enable
|
|
442
|
+
NCrystal support by default in the conda-forge version of OpenMC. So in "the
|
|
443
|
+
near future" (summer/fall 2023) conda users will always have NCrystal support
|
|
444
|
+
available in OpenMC.
|
|
445
|
+
|
|
446
|
+
For more information, please consult the user guide at:
|
|
447
|
+
|
|
448
|
+
https://docs.openmc.org/
|
|
449
|
+
|
|
450
|
+
In particular note the sections concerning installation and usage of NCrystal in
|
|
451
|
+
the sections:
|
|
452
|
+
|
|
453
|
+
https://docs.openmc.org/en/stable/usersguide/install.html
|
|
454
|
+
https://docs.openmc.org/en/stable/usersguide/materials.html
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
Using the NCrystal installation from McStas
|
|
459
|
+
-----------------------------------------------------------------------------
|
|
460
|
+
|
|
461
|
+
NOTE: The following discussion concerns the modern McStas 3 branch, and might in
|
|
462
|
+
particular not be 100% accurate for releases earlier than McStas 3.3 (probably
|
|
463
|
+
OK for v3.2 though).
|
|
464
|
+
|
|
465
|
+
You can use NCrystal in two ways in McStas. You can either use it for advanced
|
|
466
|
+
studies with the McStas Union sub-system through the NCrystal_process component,
|
|
467
|
+
or it can be used via the dedicated NCrystal_sample.comp which is simpler but
|
|
468
|
+
less feature rich. In any case, the McStas instrument file compilation will need
|
|
469
|
+
to build against NCrystal, and it uses the ncrystal-config command to figure out
|
|
470
|
+
the correct settings for doing so. Thus, you can always invoke "ncrystal-config
|
|
471
|
+
-s" to find out if you have the right NCrystal installation available and
|
|
472
|
+
active. Depending on how you installed McStas, NCrystal is most likely already
|
|
473
|
+
available. If not, you can try one of the following ways of enabling it:
|
|
474
|
+
|
|
475
|
+
$> conda install -c conda-forge ncrystal [if you are in a conda-forge env]
|
|
476
|
+
$> python3 -mpip install ncrystal [for non-conda users]
|
|
477
|
+
$> . $MCSTAS/setup.sh [obsolete way]
|
|
478
|
+
|
|
479
|
+
It is beyond the scope for this README to provide a full documentation of
|
|
480
|
+
McStas, or the Union sub-system, but if you are using McStasScript to compose
|
|
481
|
+
your instruments, you can add NCrystal materials into your Union geometry using
|
|
482
|
+
code like:
|
|
483
|
+
|
|
484
|
+
from mcstasscript.tools.ncrystal_union import add_ncrystal_union_material
|
|
485
|
+
add_ncrystal_union_material(instr, name="myAl", cfgstr="Al_sg225.ncmat;temp=10C")
|
|
486
|
+
|
|
487
|
+
This creates the material and gives it the name "myAl", which you must later
|
|
488
|
+
attach to a particular Union volume, like for instance:
|
|
489
|
+
|
|
490
|
+
myvol.set_parameters(radius=0.01, yheight=0.01,
|
|
491
|
+
material_string='"myAl"', priority=1)
|
|
492
|
+
|
|
493
|
+
If you are instead hand-editing your instrument files, you can generate code
|
|
494
|
+
which defines Union materials from an NCrystal cfg-string by invoking:
|
|
495
|
+
|
|
496
|
+
$> python3 -mNCrystal.mcstasutils --union myAl 'Al_sg225.ncmat;temp=250K'
|
|
497
|
+
|
|
498
|
+
It should be noted that McStas 3.3 also provides a new SHELL syntax which can
|
|
499
|
+
also be used to faciliate this invocation from with a classic .instr file.
|
|
500
|
+
|
|
501
|
+
On the other hand, the dedicated NCrystal_sample.comp component, embeds NCrystal
|
|
502
|
+
material simulations into simple shapes (currently boxes, cylinders and
|
|
503
|
+
spheres), and can be used for components representing samples, filters or
|
|
504
|
+
monochromators, entrance windows, etc. The component is since McStas v3.3 part
|
|
505
|
+
of the McStas release itself, and can be used in a .instr file - for instance if
|
|
506
|
+
you wish to set up an r=1cm sphere with powdered sapphire you would write:
|
|
507
|
+
|
|
508
|
+
COMPONENT mysample = NCrystal_sample(cfg="Al2O3_sg167_Corundum.ncmat",radius=0.01)
|
|
509
|
+
AT (0, 0, 0) RELATIVE PREVIOUS
|
|
510
|
+
|
|
511
|
+
For more documentation about the NCrystal_sample component, run:
|
|
512
|
+
|
|
513
|
+
$> mcdoc NCrystal_sample
|
|
514
|
+
|
|
515
|
+
Or consult the documentation online at https://www.mcstas.org/download/components/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
NCrystal/__init__.py,sha256=iW-1Op3B23PPZh9E6V18ZYz8dS8Q3fFTBGuOfhpxJlk,4158
|
|
2
|
+
NCrystal/__main__.py,sha256=VktGc2i4pb5AYRnntQ3PVPp48H5q1zKS9ARq2IjJn-s,3624
|
|
3
|
+
NCrystal/_chooks.py,sha256=VnE8qlBbcdKZmDs7K4P7VzjDcRJyqvcnsdXYfwfy_uE,43273
|
|
4
|
+
NCrystal/_cli_cif2ncmat.py,sha256=6b_M8JHioMI3Mddmye1-FOUSFKemip15t8Lg_bGSs8g,14626
|
|
5
|
+
NCrystal/_cli_endf2ncmat.py,sha256=QnDPObYHLQQydyUATLPnTR5FrIw31o0iw3HALJg3GKA,23391
|
|
6
|
+
NCrystal/_cli_hfg2ncmat.py,sha256=LA9jvog6aL73i4Ff_UIzhlr_HX_-xzzT8Jp0GOSO3-g,7280
|
|
7
|
+
NCrystal/_cli_mcstasunion.py,sha256=gcT2eTt6CcEfkAMd6Pk1SbU5Ot80aj4u0ICA7P-Z6is,3960
|
|
8
|
+
NCrystal/_cli_ncmat2cpp.py,sha256=8a9VylKxurEVPXyuz8dcYY0hOtisMZTeb77S9j5503Y,1856
|
|
9
|
+
NCrystal/_cli_ncmat2hkl.py,sha256=U6N0hcbj66QIWaTkVNQ4qRu1cN4t7ugEwT8WZwAUkHQ,7593
|
|
10
|
+
NCrystal/_cli_nctool.py,sha256=Ul6CZ1xXKY5g5-H7IZ2xmsB4MmX-NoKpSSTONr8JDt4,41488
|
|
11
|
+
NCrystal/_cli_vdos2ncmat.py,sha256=al-5X0FkVXJpgsNL5Fz3QRnIjvE5V_4R66zqEnfqPXI,20308
|
|
12
|
+
NCrystal/_cli_verifyatompos.py,sha256=39jVoVPxMOLDnoCIqakoLvsmkNu_Hj3xTHlnI6oLW5k,12348
|
|
13
|
+
NCrystal/_cliimpl.py,sha256=9XqSmrWjNkWI6cTu4j5gC6qfG1tTms_U-CUwp15kjLg,13354
|
|
14
|
+
NCrystal/_cliwrap_config.py,sha256=Pq0rdjd_8g-d41Xobcc9iwhLG2BNYg0auaZuxbiklJM,2002
|
|
15
|
+
NCrystal/_common.py,sha256=a155CzrTqszG96QKODuftTjo7WhrNTx_MxCisW-xF9o,18255
|
|
16
|
+
NCrystal/_coreimpl.py,sha256=iP5xRnZ1soUjxfVFFI8kRxbRMYrhmUr-j0RxDT3_s38,5727
|
|
17
|
+
NCrystal/_hfgdata.py,sha256=V3TEiVrFG_Bs0wMMCiXV-dZk7eoafK113lcXv9LB4JI,62828
|
|
18
|
+
NCrystal/_hklobjects.py,sha256=7ciyhmeGxQ0L0vr4EbG5yNfrFAPX9e2ATMVgE8mTPpo,4974
|
|
19
|
+
NCrystal/_is_std.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
+
NCrystal/_locatelib.py,sha256=_84Zshdt6H3cG2r2ox2I7FZywCDwX2lfhpZWB1WYiiU,9436
|
|
21
|
+
NCrystal/_miscimpl.py,sha256=4F-zSVpHz96k1FDycn3yv-u6Klz1NhtpO3fRqjpbHCk,16549
|
|
22
|
+
NCrystal/_mmc.py,sha256=8hme-V99GVVRz9nhKuDJYfDVIlBD5ypgnKPmbPD7TwE,29349
|
|
23
|
+
NCrystal/_msg.py,sha256=alf2wdgWkiQCyOltSIYZO-K4frWXlLL_CcXpbcmH2cw,2624
|
|
24
|
+
NCrystal/_ncmat2cpp_impl.py,sha256=y0vdtjaEz1RhqW2lvP3ZGQd3TGhUbQ7N66ftuf_7HZ0,18383
|
|
25
|
+
NCrystal/_ncmatimpl.py,sha256=F3INShPmK5q-afLaOMJWS3Ct9lzVkfDHqHfQCTh86N4,94301
|
|
26
|
+
NCrystal/_numpy.py,sha256=_eQz0pXJ9u65a6RAy4YLYRvo2tbWHgkE04Q52DauaZU,2924
|
|
27
|
+
NCrystal/_testimpl.py,sha256=Uy8ktgXlDjU01xmQvR06bZypIU9Drerrtwkv4Al7zeQ,27333
|
|
28
|
+
NCrystal/api.py,sha256=Yzc8vbThMdZJ2QoCXat_0fYGuKRTGokKp_OJrxkQVQU,2973
|
|
29
|
+
NCrystal/atomdata.py,sha256=pjStH5gmNFr-Tcrz68d29AXnffexHF_BVoCqwQYPr1s,8072
|
|
30
|
+
NCrystal/cfgstr.py,sha256=uaupapzw3jt5dxXd_nSPvVSfMBdgpp9NAbT08obUhgE,3741
|
|
31
|
+
NCrystal/cifutils.py,sha256=9HvzI4o1acKcqUk_8ej_vsUzNraw37OlQQNmGxVB6uA,78162
|
|
32
|
+
NCrystal/cli.py,sha256=4JL1KLtahgF0WbRLDSGqUq8n0G_Ya4RoAGmDBHOjPVk,4395
|
|
33
|
+
NCrystal/constants.py,sha256=jvJhqjgW7bQALhYrPSb_j02Xw12hr_8sBW7StFIgjUQ,5919
|
|
34
|
+
NCrystal/core.py,sha256=UihJfqnI0Z-X21p0Y0wiy6P0ZjXGsMll0iUlrcX2wmQ,83339
|
|
35
|
+
NCrystal/datasrc.py,sha256=gC6-RN0NQGX-9ObK1oJv5_IPeAGt6XB80FHCyaKveY0,9978
|
|
36
|
+
NCrystal/exceptions.py,sha256=o6M0ZO--68DJdl7_FndePm_9EFEaimeE1yfhOf9mRdI,2679
|
|
37
|
+
NCrystal/hfg2ncmat.py,sha256=bIcdAtl9tSx1iJQ5AM9mPS1phvWZqplVSPumT51Cu-A,10189
|
|
38
|
+
NCrystal/mcstasutils.py,sha256=q1XGTvQhnMl0ucr5kacBivgI3GHnxJW-QVLC4-e42MM,18540
|
|
39
|
+
NCrystal/misc.py,sha256=Ik4qSKjO8qoWhBEjQ-9T0bU7nz-GKhTDBaMU6Klc9i8,14083
|
|
40
|
+
NCrystal/mmc.py,sha256=jccBqRmKNgHH4-vZx0hG9s6huQpxmdLnt90MRxuuuOQ,1948
|
|
41
|
+
NCrystal/ncmat.py,sha256=cZumVWkQUj0a8jk8spG9QAj8ipTvJi1w5GOl1_bcEoE,42230
|
|
42
|
+
NCrystal/ncmat2cpp.py,sha256=rpJLd3n_vNwjr5wAwvdPMG9RPy3usaRSy4Mb5c3541o,4398
|
|
43
|
+
NCrystal/obsolete.py,sha256=40M2V67Fqh1yBqqhletJEGbR3l1dQ8jxv9NCSrN93Io,3451
|
|
44
|
+
NCrystal/plot.py,sha256=C9L7XBjp_cKSlXlH53nELcOhIYhy20AlV2UyV0aNegU,19959
|
|
45
|
+
NCrystal/plugins.py,sha256=QjoXJ9253ff0LaP9cw5Dk9zMm5qZNcdB1jV_rtwDdYU,2440
|
|
46
|
+
NCrystal/test.py,sha256=5UohpebPKeABHTkSWNmsqdAHLN2qQmTM81zqw2A4QLw,3310
|
|
47
|
+
NCrystal/vdos.py,sha256=9lHF0sTuQYkfdxe0hu7461pJfCkc2HUlVzNkwAdyQ0A,46763
|
|
48
|
+
ncrystal_python-3.9.81.dist-info/LICENSE,sha256=cSwpZfFyXSC1mBPZgO2TbtGwoH2tR1SomMa5tEUU9o0,11509
|
|
49
|
+
ncrystal_python-3.9.81.dist-info/METADATA,sha256=dnLJA6KFLoPzTVS8asRgvDXbt3K4KLyafMvYSsLphlI,27960
|
|
50
|
+
ncrystal_python-3.9.81.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
51
|
+
ncrystal_python-3.9.81.dist-info/entry_points.txt,sha256=JoeikOrVDenZuTEmdgeGAfHw_CsujEJPIGl3BP_tcKQ,469
|
|
52
|
+
ncrystal_python-3.9.81.dist-info/top_level.txt,sha256=VIJdIQMfLIbKpFXA8xm0fKY5okz8s5IHrZTYDSH18y0,9
|
|
53
|
+
ncrystal_python-3.9.81.dist-info/RECORD,,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
ncrystal_cif2ncmat = NCrystal._cli_cif2ncmat:main
|
|
3
|
+
ncrystal_endf2ncmat = NCrystal._cli_endf2ncmat:main
|
|
4
|
+
ncrystal_hfg2ncmat = NCrystal._cli_hfg2ncmat:main
|
|
5
|
+
ncrystal_mcstasunion = NCrystal._cli_mcstasunion:main
|
|
6
|
+
ncrystal_ncmat2cpp = NCrystal._cli_ncmat2cpp:main
|
|
7
|
+
ncrystal_ncmat2hkl = NCrystal._cli_ncmat2hkl:main
|
|
8
|
+
ncrystal_vdos2ncmat = NCrystal._cli_vdos2ncmat:main
|
|
9
|
+
ncrystal_verifyatompos = NCrystal._cli_verifyatompos:main
|
|
10
|
+
nctool = NCrystal._cli_nctool:main
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
NCrystal
|