Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(model-input): #45 model input using time sequence #75

Merged
merged 6 commits into from
Aug 14, 2024
Prev Previous commit
Next Next commit
docs(model-input): fix the tutorials after changing the interface
emptymalei committed Aug 6, 2024
commit 4cbe8bb3a11fe7b20be553fe8ba3e7e9de4cac5f
6 changes: 3 additions & 3 deletions docs/tutorials/brownian_motion.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# jupytext_version: 1.16.3
# kernelspec:
# display_name: .venv
# language: python
@@ -56,7 +56,7 @@
# Call the model to generate 1000 steps.

# %%
df_1d = bm_1d(n_steps=1000)
df_1d = bm_1d.generate_from(n_steps=1000)

# %%
px.line(df_1d, x="t", y="x_0")
@@ -79,7 +79,7 @@
# We call the model to generate 1000 steps.

# %%
df_2d = bm_2d(n_steps=500)
df_2d = bm_2d.generate_from(n_steps=500)

# %%
(
2 changes: 1 addition & 1 deletion docs/tutorials/complex_harmonic_oscillator.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# jupytext_version: 1.16.3
# kernelspec:
# display_name: .venv
# language: python
2 changes: 1 addition & 1 deletion docs/tutorials/harmonic_oscillator.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# jupytext_version: 1.16.3
# kernelspec:
# display_name: .venv
# language: python
12 changes: 6 additions & 6 deletions docs/tutorials/harmonic_oscillator_chain.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# jupytext_version: 1.16.3
# kernelspec:
# display_name: .venv
# language: python
@@ -113,22 +113,22 @@
#
# This system can be solved in terms of _travelling waves_, obtained by discrete Fourier transform.
#

#
# We can complexify the system
# $$S_L[x_i] = S_L[x_i, \phi_j] \equiv S_L[X^\ast_i, X_j] = \int_{t_0}^{t_1}\mathbb{d} t \left\\{ \frac{1}{2}m \dot X^\ast_i \delta_{ij} \dot X_j - \frac{1}{2}m X^\ast_i A_{ij} X_j\right\\}\\,,$$
# where $A_{ij} / \omega^2$ is equal to $(-2)$ if $i=j$, $1$ if $|i-j|=1$ or $|i-j|=N$, and $0$ otherwise;
# $X_i \coloneqq x_i \mathbb{e}^{-\phi_i}$, $X^\ast_i \coloneqq x_i \mathbb{e}^{+\phi_i}$.

#
# $A_{ij}$ can be diagonalised by the inverse discrete Fourier transform
# $$X_i = (F^{-1})_{ik} Y_k = \frac{1}{\sqrt{N}}\sum_k \mathbb{e}^{i \frac{2\mathbb{\pi}}{N} k\mathbb{i}} Y_k\\,.$$

#
# Calculating gives
# $$S_L[X^\ast_i, X_j] = S_L[Y^\ast_i, Y_j] = \sum_{k=0}^{N-1} \int_{t_0}^{t_1}\mathbb{d} t \left\\{ \frac{1}{2}m \dot Y^\ast_k \dot Y_k - \frac{1}{2}m \omega^2\cdot4\sin^2\frac{2\mathbb{\pi}k}{N} Y^\ast_k Y_k\right\\}\\,.$$
# We can arrive at an action for the Fourier modes
# $$S_L[Y, Y^*] = \sum_{k=0}^{N-1} \int_{t_0}^{t_1}\mathbb{d} t \left\\{ \frac{1}{2}m \dot Y_k^* Y_k - \frac{1}{2}m \omega^2\cdot4\sin^2\frac{2\mathbb{\pi}k}{N} Y_k^* Y_k\right\\}\\,.$$

#
# The origional system can then be solved by $N$ complex oscillators.

#
# Since the original degrees of freedom are real, the initial conditions of the propagating waves need to satisfy
# $Y_k = Y^*_{-k \mod N}$, see [Wikipedia](https://en.wikipedia.org/wiki/Discrete_Fourier_transform#DFT_of_real_and_purely_imaginary_signals).

6 changes: 4 additions & 2 deletions docs/tutorials/pendulum.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# jupytext_version: 1.16.3
# kernelspec:
# display_name: .venv
# language: python
@@ -46,7 +46,9 @@
# ## Data

# %%
df_pen = pen(n_periods=n_periods, n_samples_per_period=n_samples_per_period)
df_pen = pen.generate_from(
n_periods=n_periods, n_samples_per_period=n_samples_per_period
)
df_pen.head()

# %%