Commit aec0fda5 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added more NOMAD parsers.

parent d41015e7
......@@ -52,3 +52,5 @@ TAGS
lib/
env/
*.egg-info
\ No newline at end of file
# Copyright 2018-2018 Berk Onat, Fawzi Mohamed
#
#
# 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.
# See the License for the specific language governing permissions and
# limitations under the License.
import setup_paths
import numpy as np
from NAMDCommon import PARSERNAME, PROGRAMNAME, PARSERTAG
from .NAMDCommon import PARSERNAME, PROGRAMNAME, PARSERTAG
from nomadcore.smart_parser.SmartParserDictionary import metaNameConverter, metaNameConverter_UnderscoreSpaceDash
from nomadcore.smart_parser.SmartParserDictionary import MetaInfoMap, FileInfoMap, MapDictionary
from nomadcore.smart_parser.SmartParserDictionary import MetaInfoMap, FileInfoMap, MapDictionary
from nomadcore.smart_parser.SmartParserDictionary import getDict_MetaStrInDict, getList_MetaStrInDict, get_unitDict
import nomadcore.md_data_access.MDDataAccess as MDData
......@@ -26,7 +25,7 @@ def get_fileListDict():
Returns:
the list of defaults file namelists
"""
startpage = {
'nameTranslate' : metaNameConverter,
'metaHeader' : PARSERTAG,
......@@ -36,19 +35,19 @@ def get_fileListDict():
'activeSections' : [PARSERTAG+'_section_input_output_files']
}
namelist = {
'structure' : FileInfoMap(startpage, fileFormat=['.psf'], activeInfo=True,
'structure' : FileInfoMap(startpage, fileFormat=['.psf'], activeInfo=True,
infoPurpose=['topology', 'unitcell']),
'traj_coord' : FileInfoMap(startpage, fileFormat=['.dcd'], activeInfo=True,
'traj_coord' : FileInfoMap(startpage, fileFormat=['.dcd'], activeInfo=True,
infoPurpose=['trajectory', 'unitcell']),
'traj_vel' : FileInfoMap(startpage, fileFormat=['.dcd'], activeInfo=True,
infoPurpose=['velocities']),
'traj_force' : FileInfoMap(startpage, fileFormat=['.dcd'], activeInfo=True,
'traj_force' : FileInfoMap(startpage, fileFormat=['.dcd'], activeInfo=True,
infoPurpose=['forces']),
'output_coord' : FileInfoMap(startpage, fileFormat=['.namdbin'], activeInfo=False,
infoPurpose=['outputcoordinates', 'unitcell']),
'output_vel' : FileInfoMap(startpage, fileFormat=['.namdbin'], activeInfo=False,
'output_vel' : FileInfoMap(startpage, fileFormat=['.namdbin'], activeInfo=False,
infoPurpose=['outputvelocities']),
'output_force' : FileInfoMap(startpage, fileFormat=['.namdbin'], activeInfo=False,
'output_force' : FileInfoMap(startpage, fileFormat=['.namdbin'], activeInfo=False,
infoPurpose=['outputforces']),
'input_coord' : FileInfoMap(startpage, fileFormat=['.pdb'],
infoPurpose=['inputcoordinates', 'inputunitcell']),
......@@ -71,11 +70,11 @@ def get_nameListDict(deflist):
matchWith parameters:
EOL = End of line
PL = Match with previous line
PL = Match with previous line
PW = Previous word
NW = Next word (until space, comma) (DEFAULT)
UD = until delimeter (can be any string/character)
The text matched inside apostrophe or qoutation is extracted
Returns:
......@@ -224,11 +223,11 @@ def get_nameListDict(deflist):
'activeSections' : ['section_single_configuration_calculation']
})
mddatalist = {
'WRITING COORDINATES TO DCD FILE' : MetaInfoMap(startpage,
'WRITING COORDINATES TO DCD FILE' : MetaInfoMap(startpage,
replaceTag='DCDSTEP', subFunc=lambda x: x.split()[-1].replace('\n','').strip()),
'WRITING VELOCITIES TO DCD FILE AT STEP' : MetaInfoMap(startpage,
'WRITING VELOCITIES TO DCD FILE AT STEP' : MetaInfoMap(startpage,
replaceTag='VELSTEP', subFunc=lambda x: x.replace('\n','').strip()),
'WRITING FORCES TO DCD FILE AT STEP' : MetaInfoMap(startpage,
'WRITING FORCES TO DCD FILE AT STEP' : MetaInfoMap(startpage,
replaceTag='FORCESTEP', subFunc=lambda x: x.replace('\n','').strip()),
'TS' : MetaInfoMap(startpage),
'BOND' : MetaInfoMap(startpage),
......@@ -299,7 +298,7 @@ def set_Dictionaries(self):
self.stepcontrolDict = {
'logsteps' : None,
'nextlogsteps' : None,
'trajsteps' : None,
'trajsteps' : None,
'velsteps' : None,
'forcesteps' : None,
'steps' : None,
......@@ -313,12 +312,12 @@ def set_Dictionaries(self):
'mddata' : self.mddataDict,
'extra' : self.extraDict,
}
self.sectionDict = {
'section' : {
"metaNameTag" : ['input_output_files',
'control_parameters'],
"listTypStr" : 'type_section',
"repeatingSection" : False,
self.sectionDict = {
'section' : {
"metaNameTag" : ['input_output_files',
'control_parameters'],
"listTypStr" : 'type_section',
"repeatingSection" : False,
"supraNames" : ["section_run"]
}
}
......@@ -340,7 +339,7 @@ def get_updateDictionary(self, defname):
if(st is not None and isinstance(st, str)):
if("[" in st or "(" in st):
val.append(list(storedtext))
if val:
if val:
return False, np.linalg.norm(np.asarray(val)), itemdict
else:
return False, itemdict["value"], itemdict
......@@ -355,27 +354,27 @@ def get_updateDictionary(self, defname):
# ---------------------------------------------------------------
# Definitions of meta data values for section_sampling_method
# ---------------------------------------------------------------
sampling = {
sampling = {
'ensemble_type' : MetaInfoMap(startpage, activeInfo=True,
depends=[
{'test' : [['minimization', ' is None'],
{'test' : [['minimization', ' is None'],
['thermostat', ' in [\"tcouple\",'
'\"rescale\",'
'\"reassign\",'
'\"andersen\",'
'\"langevin\"]'],
'\"langevin\"]'],
['barostat', ' in [\"berendsen\",'
'\"langevin\"]']],
'\"langevin\"]']],
'assign' : 'NPT'},
{'test' : [['minimization', ' is None'],
['thermostat', ' in [\"langevin\"]'],
{'test' : [['minimization', ' is None'],
['thermostat', ' in [\"langevin\"]'],
['thermostat', ' not in [\"tcouple\",'
'\"rescale\",'
'\"reassign\",'
'\"andersen\"]'],
['barostat', ' is None']],
'assign' : 'Langevin'},
{'test' : [['minimization', ' is None'],
{'test' : [['minimization', ' is None'],
['thermostat', ' in [\"tcouple\",'
'\"rescale\",'
'\"reassign\",'
......@@ -384,16 +383,16 @@ def get_updateDictionary(self, defname):
'assign' : 'NVT'},
{'test' : [['minimization', ' is None'],
['thermostat', ' is None'],
['barostat', ' is None']],
['barostat', ' is None']],
'assign' : 'NVE'},
{'test' : [['minimization', ' is not None']],
{'test' : [['minimization', ' is not None']],
'assign' : 'minimization'},
],
lookupdict=self.extraDict
),
'sampling_method' : MetaInfoMap(startpage, activeInfo=True,
'sampling_method' : MetaInfoMap(startpage, activeInfo=True,
depends=[
{'test' : [['minimization', ' is not None']],
{'test' : [['minimization', ' is not None']],
'assign' : 'geometry_optimization'},
{'test' : [['minimization', ' is None']],
'assign' : 'molecular_dynamics'}
......@@ -413,9 +412,9 @@ def get_updateDictionary(self, defname):
# 'geometry_optimization_geometry_change' : MetaInfoMap(startpage),
'geometry_optimization_method' : MetaInfoMap(startpage,
depends=[
{'test' : [['minimization', ' == \"cg\"']],
{'test' : [['minimization', ' == \"cg\"']],
'assign' : 'CG'},
{'test' : [['minimization', ' == \"quench\"']],
{'test' : [['minimization', ' == \"quench\"']],
'assign' : 'Velocity Quenching'},
],
lookupdict=self.extraDict,
......@@ -424,12 +423,12 @@ def get_updateDictionary(self, defname):
# 'geometry_optimization_threshold_force' : MetaInfoMap(startpage),
'x_namd_barostat_type' : MetaInfoMap(startpage,
depends=[
{'test' : [['minimization', ' is None'],
{'test' : [['minimization', ' is None'],
['barostat', '== \"berendsen\"']],
'assign' : 'Berendsen'},
{'test' : [['minimization', ' is None'],
{'test' : [['minimization', ' is None'],
['barostat', '== \"langevin\"']],
'assign' : 'Nose-Hoover Langevin'}
'assign' : 'Nose-Hoover Langevin'}
],
lookupdict=self.extraDict,
#autoSections=True,
......@@ -439,7 +438,7 @@ def get_updateDictionary(self, defname):
'x_namd_barostat_target_pressure' : MetaInfoMap(startpage,
depends=[
{'test' : [['TARGET PRESSURE', ' is not None']],
'value' : 'TARGET PRESSURE'}
'value' : 'TARGET PRESSURE'}
],
lookupdict=self.cntrlDict,
valtype='float',
......@@ -452,9 +451,9 @@ def get_updateDictionary(self, defname):
'x_namd_barostat_tau' : MetaInfoMap(startpage,
depends=[
{'test' : [['LANGEVIN OSCILLATION PERIOD', ' is not None']],
'value' : 'LANGEVIN OSCILLATION PERIOD'},
'value' : 'LANGEVIN OSCILLATION PERIOD'},
{'test' : [['BERENDSEN RELAXATION TIME', ' is not None']],
'value' : 'BERENDSEN RELAXATION TIME'}
'value' : 'BERENDSEN RELAXATION TIME'}
],
lookupdict=self.cntrlDict,
valtype='float',
......@@ -467,7 +466,7 @@ def get_updateDictionary(self, defname):
'x_namd_integrator_type' : MetaInfoMap(startpage,
depends=[
{'test' : [['integrator', ' is not None']],
'value' : 'integrator'},
'value' : 'integrator'},
{'test' : [['thermostat', ' == \"langevin\"']],
'assign' : 'Langevin'}
],
......@@ -500,21 +499,21 @@ def get_updateDictionary(self, defname):
),
'x_namd_thermostat_type' : MetaInfoMap(startpage,
depends=[
{'test' : [['minimization', ' is None'],
{'test' : [['minimization', ' is None'],
['thermostat', ' == \"tcouple\"']],
'assign' : 'Berendsen'},
{'test' : [['minimization', ' is None'],
'assign' : 'Berendsen'},
{'test' : [['minimization', ' is None'],
['thermostat', ' == \"rescale\"']],
'assign' : 'Velocity Rescaling'},
{'test' : [['minimization', ' is None'],
'assign' : 'Velocity Rescaling'},
{'test' : [['minimization', ' is None'],
['thermostat', ' == \"reassign\"']],
'assign' : 'Velocity Reassigning'},
{'test' : [['minimization', ' is None'],
'assign' : 'Velocity Reassigning'},
{'test' : [['minimization', ' is None'],
['thermostat', ' == \"andersen\"']],
'assign' : 'Andersen'},
{'test' : [['minimization', ' is None'],
['thermostat', ' == \"langevin\"']],
'assign' : 'Nose-Hoover Langevin'},
'assign' : 'Andersen'},
{'test' : [['minimization', ' is None'],
['thermostat', ' == \"langevin\"']],
'assign' : 'Nose-Hoover Langevin'},
],
lookupdict=self.extraDict,
#autoSections=True,
......@@ -592,7 +591,7 @@ def get_updateDictionary(self, defname):
# ------------------------------------------------------------
# Definitions for section_single_configuration_calculation
# ------------------------------------------------------------
singleconfcalc = {
singleconfcalc = {
#'atom_forces_type' : MetaInfoMap(startpage,
# depends=[{'assign' : 'Force Field'}],
# lookupdict=self.mddataDict
......@@ -648,7 +647,7 @@ def get_updateDictionary(self, defname):
'time_single_configuration_calculation_wall_start' : MetaInfoMap(startpage),
#'stress_tensor_kind' : MetaInfoMap(startpage,
# depends=[
# {'test' : [['minimization', ' is not None']],
# {'test' : [['minimization', ' is not None']],
# 'assign' : 'geometry_optimization'},
# {'test' : [['minimization', ' is None']],
# 'assign' : 'molecular_dynamics'}
......@@ -671,11 +670,11 @@ def get_updateDictionary(self, defname):
activeSections=['section_energy_van_der_Waals']
),
}
# ------------------------------------------
# Definitions for section_frame_sequence
# ------------------------------------------
frameseq = {
frameseq = {
#'frame_sequence_conserved_quantity_frames' : MetaInfoMap(startpage,
# depends=[{'store' : 'TS'}],
# valtype='int',
......@@ -950,7 +949,7 @@ def get_updateDictionary(self, defname):
#'previous_sequence_ref' : MetaInfoMap(startpage)
}
frameseqend = {
frameseqend = {
#'number_of_conserved_quantity_evaluations_in_sequence' : MetaInfoMap(startpage,
# activeInfo=True,
# value=(lambda x: np.array(x['val']).flatten().shape[0] if(
......@@ -1158,7 +1157,7 @@ def get_updateDictionary(self, defname):
'spacegroup_3D_wyckoff' : MetaInfoMap(startpage),
'symmorphic' : MetaInfoMap(startpage),
'system_name' : MetaInfoMap(startpage,
subfunction={
subfunction={
'function' : MDData.MDDataConverter.topology_system_name,
'supportDict' : self.topoDict,
},
......@@ -1285,7 +1284,7 @@ def get_updateDictionary(self, defname):
'number_of_atoms_per_molecule_interaction' : MetaInfoMap(startpage),
'number_of_molecule_interactions' : MetaInfoMap(startpage)
}
# section_atom_in_molecule of section_molecule_type
atom_in_mol = {
'atom_in_molecule_charge' : MetaInfoMap(startpage),
......
# Copyright 2018-2018 Berk Onat, Fawzi Mohamed
#
#
# 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.
......@@ -15,7 +15,6 @@
from builtins import map
from builtins import range
from builtins import object
import setup_paths
import numpy as np
import nomadcore.ActivateLogging
from nomadcore.caching_backend import CachingLevel
......@@ -24,9 +23,9 @@ from nomadcore.smart_parser import SmartParserCommon as SmartParser
from nomadcore.smart_parser.SmartParserCommon import get_metaInfo, conv_str, conv_int, conv_float, open_section
from nomadcore.smart_parser.SmartParserDictionary import getList_MetaStrInDict, getDict_MetaStrInDict
from nomadcore.smart_parser.SmartParserDictionary import isMetaStrInDict
from NAMDDictionary import get_updateDictionary, set_Dictionaries
from NAMDCommon import PARSERNAME, PROGRAMNAME, PARSERVERSION, PARSERTAG, LOGGER
from NAMDCommon import PARSER_INFO_DEFAULT, META_INFO_PATH, set_excludeList, set_includeList
from .NAMDDictionary import get_updateDictionary, set_Dictionaries
from .NAMDCommon import PARSERNAME, PROGRAMNAME, PARSERVERSION, PARSERTAG, LOGGER
from .NAMDCommon import PARSER_INFO_DEFAULT, META_INFO_PATH, set_excludeList, set_includeList
from nomadcore.md_data_access import MDDataAccess as MDDA
import argparse
import logging
......@@ -61,7 +60,7 @@ class NAMDParser(SmartParser.ParserBase):
}
SmartParser.ParserBase.__init__(
self, re_program_name=re.compile(r"\s*"+PROGRAMNAME+"$"),
parsertag=PARSERTAG, metainfopath=META_INFO_PATH,
parsertag=PARSERTAG, metainfopath=META_INFO_PATH,
parserinfodef=PARSER_INFO_DEFAULT)
set_Dictionaries(self)
......@@ -79,27 +78,27 @@ class NAMDParser(SmartParser.ParserBase):
metaInfo = self.metaInfoEnv.infoKinds[name]
if (name.startswith(PARSERTAG + '_mdin_') and
metaInfo.kindStr == "type_document_content" and
(PARSERTAG + "_mdin_method" in metaInfo.superNames or
PARSERTAG + "_mdin_run" in metaInfo.superNames or
(PARSERTAG + "_mdin_method" in metaInfo.superNames or
PARSERTAG + "_mdin_run" in metaInfo.superNames or
PARSERTAG + "_mdin_system" in metaInfo.superNames) or
name.startswith(PARSERTAG + '_parm_') and
metaInfo.kindStr == "type_document_content" and
(PARSERTAG + "_mdin_method" in metaInfo.superNames or
(PARSERTAG + "_mdin_method" in metaInfo.superNames or
PARSERTAG + "_mdin_run" in metaInfo.superNames or
PARSERTAG + "_mdin_system" in metaInfo.superNames) or
#name.startswith(PARSERTAG + '_mdin_file_') and
name.startswith(PARSERTAG + '_inout_file_') or
#metaInfo.kindStr == "type_document_content" and
#(PARSERTAG + "_section_input_output_files" in metaInfo.superNames or
#(PARSERTAG + "_section_input_output_files" in metaInfo.superNames or
# "section_run" in metaInfo.superNames) or
name.startswith(PARSERTAG + '_inout_control_') or
#(PARSERTAG + "_section_control_parameters" in metaInfo.superNames) or
#(PARSERTAG + "_section_control_parameters" in metaInfo.superNames) or
#name.startswith(PARSERTAG + '_mdin_') and
#(PARSERTAG + "_section_control_parameters" in metaInfo.superNames) or
name.startswith(PARSERTAG + '_mdout_') or
name.startswith(PARSERTAG + '_mdout_') and
#metaInfo.kindStr == "type_document_content" and
(PARSERTAG + "_mdout_method" in metaInfo.superNames or
(PARSERTAG + "_mdout_method" in metaInfo.superNames or
PARSERTAG + "_mdout_system" in metaInfo.superNames or
"section_run" in metaInfo.superNames or
PARSERTAG + "_mdout_single_configuration_calculation" in metaInfo.superNames)
......@@ -197,8 +196,8 @@ class NAMDParser(SmartParser.ParserBase):
def onClose_section_run(self, backend, gIndex, section):
"""Trigger called when section_run is closed.
Write the keywords from control parametres and
the NAMD output from the parsed log output,
Write the keywords from control parametres and
the NAMD output from the parsed log output,
which belong to settings_run.
Variables are reset to ensure clean start for new run.
"""
......@@ -211,7 +210,7 @@ class NAMDParser(SmartParser.ParserBase):
'dictionary' : section_frameseq_Dict
}
self.metaStorage.update(updateFrameDict)
self.metaStorage.updateBackend(backend.superBackend,
self.metaStorage.updateBackend(backend.superBackend,
startsection=['section_frame_sequence'],
autoopenclose=False)
backend.addValue("frame_sequence_to_sampling_ref", self.secSamplingGIndex)
......@@ -226,14 +225,14 @@ class NAMDParser(SmartParser.ParserBase):
Determine whether topology, trajectory and input coordinate files are
supplied to the parser
Initiates topology and trajectory file handles.
Captures topology, atomic positions, atom labels, lattice vectors and
stores them before section_system and
Captures topology, atomic positions, atom labels, lattice vectors and
stores them before section_system and
section_single_configuration_calculation are encountered.
"""
# Checking whether topology, input
# Checking whether topology, input
# coordinates and trajectory files exist
atLeastOneFileExist = False
working_dir_name = os.path.dirname(os.path.abspath(self.fName))
......@@ -287,7 +286,7 @@ class NAMDParser(SmartParser.ParserBase):
'dictionary' : section_control_Dict
}
self.metaStorage.update(updateDict)
self.metaStorage.updateBackend(backend.superBackend,
self.metaStorage.updateBackend(backend.superBackend,
startsection=[PARSERTAG+'_section_control_parameters'],
autoopenclose=False)
nparms = 0
......@@ -298,7 +297,7 @@ class NAMDParser(SmartParser.ParserBase):
if nparms>0:
backend.superBackend.addValue(PARSERTAG+"_inout_control_number_of_parameters", int(nparms))
# NAMD prints the initial and final energies to the log file.
# The total number of MD steps in NAMD is nsteps irrelevant
# The total number of MD steps in NAMD is nsteps irrelevant
# to the number of steps in log file of energy file (.edr)
nsteps = 0
nlogsteps = 0
......@@ -307,8 +306,8 @@ class NAMDParser(SmartParser.ParserBase):
noutputstep = 0
nbinsteps = 0
ntrajsteps = 0
nvelsteps = 0
nforcesteps = 0
nvelsteps = 0
nforcesteps = 0
nstructKey = isMetaStrInDict("STRUCTURE FILE",self.cntrlDict)
ninputKey = isMetaStrInDict("COORDINATE PDB",self.cntrlDict)
noutputKey = isMetaStrInDict("OUTPUT FILENAME",self.cntrlDict)
......@@ -354,7 +353,7 @@ class NAMDParser(SmartParser.ParserBase):
if nfoutKey is not None:
if self.cntrlDict[nfoutKey].activeInfo:
nforcesteps = conv_int(self.cntrlDict[nfoutKey].value, default=0)
if nlogsteps>0:
logsteps = [i for i in range(0, nsteps, nlogsteps)]
logsteps.append(nsteps)
......@@ -442,11 +441,11 @@ class NAMDParser(SmartParser.ParserBase):
'dictionary' : section_sampling_Dict
}
self.metaStorage.update(updateDict)
self.metaStorage.updateBackend(backend.superBackend,
self.metaStorage.updateBackend(backend.superBackend,
startsection=['section_run'],
#startsection=['section_sampling_method'],
autoopenclose=False)
def onOpen_section_topology(self, backend, gIndex, section):
# keep track of the latest topology description section
if (gIndex is None or gIndex == -1 or gIndex == "-1"):
......@@ -465,7 +464,7 @@ class NAMDParser(SmartParser.ParserBase):
'dictionary' : section_topology_Dict
}
self.metaStorage.update(updateDict)
self.metaStorage.updateBackend(backend.superBackend,
self.metaStorage.updateBackend(backend.superBackend,
startsection=['section_topology'],
autoopenclose=False)
self.topology_atom_type_and_interactions(backend, gIndex)
......@@ -491,7 +490,7 @@ class NAMDParser(SmartParser.ParserBase):
SloppyBackend = backend.superBackend
else:
SloppyBackend = backend
numatoms = None
# NAMD default unit vectors. If all are zeros than the simulation cell is not periodic.
......@@ -515,10 +514,10 @@ class NAMDParser(SmartParser.ParserBase):
if self.trajectory is not None:
if self.trajectory.unitcell_vectors is None:
self.trajectory.unitcell_vectors = unit_vectors
if self.topology:
if (self.secTopologyGIndex is None or
(self.secTopologyGIndex == -1 or
(self.secTopologyGIndex == -1 or
self.secTopologyGIndex == "-1")):
self.onOpen_section_topology(backend, None, None)
self.onClose_section_topology(backend, None, None)
......@@ -529,7 +528,7 @@ class NAMDParser(SmartParser.ParserBase):
if self.trajectory is not None:
coordinates=self.trajectory
positions=self.atompositions
elif(self.inputcoords is not None and
elif(self.inputcoords is not None and
self.MDcurrentstep == steps[0]):
coordinates=self.inputcoords
positions=self.inputpositions
......@@ -557,9 +556,9 @@ class NAMDParser(SmartParser.ParserBase):
SloppyBackend.addArrayValues('atom_positions', np.transpose(np.asarray(
self.metaStorage.convertUnits(positions, "Angstrom", self.unitDict))))
if coordinates.velocities is not None:
# Velocities in PDB files are stored in A/ps units.(PDB files are read for input
# Velocities in PDB files are stored in A/ps units.(PDB files are read for input
# coordinates, velocities, and forces)
# Velocities in NAMD binary/DCD files are stored in NAMD internal units and must be multiplied
# Velocities in NAMD binary/DCD files are stored in NAMD internal units and must be multiplied
# by PDBVELFACTOR=20.45482706 to convert to A/ps. (These files are used for output trajectory)
SloppyBackend.addArrayValues('atom_velocities', np.transpose(np.asarray(
self.metaStorage.convertUnits(
......@@ -663,7 +662,7 @@ class NAMDParser(SmartParser.ParserBase):
}
self.secVDWGIndex = backend.superBackend.openSection("section_energy_van_der_Waals")
self.metaStorage.update(updateDictVDW)
self.metaStorage.updateBackend(backend.superBackend,
self.metaStorage.updateBackend(backend.superBackend,
startsection=['section_energy_van_der_Waals'],
autoopenclose=False)
backend.superBackend.closeSection("section_energy_van_der_Waals", self.secVDWGIndex)
......@@ -675,7 +674,7 @@ class NAMDParser(SmartParser.ParserBase):
'dictionary' : section_singlecalc_Dict
}
self.metaStorage.update(updateDict)
self.metaStorage.updateBackend(backend.superBackend,
self.metaStorage.updateBackend(backend.superBackend,
startsection=['section_single_configuration_calculation'],
autoopenclose=False)
if self.MDcurrentstep in forcesteps:
......@@ -688,7 +687,7 @@ class NAMDParser(SmartParser.ParserBase):
self.atompositions.velocities, "kcal/(mol*Angstrom)", self.unitDict))))
# need to transpose array since its shape is [number_of_atoms,3] in the metadata
if(self.MDcurrentstep in trajsteps or
if(self.MDcurrentstep in trajsteps or
self.MDcurrentstep in velsteps):
#print("PRINTING traj steps:",self.MDcurrentstep,trajsteps)
self.onOpen_section_system(backend, None, None)
......@@ -696,12 +695,12 @@ class NAMDParser(SmartParser.ParserBase):
backend.addValue('single_configuration_calculation_to_system_ref', self.secSystemGIndex)
self.MDiter += 1
else:
if(self.MDcurrentstep in logsteps or
if(self.MDcurrentstep in logsteps or
self.MDcurrentstep in forcesteps):
self.MDiter += 1
#if((self.MDcurrentstep in logsteps and
# self.MDiter+1 in steps) or
# (self.MDcurrentstep in forcesteps and
#if((self.MDcurrentstep in logsteps and
# self.MDiter+1 in steps) or
# (self.MDcurrentstep in forcesteps and
# self.MDiter+1 in steps)):
# self.MDiter += 1
#if self.MDiter<len(steps):
......@@ -735,7 +734,7 @@ class NAMDParser(SmartParser.ParserBase):
if fname in k:
return value+v
return value
def mdInfoTrans(self, fname, value):
mdInfoDict = {
"minimization" : [],
......@@ -792,7 +791,7 @@ class NAMDParser(SmartParser.ParserBase):
else:
return value
return value
def convertInt(self, fname, value):
keyMapper = {
"TS" : "MDcurrentstep",
......@@ -820,7 +819,7 @@ class NAMDParser(SmartParser.ParserBase):
if fname in k:
return float(value)*timestep
return value
def build_subMatchers(self):
"""Builds the sub matchers to parse the main output file.
"""
......@@ -834,24 +833,24 @@ class NAMDParser(SmartParser.ParserBase):
"waitlist" : None,
"stopOnMatchStr" : r"(?:^\s*$|\s*ENERGY:\s*)",