Skip to content
Snippets Groups Projects
Commit 57c4b80e authored by Mohamed, Fawzi Roberto (fawzi)'s avatar Mohamed, Fawzi Roberto (fawzi)
Browse files

Henrik's initial version of quasi harmonic parser

parents
Branches
Tags 0.0.0
No related merge requests found
import numpy as np
from nomadcore.unit_conversion.unit_conversion import convert_unit_function
from nomadcore.parser_backend import *
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from phonopy.units import EvTokJmol, Kb as kBoltzmann
parser_info = {"name": "parser_quasi_harmonic_properties", "version": "1.0"}
path = "../../../../nomad-meta-info/meta_info/nomad_meta_info/quasi-harmonic-properties.nomadmetainfo.json"
metaInfoPath = os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), path))
metaInfoEnv, warns = loadJsonFile(filePath=metaInfoPath,
dependencyLoader=None,
extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
uri=None)
def parse(name):
Parse = JsonParseEventsWriterBackend(metaInfoEnv)
Parse.startedParsingSession(name, parser_info)
sRun = Parse.openSection("section_run")
system = Parse.openSection("section_system")
Parse.addValue("spacegroup_3D_number", spacegroup)
springermat = Parse.openSection("section_springer_material")
Parse.addValue("springer_formula", material)
Parse.closeSection("section_springer_material", springermat)
Parse.closeSection("section_system", system)
results = Parse.openSection("section_single_configuration_calculation")
sTD = Parse.openSection("section_thermodynamical_properties")
fref = Parse.openSection("section_calculation_to_folder_refs")
Parse.addValue("calculation_to_folder_kind", "folder_containing_calculations")
Parse.addValue("calculation_to_folder_external_url", name)
Parse.closeSection("section_calculation_to_folder_refs", fref)
Parse.addArrayValues("thermodynamical_property_temperature", T)
Parse.addArrayValues("thermodynamical_property_heat_capacity_C_v", cV)
Parse.addArrayValues("x_qhp_quasi_harmonic_free_energy", Free)
Parse.addArrayValues("x_qhp_quasi_harmonic_bulk_modulus", B)
Parse.addArrayValues("x_qhp_quasi_harmonic_volume", V)
Parse.addArrayValues("x_qhp_quasi_harmonic_thermal_expansion", alpha)
Parse.closeSection("section_thermodynamical_properties", sTD)
Parse.closeSection("section_single_configuration_calculation", results)
Parse.closeSection("section_run", sRun)
Parse.finishedParsingSession("ParseSuccess", None)
if __name__ == '__main__':
import sys
parser = argparse.ArgumentParser(description='Parses a txt file containing quasi harmonic data.')
parser.add_argument('mainFileUri',
help='The uri of the main file associated with this calculation.')
parser.add_argument('mainFilePath', default = None,
help='The path to the main file associated with this calculation.')
args = parser.parse_args()
if args.mainFilePath:
mainDir = os.path.dirname(os.path.dirname(os.path.abspath(args.mainFilePath)))
os.chdir(mainDir)
with open("Quasiharmonic_properties.txt") as qh:
for line in qh:
if "Quasi-harmonic" in line:
spacegroup = line.split()[-1]
material = line.split()[-3]
name = args.mainFileUri
T, V, alpha, B, Free, cV = np.loadtxt("Quasiharmonic_properties.txt")
cV = kBoltzmann / JmolToEv * cV
cubAtocubm = convert_unit_function('a**3', 'm**3')
eVpercubAtoJoulespercubm = convert_unit_function('eV*a**-3', 'joules*m**-3')
eVtoJoules = convert_unit_function('eV', 'joules')
eVperKtoJoules = convert_unit_function('eV*K**-1', 'joules*K**-1')
Free = eVtoJoules(Free)
V = cubAtocubm(V)
B = eVpercubAtoJoulespercubm(B)
cV = eVperKtoJoules(cV)
parse(name)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment