Skip to content

Commit 8a8dc77

Browse files
authored
docs: update state dependent example (#355)
1 parent 5069257 commit 8a8dc77

File tree

3 files changed

+41
-36
lines changed

3 files changed

+41
-36
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HarmonicBalance"
22
uuid = "e13b9ff6-59c3-11ec-14b1-f3d2cc6c135e"
33
authors = ["Jan Kosata <kosataj@phys.ethz.ch>", "Javier del Pino <jdelpino@phys.ethz.ch>", "Orjan Ameye <orjan.ameye@hotmail.com>"]
4-
version = "0.12.3"
4+
version = "0.12.4"
55

66
[deps]
77
BijectiveHilbert = "91e7fc40-53cd-4118-bd19-d7fcd1de2a54"

docs/src/examples/state_dependent_perturbation.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ end
4646

4747
We will consider two coupled linearly coupled parametrons, i.e., Duffing resonators with a global parametric drive. The equations of motion are given by:
4848
```math
49-
\ddot{x}_1 + (\omega_0^2 - \lambda \cos(2\omega t)) x_1 + \gamma \dot{x}_1 + \alpha x_1^3 -J x_2 = 0
50-
\ddot{x}_2 + (\omega_0^2 - \lambda \cos(2\omega t)) x_2 + \gamma \dot{x}_2 + \alpha x_2^3 -J x_1 = 0
49+
\begin{aligned}
50+
& \ddot{x}_1 + (\omega_0^2 - \lambda \cos(2\omega t)) x_1 + \gamma \dot{x}_1 + \alpha x_1^3 -J x_2 = 0\\
51+
& \ddot{x}_2 + (\omega_0^2 - \lambda \cos(2\omega t)) x_2 + \gamma \dot{x}_2 + \alpha x_2^3 -J x_1 = 0
52+
\end{aligned}
5153
```
52-
where $x_1$ and $x_2$ are the two induidual modes. The system is parametrized by the following parameters: $\omega_0$ (bare frequency), $\omega$ (drive frequency), $\lambda$ (parametric drive amplitude), $\alpha$ (nonlinearity), $J$ (coupling strength), and $\gamma$ (damping).
54+
where $x_1$ and $x_2$ are the two individual modes. The system is characterized by several parameters. The parameter `ω₀` represents the bare frequency of the system, which is the natural frequency at which the system oscillates in the absence of any external driving force. The parameter `ω` denotes the drive frequency, which is the frequency of an external driving force applied to the system. The parameter `λ` stands for the amplitude of the parametric drive, which modulates the natural frequency periodically. The parameter `α` represents the nonlinearity of the system, indicating how the system's response deviates from a linear behavior. The parameter `J` signifies the coupling strength, which measures the interaction strength between different parts or modes of the system. Finally, the parameter `γ` denotes the damping, which quantifies the rate at which the system loses energy to its surroundings.
5355

5456
With HarmonicBalance.jl, we can easily solve the phase diagram of the system in the limit where the modes oscillate at the frequency $\omega$:
5557

@@ -63,22 +65,17 @@ equations = [
6365
system = DifferentialEquation(equations, [x1, x2])
6466
add_harmonic!(system, x1, ω)
6567
add_harmonic!(system, x2, ω)
66-
harmonic_normal = get_harmonic_equations(system);
67-
nothing #hide
68+
harmonic_normal = get_harmonic_equations(system)
6869
````
6970

7071
We sweep over the system where we both increase the drive frequency $\omega$ and the parametric drive amplitude $\lambda$:
7172

7273
````@example state_dependent_perturbation
7374
res = 80
74-
fixed = HB.OrderedDict(Dict(ω0 => 1.0, α => 1.0, J => 0.005, γ => 0.005))
75+
fixed = HB.OrderedDict(ω0 => 1.0, α => 1.0, J => 0.005, γ => 0.005)
7576
varied = HB.OrderedDict((ω => range(0.99, 1.01, res), λ => range(1e-6, 0.03, res)))
76-
````
77-
7877
method = TotalDegree()
79-
80-
````@example state_dependent_perturbation
81-
result_ωλ = get_steady_states(harmonic_normal, varied, fixed; show_progress=false);
78+
result_ωλ = get_steady_states(harmonic_normal, method, varied, fixed; show_progress=false);
8279
plot_phase_diagram(result_ωλ; class="stable")
8380
````
8481

@@ -105,10 +102,12 @@ plot!(
105102

106103
These frequencies where the lobes are centered around corresponds to the normal mode frequency of the coupled system. Indeed, when resonators are strongly coupled, the system is better described in the normal mode basis. However, in addition, we also find additional bifurcation lines in the phase diagram. These bifurcation lines we would like to understand with a state-dependent perturbation.
107104

108-
As the system, in the strongly coupled limit, is better described in the normal mode basis, let's us consider the symmetric and antisymmetric modes $x_s = (x_1 + x_2)/\sqrt{2}$ and $x_a = (x_1 - x_2)/\sqrt{2}$, respectively. The equations of motion in this basis are given by:
105+
As the system, in the strongly coupled limit, is better described in the normal mode basis, let's us consider the symmetric and antisymmetric modes $x_s = (x_1 + x_2)/2$ and $x_a = (x_1 - x_2)/2$, respectively. The equations of motion in this basis are given by:
109106
```math
110-
\ddot{x}_s + (\omega_0^2 - J - \lambda \cos(2\omega t)) x_s + \gamma \dot{x}_s + \frac{\alpha}{4} (x_s^3 + 3 * x_a^2 * x_s) = 0
111-
\ddot{x}_a + (\omega_0^2 + J - \lambda \cos(2\omega t)) x_a + \gamma \dot{x}_a + \frac{\alpha}{4} (x_a^3 + 3 * x_s^2 * x_a)= 0
107+
\begin{aligned}
108+
& \ddot{x}_s + (\omega_0^2 - J - \lambda \cos(2\omega t)) x_s + \gamma \dot{x}_s + \alpha (x_s^3 + 3 * x_a^2 * x_s) = 0
109+
& \ddot{x}_a + (\omega_0^2 + J - \lambda \cos(2\omega t)) x_a + \gamma \dot{x}_a + \alpha (x_a^3 + 3 * x_s^2 * x_a)= 0
110+
\end{aligned}
112111
```
113112
Note that the system couples nonlinearly through the Kerr medium. However, solving the full system with HarmonicBalance.jl, expanding the normal modes in the the frequency $\omega$ yields the same phase diagram:
114113

@@ -119,11 +118,11 @@ equations = [
119118
d(d(xs, t), t) +
120119
(ω0^2 - J - λ * cos(2 * ω * t)) * xs +
121120
γ * d(xs, t) +
122-
(α / 4) * (xs^3 + 3 * xa^2 * xs),
121+
α * (xs^3 + 3 * xa^2 * xs),
123122
d(d(xa, t), t) +
124123
(ω0^2 + J - λ * cos(2 * ω * t)) * xa +
125124
γ * d(xa, t) +
126-
(α / 4) * (xa^3 + 3 * xs^2 * xa),
125+
α * (xa^3 + 3 * xs^2 * xa),
127126
]
128127
system = DifferentialEquation(equations, [xs, xa])
129128
@@ -180,10 +179,12 @@ plot!(
180179
Let us assume that the antisymmetrcic mode is in the parametric non-zero amplitude state. We will dress the symmetric mode with the non-zero amplitude solution of the antisymmetric mode.
181180

182181
````@example state_dependent_perturbation
183-
equations_xa =
184-
[d(d(xa, t), t) + (ω0^2 + J - λ * cos(2 * ω * t)) * xa + γ * d(xa, t) + (α / 4) * xa^3]
185-
equations_xs =
186-
[d(d(xs, t), t) + (ω0^2 - J - λ * cos(2 * ω * t)) * xs + γ * d(xs, t) + (α / 4) * xs^3]
182+
equations_xa = [
183+
d(d(xa, t), t) + (ω0^2 + J - λ * cos(2 * ω * t)) * xa + γ * d(xa, t) + α * xa^3
184+
]
185+
equations_xs = [
186+
d(d(xs, t), t) + (ω0^2 - J - λ * cos(2 * ω * t)) * xs + γ * d(xs, t) + α * xs^3
187+
]
187188
system_xa = DifferentialEquation(equations_xa, [xa])
188189
system_xs = DifferentialEquation(equations_xs, [xs])
189190
add_harmonic!(system_xa, xa, ω)

examples/state_dependent_perturbation.jl

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ end
3737

3838
# We will consider two coupled linearly coupled parametrons, i.e., Duffing resonators with a global parametric drive. The equations of motion are given by:
3939
# ```math
40-
# \ddot{x}_1 + (\omega_0^2 - \lambda \cos(2\omega t)) x_1 + \gamma \dot{x}_1 + \alpha x_1^3 -J x_2 = 0
41-
# \ddot{x}_2 + (\omega_0^2 - \lambda \cos(2\omega t)) x_2 + \gamma \dot{x}_2 + \alpha x_2^3 -J x_1 = 0
40+
# \begin{aligned}
41+
# & \ddot{x}_1 + (\omega_0^2 - \lambda \cos(2\omega t)) x_1 + \gamma \dot{x}_1 + \alpha x_1^3 -J x_2 = 0\\
42+
# & \ddot{x}_2 + (\omega_0^2 - \lambda \cos(2\omega t)) x_2 + \gamma \dot{x}_2 + \alpha x_2^3 -J x_1 = 0
43+
# \end{aligned}
4244
# ```
43-
# where $x_1$ and $x_2$ are the two induidual modes. The system is parametrized by the following parameters: $\omega_0$ (bare frequency), $\omega$ (drive frequency), $\lambda$ (parametric drive amplitude), $\alpha$ (nonlinearity), $J$ (coupling strength), and $\gamma$ (damping).
45+
# where $x_1$ and $x_2$ are the two individual modes. The system is characterized by several parameters. The parameter `ω₀` represents the bare frequency of the system, which is the natural frequency at which the system oscillates in the absence of any external driving force. The parameter `ω` denotes the drive frequency, which is the frequency of an external driving force applied to the system. The parameter `λ` stands for the amplitude of the parametric drive, which modulates the natural frequency periodically. The parameter `α` represents the nonlinearity of the system, indicating how the system's response deviates from a linear behavior. The parameter `J` signifies the coupling strength, which measures the interaction strength between different parts or modes of the system. Finally, the parameter `γ` denotes the damping, which quantifies the rate at which the system loses energy to its surroundings.
4446

4547
# With HarmonicBalance.jl, we can easily solve the phase diagram of the system in the limit where the modes oscillate at the frequency $\omega$:
4648

@@ -53,15 +55,15 @@ equations = [
5355
system = DifferentialEquation(equations, [x1, x2])
5456
add_harmonic!(system, x1, ω)
5557
add_harmonic!(system, x2, ω)
56-
harmonic_normal = get_harmonic_equations(system);
58+
harmonic_normal = get_harmonic_equations(system)
5759

5860
# We sweep over the system where we both increase the drive frequency $\omega$ and the parametric drive amplitude $\lambda$:
5961

6062
res = 80
61-
fixed = HB.OrderedDict(Dict(ω0 => 1.0, α => 1.0, J => 0.005, γ => 0.005))
63+
fixed = HB.OrderedDict(ω0 => 1.0, α => 1.0, J => 0.005, γ => 0.005)
6264
varied = HB.OrderedDict((ω => range(0.99, 1.01, res), λ => range(1e-6, 0.03, res)))
63-
# method = TotalDegree()
64-
result_ωλ = get_steady_states(harmonic_normal, varied, fixed; show_progress=false);
65+
method = TotalDegree()
66+
result_ωλ = get_steady_states(harmonic_normal, method, varied, fixed; show_progress=false);
6567
plot_phase_diagram(result_ωλ; class="stable")
6668

6769
# The phase diagram shows the number of stable steady states in the $\omega-\lambda$ plane. We find a familiar structure with two Arnold tongues (also known as Mathieu stability zones) around the drive frequency $\omega_s=\sqrt{\omega_0^2-J}$ and $\omega_s=\sqrt{\omega_0^2+J}$.
@@ -85,10 +87,12 @@ plot!(
8587

8688
# These frequencies where the lobes are centered around corresponds to the normal mode frequency of the coupled system. Indeed, when resonators are strongly coupled, the system is better described in the normal mode basis. However, in addition, we also find additional bifurcation lines in the phase diagram. These bifurcation lines we would like to understand with a state-dependent perturbation.
8789

88-
# As the system, in the strongly coupled limit, is better described in the normal mode basis, let's us consider the symmetric and antisymmetric modes $x_s = (x_1 + x_2)/\sqrt{2}$ and $x_a = (x_1 - x_2)/\sqrt{2}$, respectively. The equations of motion in this basis are given by:
90+
# As the system, in the strongly coupled limit, is better described in the normal mode basis, let's us consider the symmetric and antisymmetric modes $x_s = (x_1 + x_2)/2$ and $x_a = (x_1 - x_2)/2$, respectively. The equations of motion in this basis are given by:
8991
# ```math
90-
# \ddot{x}_s + (\omega_0^2 - J - \lambda \cos(2\omega t)) x_s + \gamma \dot{x}_s + \frac{\alpha}{4} (x_s^3 + 3 * x_a^2 * x_s) = 0
91-
# \ddot{x}_a + (\omega_0^2 + J - \lambda \cos(2\omega t)) x_a + \gamma \dot{x}_a + \frac{\alpha}{4} (x_a^3 + 3 * x_s^2 * x_a)= 0
92+
# \begin{aligned}
93+
# & \ddot{x}_s + (\omega_0^2 - J - \lambda \cos(2\omega t)) x_s + \gamma \dot{x}_s + \alpha (x_s^3 + 3 * x_a^2 * x_s) = 0\\
94+
# & \ddot{x}_a + (\omega_0^2 + J - \lambda \cos(2\omega t)) x_a + \gamma \dot{x}_a + \alpha (x_a^3 + 3 * x_s^2 * x_a)= 0
95+
# \end{aligned}
9296
# ```
9397
# Note that the system couples nonlinearly through the Kerr medium. However, solving the full system with HarmonicBalance.jl, expanding the normal modes in the the frequency $\omega$ yields the same phase diagram:
9498

@@ -98,11 +102,11 @@ equations = [
98102
d(d(xs, t), t) +
99103
(ω0^2 - J - λ * cos(2 * ω * t)) * xs +
100104
γ * d(xs, t) +
101-
/ 4) * (xs^3 + 3 * xa^2 * xs),
105+
α * (xs^3 + 3 * xa^2 * xs),
102106
d(d(xa, t), t) +
103107
(ω0^2 + J - λ * cos(2 * ω * t)) * xa +
104108
γ * d(xa, t) +
105-
/ 4) * (xa^3 + 3 * xs^2 * xa),
109+
α * (xa^3 + 3 * xs^2 * xa),
106110
]
107111
system = DifferentialEquation(equations, [xs, xa])
108112

@@ -155,10 +159,10 @@ plot!(
155159

156160
# Let us assume that the antisymmetrcic mode is in the parametric non-zero amplitude state. We will dress the symmetric mode with the non-zero amplitude solution of the antisymmetric mode.
157161
equations_xa = [
158-
d(d(xa, t), t) + (ω0^2 + J - λ * cos(2 * ω * t)) * xa + γ * d(xa, t) + / 4) * xa^3
162+
d(d(xa, t), t) + (ω0^2 + J - λ * cos(2 * ω * t)) * xa + γ * d(xa, t) + α * xa^3
159163
]
160164
equations_xs = [
161-
d(d(xs, t), t) + (ω0^2 - J - λ * cos(2 * ω * t)) * xs + γ * d(xs, t) + / 4) * xs^3
165+
d(d(xs, t), t) + (ω0^2 - J - λ * cos(2 * ω * t)) * xs + γ * d(xs, t) + α * xs^3
162166
]
163167
system_xa = DifferentialEquation(equations_xa, [xa])
164168
system_xs = DifferentialEquation(equations_xs, [xs])
@@ -212,7 +216,7 @@ param_ranges = collect(values(varied))
212216
input_array = collect(Iterators.product(param_ranges..., values(fixed)...))
213217
input_array = getindex.(input_array, [permutation])
214218
input_array = HB.tuple_to_vector.(input_array)
215-
input_array = map(idx -> push!(input_array[idx], A[idx]...), CartesianIndices(input_array))
219+
input_array = map(idx -> push!(input_array[idx], A[idx]...), CartesianIndices(input_array));
216220

217221
# Solving for the steady states of the dressed symmetric mode:
218222
function solve_perturbed_system(prob, input)

0 commit comments

Comments
 (0)