Commit 11d2ead3 authored by Ask Hjorth Larsen's avatar Ask Hjorth Larsen

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
......@@ -5,7 +5,7 @@ import setup_paths
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.unit_conversion.unit_conversion \
import register_userdefined_quantity
import register_userdefined_quantity, convert_unit
import os, sys, json
from util import OCT_ENERGY_UNIT_NAME, f_num, i_num, numpattern, integer,\
......@@ -80,6 +80,40 @@ class OctopusParserContext(object):
#logging.getLogger("nomadcore.parsing").info("closing section_scf_iteration bla gIndex %d %s", gIndex, section.simpleValues)
#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):
parse_file_without_decorations(pew, meta_info_env, infoFileDescription,
parserInfo, OctopusParserContext(), fname)
with open(fname) as fd:
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(
weak=True,
startReStr='',
fixedStartValues={'program_name': 'octopus'},
sections=['section_run'],
#sections=['section_run'],
subFlags=SM.SubFlags.Sequenced,
subMatchers=[
SM(r'Version\s*:\s*%s' % word('program_version')),
......@@ -29,6 +29,21 @@ class OctopusLogFileParserContext(object):
def parse_logfile(meta_info_env, pew, fname):
parse_file_without_decorations(pew, meta_info_env, logFileDescription,
parserInfo, OctopusLogFileParserContext(),
fname)
# XXX this is just a hack until we decide to do more
maxlines = 100
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)
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