Commit 3837974b authored by Mikkel Strange's avatar Mikkel Strange

velocities and raw forces

parent 5f407d1b
......@@ -3,6 +3,7 @@ import os
from contextlib import contextmanager
import numpy as np
from ase.io.trajectory import Trajectory
from ase import units
import setup_paths
from constraint_conversion import get_nomad_name
from nomadcore.unit_conversion.unit_conversion import convert_unit as cu
......@@ -19,7 +20,7 @@ def open_section(p, name):
def c(value, unit=None):
""" Dummy function for unit conversion"""
return value
# return value
return cu(value, unit)
......@@ -46,8 +47,8 @@ def parse(filename):
p.addValue('program_version', 'unknown')
with o(p, 'section_topology'):
p.addValue('topology_force_field_name', 'EMT')
with o(p, 'section_constraint'):
indices = []
with o(p, 'section_constraint'): # assuming constraints do not
indices = [] # change from frame to frame
for constraint in t[0].constraints:
indices.extend(constraint.get_indices())
p.addArrayValues('constraint_atoms',
......@@ -62,26 +63,32 @@ def parse(filename):
f.get_cell(),
'angstrom')
p.addArrayValues('atom_labels',
np.asarray(t[0].get_chemical_symbols()))
np.asarray(f.get_chemical_symbols()))
p.addArrayValues('atom_positions',
c(f.get_positions(),
'angstrom'))
p.addArrayValues('configuration_periodic_dimensions',
f.get_pbc())
p.addArrayValues('atom_velocities',
c(f.get_velocities() * units.fs /
units.Angstrom,
'angstrom/femtosecond'))
p.addArrayValues('atom_velocities', f.get_velocities())
with o(p, 'section_single_configuration_calculation'):
p.addValue('single_configuration_to_calculation_method_ref',
method_gid)
p.addValue('single_configuration_calculation_to_system_ref',
system_gid)
mref = 'single_configuration_to_calculation_method_ref'
sref = 'single_configuration_calculation_to_system_ref'
p.addValue(mref, method_gid)
p.addValue(sref, system_gid)
p.addRealValue('energy_total',
c(f.get_total_energy(), 'eV'))
p.addArrayValues('atom_forces',
c(f.get_forces(), 'angstrom/eV'))
c(f.get_forces(),
'angstrom/eV'))
p.addArrayValues('atom_forces_raw',
c(f.get_forces(apply_constraint=False),
'angstrom/eV'))
with o(p, 'section_sampling_method'):
p.addValue('ensemble_type', 'NVE')
# p.addValue('x_asap_electronic_structure_method', 'EMT')
p.finishedParsingSession("ParseSuccess", None)
if __name__ == '__main__':
......
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