Skip to content

Commit

Permalink
fix(harmonic-oscillator): add initial phase to harmonic oscillator (s…
Browse files Browse the repository at this point in the history
…imple)

#34
  • Loading branch information
emptymalei committed Apr 13, 2024
1 parent 01dc720 commit 0352c4e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hamilflow/models/harmonic_oscillator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ class HarmonicOscillatorIC(BaseModel):
:cvar x0: the initial displacement
:cvar v0: the initial velocity
:cvar phi: initial phase
"""

x0: float = 1.0
v0: float = 0.0
phi: float = 0.0


class HarmonicOscillatorBase(ABC):
Expand Down Expand Up @@ -163,7 +165,7 @@ def _x(self, t: ArrayLike) -> ArrayLike:
r"""Solution to simple harmonic oscillators:
$$
x(t) = x_0 \cos(\omega t).
x(t) = x_0 \cos(\omega t + \phi).
$$
"""
return self.initial_condition.x0 * np.cos(
Expand Down

0 comments on commit 0352c4e

Please sign in to comment.