Skip to content

Commit

Permalink
update: adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Aug 13, 2024
1 parent 4d6be39 commit 714c988
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/py/mat3ra/made/tools/build/perturbation/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _post_process(
return [wrap_to_unit_cell(item) for item in items]

def _update_material_name(self, material: Material, configuration: _ConfigurationType) -> Material:
perturbation_details = f"Perturbation: {configuration.perturbation_function_holder.get_json().get('type')}"
perturbation_details = f"Perturbation: {configuration.perturbation_function_holder.get_json().get('function')}"
material.name = f"{material.name} ({perturbation_details})"
return material

Expand Down
11 changes: 4 additions & 7 deletions src/py/mat3ra/made/tools/utils/perturbation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,17 @@ def calculate_derivative(self, coordinate: List[float], axis: str) -> float:
return 0

def _integrand(self, t: float, coordinate: List[float], axis: str) -> float:
index = AXIS_TO_INDEX_MAP[axis]
temp_coordinate = coordinate[:]
temp_coordinate[index] = t
temp_coordinate[AXIS_TO_INDEX_MAP[axis]] = t
return np.sqrt(1 + self.calculate_derivative(temp_coordinate, axis) ** 2)

def get_arc_length_equation(self, w_prime: float, coordinate: List[float], axis: str) -> float:
"""
Calculate arc length considering a change along one specific axis.
"""
index = AXIS_TO_INDEX_MAP[axis]
a, b = 0, w_prime
integrand = lambda t: self._integrand(t, coordinate, axis)
arc_length = quad(integrand, a, b)[0]
return arc_length - coordinate[index]
arc_length = quad(self._integrand, a, b, args=(coordinate, axis))[0]
return arc_length - coordinate[AXIS_TO_INDEX_MAP[axis]]

def transform_coordinates(self, coordinate: List[float]) -> List[float]:
"""
Expand Down Expand Up @@ -128,7 +125,7 @@ def __init__(
self.phase = phase
self.axis = axis

def _create_function(self, amplitude, wavelength, phase, axis) -> sp.Expr:
def _create_function(self, amplitude: float, wavelength: float, phase: float, axis: str) -> sp.Expr:
w = sp.Symbol(axis)
return amplitude * sp.sin(2 * sp.pi * w / wavelength + phase)

Expand Down

0 comments on commit 714c988

Please sign in to comment.