Skip to content

Commit

Permalink
Merge branch 'main' into tutorial-harmonic-oscillator-conf
Browse files Browse the repository at this point in the history
  • Loading branch information
emptymalei committed Mar 2, 2024
2 parents 6d14c3f + b60fe4c commit d2fb0a6
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ cython_debug/
#.idea/

.vscode
docs/tutorials/*.ipynb
*.ipynb
13 changes: 10 additions & 3 deletions hamiltonian_flow/models/harmonic_oscillator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

import numpy as np
import pandas as pd
from pydantic import BaseModel, computed_field
from pydantic import BaseModel, computed_field, field_validator


class HarmonicOscillatorSystem(BaseModel):
"""The params for the harmonic oscillator
:param omega: angular frequency of the harmonic oscillator
:param amplitude: the amplitude of the oscillation
:param phi: initial phase
:param zeta: damping ratio
"""

omega: float
Expand Down Expand Up @@ -44,6 +43,14 @@ def type(
else:
return "over_damped"

@field_validator("zeta")
@classmethod
def check_zeta_non_negative(cls, v: float) -> float:
if v < 0:
raise ValueError(f"Value of zeta should be possitive: {v=}")

return v


class HarmonicOscillatorIC(BaseModel):
"""The initial condition for a harmonic oscillator
Expand Down
Loading

0 comments on commit d2fb0a6

Please sign in to comment.