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.
Files changed (53) hide show
  1. NCrystal/__init__.py +85 -0
  2. NCrystal/__main__.py +98 -0
  3. NCrystal/_chooks.py +854 -0
  4. NCrystal/_cli_cif2ncmat.py +269 -0
  5. NCrystal/_cli_endf2ncmat.py +503 -0
  6. NCrystal/_cli_hfg2ncmat.py +144 -0
  7. NCrystal/_cli_mcstasunion.py +74 -0
  8. NCrystal/_cli_ncmat2cpp.py +31 -0
  9. NCrystal/_cli_ncmat2hkl.py +180 -0
  10. NCrystal/_cli_nctool.py +1018 -0
  11. NCrystal/_cli_vdos2ncmat.py +463 -0
  12. NCrystal/_cli_verifyatompos.py +257 -0
  13. NCrystal/_cliimpl.py +307 -0
  14. NCrystal/_cliwrap_config.py +36 -0
  15. NCrystal/_common.py +499 -0
  16. NCrystal/_coreimpl.py +114 -0
  17. NCrystal/_hfgdata.py +546 -0
  18. NCrystal/_hklobjects.py +136 -0
  19. NCrystal/_is_std.py +0 -0
  20. NCrystal/_locatelib.py +210 -0
  21. NCrystal/_miscimpl.py +354 -0
  22. NCrystal/_mmc.py +757 -0
  23. NCrystal/_msg.py +60 -0
  24. NCrystal/_ncmat2cpp_impl.py +445 -0
  25. NCrystal/_ncmatimpl.py +2131 -0
  26. NCrystal/_numpy.py +76 -0
  27. NCrystal/_testimpl.py +579 -0
  28. NCrystal/api.py +56 -0
  29. NCrystal/atomdata.py +177 -0
  30. NCrystal/cfgstr.py +77 -0
  31. NCrystal/cifutils.py +1795 -0
  32. NCrystal/cli.py +96 -0
  33. NCrystal/constants.py +134 -0
  34. NCrystal/core.py +1910 -0
  35. NCrystal/datasrc.py +226 -0
  36. NCrystal/exceptions.py +66 -0
  37. NCrystal/hfg2ncmat.py +270 -0
  38. NCrystal/mcstasutils.py +438 -0
  39. NCrystal/misc.py +317 -0
  40. NCrystal/mmc.py +35 -0
  41. NCrystal/ncmat.py +778 -0
  42. NCrystal/ncmat2cpp.py +80 -0
  43. NCrystal/obsolete.py +67 -0
  44. NCrystal/plot.py +484 -0
  45. NCrystal/plugins.py +49 -0
  46. NCrystal/test.py +76 -0
  47. NCrystal/vdos.py +1034 -0
  48. ncrystal_python-3.9.81.dist-info/LICENSE +206 -0
  49. ncrystal_python-3.9.81.dist-info/METADATA +515 -0
  50. ncrystal_python-3.9.81.dist-info/RECORD +53 -0
  51. ncrystal_python-3.9.81.dist-info/WHEEL +5 -0
  52. ncrystal_python-3.9.81.dist-info/entry_points.txt +10 -0
  53. ncrystal_python-3.9.81.dist-info/top_level.txt +1 -0
NCrystal/__init__.py ADDED
@@ -0,0 +1,85 @@
1
+
2
+ ################################################################################
3
+ ## ##
4
+ ## This file is part of NCrystal (see https://mctools.github.io/ncrystal/) ##
5
+ ## ##
6
+ ## Copyright 2015-2024 NCrystal developers ##
7
+ ## ##
8
+ ## Licensed under the Apache License, Version 2.0 (the "License"); ##
9
+ ## you may not use this file except in compliance with the License. ##
10
+ ## You may obtain a copy of the License at ##
11
+ ## ##
12
+ ## http://www.apache.org/licenses/LICENSE-2.0 ##
13
+ ## ##
14
+ ## Unless required by applicable law or agreed to in writing, software ##
15
+ ## distributed under the License is distributed on an "AS IS" BASIS, ##
16
+ ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
17
+ ## See the License for the specific language governing permissions and ##
18
+ ## limitations under the License. ##
19
+ ## ##
20
+ ################################################################################
21
+
22
+ """
23
+
24
+ Python module for using the NCrystal library for thermal neutron transport in
25
+ crystals and other materials.
26
+
27
+ Please find more information about NCrystal at the website:
28
+
29
+ https://mctools.github.io/ncrystal/
30
+
31
+ In particular, a small example using the NCrystal python module can be found at:
32
+
33
+ https://github.com/mctools/ncrystal/blob/master/examples/ncrystal_example_py
34
+
35
+ A substantial effort went into developing NCrystal. If you use it for your work,
36
+ we would appreciate it if you would use the following reference in your work:
37
+
38
+ X.-X. Cai and T. Kittelmann, NCrystal: A library for thermal neutron
39
+ transport, Computer Physics Communications 246 (2020) 106851,
40
+ https://doi.org/10.1016/j.cpc.2019.07.015
41
+
42
+ For work benefitting from our inelastic physics, we furthermore request that you
43
+ additionally also use the following reference in your work:
44
+
45
+ X.-X. Cai, T. Kittelmann, et. al., "Rejection-based sampling of inelastic
46
+ neutron scattering", Journal of Computational Physics 380 (2019) 400-407,
47
+ https://doi.org/10.1016/j.jcp.2018.11.043
48
+
49
+ For detailed usage conditions and licensing of this open source project, see:
50
+
51
+ https://github.com/mctools/ncrystal/blob/master/NOTICE
52
+ https://github.com/mctools/ncrystal/blob/master/LICENSE
53
+
54
+ """
55
+
56
+ #NB: Synchronize meta-data below with fields in setup.py+template_setup.py.in meta data:
57
+ __license__ = "Apache 2.0, http://www.apache.org/licenses/LICENSE-2.0"
58
+ __version__ = '3.9.81'
59
+ __status__ = "Production"
60
+ __author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
61
+ __copyright__ = "Copyright 2015-2024 %s"%__author__
62
+ __maintainer__ = __author__
63
+ __email__ = "ncrystal-developers@cern.ch"
64
+
65
+ import sys as _sys
66
+ import os as _os
67
+
68
+ #Place f-string here to catch python <3.6 in a more obvious way than a syntax error below:
69
+ f'NCrystal does not work with Python2 (or Python3 < v3.8)' #noqa F541
70
+ _minpyversion=(3,8,0)
71
+
72
+ pyversion = _sys.version_info[0:3]
73
+ if pyversion < _minpyversion:
74
+ raise RuntimeError('Unsupported python version %i.%i.%i detected (needs %i.%i.%i or later).'%(pyversion+_minpyversion))
75
+
76
+ #NB: The following env var can NOT be namespaced. E.g. it will always be
77
+ #NCRYSTAL_SLIMPYINIT and never e.g. NCRYSTAL<namespacehere>_SLIMPYINIT:
78
+
79
+ if not _os.environ.get('NCRYSTAL_SLIMPYINIT'):
80
+ from .api import * # noqa F403
81
+
82
+ ###################################
83
+ #Same as NCRYSTAL_VERSION macro (same as the get_version_num() function from .core):
84
+ version_tuple = tuple( int(i) for i in __version__.split('.') )#introduced in release 3.6.0
85
+ version_num = sum(int(i)*j for i,j in zip(version_tuple,(1000000,1000,1)))#Introduced in release 0.9.1
NCrystal/__main__.py ADDED
@@ -0,0 +1,98 @@
1
+
2
+ ################################################################################
3
+ ## ##
4
+ ## This file is part of NCrystal (see https://mctools.github.io/ncrystal/) ##
5
+ ## ##
6
+ ## Copyright 2015-2024 NCrystal developers ##
7
+ ## ##
8
+ ## Licensed under the Apache License, Version 2.0 (the "License"); ##
9
+ ## you may not use this file except in compliance with the License. ##
10
+ ## You may obtain a copy of the License at ##
11
+ ## ##
12
+ ## http://www.apache.org/licenses/LICENSE-2.0 ##
13
+ ## ##
14
+ ## Unless required by applicable law or agreed to in writing, software ##
15
+ ## distributed under the License is distributed on an "AS IS" BASIS, ##
16
+ ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
17
+ ## See the License for the specific language governing permissions and ##
18
+ ## limitations under the License. ##
19
+ ## ##
20
+ ################################################################################
21
+
22
+ """
23
+
24
+ This __main__.py module is here to ensure that NCrystal commandline script
25
+ can be accessed even when not terminal scripts (entry points) are
26
+ installed. This is for instance done via:
27
+
28
+ $> python3 -mNCrystal nctool <args>
29
+ $> python3 -mNCrystal ncmat2cpp <args>
30
+ $> python3 -mNCrystal ncrystal_ncmat2cpp <args>
31
+
32
+ Note that the two last commands above run the same command line script.
33
+
34
+ """
35
+
36
+ def _print_usage():
37
+ from ._common import print
38
+ from .cli import cli_tool_list
39
+ import textwrap
40
+ usagestr = textwrap.dedent("""
41
+ Usage: provide name and arguments of NCrystal commandline-tool to run.
42
+
43
+ Available tools:
44
+
45
+ <<TOOLLIST>>
46
+ Specifying -h or --help displays this message.""").lstrip()
47
+ toolliststr = ''.join( f' {t}\n' for t
48
+ in cli_tool_list( canonical_names = False ))
49
+ print(usagestr.replace('<<TOOLLIST>>',toolliststr))
50
+
51
+ def _prepare():
52
+ import sys
53
+ from ._cliimpl import _resolve_cmd_and_import_climod as _resolve
54
+
55
+ args = sys.argv[1:]
56
+
57
+ initial_optargs = []
58
+ for a in args:
59
+ if a.startswith('-'):
60
+ initial_optargs.append(a)
61
+ else:
62
+ break
63
+ args = args[len(initial_optargs):]
64
+
65
+ is_help_req = False
66
+ opt_unblock = False
67
+ bad_usage = False
68
+ for a in initial_optargs:
69
+ if a in ('-h','--help','/?'):
70
+ is_help_req = True
71
+ elif a == '--unblock':
72
+ opt_unblock = True
73
+ else:
74
+ bad_usage = True
75
+
76
+ if is_help_req or bad_usage or not args:
77
+ _print_usage()
78
+ raise SystemExit(0 if is_help_req else 1)
79
+
80
+ return _resolve( args[0], args[1:] ), opt_unblock
81
+
82
+ def main():
83
+ try:
84
+ (climod, argv), opt_unblock = _prepare()
85
+ except RuntimeError as e:
86
+ from ._common import print
87
+ _print_usage()
88
+ print()
89
+ raise SystemExit(f'ERROR: {e}')
90
+ if opt_unblock:
91
+ #Run like in pyapi (in particular letting all exceptions escape):
92
+ from .cli import run
93
+ run( *argv )
94
+ else:
95
+ climod.main( argv )
96
+
97
+ if __name__ == '__main__':
98
+ main()