Skip to content

Commit

Permalink
Merge pull request #43 from JPchico/workchains
Browse files Browse the repository at this point in the history
Fixing an issue in which the arrays names do not conform to aiida's standards
  • Loading branch information
JPchico authored Jun 16, 2022
2 parents ee2a009 + c612773 commit e7186d7
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 60 deletions.
2 changes: 1 addition & 1 deletion aiida_lammps/calculations/lammps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BaseLammpsCalculation(CalcJob):

_DEFAULT_LOGFILE_FILENAME = "log.lammps"
_DEFAULT_OUTPUT_FILENAME = "lammps_output"
_DEFAULT_TRAJECTORY_FILENAME = "aiida_lampps.trajectory.dump"
_DEFAULT_TRAJECTORY_FILENAME = "aiida_lammps.trajectory.dump"
_DEFAULT_VARIABLES_FILENAME = "aiida_lammps.yaml"
_DEFAULT_RESTART_FILENAME = "lammps.restart"
_DEFAULT_POTENTIAL_FILENAME = "potential.dat"
Expand Down
4 changes: 2 additions & 2 deletions aiida_lammps/common/generate_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def generate_lammps_structure(
:param structure: the structure to use in the simulation
:type structure: orm.StructureData
:param atom_style: treatment of the particles accroding to lammps, defaults to 'atomic'
:param atom_style: treatment of the particles according to lammps, defaults to 'atomic'
:type atom_style: str, optional
:param charge_dict: dictionary with the charge for the particles, defaults to None
:type charge_dict: dict, optional
:param round_dp: precision to which to round the postions, defaults to None
:param round_dp: precision to which to round the positions, defaults to None
:type round_dp: float, optional
:param docstring: header for the structure file, defaults to 'generated by aiida_lammps'
:type docstring: str, optional
Expand Down
3 changes: 2 additions & 1 deletion aiida_lammps/common/input_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from builtins import ValueError
import json
import os
import re
from typing import Union

from aiida import orm
Expand Down Expand Up @@ -437,7 +438,7 @@ def write_final_variables_block(
variables_block = generate_header("Start of the Final Variables information")

for _thermo in fixed_thermo:
_variables.append(_thermo.replace("[", "_").replace("]", ""))
_variables.append(re.sub("[^a-zA-Z0-9_]", "__", _thermo))
variables_block += f"variable final_{_variables[-1]} equal {_thermo}\n"
variables_block += generate_header("End of the Final Variables information")

Expand Down
5 changes: 4 additions & 1 deletion aiida_lammps/common/parse_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
# pylint: disable=fixme
from collections import namedtuple
import re

from aiida import orm
import numpy as np
Expand Down Expand Up @@ -88,7 +89,9 @@ def parse_step(lines, initial_line=0) -> namedtuple:
]
)
cell = super_cell.T
field_names = lines[8].split()[2:]
field_names = [
re.sub("[^a-zA-Z0-9_]", "__", entry) for entry in lines[8].split()[2:]
]
fields = []
for i in range(number_of_atoms):
fields.append(lines[9 + i].split())
Expand Down
4 changes: 3 additions & 1 deletion aiida_lammps/common/raw_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def parse_logfile(filename: str = None, file_contents: str = None) -> Union[dict
global_parsed_data["bin"] = line.split()[-1]
if line.startswith("Step"):
header_line_position = index
header_line = line.split()
header_line = [
re.sub("[^a-zA-Z0-9_]", "__", entry) for entry in line.split()
]
if header_line_position > 0 and index != header_line_position and not end_found:
if not line.split()[0].replace(".", "", 1).isdigit():
end_found = True
Expand Down
12 changes: 6 additions & 6 deletions tests/test_calculations/test_optimize_process_eam_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ trajectory_data:
elements:
- Fe
field_names:
- c_stpa[1]
- c_stpa[2]
- c_stpa[3]
- c_stpa[4]
- c_stpa[5]
- c_stpa[6]
- c_stpa__1__
- c_stpa__2__
- c_stpa__3__
- c_stpa__4__
- c_stpa__5__
- c_stpa__6__
- element
- fx
- fy
Expand Down
12 changes: 6 additions & 6 deletions tests/test_calculations/test_optimize_process_lennard_jones_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ trajectory_data:
elements:
- Ar
field_names:
- c_stpa[1]
- c_stpa[2]
- c_stpa[3]
- c_stpa[4]
- c_stpa[5]
- c_stpa[6]
- c_stpa__1__
- c_stpa__2__
- c_stpa__3__
- c_stpa__4__
- c_stpa__5__
- c_stpa__6__
- element
- fx
- fy
Expand Down
12 changes: 6 additions & 6 deletions tests/test_calculations/test_optimize_process_reaxff_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ trajectory_data:
- Fe
- S
field_names:
- c_stpa[1]
- c_stpa[2]
- c_stpa[3]
- c_stpa[4]
- c_stpa[5]
- c_stpa[6]
- c_stpa__1__
- c_stpa__2__
- c_stpa__3__
- c_stpa__4__
- c_stpa__5__
- c_stpa__6__
- element
- fx
- fy
Expand Down
12 changes: 6 additions & 6 deletions tests/test_calculations/test_optimize_process_tersoff_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ trajectory_data:
- Ga
- N
field_names:
- c_stpa[1]
- c_stpa[2]
- c_stpa[3]
- c_stpa[4]
- c_stpa[5]
- c_stpa[6]
- c_stpa__1__
- c_stpa__2__
- c_stpa__3__
- c_stpa__4__
- c_stpa__5__
- c_stpa__6__
- element
- fx
- fy
Expand Down
24 changes: 12 additions & 12 deletions tests/test_generate_inputs/test_generate_input_eam_alloy_md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ variable final_pyy equal pyy
variable final_pzz equal pzz
variable final_etotal equal etotal
variable final_c_pressure_all_aiida equal c_pressure_all_aiida
variable final_c_pressure_all_aiida_1 equal c_pressure_all_aiida[1]
variable final_c_pressure_all_aiida_2 equal c_pressure_all_aiida[2]
variable final_c_pressure_all_aiida_3 equal c_pressure_all_aiida[3]
variable final_c_pressure_all_aiida_4 equal c_pressure_all_aiida[4]
variable final_c_pressure_all_aiida_5 equal c_pressure_all_aiida[5]
variable final_c_pressure_all_aiida_6 equal c_pressure_all_aiida[6]
variable final_c_pressure_all_aiida__1__ equal c_pressure_all_aiida[1]
variable final_c_pressure_all_aiida__2__ equal c_pressure_all_aiida[2]
variable final_c_pressure_all_aiida__3__ equal c_pressure_all_aiida[3]
variable final_c_pressure_all_aiida__4__ equal c_pressure_all_aiida[4]
variable final_c_pressure_all_aiida__5__ equal c_pressure_all_aiida[5]
variable final_c_pressure_all_aiida__6__ equal c_pressure_all_aiida[6]
#---------------------End of the Final Variables information---------------------#
#---------------Start of the Printing Final Variables information----------------#
print "#Final results" file aiida_lammps.yaml
Expand All @@ -68,12 +68,12 @@ print "final_pyy: ${final_pyy}" append aiida_lammps.yaml
print "final_pzz: ${final_pzz}" append aiida_lammps.yaml
print "final_etotal: ${final_etotal}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida: ${final_c_pressure_all_aiida}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_1: ${final_c_pressure_all_aiida_1}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_2: ${final_c_pressure_all_aiida_2}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_3: ${final_c_pressure_all_aiida_3}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_4: ${final_c_pressure_all_aiida_4}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_5: ${final_c_pressure_all_aiida_5}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_6: ${final_c_pressure_all_aiida_6}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__1__: ${final_c_pressure_all_aiida__1__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__2__: ${final_c_pressure_all_aiida__2__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__3__: ${final_c_pressure_all_aiida__3__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__4__: ${final_c_pressure_all_aiida__4__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__5__: ${final_c_pressure_all_aiida__5__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__6__: ${final_c_pressure_all_aiida__6__}" append aiida_lammps.yaml
#----------------End of the Printing Final Variables information-----------------#
#---------------------Start of the write restart information---------------------#
write_restart restart.aiida
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ variable final_pyy equal pyy
variable final_pzz equal pzz
variable final_etotal equal etotal
variable final_c_pressure_all_aiida equal c_pressure_all_aiida
variable final_c_pressure_all_aiida_1 equal c_pressure_all_aiida[1]
variable final_c_pressure_all_aiida_2 equal c_pressure_all_aiida[2]
variable final_c_pressure_all_aiida_3 equal c_pressure_all_aiida[3]
variable final_c_pressure_all_aiida_4 equal c_pressure_all_aiida[4]
variable final_c_pressure_all_aiida_5 equal c_pressure_all_aiida[5]
variable final_c_pressure_all_aiida_6 equal c_pressure_all_aiida[6]
variable final_c_pressure_all_aiida__1__ equal c_pressure_all_aiida[1]
variable final_c_pressure_all_aiida__2__ equal c_pressure_all_aiida[2]
variable final_c_pressure_all_aiida__3__ equal c_pressure_all_aiida[3]
variable final_c_pressure_all_aiida__4__ equal c_pressure_all_aiida[4]
variable final_c_pressure_all_aiida__5__ equal c_pressure_all_aiida[5]
variable final_c_pressure_all_aiida__6__ equal c_pressure_all_aiida[6]
#---------------------End of the Final Variables information---------------------#
#---------------Start of the Printing Final Variables information----------------#
print "#Final results" file aiida_lammps.yaml
Expand All @@ -66,12 +66,12 @@ print "final_pyy: ${final_pyy}" append aiida_lammps.yaml
print "final_pzz: ${final_pzz}" append aiida_lammps.yaml
print "final_etotal: ${final_etotal}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida: ${final_c_pressure_all_aiida}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_1: ${final_c_pressure_all_aiida_1}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_2: ${final_c_pressure_all_aiida_2}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_3: ${final_c_pressure_all_aiida_3}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_4: ${final_c_pressure_all_aiida_4}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_5: ${final_c_pressure_all_aiida_5}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida_6: ${final_c_pressure_all_aiida_6}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__1__: ${final_c_pressure_all_aiida__1__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__2__: ${final_c_pressure_all_aiida__2__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__3__: ${final_c_pressure_all_aiida__3__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__4__: ${final_c_pressure_all_aiida__4__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__5__: ${final_c_pressure_all_aiida__5__}" append aiida_lammps.yaml
print "final_c_pressure_all_aiida__6__: ${final_c_pressure_all_aiida__6__}" append aiida_lammps.yaml
#----------------End of the Printing Final Variables information-----------------#
#---------------------Start of the write restart information---------------------#
write_restart restart.aiida
Expand Down
12 changes: 6 additions & 6 deletions tests/test_raw_parsers/test_parse_log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ time_dependent:
- -60616.181
- -60998.054
- -61353.826
c_pressure_all_aiida[1]:
c_pressure_all_aiida__1__:
- -65784.86
- -65754.123
- -65658.395
Expand Down Expand Up @@ -532,7 +532,7 @@ time_dependent:
- -56496.14
- -56926.184
- -57340.453
c_pressure_all_aiida[2]:
c_pressure_all_aiida__2__:
- -66151.806
- -66129.949
- -66064.381
Expand Down Expand Up @@ -584,7 +584,7 @@ time_dependent:
- -63084.235
- -63403.866
- -63702.654
c_pressure_all_aiida[3]:
c_pressure_all_aiida__3__:
- -65307.943
- -65282.65
- -65204.64
Expand Down Expand Up @@ -636,7 +636,7 @@ time_dependent:
- -62268.168
- -62664.111
- -63018.371
c_pressure_all_aiida[4]:
c_pressure_all_aiida__4__:
- -968.80346
- -973.77775
- -989.84677
Expand Down Expand Up @@ -688,7 +688,7 @@ time_dependent:
- -1884.7159
- -1744.5319
- -1602.112
c_pressure_all_aiida[5]:
c_pressure_all_aiida__5__:
- -1835.8858
- -1846.5829
- -1879.7798
Expand Down Expand Up @@ -740,7 +740,7 @@ time_dependent:
- -4043.8155
- -3741.0193
- -3438.0051
c_pressure_all_aiida[6]:
c_pressure_all_aiida__6__:
- -293.61095
- -291.26981
- -286.53978
Expand Down

0 comments on commit e7186d7

Please sign in to comment.