ncrystal-python 4.2.12__tar.gz → 4.3.0__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 (72) hide show
  1. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/PKG-INFO +1 -1
  2. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/pyproject.toml +3 -0
  3. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/__init__.py +1 -1
  4. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_chooks.py +93 -47
  5. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_cif2ncmat.py +7 -0
  6. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_endf2ncmat.py +11 -2
  7. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_hfg2ncmat.py +7 -0
  8. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_mcstasunion.py +7 -0
  9. ncrystal_python-4.3.0/src/NCrystal/_cli_minimc.py +507 -0
  10. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_ncmat2cpp.py +7 -0
  11. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_ncmat2endf.py +7 -0
  12. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_ncmat2hkl.py +7 -0
  13. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_nctool.py +37 -74
  14. ncrystal_python-4.3.0/src/NCrystal/_cli_query.py +92 -0
  15. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_vdos2ncmat.py +9 -0
  16. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cli_verifyatompos.py +7 -0
  17. ncrystal_python-4.3.0/src/NCrystal/_clientry.py +142 -0
  18. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cliimpl.py +12 -3
  19. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_cliwrap_config.py +15 -2
  20. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_common.py +77 -0
  21. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_coreimpl.py +0 -9
  22. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_hklobjects.py +1 -1
  23. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_miscimpl.py +21 -2
  24. ncrystal_python-4.3.0/src/NCrystal/_mmc.py +113 -0
  25. ncrystal_python-4.3.0/src/NCrystal/_mmc_doc.py +473 -0
  26. ncrystal_python-4.3.0/src/NCrystal/_mmc_impl.py +444 -0
  27. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_ncmatimpl.py +22 -12
  28. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_testimpl.py +21 -11
  29. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/cifutils.py +1 -1
  30. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/core.py +22 -3
  31. ncrystal_python-4.3.0/src/NCrystal/hist.py +1078 -0
  32. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/mcstasutils.py +9 -4
  33. ncrystal_python-4.3.0/src/NCrystal/minimc.py +146 -0
  34. ncrystal_python-4.3.0/src/NCrystal/minimc_objects.py +481 -0
  35. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/misc.py +16 -0
  36. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/mmc.py +4 -12
  37. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/ncmat.py +32 -1
  38. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/plot.py +318 -115
  39. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/vdos.py +59 -70
  40. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/ncrystal_python.egg-info/PKG-INFO +1 -1
  41. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/ncrystal_python.egg-info/SOURCES.txt +8 -1
  42. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/ncrystal_python.egg-info/entry_points.txt +3 -0
  43. ncrystal_python-4.2.12/src/NCrystal/_hist.py +0 -297
  44. ncrystal_python-4.2.12/src/NCrystal/_mmc.py +0 -491
  45. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/LICENSE +0 -0
  46. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/README.md +0 -0
  47. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/setup.cfg +0 -0
  48. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/__main__.py +0 -0
  49. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_hfgdata.py +0 -0
  50. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_is_std.py +0 -0
  51. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_locatelib.py +0 -0
  52. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_msg.py +0 -0
  53. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_ncmat2cpp_impl.py +0 -0
  54. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_ncmat2endf_impl.py +0 -0
  55. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_numpy.py +0 -0
  56. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/_sabutils.py +0 -0
  57. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/api.py +0 -0
  58. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/atomdata.py +0 -0
  59. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/cfgstr.py +0 -0
  60. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/cli.py +0 -0
  61. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/constants.py +0 -0
  62. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/datasrc.py +0 -0
  63. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/exceptions.py +0 -0
  64. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/hfg2ncmat.py +0 -0
  65. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/ncmat2cpp.py +0 -0
  66. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/ncmat2endf.py +0 -0
  67. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/obsolete.py +0 -0
  68. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/plugins.py +0 -0
  69. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/NCrystal/test.py +0 -0
  70. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/ncrystal_python.egg-info/dependency_links.txt +0 -0
  71. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/ncrystal_python.egg-info/requires.txt +0 -0
  72. {ncrystal_python-4.2.12 → ncrystal_python-4.3.0}/src/ncrystal_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ncrystal-python
3
- Version: 4.2.12
3
+ Version: 4.3.0
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:
@@ -47,13 +47,16 @@ classifiers = [
47
47
  "Bug Tracker" = "https://github.com/mctools/ncrystal/issues"
48
48
 
49
49
  [project.scripts]
50
+ ncrystal = "NCrystal._clientry:main"
50
51
  nctool = "NCrystal._cli_nctool:main"
51
52
  ncrystal_cif2ncmat = "NCrystal._cli_cif2ncmat:main"
52
53
  ncrystal_endf2ncmat = "NCrystal._cli_endf2ncmat:main"
53
54
  ncrystal_hfg2ncmat = "NCrystal._cli_hfg2ncmat:main"
54
55
  ncrystal_mcstasunion = "NCrystal._cli_mcstasunion:main"
56
+ ncrystal_minimc = "NCrystal._cli_minimc:main"
55
57
  ncrystal_ncmat2endf = "NCrystal._cli_ncmat2endf:main"
56
58
  ncrystal_ncmat2cpp = "NCrystal._cli_ncmat2cpp:main"
57
59
  ncrystal_ncmat2hkl = "NCrystal._cli_ncmat2hkl:main"
58
60
  ncrystal_vdos2ncmat = "NCrystal._cli_vdos2ncmat:main"
59
61
  ncrystal_verifyatompos = "NCrystal._cli_verifyatompos:main"
62
+ ncrystal_query = "NCrystal._cli_query: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.2.12'
58
+ __version__ = '4.3.0'
59
59
  __status__ = "Production"
60
60
  __author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
61
61
  __copyright__ = "Copyright 2015-2024 %s"%__author__
@@ -162,8 +162,9 @@ def _load(nclib_filename, ncrystal_namespace_protection ):
162
162
  def fct(*args):
163
163
  return raw(*args)
164
164
  if error_check:
165
- #NB: we should read about return types in the ctypes tutorial. Apparently one
166
- #can just set an error checking function as the restype.
165
+ #NB: we should read about return types in the ctypes
166
+ #tutorial. Apparently one can just set an error checking function as
167
+ #the restype.
167
168
  raw_fct = fct
168
169
  def fcte(*aaa):
169
170
  r = raw_fct(*aaa)
@@ -284,12 +285,15 @@ def _load(nclib_filename, ncrystal_namespace_protection ):
284
285
  functions['iter_hkllist']=iter_hkllist
285
286
 
286
287
  _raw_dealloc_dblptr = _wrap('ncrystal_dealloc_doubleptr',None,(_dblp,),hide=True)
287
- def _cptr_to_nparray( cptr, n, free_after_with_ncrystal_dealloc = True ):
288
+
289
+ def _cptr_to_nparray( cptr, n, dealloc = True ):
288
290
  import numpy.ctypeslib as _np_ctypeslib
289
- np_arr = _np_ctypeslib.as_array(cptr,shape=(int(n.value if hasattr(n,'value') else n),)).copy()
290
- if free_after_with_ncrystal_dealloc:
291
+ s = (int( n.value if hasattr(n,'value') else n ),)
292
+ a = _np_ctypeslib.as_array( cptr, shape=s )
293
+ a = a.copy()
294
+ if dealloc:
291
295
  _raw_dealloc_dblptr(cptr)
292
- return np_arr
296
+ return a
293
297
 
294
298
  _wrap('ncrystal_info_ndyninfo',_uint,(ncrystal_info_t,))
295
299
  _raw_di_base = _wrap('ncrystal_dyninfo_base',None,(ncrystal_info_t,_uint,_dblp,_uintp,_dblp,_uintp),hide=True)
@@ -820,49 +824,91 @@ def _load(nclib_filename, ncrystal_namespace_protection ):
820
824
  _raw_setmsghandler(keepalive[-1])
821
825
  functions['setmsghandler'] = ncrystal_setmsghandler
822
826
 
823
- _raw_runmmcsim_stdengine = _wrap('ncrystal_runmmcsim_stdengine',None,
824
- (_uint,_uint,
825
- _cstr,_cstr,_cstr,
826
- _charptrptr,_uintp,_dblpp,_dblpp),
827
- hide=True)
828
- def nc_runmmcsim_stdengine( nthreads,
829
- tally_detail_lvl,
830
- mat_cfgstr,
831
- mmc_geomcfg,
832
- mmc_srccfg ):
833
- nthreads_ = _uint(int(nthreads))
834
- assert 0<=tally_detail_lvl<=2
835
- tally_detail_lvl_ = _uint(int(tally_detail_lvl))
836
- mat_cfgstr_ = _str2cstr(mat_cfgstr)
837
- mmc_geomcfg_ = _str2cstr(mmc_geomcfg)
838
- mmc_srccfg_ = _str2cstr(mmc_srccfg)
839
- t_json = _charptr()
840
- t_exitangle_nbins = _uint()
841
- t_exitangle_ct = _dblp()
842
- t_exitangle_errsq = _dblp()
843
- _raw_runmmcsim_stdengine( nthreads_,
844
- tally_detail_lvl_,
845
- mat_cfgstr_,
846
- mmc_geomcfg_,
847
- mmc_srccfg_,
848
- t_json,
849
- t_exitangle_nbins,
850
- ctypes.byref(t_exitangle_ct),
851
- ctypes.byref(t_exitangle_errsq) )
852
- if t_json is not None:
853
- t_json_cstr = ctypes.cast(t_json,_cstr).value
854
- if t_json_cstr is not None:
855
- _ = _cstr2str(t_json_cstr)
856
- _raw_deallocstr(t_json)
857
- t_json = _
858
- else:
859
- t_json = None
827
+ _raw_jsonquery = _wrap('ncrystal_jsonquery',_charptr,(_cstr,), hide=True)
860
828
 
861
- tally_exitangle_contents = _cptr_to_nparray( t_exitangle_ct, t_exitangle_nbins )
862
- tally_exitangle_errsq = _cptr_to_nparray( t_exitangle_errsq, t_exitangle_nbins )
863
- return tally_exitangle_contents,tally_exitangle_errsq,t_json
829
+ def prepare_query_cstr( query ):
830
+ if not query:
831
+ raise NCBadInput("Missing or empty query")
832
+ sc = '\x07'
833
+ str_query = sc.join(query)
834
+ if len(query) != str_query.count(sc)+1:
835
+ raise NCBadInput("Can not use character 0x07 (ASCII BEL) in"
836
+ " JSON query strings" )
837
+ return _str2cstr(str_query)
864
838
 
865
- functions['runmmcsim_stdengine']=nc_runmmcsim_stdengine
839
+ def decode_query_result( raw_str ):
840
+ assert raw_str is not None
841
+ res=_cstr2str(ctypes.cast(raw_str,_cstr).value)
842
+ _raw_deallocstr(raw_str)
843
+ return res
844
+
845
+ def jsonquery( query ):
846
+ cstr_query = prepare_query_cstr(query)
847
+ raw_str = _raw_jsonquery( cstr_query )
848
+ return decode_query_result(raw_str)
849
+ functions['jsonquery'] = jsonquery
866
850
 
851
+ _FLEXMMCRUNCBTYPE = ctypes.CFUNCTYPE( _uint, _dblpp, _ulong, _ulong )
852
+ _raw_flexmmcrun = _wrap( 'ncrystal_flexmmcrun',_charptr,
853
+ (_cstr,_cstr,_FLEXMMCRUNCBTYPE ), hide=True )
854
+ def flexmmcrun( query, user_callback, callback_options ):
855
+ _ensure_numpy()
856
+ cstr_query = prepare_query_cstr(query)
857
+ cb_errors = []
858
+ def cb_wrapper( data, cbtype, data_len ):
859
+ if cb_errors:
860
+ return 2
861
+ rv = 0
862
+ try:
863
+ cbtype = int(cbtype)
864
+ assert cbtype in (1,2)
865
+
866
+ n = int(data_len)
867
+ assert 0 < n <= 1000000000
868
+ def load( i ):
869
+ return _cptr_to_nparray( data[i], n, dealloc=False)
870
+
871
+ pydata = dict( x = load(0), y = load(1), z = load(2),
872
+ ux = load(3), uy = load(4), uz = load(5),
873
+ ekin = load(6), w = load(7), nscat = load(8),
874
+ nscat_inelas = load(9) )
875
+ if cbtype==2:
876
+ pydata.update(
877
+ dict( x0 = load(10), y0 = load(11), z0 = load(12),
878
+ ux0 = load(13),uy0 = load(14), uz0 = load(15),
879
+ ekin0 = load(16), w0 = load(17) )
880
+ )
881
+
882
+ user_rv = user_callback( pydata )
883
+ #TODO: Currently not aborting a long simjob on ctrl-C if
884
+ # nthreads>2. Tricky to fix.
885
+ if not bool(user_rv):
886
+ rv = 0 # STD (usual case)
887
+ else:
888
+ #HALTERR or HALTSRC:
889
+ rv = ( 2 if ( isinstance(user_rv,str)
890
+ and user_rv=='error' ) else 1 )
891
+ if rv == 2 and not cb_errors:
892
+ cb_errors.append(None)
893
+ except BaseException as exc:
894
+ rv = 2
895
+ cb_errors.append(exc)
896
+ del exc #maybe not needed, but exc.__traceback__ references the
897
+ #function frame, so the function frame best not
898
+ #reference exc.
899
+ return rv
900
+
901
+ cb_c = _FLEXMMCRUNCBTYPE(cb_wrapper)
902
+ cbopt_c = None
903
+ if callback_options is not None and callback_options.strip():
904
+ cbopt_c = _str2cstr(callback_options)
905
+ raw_str = _raw_flexmmcrun( cstr_query, cbopt_c, cb_c )
906
+ if cb_errors:
907
+ #Rethrow exception from callback function
908
+ user_callback_exception = cb_errors[0]
909
+ raise user_callback_exception
910
+ return decode_query_result(raw_str)
911
+
912
+ functions['flexmmcrun'] = flexmmcrun
867
913
 
868
914
  return functions
@@ -23,6 +23,13 @@ from ._cliimpl import ( create_ArgumentParser,
23
23
  cli_entry_point,
24
24
  print )
25
25
 
26
+ def climod_metadata():
27
+ return dict(
28
+ displaygroup = 'conv',
29
+ displayorder = 10,
30
+ descr = "Create NCMAT data based on CIF input."
31
+ )
32
+
26
33
  def parseArgs( progname, arglist, return_parser=False ):
27
34
  import textwrap
28
35
  helpw = 60
@@ -30,6 +30,13 @@ from . import core as nccore
30
30
  import warnings
31
31
  import pathlib
32
32
 
33
+ def climod_metadata():
34
+ return dict(
35
+ displaygroup = 'conv',
36
+ displayorder = 999,
37
+ descr = "Import ENDF data to NCMAT format (based on PyNE)."
38
+ )
39
+
33
40
  __pynecache=[None]
34
41
  def import_pyne():
35
42
  global __pynecache
@@ -38,10 +45,12 @@ def import_pyne():
38
45
 
39
46
  try:
40
47
  with warnings.catch_warnings():
41
- warnings.simplefilter("ignore")#silence annoying pyne.endf QAWarning's.
48
+ #silence annoying pyne.endf QAWarning's:
49
+ warnings.simplefilter("ignore")
42
50
  import pyne.endf
43
51
  except ImportError:
44
- raise RuntimeError('Could not "import pyne.endf". You probably need to install PyNE (see http://pyne.io/)')
52
+ raise RuntimeError('Could not "import pyne.endf". You probably need'
53
+ ' to install PyNE (see http://pyne.io/)')
45
54
 
46
55
  #Monkey-patch pyne.endf reader, which was ignoring optional sections with teff
47
56
  #curves of non-principal atoms (see
@@ -23,6 +23,13 @@ from ._cliimpl import ( create_ArgumentParser,
23
23
  cli_entry_point,
24
24
  print )
25
25
 
26
+ def climod_metadata():
27
+ return dict(
28
+ displaygroup = 'conv',
29
+ displayorder = 20,
30
+ descr = "Create NCMAT data for amorphous hydrogen-rich materials."
31
+ )
32
+
26
33
  def _parseArgs( default_debye_temp, progname, arglist, return_parser=False ):
27
34
  from argparse import RawTextHelpFormatter
28
35
 
@@ -23,6 +23,13 @@ from ._cliimpl import ( create_ArgumentParser,
23
23
  cli_entry_point,
24
24
  print )
25
25
 
26
+ def climod_metadata():
27
+ return dict(
28
+ displaygroup = 'misc',
29
+ displayorder = 999,
30
+ descr = "Generate McStas-Union code for using NCrystal materials."
31
+ )
32
+
26
33
  def parseArgs( progname, args, return_parser=False ):
27
34
 
28
35
  descr="""Output McStas-Union code in McStas instrument (.instr) format to