Commit ac4d5ad3 authored by Mohamed, Fawzi Roberto (fawzi)'s avatar Mohamed, Fawzi Roberto (fawzi)
Browse files

meta 2.0 changes

parent 5215a7fb
...@@ -42,6 +42,9 @@ metaInfoEnv, warnings = loadJsonFile(filePath=metaInfoPath, ...@@ -42,6 +42,9 @@ metaInfoEnv, warnings = loadJsonFile(filePath=metaInfoPath,
parser_info = {'name':'siesta-parser', 'version': '1.0'} parser_info = {'name':'siesta-parser', 'version': '1.0'}
def metaN(metaName):
"""Retrurns a normalized meta name"""
return metaName.replace(".", "_").replace("-", "_").lower()
def siesta_energy(title, meta, **kwargs): def siesta_energy(title, meta, **kwargs):
return SM(r'siesta:\s*%s\s*=\s*(?P<%s__eV>\S+)' % (title, meta), return SM(r'siesta:\s*%s\s*=\s*(?P<%s__eV>\S+)' % (title, meta),
...@@ -213,7 +216,7 @@ class SiestaContext(object): ...@@ -213,7 +216,7 @@ class SiestaContext(object):
#def onClose_x_siesta_section_xc_authors(self, backend, gindex, section): #def onClose_x_siesta_section_xc_authors(self, backend, gindex, section):
def onClose_section_frame_sequence(self, backend, gindex, section): def onClose_section_frame_sequence(self, backend, gindex, section):
backend.addValue('frame_sequence_to_sampling_ref', backend.addValue('frame_sequence_to_sampling_method_ref',
self.section_refs['sampling_method']) self.section_refs['sampling_method'])
def onOpen_section_sampling_method(self, backend, gindex, section): def onOpen_section_sampling_method(self, backend, gindex, section):
...@@ -320,7 +323,7 @@ class SiestaContext(object): ...@@ -320,7 +323,7 @@ class SiestaContext(object):
meta['atom_positions'] = positions meta['atom_positions'] = positions
for key, value in meta.items(): for key, value in meta.items():
backend.addArrayValues(key, value) backend.addArrayValues(metaN(key), value)
backend.addArrayValues('configuration_periodic_dimensions', backend.addArrayValues('configuration_periodic_dimensions',
np.ones(3, bool)) np.ones(3, bool))
...@@ -336,7 +339,11 @@ class SiestaContext(object): ...@@ -336,7 +339,11 @@ class SiestaContext(object):
if forces is not None: if forces is not None:
forces = forces.astype(float) forces = forces.astype(float)
forces = convert_unit(forces, 'eV/angstrom') forces = convert_unit(forces, 'eV/angstrom')
backend.addArrayValues('atom_forces_free_raw', forces) fId = backend.openSection('section_atom_forces')
backend.addValue('atom_forces_quantity', 'energy_free')
backend.addValue('atom_forces_constraints', 'raw')
backend.addArrayValues('atom_forces', forces)
backend.closeSection('section_atom_forces', fId)
stress = self.data.pop('stress_tensor_ev_ang', None) stress = self.data.pop('stress_tensor_ev_ang', None)
if stress is not None: if stress is not None:
...@@ -344,7 +351,7 @@ class SiestaContext(object): ...@@ -344,7 +351,7 @@ class SiestaContext(object):
stress = convert_unit(stress, 'eV/angstrom^3') stress = convert_unit(stress, 'eV/angstrom^3')
backend.addArrayValues('stress_tensor', stress) backend.addArrayValues('stress_tensor', stress)
backend.addValue('single_configuration_to_calculation_method_ref', backend.addValue('single_configuration_calculation_to_method_ref',
self.section_refs['method']) self.section_refs['method'])
backend.addValue('single_configuration_calculation_to_system_ref', backend.addValue('single_configuration_calculation_to_system_ref',
self.section_refs['system']) self.section_refs['system'])
...@@ -357,7 +364,7 @@ class SiestaContext(object): ...@@ -357,7 +364,7 @@ class SiestaContext(object):
inputvars, blocks = get_input_metadata(inputvars_file, inputvars, blocks = get_input_metadata(inputvars_file,
self.format == 'new') self.format == 'new')
for varname, value in inputvars.items(): for varname, value in inputvars.items():
backend.addValue('x_siesta_input_%s' % varname, value) backend.addValue(metaN('x_siesta_input_%s' % varname), value)
for special_name in ['LatticeConstant', for special_name in ['LatticeConstant',
'AtomicCoordinatesFormat', 'AtomicCoordinatesFormat',
...@@ -404,9 +411,9 @@ class SiestaContext(object): ...@@ -404,9 +411,9 @@ class SiestaContext(object):
% authors) % authors)
for funcname in xc: for funcname in xc:
gid = backend.openSection('section_XC_functionals') gid = backend.openSection('section_xc_functionals')
backend.addValue('XC_functional_name', funcname) backend.addValue('xc_functional_name', funcname)
backend.closeSection('section_XC_functionals', gid) backend.closeSection('section_xc_functionals', gid)
def read_eigenvalues(self, backend): def read_eigenvalues(self, backend):
eigfile = self.files.get('EIG') eigfile = self.files.get('EIG')
...@@ -450,8 +457,8 @@ class SiestaContext(object): ...@@ -450,8 +457,8 @@ class SiestaContext(object):
coords = data[:, 1:4].astype(float) coords = data[:, 1:4].astype(float)
weights = data[:, 4].astype(float) weights = data[:, 4].astype(float)
backend.addArrayValues('eigenvalues_kpoints', coords) backend.addArrayValues('eigenvalues_kpoints', coords)
# XXX metadata for Fermi level? # XXX metadata for Fermi level? -> energy_reference_fermi
# k-point weights? backend.addArrayValues('eigenvalues_kpoints_weights', weights)
def save_array(self, key, dtype=float, istart=0, iend=None, def save_array(self, key, dtype=float, istart=0, iend=None,
unit=None): unit=None):
...@@ -622,7 +629,7 @@ def get_step_matcher(): ...@@ -622,7 +629,7 @@ def get_step_matcher():
siesta_energy('Kinetic', 'electronic_kinetic_energy'), siesta_energy('Kinetic', 'electronic_kinetic_energy'),
siesta_energy('Hartree', 'energy_electrostatic'), siesta_energy('Hartree', 'energy_electrostatic'),
#siesta_energy('Ext\. field', ''), #siesta_energy('Ext\. field', ''),
siesta_energy('Exch\.-corr\.', 'energy_XC'), siesta_energy('Exch\.-corr\.', 'energy_xc'),
#siesta_energy('Ion-electron', ''), #siesta_energy('Ion-electron', ''),
#siesta_energy('Ion-Ion', ''), #siesta_energy('Ion-Ion', ''),
#siesta_energy('Ekinion', ''), #siesta_energy('Ekinion', ''),
......
...@@ -62,6 +62,10 @@ import sys ...@@ -62,6 +62,10 @@ import sys
inputvars_fd = open('inputvars.py', 'w') inputvars_fd = open('inputvars.py', 'w')
print('varlist = [', file=inputvars_fd) print('varlist = [', file=inputvars_fd)
def metaN(metaName):
"""Retrurns a normalized meta name"""
return metaName.replace(".", "_").replace("-", "_").lower()
def getlines(): def getlines():
fd = open('test/H2O/fdf-95611.log') fd = open('test/H2O/fdf-95611.log')
for line in fd: for line in fd:
...@@ -107,7 +111,7 @@ if 1: ...@@ -107,7 +111,7 @@ if 1:
print(" '%s'," % var, file=inputvars_fd) print(" '%s'," % var, file=inputvars_fd)
json = json_template % dict(description=r'siesta input variable \"%s\"' json = json_template % dict(description=r'siesta input variable \"%s\"'
% var, % var,
name='x_siesta_input_%s' % var, name=metaN('x_siesta_input_%s' % var),
dtypeStr='C', dtypeStr='C',
supername='x_siesta_input') supername='x_siesta_input')
jsontokens.append(json) jsontokens.append(json)
......
...@@ -47,8 +47,8 @@ object SiestaParser extends SimpleExternalParserGenerator( ...@@ -47,8 +47,8 @@ object SiestaParser extends SimpleExternalParserGenerator(
"parser-siesta/setup_paths.py", "parser-siesta/setup_paths.py",
"nomad_meta_info/public.nomadmetainfo.json", "nomad_meta_info/public.nomadmetainfo.json",
"nomad_meta_info/common.nomadmetainfo.json", "nomad_meta_info/common.nomadmetainfo.json",
"nomad_meta_info/meta_types.nomadmetainfo.json", "nomad_meta_info/meta.nomadmetainfo.json",
"nomad_meta_info/siesta.autogenerated.nomadmetainfo.json", "nomad_meta_info/siesta_autogenerated.nomadmetainfo.json",
"nomad_meta_info/siesta.nomadmetainfo.json" "nomad_meta_info/siesta.nomadmetainfo.json"
) ++ DefaultPythonInterpreter.commonFiles(), ) ++ DefaultPythonInterpreter.commonFiles(),
dirMap = Map( dirMap = Map(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment