-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(typing): #69 * doc(model): #71 tutorial for the complex oscillator * chore(poetry): #71 docs versions * chore(cd): #71 fix NameError: name 'system_specs' is not defined * fix(comment): #71 @emptymalei #72 (review)
- Loading branch information
Showing
7 changed files
with
97 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# formats: ipynb,py:percent | ||
# text_representation: | ||
# extension: .py | ||
# format_name: percent | ||
# format_version: '1.3' | ||
# jupytext_version: 1.16.4 | ||
# kernelspec: | ||
# display_name: .venv | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] | ||
# # Complex Harmonic Oscillator | ||
# | ||
# In this tutorial, we show a few interesting examples of the complex simple harmonic oscillator. | ||
|
||
# %% | ||
import math | ||
|
||
import numpy as np | ||
from plotly import express as px | ||
|
||
from hamilflow.models.harmonic_oscillator import ComplexSimpleHarmonicOscillator | ||
|
||
# %% [markdown] | ||
# ## Basic setups | ||
|
||
# %% | ||
t = np.linspace(0, 3, 257) | ||
system_specs = dict(omega=2 * math.pi) | ||
|
||
# %% [markdown] | ||
# ## Positive-frequency, circular-polarised mode | ||
# Also known as the left-rotating mode. | ||
|
||
# %% | ||
csho = ComplexSimpleHarmonicOscillator(system_specs, initial_condition=dict(x0=(1, 0))) | ||
|
||
df = csho(t) | ||
|
||
arr_z = df["z"].to_numpy(copy=False) | ||
|
||
px.line_3d(x=arr_z.real, y=arr_z.imag, z=t, labels=dict(x="real", y="imag", z="time")) | ||
|
||
# %% [markdown] | ||
# ## Negative-frequency, circular-polarised mode | ||
# Also known as the right-rotating mode. | ||
|
||
# %% | ||
csho = ComplexSimpleHarmonicOscillator(system_specs, initial_condition=dict(x0=(0, 1))) | ||
|
||
df = csho(t) | ||
|
||
arr_z = df["z"].to_numpy(copy=False) | ||
|
||
px.line_3d(x=arr_z.real, y=arr_z.imag, z=t, labels=dict(x="real", y="imag", z="time")) | ||
|
||
# %% [markdown] | ||
# ## Positive-frequency, elliptic-polarised mode | ||
|
||
# %% | ||
csho = ComplexSimpleHarmonicOscillator( | ||
system_specs, | ||
initial_condition=dict(x0=(math.cos(math.pi / 12), math.sin(math.pi / 12))), | ||
) | ||
|
||
df = csho(t) | ||
|
||
arr_z = df["z"].to_numpy(copy=False) | ||
|
||
px.line_3d(x=arr_z.real, y=arr_z.imag, z=t, labels=dict(x="real", y="imag", z="time")) | ||
|
||
# %% [markdown] | ||
# # End of Notebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters