Skip to content

Commit

Permalink
update: add set coordintes as a method
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Aug 7, 2024
1 parent f84e873 commit 963822a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/py/mat3ra/made/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 2 additions & 10 deletions src/py/mat3ra/made/tools/build/perturbation/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


Expand All @@ -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


Expand Down

0 comments on commit 963822a

Please sign in to comment.