diff --git a/aiida_lammps/calculations/lammps/__init__.py b/aiida_lammps/calculations/lammps/__init__.py index 81afa49..34d63f3 100644 --- a/aiida_lammps/calculations/lammps/__init__.py +++ b/aiida_lammps/calculations/lammps/__init__.py @@ -12,87 +12,6 @@ from aiida_lammps.data.potential import EmpiricalPotential -def get_supercell( - structure: orm.StructureData, - supercell_shape: orm.Dict, -) -> orm.StructureData: - """Generate a supercell from a given StructureData - - :param structure: original structure that will be used to generate the supercell - :type structure: orm.StructureData - :param supercell_shape: dictionary with the supercell information - :type supercell_shape: orm.Dict - :return: generated supercell - :rtype: orm.StructureData - """ - symbols = np.array([site.kind_name for site in structure.sites]) - positions = np.array([site.position for site in structure.sites]) - cell = np.array(structure.cell) - supercell_shape = np.array(supercell_shape.dict.shape) - - supercell_array = np.dot(cell, np.diag(supercell_shape)) - - supercell = orm.StructureData(cell=supercell_array) - for k in range(positions.shape[0]): - for entry in itertools.product(*[range(i) for i in supercell_shape[::-1]]): - position = positions[k, :] + np.dot(np.array(entry[::-1]), cell) - symbol = symbols[k] - supercell.append_atom(position=position, symbols=symbol) - - return supercell - - -def get_force_constants(force_constants: orm.ArrayData) -> str: - """Get the force constants in text format - - :param force_constants: Array with the information needed for the force constants - :type force_constants: orm.ArrayData - :return: force constants in text - :rtype: str - """ - force_constants = force_constants.get_array("force_constants") - - fc_shape = force_constants.shape - fc_txt = "%4d\n" % (fc_shape[0]) - for i in range(fc_shape[0]): - for j in range(fc_shape[1]): - fc_txt += "%4d%4d\n" % (i + 1, j + 1) - for vec in force_constants[i][j]: - fc_txt += ("%22.15f" * 3 + "\n") % tuple(vec) - - return fc_txt - - -def structure_to_poscar(structure: orm.StructureData) -> str: - """Write the structure into a POSCAR - - :param structure: structure used for the simulation - :type structure: orm.StructureData - :return: POSCAR format for the structure - :rtype: str - """ - atom_type_unique = np.unique( - [site.kind_name for site in structure.sites], - return_index=True, - )[1] - labels = np.diff(np.append(atom_type_unique, [len(structure.sites)])) - - poscar = " ".join(np.unique([site.kind_name for site in structure.sites])) - poscar += "\n1.0\n" - cell = structure.cell - for row in cell: - poscar += f"{row[0]: 22.16f} {row[1]: 22.16f} {row[2]: 22.16f}\n" - poscar += " ".join(np.unique([site.kind_name for site in structure.sites])) + "\n" - poscar += " ".join(np.array(labels, dtype=str)) + "\n" - poscar += "Cartesian\n" - for site in structure.sites: - poscar += f"{site.position[0]: 22.16f} " - poscar += f"{site.position[1]: 22.16f} " - poscar += f"{site.position[2]: 22.16f}\n" - - return poscar - - class BaseLammpsCalculation(CalcJob): """ A basic plugin for calculating force constants using Lammps. @@ -372,7 +291,6 @@ def prepare_for_submission(self, tempfolder): # pylint: disable=arguments-diffe codeinfo = CodeInfo() codeinfo.cmdline_params = list(self._cmdline_params) codeinfo.code_uuid = self.inputs.code.uuid - codeinfo.withmpi = self.metadata.options.withmpi codeinfo.stdout_name = self._stdout_name calcinfo = CalcInfo() diff --git a/aiida_lammps/calculations/lammps/base.py b/aiida_lammps/calculations/lammps/base.py index 2311558..56f9e0f 100644 --- a/aiida_lammps/calculations/lammps/base.py +++ b/aiida_lammps/calculations/lammps/base.py @@ -101,11 +101,8 @@ def define(cls, spec): valid_type=str, default=cls._DEFAULT_RESTART_FILENAME, ) - spec.input( - "metadata.options.parser_name", - valid_type=str, - default=cls._DEFAULT_PARSER, - ) + spec.inputs["metadata"]["options"]["parser_name"].default = cls._DEFAULT_PARSER + spec.output( "results", valid_type=orm.Dict, @@ -258,8 +255,6 @@ def prepare_for_submission(self, folder): codeinfo.code_uuid = self.inputs.code.uuid # Set the name of the stdout codeinfo.stdout_name = _output_filename - # Set whether or not one is running with MPI - codeinfo.withmpi = self.inputs.metadata.options.withmpi # Generate the datastructure for the calculation information calcinfo = datastructures.CalcInfo() diff --git a/aiida_lammps/calculations/lammps/force.py b/aiida_lammps/calculations/lammps/force.py index 9a2b784..6d4885a 100644 --- a/aiida_lammps/calculations/lammps/force.py +++ b/aiida_lammps/calculations/lammps/force.py @@ -14,11 +14,7 @@ class ForceCalculation(BaseLammpsCalculation): def define(cls, spec): super().define(spec) - spec.input( - "metadata.options.parser_name", - valid_type=str, - default="lammps.force", - ) + spec.inputs["metadata"]["options"]["parser_name"].default = "lammps.force" spec.output( "arrays", diff --git a/aiida_lammps/calculations/lammps/md.py b/aiida_lammps/calculations/lammps/md.py index d58ef59..d599f9b 100644 --- a/aiida_lammps/calculations/lammps/md.py +++ b/aiida_lammps/calculations/lammps/md.py @@ -17,11 +17,7 @@ class MdCalculation(BaseLammpsCalculation): def define(cls, spec): super().define(spec) - spec.input( - "metadata.options.parser_name", - valid_type=str, - default="lammps.md", - ) + spec.inputs["metadata"]["options"]["parser_name"].default = "lammps.md" spec.default_output_port = "results" spec.output( diff --git a/aiida_lammps/calculations/lammps/md_multi.py b/aiida_lammps/calculations/lammps/md_multi.py index af93b4d..1224b4e 100644 --- a/aiida_lammps/calculations/lammps/md_multi.py +++ b/aiida_lammps/calculations/lammps/md_multi.py @@ -16,11 +16,7 @@ class MdMultiCalculation(BaseLammpsCalculation): def define(cls, spec): super().define(spec) - spec.input( - "metadata.options.parser_name", - valid_type=str, - default="lammps.md.multi", - ) + spec.inputs["metadata"]["options"]["parser_name"].default = "lammps.md.multi" spec.default_output_port = "results" spec.output_namespace( diff --git a/aiida_lammps/calculations/lammps/optimize.py b/aiida_lammps/calculations/lammps/optimize.py index 7544d2c..9edf68a 100644 --- a/aiida_lammps/calculations/lammps/optimize.py +++ b/aiida_lammps/calculations/lammps/optimize.py @@ -19,11 +19,7 @@ class OptimizeCalculation(BaseLammpsCalculation): def define(cls, spec): super().define(spec) - spec.input( - "metadata.options.parser_name", - valid_type=str, - default="lammps.optimize", - ) + spec.inputs["metadata"]["options"]["parser_name"].default = "lammps.optimize" spec.output( "structure",