-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature/SOF 7397 #151
feature/SOF 7397 #151
Conversation
VsevolodX
commented
Jul 25, 2024
•
edited
Loading
edited
- feat: add first implementations of perturbation
|
||
@staticmethod | ||
def deform_slab(configuration): | ||
new_material = configuration.slab.clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is ambiguous - why is there slab in configuration for deformation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to SlabDeformationBuilder
|
||
|
||
class ContinuousDeformationBuilder(DeformationBuilder): | ||
def deform_slab_isometrically(self, configuration): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
new_basis.to_crystal() | ||
new_material.basis = new_basis | ||
|
||
# TODO: adjust the lattice parameters with the same coordinates transformation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove or implement
from ...utils import DeformationFunctionBuilder | ||
|
||
|
||
class DeformationConfiguration(BaseModel, InMemoryEntity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeformationConfiguration with deformation_function
SlabDeformationConfiguration inheriting from it and adding slab
Same for builders
src/py/mat3ra/made/tools/utils.py
Outdated
] | ||
|
||
|
||
class DeformationFunctionBuilder: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Builder -> Holder for this and above class
src/py/mat3ra/made/tools/utils.py
Outdated
return coordinate | ||
|
||
|
||
def solve_sine_wave_coordinate_prime( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring
src/py/mat3ra/made/tools/utils.py
Outdated
return sine_wave(coordinate_prime, amplitude, wavelength, phase, axis="x") | ||
|
||
|
||
def sine_wave_radial( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coordinate functions need to be better organized
@@ -0,0 +1,63 @@ | |||
from typing import List |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use perturbation
return new_material | ||
|
||
@staticmethod | ||
def _set_new_coordinates(new_material, new_coordinates): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be inside material class or basis class
|
||
|
||
class SlabPerturbationBuilder(PerturbationBuilder): | ||
def create_perturbed_slab(self, configuration): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and elsewhere - type hints
|
||
|
||
class CellMatchingDistancePreservingSlabPerturbationBuilder(DistancePreservingSlabPerturbationBuilder): | ||
def _transform_cell_vectors(self, configuration: PerturbationConfiguration) -> List[List[float]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_transform_lattice_vectors
or _transform_cell
|
||
class PerturbationConfiguration(BaseModel, InMemoryEntity): | ||
material: Material | ||
perturbation_function: Tuple[Callable, Dict] = PerturbationFunctionHolder.sine_wave() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to call things for what they are if this is a tuple, we should call it a tuple, or object, or function_config_tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restructured instead
return converted_array.tolist() | ||
|
||
|
||
class CoordinateConditionBuilder: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should go to coordinate
) | ||
|
||
|
||
class PerturbationFunctionHolder: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be inside perturbation
subfolder
raise NotImplementedError | ||
|
||
|
||
class SineWave(FunctionHolder): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SineWaveFunctionHolder
) -> Callable[[List[float]], List[float]]: | ||
index = AXIS_TO_INDEX_MAP[axis] | ||
|
||
def coordinate_transformation(coordinate: List[float]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid nested defs
from mat3ra.utils.factory import BaseFactory | ||
|
||
|
||
class PerturbationFunctionHelperFactory(BaseFactory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PerturbationFunctionHolderFactory
@@ -0,0 +1,84 @@ | |||
from typing import Callable, List, Literal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file should be called functions
""" | ||
raise NotImplementedError | ||
|
||
def apply_derivative(self, coordinate: List[float]) -> float: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calculate_derivative
""" | ||
raise NotImplementedError | ||
|
||
def get_arc_length(self, a: float, b: float) -> float: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calculate_arc_length
raise NotImplementedError | ||
|
||
|
||
class PerturbationFunctionHolder(FunctionHolder): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be in perturbation
folder
""" | ||
raise NotImplementedError | ||
|
||
def get_json(self) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check for this to be used instead of the tuple logic in all the previously written code also