Commit 6ce09bd7 authored by temok-mx's avatar temok-mx

dirty commit. I am moving files to new installation

parent b2eaed00
# Copyright 2015-2018 Ask Hjorth Larsen, Fawzi Mohamed, Ankit Kariryaa
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......@@ -311,15 +311,24 @@ def read_static_info_kpoints(fd):
def read_static_info_eigenvalues(fd, energy_unit):
#import os # tmk
values_sknx = {}
nbands = 0
for line in fd:
line = line.strip()
#print('\t\t' , line)
if line.startswith('#'):
continue
if line.startswith('Fermi'): # tmk
pass # print(line)
if not line[:1].isdigit():
# print('hithere', line)
# I SHOULD JUMP BACK ONE LINE RIGTH HERE
# fd.seek(-len(line))
# I TRIED THIS:
# fd.seek(fd.tell() - len(line))
# -> "OSError: telling position disabled by next() call"
break
tokens = line.split()
......@@ -359,20 +368,33 @@ def read_static_info_energy(fd, energy_unit):
def read_static_info(fd):
results = {}
# print('?????????????????????', type(fd)) # tmk
# print('read_static_info()@aseoct.py') # tmk
def get_energy_unit(line): # Convert "title [unit]": ---> unit
return {'[eV]': eV, '[H]': Hartree}[line.split()[1].rstrip(':')]
for line in fd:
# print('line::', line.strip())
if line.startswith('Fermi'):
#print('EUREKA:', line)
if line.strip('*').strip().startswith('Brillouin zone'):
#print('X1', line)
results.update(read_static_info_kpoints(fd))
elif line.startswith('Eigenvalues ['):
#print('X2', line)
unit = get_energy_unit(line)
results.update(read_static_info_eigenvalues(fd, unit))
fd.seek(0, 0) # TMK:
elif line.startswith('Fermi'):
#print('X2b1') # TMK:
fd.seek(-1, 1) # TMK:
#print('X2b2', line)
elif line.startswith('Energy ['):
#print('\nX3', line)
unit = get_energy_unit(line)
results.update(read_static_info_energy(fd, unit))
elif line.startswith('Total Magnetic Moment'):
#print('X4', line)
if 0:
line = next(fd)
values = line.split()
......@@ -393,10 +415,12 @@ def read_static_info(fd):
results['magmoms'] = np.array(mag_moment)
elif line.startswith('Dipole'):
#print('X5', line)
assert line.split()[-1] == '[Debye]'
dipole = [float(next(fd).split()[-1]) for i in range(3)]
results['dipole'] = np.array(dipole) * Debye
elif line.startswith('Forces'):
#print('X6', line)
forceunitspec = line.split()[-1]
forceunit = {'[eV/A]': eV / Angstrom,
'[H/b]': Hartree / Bohr}[forceunitspec]
......@@ -410,10 +434,23 @@ def read_static_info(fd):
forces.append([float(f) for f in tokens])
results['forces'] = np.array(forces) * forceunit
elif line.startswith('Fermi'):
#print('X7', line)
tokens = line.split()
unit = {'eV': eV, 'H': Hartree}[tokens[-1]]
eFermi = float(tokens[-2]) * unit
results['efermi'] = eFermi
#print('####1', line)
# TMK: MARKUS:the last `elif` should be simply `if`
# otherwise when the head `if` is True
# then all other `elif`s wont be evaluated
if line.startswith('Fermi'):
tokens = line.split()
unit = {'eV': eV, 'H': Hartree}[tokens[-1]]
eFermi = float(tokens[-2]) * unit
results['efermi'] = eFermi
print('####2', line)
if 'ibz_k_points' not in results:
results['ibz_k_points'] = np.zeros((1, 3))
......@@ -430,6 +467,7 @@ def read_static_info(fd):
break
eFermi = all_energies[arg]
results['efermi'] = eFermi
print('eFermi NOW', eFermi) # this produces bad estimate
return results
......
......@@ -58,13 +58,30 @@ is largely irrelevant.
metaInfoEnv = None
def parse_infofile(meta_info_env, pew, fname):
# print('\n\n### parse_infofile()')
# print('\tPROBLEM: {}\n\t{} ' .format(fname, 'should be static/info!!'))
with open(fname) as fd:
for line in fd:
# print(line)
if line.startswith('SCF converged'):
iterations = int(line.split()[-2])
pew.addValue('x_octopus_info_scf_converged_iterations',
iterations)
# - - - -
if line.startswith('Fermi'):
# print('\tLINE:', line)
#pew.addValue('energy_reference_fermi', fermiref)
break
# ############
# CHAT WITH MARKUS
for line in fd: # Jump down to Fermi FIXME as in FIRST BLOCK
# beware of units
# 'Fermi energy': 'energy_reference_fermi'
if line.startswith('Fermi'):
#octunit = line.strip().split()[-1].strip('[]:')
#nomadunit = {'eV': 'eV', 'H': 'hartree'}[octunit] # keep it
break
for line in fd: # Jump down to energies:
if line.startswith('Energy ['):
octunit = line.strip().split()[-1].strip('[]:')
......@@ -92,6 +109,11 @@ def parse_infofile(meta_info_env, pew, fname):
if tokens[0] in names:
pew.addValue(names[tokens[0]],
convert_unit(float(tokens[2]), nomadunit))
if tokens[0] == 'Fermi energy':
# print(tokens)
# print('#', line)
def parse_logfile(meta_info_env, pew, fname):
......@@ -241,6 +263,7 @@ parser_info = {
def read_parser_log(path):
exec_kwargs = {}
# print("\n\nPATH: ", path) # 'exec/parser.log'
with open(path) as fd:
for line in fd:
# Remove comment:
......@@ -364,6 +387,7 @@ def register_octopus_keywords(pew, category, kwargs):
def parse_without_class(fname, backend, parser_info):
# print('# ', fname )
# fname refers to the static/info file.
# Look for files before we create some of our own files for logging etc.:
# fd = stdout # Print output to stdout
......@@ -516,7 +540,7 @@ def parse_without_class(fname, backend, parser_info):
with open_section('section_single_configuration_calculation'):
pew.addValue('single_configuration_calculation_to_system_ref',
system_gid)
# print('Parse info file %s' % fname, file=fd)
# print('Parse info file %s' % fname) #, file=fd)
logging.debug('Parse info file %s' % fname)
parse_infofile(metaInfoEnv, pew, fname)
......@@ -639,5 +663,6 @@ class OctopusParserWrapper():
if __name__ == '__main__':
fname = sys.argv[1]
logfname = 'parse.log'
# print('pppp')
with open(logfname, 'w') as fd:
parse(fname, fd)
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