From 716157f80d383ea963df6cb2b6da2540a06f4b4f Mon Sep 17 00:00:00 2001 From: LM Date: Mon, 15 Apr 2024 23:31:27 +0200 Subject: [PATCH] docs(harmonic-oscillator): adjust tutorials to include ations or equation of motion #49 --- docs/tutorials/harmonic_oscillator.py | 20 ++++++++++++++++++++ hamilflow/models/harmonic_oscillator.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/harmonic_oscillator.py b/docs/tutorials/harmonic_oscillator.py index 3ee81af..9bf2db7 100644 --- a/docs/tutorials/harmonic_oscillator.py +++ b/docs/tutorials/harmonic_oscillator.py @@ -33,6 +33,18 @@ # %% [markdown] # ## Simple Harmonic Oscillator +# +# For an simple harmonic oscillator, the action of a simple harmonic oscillator is +# +# $$S_L[x] = \int_{t_0}^{t_1} \mathbb{d}t \left\{\frac{1}{2} m \dot x^2 - \frac{1}{2} m \omega^2 x^2 \right\}\,,$$ +# +# where the least action principle leads to the following equation of motion, +# +# $$ +# \ddot x + \omega^2 x = 0\,. +# $$ +# +# A simple harmonic oscillator is a periodic motion. # %% sho_omega = 0.5 @@ -57,6 +69,14 @@ # %% [markdown] # ## Damped Harmonic Oscillator +# +# A damped harmonic oscillator is a simple harmonic oscillator with damping force that is proportional to its velocity, +# +# $$ +# \ddot x + \omega^2 x = - 2\xi\omega \dot x\,. +# $$ +# +# In this section, we demonstrate three scenarios of a damped harmonic oscillator. # %% dho_systems = { diff --git a/hamilflow/models/harmonic_oscillator.py b/hamilflow/models/harmonic_oscillator.py index bda660d..072d869 100644 --- a/hamilflow/models/harmonic_oscillator.py +++ b/hamilflow/models/harmonic_oscillator.py @@ -174,7 +174,7 @@ def _x(self, t: ArrayLike) -> ArrayLike: class DampedHarmonicOscillator(HarmonicOscillatorBase): - r"""Generate time series data for a [simple harmonic oscillator](https://en.wikipedia.org/wiki/Harmonic_oscillator). + r"""Generate time series data for a [damped harmonic oscillator](https://en.wikipedia.org/wiki/Harmonic_oscillator). The equation for a general un-driven harmonic oscillator is[^wiki_ho][^libretext_ho]