ncrystal-python 4.1.5__tar.gz → 4.1.8__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.
Files changed (59) hide show
  1. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/PKG-INFO +3 -2
  2. ncrystal_python-4.1.8/pyproject.toml +58 -0
  3. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/__init__.py +1 -1
  4. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_chooks.py +22 -8
  5. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_miscimpl.py +23 -2
  6. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/vdos.py +27 -3
  7. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/ncrystal_python.egg-info/PKG-INFO +3 -2
  8. ncrystal_python-4.1.5/pyproject.toml +0 -37
  9. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/LICENSE +0 -0
  10. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/README.md +0 -0
  11. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/setup.cfg +0 -0
  12. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/__main__.py +0 -0
  13. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_cif2ncmat.py +0 -0
  14. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_endf2ncmat.py +0 -0
  15. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_hfg2ncmat.py +0 -0
  16. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_mcstasunion.py +0 -0
  17. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_ncmat2cpp.py +0 -0
  18. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_ncmat2hkl.py +0 -0
  19. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_nctool.py +0 -0
  20. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_vdos2ncmat.py +0 -0
  21. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cli_verifyatompos.py +0 -0
  22. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cliimpl.py +0 -0
  23. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_cliwrap_config.py +0 -0
  24. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_common.py +0 -0
  25. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_coreimpl.py +0 -0
  26. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_hfgdata.py +0 -0
  27. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_hklobjects.py +0 -0
  28. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_is_std.py +0 -0
  29. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_locatelib.py +0 -0
  30. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_mmc.py +0 -0
  31. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_msg.py +0 -0
  32. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_ncmat2cpp_impl.py +0 -0
  33. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_ncmatimpl.py +0 -0
  34. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_numpy.py +0 -0
  35. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/_testimpl.py +0 -0
  36. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/api.py +0 -0
  37. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/atomdata.py +0 -0
  38. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/cfgstr.py +0 -0
  39. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/cifutils.py +0 -0
  40. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/cli.py +0 -0
  41. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/constants.py +0 -0
  42. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/core.py +0 -0
  43. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/datasrc.py +0 -0
  44. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/exceptions.py +0 -0
  45. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/hfg2ncmat.py +0 -0
  46. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/mcstasutils.py +0 -0
  47. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/misc.py +0 -0
  48. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/mmc.py +0 -0
  49. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/ncmat.py +0 -0
  50. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/ncmat2cpp.py +0 -0
  51. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/obsolete.py +0 -0
  52. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/plot.py +0 -0
  53. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/plugins.py +0 -0
  54. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/NCrystal/test.py +0 -0
  55. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/ncrystal_python.egg-info/SOURCES.txt +0 -0
  56. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/ncrystal_python.egg-info/dependency_links.txt +0 -0
  57. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/ncrystal_python.egg-info/entry_points.txt +0 -0
  58. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/ncrystal_python.egg-info/requires.txt +0 -0
  59. {ncrystal_python-4.1.5 → ncrystal_python-4.1.8}/src/ncrystal_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: ncrystal-python
3
- Version: 4.1.5
3
+ Version: 4.1.8
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:
@@ -214,6 +214,7 @@ Requires-Python: >=3.8
214
214
  Description-Content-Type: text/markdown
215
215
  License-File: LICENSE
216
216
  Requires-Dist: numpy>=1.22
217
+ Dynamic: license-file
217
218
 
218
219
  NCrystal : A library for thermal neutron transport in crystals and other materials
219
220
  ----------------------------------------------------------------------------------
@@ -0,0 +1,58 @@
1
+
2
+ ################################################################################
3
+ ## ##
4
+ ## This file is part of NCrystal (see https://mctools.github.io/ncrystal/) ##
5
+ ## ##
6
+ ## Copyright 2015-2025 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
+ [build-system]
23
+ requires = ["setuptools>=64.0"]
24
+ build-backend = "setuptools.build_meta"
25
+
26
+ [tool.setuptools.dynamic]
27
+ version = {attr = "NCrystal.__version__"}
28
+
29
+ [project]
30
+ name = "ncrystal-python"
31
+ dynamic = [ 'version' ]
32
+ requires-python = ">=3.8"
33
+ dependencies = [ 'numpy>=1.22' ]
34
+ authors = [
35
+ { name="NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)" },
36
+ ]
37
+ description = "Library for thermal neutron transport in crystals and other materials."
38
+ readme = "README.md"
39
+ license = {file = "LICENSE"}
40
+ classifiers = [
41
+ "Programming Language :: Python :: 3",
42
+ "License :: OSI Approved :: Apache Software License",
43
+ ]
44
+
45
+ [project.urls]
46
+ "Homepage" = "https://mctools.github.io/ncrystal/"
47
+ "Bug Tracker" = "https://github.com/mctools/ncrystal/issues"
48
+
49
+ [project.scripts]
50
+ nctool = "NCrystal._cli_nctool:main"
51
+ ncrystal_cif2ncmat = "NCrystal._cli_cif2ncmat:main"
52
+ ncrystal_endf2ncmat = "NCrystal._cli_endf2ncmat:main"
53
+ ncrystal_hfg2ncmat = "NCrystal._cli_hfg2ncmat:main"
54
+ ncrystal_mcstasunion = "NCrystal._cli_mcstasunion:main"
55
+ ncrystal_ncmat2cpp = "NCrystal._cli_ncmat2cpp:main"
56
+ ncrystal_ncmat2hkl = "NCrystal._cli_ncmat2hkl:main"
57
+ ncrystal_vdos2ncmat = "NCrystal._cli_vdos2ncmat:main"
58
+ ncrystal_verifyatompos = "NCrystal._cli_verifyatompos:main"
@@ -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.1.5'
58
+ __version__ = '4.1.8'
59
59
  __status__ = "Production"
60
60
  __author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
61
61
  __copyright__ = "Copyright 2015-2024 %s"%__author__
@@ -319,12 +319,24 @@ def _load(nclib_filename, ncrystal_namespace_protection ):
319
319
  functions['raw_vdos2gn'] = raw_vdos2gn
320
320
 
321
321
  _ORDERWEIGHTFCTTYPE = ctypes.CFUNCTYPE( _dbl, _uint )
322
- _raw_vdos2knl = _wrap('ncrystal_raw_vdos2knl',None,(_dblp,_dblp,_uint,_uint,_dbl,_dbl,_dbl,_uint,_ORDERWEIGHTFCTTYPE,_uintp,_uintp,_dblpp,_dblpp,_dblpp),hide=True)
323
- def raw_vdos2knl( egrid, density, scatxs, mass_amu, temperature, vdoslux, order_weight_fct ):
322
+ _raw_vdos2knl = _wrap('ncrystal_raw_vdos2kernel',None,
323
+ (_dblp,_dblp,_uint,_uint,_dbl,_dbl,_dbl,_uint,
324
+ _ORDERWEIGHTFCTTYPE,_uintp,_uintp,_dblpp,_dblpp,
325
+ _dblpp,_dbl,_dblp),
326
+ hide=True)
327
+ def raw_vdos2knl( egrid, density, scatxs, mass_amu, temperature,
328
+ vdoslux, order_weight_fct, target_emax ):
324
329
  _ensure_numpy()
325
- _egrid,_density = _np.asarray(egrid,dtype=float),_np.asarray(density,dtype=float)
326
- _s,_m,_t,_vdl = _dbl(float(scatxs)),_dbl(float(mass_amu)),_dbl(float(temperature)),_uint(int(vdoslux))
327
- nalpha, nbeta,agrid, bgrid, sab = _uint(), _uint(),_dblp(), _dblp(), _dblp()
330
+ _egrid = _np.asarray(egrid,dtype=float)
331
+ _density = _np.asarray(density,dtype=float)
332
+ _s = _dbl(float(scatxs))
333
+ _m = _dbl(float(mass_amu))
334
+ _t = _dbl(float(temperature))
335
+ _vdl = _uint(int(vdoslux))
336
+ _tgtemax = target_emax or 0.0
337
+ _tgtemax = _dbl( float(_tgtemax if _tgtemax>0.0 else 0.0 ) )
338
+ nalpha, nbeta, suggest_emax = _uint(), _uint(), _dbl()
339
+ agrid, bgrid, sab = _dblp(), _dblp(), _dblp()
328
340
  if order_weight_fct:
329
341
  def owf(order):
330
342
  return float(order_weight_fct( int(order.value
@@ -336,11 +348,13 @@ def _load(nclib_filename, ncrystal_namespace_protection ):
336
348
  _owf = ctypes.cast(None, _ORDERWEIGHTFCTTYPE)
337
349
  _raw_vdos2knl( ndarray_to_dblp(_egrid), ndarray_to_dblp(_density),
338
350
  _uint(len(_egrid)),_uint(len(_density)),
339
- _s,_m,_t,_vdl,_owf,nalpha, nbeta,
340
- ctypes.byref(agrid), ctypes.byref(bgrid), ctypes.byref(sab) )
351
+ _s,_m,_t,_vdl,_owf, nalpha, nbeta,
352
+ ctypes.byref(agrid), ctypes.byref(bgrid), ctypes.byref(sab),
353
+ _tgtemax, suggest_emax )
341
354
  return ( _cptr_to_nparray( agrid, nalpha ),
342
355
  _cptr_to_nparray( bgrid, nbeta ),
343
- _cptr_to_nparray( sab, nalpha.value * nbeta.value ) )
356
+ _cptr_to_nparray( sab, nalpha.value * nbeta.value ),
357
+ float( suggest_emax.value ) or None )
344
358
  functions['raw_vdos2knl'] = raw_vdos2knl
345
359
 
346
360
  def ncrystal_dyninfo_base(key):
@@ -342,13 +342,34 @@ def _anyvdos_init( class_AnyVDOS, anyvdos_extract_d, data, fmt, label ):
342
342
  return MappingProxyType( d )
343
343
 
344
344
  def detect_scatcomps( standard_comp_types, matsrc ):
345
+ from .exceptions import NCBadInput, NCCalcError
345
346
  if matsrc.is_preloaded:
346
347
  from .exceptions import NCBadInput
347
348
  raise NCBadInput('detect_scattering_components can not be used'
348
349
  ' with preloaded material sources')
349
350
  res=[]
350
351
  for ct in standard_comp_types:
351
- _ = matsrc.load( extra_cfg_params = f'vdoslux=0;comp={ct}', doInfo = False, doAbsorption = False )
352
- if not _.scatter.isNull():
352
+ def load(extra = None):
353
+ p = f'comp={ct}'
354
+ if extra is not None:
355
+ p += f';{extra}'
356
+ return matsrc.load( extra_cfg_params = p,
357
+ doInfo = False,
358
+ doAbsorption = False )
359
+ m = None
360
+ if ct == 'inelas':
361
+ #For inelas component first we try to see if we can get away with
362
+ #using a potentially smaller vdoslux than is actually used. This is
363
+ #not a great solution, but in the absence of deeper changes to
364
+ #NCrystal processes, this seems a reasonable compromise.
365
+ try:
366
+ m = load('vdoslux=0')
367
+ except NCCalcError as e:
368
+ if not str(e).startswith('VDOS expansion too slow'):
369
+ raise e
370
+ m = None
371
+ if not m:
372
+ m = load()
373
+ if not m.scatter.isNull():
353
374
  res.append(ct)
354
375
  return res
@@ -103,7 +103,8 @@ def extractGn( vdos, n, mass_amu, temperature, scatxs = 1.0, expand_egrid = True
103
103
  return _np_linspace( emin, emax, len(Gn) ), Gn
104
104
 
105
105
  def extractKnl( vdos, mass_amu, temperature, vdoslux = 3, scatxs = 1.0,
106
- order_weight_fct = None, plot = False, **plotkwargs ):
106
+ order_weight_fct = None, target_emax = None,
107
+ plot = False, **plotkwargs ):
107
108
  """Expand the VDOS to a scattering kernel, based on the provided
108
109
  parameters.
109
110
 
@@ -112,14 +113,37 @@ def extractKnl( vdos, mass_amu, temperature, vdoslux = 3, scatxs = 1.0,
112
113
  order). It must be a function taking a single parameter n (the order), and
113
114
  return a floating point value (the weight).
114
115
 
116
+ The target_emax parameter can be used to override the Emax value (eV)
117
+ targeted by the expansion, which will otherwise be based on the vdoslux
118
+ value.
119
+
120
+ The results will include alpha, beta, and sab arrays, as well as a
121
+ suggested_emax value (eV) which provides the actual Emax value of the
122
+ kernel. The latter will be None if an order_weight_function is provided.
123
+
115
124
  If plot=True, the extracted kernel will be plotted with the
116
125
  NCrystal.plot.plot_knl function.
126
+
117
127
  """
118
128
  from .misc import AnyVDOS
119
129
  v = AnyVDOS(vdos)
120
130
  from ._chooks import _get_raw_cfcts
121
- a,b,sab = _get_raw_cfcts()['raw_vdos2knl'](v.egrid(),v.dos(),scatxs, mass_amu, temperature, vdoslux, order_weight_fct )
122
- k = dict(alpha=a, beta=b, sab=sab, mass_amu=mass_amu,temperature=temperature,scatxs=scatxs)
131
+ f = _get_raw_cfcts()['raw_vdos2knl']
132
+ a, b, sab, suggested_emax = f( v.egrid(),
133
+ v.dos(),
134
+ scatxs,
135
+ mass_amu,
136
+ temperature,
137
+ vdoslux,
138
+ order_weight_fct,
139
+ target_emax )
140
+ k = dict( alpha = a,
141
+ beta = b,
142
+ sab = sab,
143
+ mass_amu = mass_amu,
144
+ temperature = temperature,
145
+ scatxs = scatxs,
146
+ suggested_emax = suggested_emax )
123
147
  if plot:
124
148
  from .plot import plot_knl
125
149
  plot_knl( k, **plotkwargs )
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: ncrystal-python
3
- Version: 4.1.5
3
+ Version: 4.1.8
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:
@@ -214,6 +214,7 @@ Requires-Python: >=3.8
214
214
  Description-Content-Type: text/markdown
215
215
  License-File: LICENSE
216
216
  Requires-Dist: numpy>=1.22
217
+ Dynamic: license-file
217
218
 
218
219
  NCrystal : A library for thermal neutron transport in crystals and other materials
219
220
  ----------------------------------------------------------------------------------
@@ -1,37 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=64.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [tool.setuptools.dynamic]
6
- version = {attr = "NCrystal.__version__"}
7
-
8
- [project]
9
- name = "ncrystal-python"
10
- dynamic = [ 'version' ]
11
- requires-python = ">=3.8"
12
- dependencies = [ 'numpy>=1.22' ]
13
- authors = [
14
- { name="NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)" },
15
- ]
16
- description = "Library for thermal neutron transport in crystals and other materials."
17
- readme = "README.md"
18
- license = {file = "LICENSE"}
19
- classifiers = [
20
- "Programming Language :: Python :: 3",
21
- "License :: OSI Approved :: Apache Software License",
22
- ]
23
-
24
- [project.urls]
25
- "Homepage" = "https://mctools.github.io/ncrystal/"
26
- "Bug Tracker" = "https://github.com/mctools/ncrystal/issues"
27
-
28
- [project.scripts]
29
- nctool = "NCrystal._cli_nctool:main"
30
- ncrystal_cif2ncmat = "NCrystal._cli_cif2ncmat:main"
31
- ncrystal_endf2ncmat = "NCrystal._cli_endf2ncmat:main"
32
- ncrystal_hfg2ncmat = "NCrystal._cli_hfg2ncmat:main"
33
- ncrystal_mcstasunion = "NCrystal._cli_mcstasunion:main"
34
- ncrystal_ncmat2cpp = "NCrystal._cli_ncmat2cpp:main"
35
- ncrystal_ncmat2hkl = "NCrystal._cli_ncmat2hkl:main"
36
- ncrystal_vdos2ncmat = "NCrystal._cli_vdos2ncmat:main"
37
- ncrystal_verifyatompos = "NCrystal._cli_verifyatompos:main"
File without changes