Skip to content

Commit

Permalink
refactor(oscillator): #35 factor out initial conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
cmp0xff committed Jun 15, 2024
1 parent be219f5 commit 5800c84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
17 changes: 3 additions & 14 deletions hamilflow/models/harmonic_oscillator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import numpy as np
import pandas as pd
from numpy.typing import ArrayLike
from pydantic import BaseModel, Field, computed_field, field_validator
from pydantic import BaseModel, computed_field, field_validator

from hamilflow.models.harmonic_oscillator.initial_conditions import HarmonicOscillatorIC


class HarmonicOscillatorSystem(BaseModel):
Expand Down Expand Up @@ -54,19 +56,6 @@ def check_zeta_non_negative(cls, v: float) -> float:
return v


class HarmonicOscillatorIC(BaseModel):
"""The initial condition for a harmonic oscillator
:cvar x0: initial displacement
:cvar v0: initial velocity
:cvar phi: initial phase
"""

x0: float = Field(default=1.0)
v0: float = Field(default=0.0)
phi: float = Field(default=0.0)


class HarmonicOscillatorBase(ABC):
r"""Base class to generate time series data
for a [harmonic oscillator](https://en.wikipedia.org/wiki/Harmonic_oscillator).
Expand Down
14 changes: 14 additions & 0 deletions hamilflow/models/harmonic_oscillator/initial_conditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pydantic import BaseModel, Field


class HarmonicOscillatorIC(BaseModel):
"""The initial condition for a harmonic oscillator
:cvar x0: initial displacement
:cvar v0: initial velocity
:cvar phi: initial phase
"""

x0: float = Field(default=1.0)
v0: float = Field(default=0.0)
phi: float = Field(default=0.0)

0 comments on commit 5800c84

Please sign in to comment.