Skip to content

Commit

Permalink
refactoring and reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoalopez committed Jun 28, 2024
1 parent da2a692 commit 489fb5c
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 537 deletions.
37 changes: 0 additions & 37 deletions src/christoffel.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,43 +164,6 @@ def _rearrange_tensor(Cij: np.ndarray) -> np.ndarray:
return Cijkl


def _normalize_vector(vector: np.ndarray):
"""Normalizes a vector in 3d cartesian space to lie
on the unit sphere.
Parameters
----------
vector : numpy.ndarray, shape (3,)
a vector in 3d cartesian space
Returns
-------
numpy.ndarray, shape (3,)
The normalized 3D vector.
Notes
-----
The function normalizes the input vector by dividing each component
by the vector's magnitude to ensure it lies on the unit sphere.
Example
--------
>>> v = np.array([1.0, 2.0, 3.0])
>>> normalize_vector(v)
array([0.26726124, 0.53452248, 0.80178373])
"""
if vector.shape != (3,):
raise ValueError("Input vector must have shape (3,).")

magnitude = np.linalg.norm(vector)

# Handle the zero vector case
if magnitude == 0:
return vector

return vector / magnitude


def _christoffel_matrix(wavevectors: np.ndarray, Cijkl: np.ndarray) -> np.ndarray:
"""Calculate the Christoffel matrix for a given wave vector
and elastic tensor Cij.
Expand Down
Loading

0 comments on commit 489fb5c

Please sign in to comment.