diff --git a/aiida_lammps/calculations/lammps/base.py b/aiida_lammps/calculations/lammps/base.py index 0504b21..2311558 100644 --- a/aiida_lammps/calculations/lammps/base.py +++ b/aiida_lammps/calculations/lammps/base.py @@ -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" diff --git a/aiida_lammps/common/generate_structure.py b/aiida_lammps/common/generate_structure.py index bda4832..282f07c 100644 --- a/aiida_lammps/common/generate_structure.py +++ b/aiida_lammps/common/generate_structure.py @@ -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 diff --git a/aiida_lammps/common/input_generator.py b/aiida_lammps/common/input_generator.py index 07d2fe3..4e9d637 100644 --- a/aiida_lammps/common/input_generator.py +++ b/aiida_lammps/common/input_generator.py @@ -13,6 +13,7 @@ from builtins import ValueError import json import os +import re from typing import Union from aiida import orm @@ -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") diff --git a/aiida_lammps/common/parse_trajectory.py b/aiida_lammps/common/parse_trajectory.py index d9e7cb3..0b6e70e 100644 --- a/aiida_lammps/common/parse_trajectory.py +++ b/aiida_lammps/common/parse_trajectory.py @@ -2,6 +2,7 @@ """ # pylint: disable=fixme from collections import namedtuple +import re from aiida import orm import numpy as np @@ -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()) diff --git a/aiida_lammps/common/raw_parsers.py b/aiida_lammps/common/raw_parsers.py index e20f39b..e0c4f71 100644 --- a/aiida_lammps/common/raw_parsers.py +++ b/aiida_lammps/common/raw_parsers.py @@ -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 diff --git a/tests/test_calculations/test_optimize_process_eam_.yml b/tests/test_calculations/test_optimize_process_eam_.yml index 7847415..0cfed69 100644 --- a/tests/test_calculations/test_optimize_process_eam_.yml +++ b/tests/test_calculations/test_optimize_process_eam_.yml @@ -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 diff --git a/tests/test_calculations/test_optimize_process_lennard_jones_.yml b/tests/test_calculations/test_optimize_process_lennard_jones_.yml index 445dd88..aa106ca 100644 --- a/tests/test_calculations/test_optimize_process_lennard_jones_.yml +++ b/tests/test_calculations/test_optimize_process_lennard_jones_.yml @@ -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 diff --git a/tests/test_calculations/test_optimize_process_reaxff_.yml b/tests/test_calculations/test_optimize_process_reaxff_.yml index 1d38888..5c3d698 100644 --- a/tests/test_calculations/test_optimize_process_reaxff_.yml +++ b/tests/test_calculations/test_optimize_process_reaxff_.yml @@ -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 diff --git a/tests/test_calculations/test_optimize_process_tersoff_.yml b/tests/test_calculations/test_optimize_process_tersoff_.yml index 17ff504..c940d6e 100644 --- a/tests/test_calculations/test_optimize_process_tersoff_.yml +++ b/tests/test_calculations/test_optimize_process_tersoff_.yml @@ -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 diff --git a/tests/test_generate_inputs/test_generate_input_eam_alloy_md.txt b/tests/test_generate_inputs/test_generate_input_eam_alloy_md.txt index 751438a..5d246b4 100644 --- a/tests/test_generate_inputs/test_generate_input_eam_alloy_md.txt +++ b/tests/test_generate_inputs/test_generate_input_eam_alloy_md.txt @@ -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 @@ -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 diff --git a/tests/test_generate_inputs/test_generate_input_eam_alloy_minimize.txt b/tests/test_generate_inputs/test_generate_input_eam_alloy_minimize.txt index 1f2aec1..389695f 100644 --- a/tests/test_generate_inputs/test_generate_input_eam_alloy_minimize.txt +++ b/tests/test_generate_inputs/test_generate_input_eam_alloy_minimize.txt @@ -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 @@ -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 diff --git a/tests/test_raw_parsers/test_parse_log.yaml b/tests/test_raw_parsers/test_parse_log.yaml index 3c1032b..9ed16d8 100644 --- a/tests/test_raw_parsers/test_parse_log.yaml +++ b/tests/test_raw_parsers/test_parse_log.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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