diff --git a/src/py/mat3ra/made/material.py b/src/py/mat3ra/made/material.py index 9b50ba47..1a5d0162 100644 --- a/src/py/mat3ra/made/material.py +++ b/src/py/mat3ra/made/material.py @@ -90,3 +90,8 @@ def to_crystal(self) -> None: new_basis = self.basis.copy() new_basis.to_crystal() self.basis = new_basis + + def set_coordinates(self, coordinates: List[List[float]]) -> None: + new_basis = self.basis.copy() + new_basis.coordinates.values = coordinates + self.basis = new_basis diff --git a/src/py/mat3ra/made/tools/build/perturbation/builders.py b/src/py/mat3ra/made/tools/build/perturbation/builders.py index 091364b6..f13ba6d3 100644 --- a/src/py/mat3ra/made/tools/build/perturbation/builders.py +++ b/src/py/mat3ra/made/tools/build/perturbation/builders.py @@ -20,14 +20,6 @@ def _prepare_material(configuration: _ConfigurationType) -> _GeneratedItemType: new_material.to_cartesian() return new_material - @staticmethod - def _set_new_coordinates(new_material: Material, new_coordinates: List[List[float]]) -> Material: - new_basis = new_material.basis.copy() - new_basis.coordinates.values = new_coordinates - new_basis.to_crystal() - new_material.basis = new_basis - return new_material - def _generate(self, configuration: _ConfigurationType) -> List[_GeneratedItemType]: """Generate materials with applied continuous perturbation based on the given configuration.""" new_material = self.create_perturbed_slab(configuration) @@ -53,7 +45,7 @@ def create_perturbed_slab(self, configuration: PerturbationConfiguration) -> Mat configuration.perturbation_function_holder.apply_perturbation(coord) for coord in new_material.basis.coordinates.values ] - new_material = self._set_new_coordinates(new_material, new_coordinates) + new_material.set_coordinates(new_coordinates) return new_material @@ -67,7 +59,7 @@ def create_perturbed_slab(self, configuration: PerturbationConfiguration) -> Mat new_coordinates = [ configuration.perturbation_function_holder.apply_perturbation(coord) for coord in new_coordinates ] - new_material = self._set_new_coordinates(new_material, new_coordinates) + new_material.set_coordinates(new_coordinates) return new_material