Closed ramic-k closed 3 years ago
Thanks @ramic-k . It will be a few weeks before I can take a look, please provide the relevant input files for reproducing the problem (a url or attached here?).
And I assume it was NCrystal v2.6.1?
Yup, the latest and greatest version of NCrystal.
tsl-H_in_MgH2_sg136_Magnesium_Hydride-iel98_endf.txt tsl-Mg_in_MgH2_sg136_Magnesium_Hydride-iel98_endf.txt
So I found the issue in ncrystal.cc, but there is another issue with your input files, you have messed up the text section near the top, in lines 35+36+43:
12 ****************************************************************** 8 1451 11
13 * * 8 1451 12
14 * Generated with NJOY+NCrystal * 8 1451 13
15 * * 8 1451 14
16 ****************************************************************** 8 1451 15
17 * * 8 1451 16
18 * Temperatures: * 8 1451 17
19 * 296.0 K * 8 1451 18
20 * * 8 1451 19
21 ****************************************************************** 8 1451 20
22 * * 8 1451 21
23 *Crystal structure obtained from: * 8 1451 22
24 * https://www.materialsproject.org/materials/mp-23710/ * 8 1451 23
25 * * 8 1451 24
26 * Phonon spectrum calculations were performed, by Davide Campi * 8 1451 25
27 * and Marco Bernasconi from University of Milano-Bicocca, within * 8 1451 26
28 * Density Functional Perturbation Theory (DFPT) by using the * 8 1451 27
29 * Perdew-Burke- Ernzerhof (PBE) approximation to the exchange * 8 1451 28
30 * and correlation energy functional. Ultrasoft pseudo-potentials * 8 1451 29
31 * and a plane wave expansion of Kohn-Sham orbitals up to a * 8 1451 30
32 * kinetic cutoff of 60 Ry was employed, as implemented in the * 8 1451 31
33 * Quantum-ESPRESSO package. * 8 1451 32
34 * In the electronic structure calculations, the Brillouin zone * 8 1451 33
35 * (BZ) integration was performed over a uniform Γ-centered 8 1451 34
36 * 10×10×14 k-point mesh [16]. 8 1451 35
37 * * 8 1451 36
38 * References: * 8 1451 37
39 * * 8 1451 38
40 * [1]: "Phonons and related crystal properties from * 8 1451 39
41 * density-functional perturbation theory" * 8 1451 40
42 * Baroni, S., De Gironcoli, S., Dal Corso, A., * 8 1451 41
43 * Giannozzi, P. Reviews of Modern Physics 73, 515–562. 8 1451 42
44 * doi: 10. 1103/RevModPhys.73.515 , arXiv:0012092v1 * 8 1451 43
45 * [2]: "QUANTUM ESPRESSO: a modular and open-source software * 8 1451 44
46 * project for quantum simulations of materials" * 8 1451 45
47 * Giannozzi, P., Baroni, S., et al., * 8 1451 46
48 * 2009. Q. J. Phys.: Condens. Mat- ter 21, 395502. * 8 1451 47
49 * * 8 1451 48
50 ****************************************************************** 8 1451 49
Fixing it up by hand, everything seems to work. I also changes the Γ to spell out "Gamma", since I am not convinced that Fortran code will appreciate the multi-byte characters. In fact, you should probably check that the file is pure ascii and not utf-8 (you can run the command "file myfilename.endf". If it says UTF-8, you are not done yet.
And a few lines further down the file you have the most serious issue yet: Once again my surname is mis-spelled!!! ;-)
I'll post the fix for ncrystal.cc here shortly, in case you need if before NCrystal v2.7.0 is out.
Thanks Thomas! You are saving me a lot of hassle here :D
We shall be regenerating all the files soon, so any typos shall be fixed, including your glorious surname.
For reference the fixes needed for ncrystal.cc and ncrystal_endf2ncmat are pasted here, in case you can't wait 1-2 days for NCrystal v2.7.0:
@@ -1448,7 +1448,9 @@ void ncrystal_info_getcomponent( ncrystal_info_t ci, unsigned icomponent,
ncrystal_atomdata_t ncrystal_create_atomdata_fromdb( unsigned z, unsigned a )
{
try {
- return ncc::createNewCHandle<ncc::Wrapped_AtomData>( NC::AtomDB::getIsotopeOrNatElem(z,a) );
+ auto opt_atomdatasp = NC::AtomDB::getIsotopeOrNatElem(z,a);
+ if ( opt_atomdatasp != nullptr )
+ return ncc::createNewCHandle<ncc::Wrapped_AtomData>( std::move(opt_atomdatasp) );
} NCCATCH;
return {nullptr};
}
@@ -1463,8 +1465,11 @@ ncrystal_atomdata_t ncrystal_create_atomdata_fromdbstr( const char* name )
z = symb.Z();
a = symb.A();
}
- if (z)
- return ncc::createNewCHandle<ncc::Wrapped_AtomData>( NC::AtomDB::getIsotopeOrNatElem(z,a) );
+ if (z) {
+ auto opt_atomdatasp = NC::AtomDB::getIsotopeOrNatElem(z,a);
+ if ( opt_atomdatasp != nullptr )
+ return ncc::createNewCHandle<ncc::Wrapped_AtomData>( std::move(opt_atomdatasp) );
+ }
} NCCATCH;
return {nullptr};
}
And
@@ -113,7 +113,7 @@ def guessElementName(ZA,mass_amu):
if ZA in (112,113):
return 'D'#ortho-D or para-D
guess_by_mass = guessElementFromMass(mass_amu)
- guess_by_z = elementZToName(z) if (z>0 and z<120) else None
+ guess_by_z = elementZToName(Z) if (Z>0 and Z<120) else None
if guess_by_z:
if guess_by_z!=guess_by_mass:
raise SystemExit(f"ERROR: Mass and Z guess gives different element name (Z={Z}=>'{guess_by_z}', mass={mass_amu}amu=>'{guess_by_mass}')")
NCrystal v2.7.0 is out, closing here.
Hi Thomas,
I think I have found an issue when converting ENDF to .NCMAT
The command used was: ncrystal_endf2ncmat tsl-H_in_MgH2_sg136_Magnesium_Hydride-iel98.endf --secondary tsl-Mg_in_MgH2_sg136_Magnesium_Hydride-iel98.endf:1/3 --outbn MgH2_converted
and the error was:
ncrystal_endf2ncmat tsl-H_in_MgH2_sg136_Magnesium_Hydride-iel98.endf --secondary tsl-Mg_in_MgH2_sg136_Magnesium_Hydride-iel98.endf:1/3 --outbn MgH2_converted Attempting to load ENDF file tsl-H_in_MgH2_sg136_Magnesium_Hydride-iel98.endf... Reading MF=1, MT=451 Descriptive Data Reading MF=7, MT=2 (z,elastic) Reading MF=7, MT=4 (z,n) Performing a few sanity checks... Traceback (most recent call last): File "/home/kemal/Desktop/final_njoy_ncrystal/install/bin/ncrystal_endf2ncmat", line 577, in <module> p1=parse_endf_file(args.ENDFFILE) File "/home/kemal/Desktop/final_njoy_ncrystal/install/bin/ncrystal_endf2ncmat", line 215, in parse_endf_file element_name=guessElementName(data.target['ZA'],data.target['mass']) File "/home/kemal/Desktop/final_njoy_ncrystal/install/bin/ncrystal_endf2ncmat", line 115, in guessElementName guess_by_mass = guessElementFromMass(mass_amu) File "/home/kemal/Desktop/final_njoy_ncrystal/install/bin/ncrystal_endf2ncmat", line 98, in guessElementFromMass elem_data=[ (abs(d.averageMassAMU()-mass_amu),d) for d in [NCrystal.atomDB(z,throwOnErrors=False) for z in range(1,120)] if d ] File "/home/kemal/Desktop/final_njoy_ncrystal/install/bin/ncrystal_endf2ncmat", line 98, in <listcomp> elem_data=[ (abs(d.averageMassAMU()-mass_amu),d) for d in [NCrystal.atomDB(z,throwOnErrors=False) for z in range(1,120)] if d ] File "/home/kemal/Desktop/final_njoy_ncrystal/install/share/NCrystal/python/NCrystal/__init__.py", line 1932, in atomDB rawatomdata=_rawfct['ncrystal_create_atomdata_fromdb'](*key) File "/home/kemal/Desktop/final_njoy_ncrystal/install/share/NCrystal/python/NCrystal/__init__.py", line 256, in fcte _raise_err() File "/home/kemal/Desktop/final_njoy_ncrystal/install/share/NCrystal/python/NCrystal/__init__.py", line 234, in _raise_err raise e NCrystal.NCBadInput: Attempt to initialise shared_obj<T> object with null pointer is illegal