Skip to content
Snippets Groups Projects
Commit 11d2ead3 authored by Ask Hjorth Larsen's avatar Ask Hjorth Larsen
Browse files

I can't get it to use the simplematchers without them having opinions about...

I can't get it to use the simplematchers without them having opinions about how sections should open and close, so for now, let's just do some hacks.
parent 01dd0ad3
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ import setup_paths ...@@ -5,7 +5,7 @@ import setup_paths
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.unit_conversion.unit_conversion \ from nomadcore.unit_conversion.unit_conversion \
import register_userdefined_quantity import register_userdefined_quantity, convert_unit
import os, sys, json import os, sys, json
from util import OCT_ENERGY_UNIT_NAME, f_num, i_num, numpattern, integer,\ from util import OCT_ENERGY_UNIT_NAME, f_num, i_num, numpattern, integer,\
...@@ -80,6 +80,40 @@ class OctopusParserContext(object): ...@@ -80,6 +80,40 @@ class OctopusParserContext(object):
#logging.getLogger("nomadcore.parsing").info("closing section_scf_iteration bla gIndex %d %s", gIndex, section.simpleValues) #logging.getLogger("nomadcore.parsing").info("closing section_scf_iteration bla gIndex %d %s", gIndex, section.simpleValues)
#self.scfIterNr += 1 #self.scfIterNr += 1
#def parse_infofile(meta_info_env, pew, fname):
# parse_file_without_decorations(pew, meta_info_env, infoFileDescription,
# parserInfo, OctopusParserContext(), fname)
def parse_infofile(meta_info_env, pew, fname): def parse_infofile(meta_info_env, pew, fname):
parse_file_without_decorations(pew, meta_info_env, infoFileDescription, with open(fname) as fd:
parserInfo, OctopusParserContext(), fname) for line in fd:
if line.startswith('SCF converged'):
iterations = int(line.split()[-2])
pew.addValue('x_octopus_info_scf_converged_iterations',
iterations)
break
for line in fd: # Jump down to energies:
if line.startswith('Energy ['):
octunit = line.strip().split()[-1].strip('[]:')
nomadunit = {'eV': 'eV', 'H': 'hartree'}[octunit]
break
names = {'Total': 'energy_total',
'Free': 'energy_free',
'Ion-ion': 'x_octopus_info_energy_ion_ion',
'Eigenvalues': 'energy_sum_eigenvalues',
'Hartree': 'energy_electrostatic',
'Exchange': 'energy_X',
'Correlation': 'energy_C',
'vanderWaals': 'energy_van_der_Waals',
'-TS': 'energy_correction_entropy',
'Kinetic': 'electronic_kinetic_energy'}
for line in fd:
tokens = line.split()
if len(tokens) < 3:
continue
if tokens[0] in names:
pew.addValue(names[tokens[0]],
convert_unit(float(tokens[2]), nomadunit))
...@@ -15,7 +15,7 @@ logFileDescription = SM( ...@@ -15,7 +15,7 @@ logFileDescription = SM(
weak=True, weak=True,
startReStr='', startReStr='',
fixedStartValues={'program_name': 'octopus'}, fixedStartValues={'program_name': 'octopus'},
sections=['section_run'], #sections=['section_run'],
subFlags=SM.SubFlags.Sequenced, subFlags=SM.SubFlags.Sequenced,
subMatchers=[ subMatchers=[
SM(r'Version\s*:\s*%s' % word('program_version')), SM(r'Version\s*:\s*%s' % word('program_version')),
...@@ -29,6 +29,21 @@ class OctopusLogFileParserContext(object): ...@@ -29,6 +29,21 @@ class OctopusLogFileParserContext(object):
def parse_logfile(meta_info_env, pew, fname): def parse_logfile(meta_info_env, pew, fname):
parse_file_without_decorations(pew, meta_info_env, logFileDescription, # XXX this is just a hack until we decide to do more
parserInfo, OctopusLogFileParserContext(), maxlines = 100
fname) with open(fname) as fd:
for i in range(maxlines):
line = next(fd)
if line.startswith('Version'):
version = line.split()[-1]
pew.addValue('program_version', version)
elif line.startswith('Revision'):
revision = line.split()[-1]
pew.addValue('x_octopus_log_svn_revision', revision)
# XXX more info
#def parse_logfile(meta_info_env, pew, fname):
# parse_file_without_decorations(pew, meta_info_env, logFileDescription,
# parserInfo, OctopusLogFileParserContext(),
# fname)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment