Commit 8b165a18 authored by Jungho Shin's avatar Jungho Shin

update main code

parent cc368278
(1) New modlue added by Jungho
NomadRepositoryParser: Entire python module of Repository parser from 'git@gitlab.mpcdf.mpg.de:NoMaD/NomadRepositoryParser.git'. This can be considered as submodule.
(2) New file added by Jungho
convert_2to3.sh: Python 2.7 scripts from the NomadRepositoryParser module needs to conver to that of Python 3.0. Only need to excute when the related files are updated from the git repository.
(3) New file added by Jungho
requirements.txt: Requirements to import NomadRepositoryParser.
......@@ -18,24 +18,21 @@ def calculateTags(inputDict, backend, calcUri):
backend.openContext(calcUri)
repoSect = backend.openSection("section_repository_info")
# fill out i.e. backend.addValue unsing input Dict
# "repository_checksum",
# "repository_chemical_formula",
# "repository_parser_id",
# "repository_atomic_elements",
# "repository_basis_set_type",
# "repository_code_version",
# "repository_crystal_system",
# "repository_program_name",
# "repository_spacegroup_nr",
# "repository_system_type",
# "repository_xc_treatment"
# add more?
#print("\n*** inputDict %s *** \n", inputDict)
work = API()
for calc, error in work._parse(inputDict, "normalizerRepo")
print("\n*** calc %s *** \n", calc)
for calc, error in work._parse("/nomad/jshin/work/normalizer/scalaOut1.txt", "normalizerRepo"):
calc, error = work.classify(calc)
backend.addValue("repository_checksum", calc.get_checksum())
backend.addValue("repository_chemical_formula", calc.info['formula']
#backend.addValue("repository_parser_id", value)
backend.addValue("repository_atomic_elements", calc.info['elements'])
backend.addValue("repository_basis_set_type", calc.info['ansatz'])
#backend.addValue("repository_code_version", value)
backend.addValue("repository_crystal_system", calc.info['symmetry'])
#backend.addValue("repository_program_name", calc.info[''])
backend.addValue("repository_spacegroup_nr", calc.info['ng'])
backend.addValue("repository_system_type", calc.info['periodicity'])
backend.addValue("repository_xc_treatment", calc.info['H_types'])
if repoSectUri:
backend.closeContext(repoSectUri)
......
2to3 -w NomadRepositoryParser/python/nomadrepo/core/settings.py
#!/bin/bash
for python_file in NomadRepositoryParser/python/nomadrepo/core/settings.py NomadRepositoryParser/python/nomadrepo/core/symmetry.py
do
2to3 -w $python_file
done
from ase import Atoms
from nomadrepo.parsers import Output
from numpy import array
class normalizerRepo(Output):
def __init__(self, filename, **kwargs):
Output.__init__(self, filename)
# fill out i.e. backend.addValue unsing input Dict
# "repository_checksum",
# "repository_chemical_formula",
# "repository_parser_id",
# "repository_atomic_elements",
# "repository_basis_set_type",
# "repository_code_version",
# "repository_crystal_system",
# "repository_program_name",
# "repository_spacegroup_nr",
# "repository_system_type",
# "repository_xc_treatment"
# add more?
filename_f = open(filename, 'r')
import json
inputDict = json.load(filename_f)[0]
filename_f.close()
atom_symbols = inputDict['section_system.last']['atom_labels']['flatData']
## Change these ##
simulation_cell = [50.0, 50.0, 50.0]
configuration_periodic_dimensions = [False, False, False]
####
atom_positions_flat = inputDict['section_system.last']['atom_positions']['flatData']
atom_positions_shape = inputDict['section_system.last']['atom_positions']['shape']
atom_positions_list = []
for atom_i in range(0, atom_positions_shape[0]):
atom_i_start = atom_i*atom_positions_shape[1]
atom_positions_list.append(atom_positions_flat[atom_i_start:atom_i_start+atom_positions_shape[1]])
atom_positions = array(atom_positions_list)
self.structures.append(Atoms(symbols = atom_symbols,
cell = simulation_cell,
positions = atom_positions,
pbc = configuration_periodic_dimensions))
self.info['energy'] = inputDict['energy_total.last']
self.info['prog'] = inputDict['program_name'][0] + ' ' + inputDict['program_version'][0]
## Need the path of mainly parsed file.
from nomadrepo.parsers.LAB.LAB import ParsingContext
from nomadrepo.parsers.LAB.LAB import save_xcFunctional
context = ParsingContext()
self.electrons['type'] = context.toDict_bs_type()[inputDict['program_name'][0]]
save_xcFunctional(self, inputDict['XC_functional_name'])
# "repository_xc_treatment"
@staticmethod
def fingerprints(test_string, file=None):
# fake method
return False
import sys, os, os.path
baseDir = os.path.dirname(os.path.abspath(__file__))
commonDir = os.path.normpath(os.path.join(baseDir,"../../../../python-common/common/python"))
repoParserDir = os.path.normpath(os.path.join(baseDir,"NomadRepositoryParser/python/"))
repoParserDir = os.path.normpath(os.path.join(baseDir,"/u/jungho/myscratch/NomadRepositoryParser/python/"))
#repoParserCoreDir = os.path.normpath(os.path.join(baseDir,"NomadRepositoryParser/python/nomadrepo/core/"))
if not commonDir in sys.path:
sys.path.insert(0, commonDir)
if not repoParserDir in sys.path:
sys.path.insert(0, repoParserDir)
#if not repoParserCoreDir in sys.path:
# sys.path.insert(0, repoParserCoreDir)
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