Skip to content

Commit c8bdee4

Browse files
committed
add magnetic pendulum to famous systems
1 parent a6ef551 commit c8bdee4

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicalSystemsBase"
22
uuid = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
33
repo = "https://github.com/JuliaDynamics/DynamicalSystemsBase.jl.git"
4-
version = "1.5.2"
4+
version = "1.5.3"
55

66
[deps]
77
DelayEmbeddings = "5732040d-69e3-5649-938a-b6b4f237613f"

src/continuous_famous_systems.jl

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ period-doubling bifurcation route to chaos. [2]
9797
The parameter container has the parameters in the same order as stated in this
9898
function's documentation string.
9999
100-
[1] : Chua, Leon O. "The genesis of Chua's circuit". Berkeley, CA, USA: Electronics Research Laboratory, College of Engineering, University of California, 1992.
100+
[1] : Chua, Leon O. "The genesis of Chua's circuit", 1992.
101101
102102
[2] : [Leon O. Chua (2007) "Chua circuit", Scholarpedia, 2(10):1488.](http://www.scholarpedia.org/article/Chua_circuit)
103103
@@ -542,7 +542,7 @@ looks like a speudo-random walk, the orbit moving around like in a labyrinth.
542542
First proposed by René Thomas (1999). [1] See discussion in Section 4.4.3 of
543543
"Elegant Chaos" by J. C. Sprott. [2]
544544
545-
[1] : Thomas, R. (1999). Deterministic chaos seen in terms of feedback circuits: Analysis, synthesis," labyrinth chaos". *International Journal of Bifurcation and Chaos*, *9*(10), 1889-1905.
545+
[1] : Thomas, R. (1999). *International Journal of Bifurcation and Chaos*, *9*(10), 1889-1905.
546546
547547
[2] : Sprott, J. C. (2010). *Elegant chaos: algebraically simple chaotic flows*. World Scientific.
548548
"""
@@ -672,7 +672,7 @@ attractor" for k = 0.1 and B = 12. Figure 5 of [1] is reproduced by
672672
using Plots
673673
ds = Systems.ueda()
674674
a = trajectory(ds, 2π*5e3, dt = 2π)
675-
scatter(a[:, 1], a[:, 2], markersize = 0.5, markercolor=:black, leg=false, title="Ueda attractor")
675+
scatter(a[:, 1], a[:, 2], markersize = 0.5, title="Ueda attractor")
676676
```
677677
678678
For more forced oscillation systems, see Chapter 2 of "Elegant Chaos" by
@@ -698,3 +698,45 @@ function ueda_jacob(u, p, t)
698698
return @SMatrix [0 1;
699699
-3*x^2 -k]
700700
end
701+
702+
703+
struct MagneticPendulum{T<:AbstractFloat}
704+
magnets::Vector{SVector{2, T}}
705+
end
706+
707+
function (m::MagneticPendulum)(u, p, t)
708+
x, y, vx, vy = u
709+
γ, d, α, ω = p
710+
dx, dy = vx, vy
711+
dvx, dvy = @. -ω^2*(x, y) - α*(vx, vy)
712+
for ma in m.magnets
713+
δx, δy = (x - ma[1]), (y - ma[2])
714+
D = sqrt(δx^2 + δy^2 + d^2)
715+
dvx -= γ*(x - ma[1])/D^3
716+
dvy -= γ*(y - ma[2])/D^3
717+
end
718+
return SVector(dx, dy, dvx, dvy)
719+
end
720+
721+
"""
722+
magnetic_pendulum(u=[cos(θ),sin(θ),0,0]; γ=1, d=0.3, α=0.2, ω=0.5, N=3)
723+
724+
Create a pangetic pendulum with `N` magnetics, equally distributed along the unit circle,
725+
with equations of motion
726+
```math
727+
\\begin{aligned}
728+
\\ddot{x} &= -\\omega ^2x - \\alpha \\dot{x} - \\sum_{i=1}^N \\frac{\\gamma (x - x_i)}{D_i^3} \\\\
729+
\\ddot{y} &= -\\omega ^2y - \\alpha \\dot{y} - \\sum_{i=1}^N \\frac{\\gamma (y - y_i)}{D_i^3} \\\\
730+
D_i &= \\sqrt{(x-x_i)^2 + (y-y_i)^2 + d^2}
731+
\\end{aligned}
732+
```
733+
where α is friction, ω is eigenfrequency, d is distance of pendulum from the magnet's plane
734+
and γ is the magnetic strength. A random initial condition is initialized by default
735+
somewhere along the unit circle with zero velocity.
736+
"""
737+
function magnetic_pendulum(u = [sincos(rand()*2π)..., 0, 0];
738+
γ = 1.0, d = 0.3, α = 0.2, ω = 0.5, N = 3)
739+
m = MagneticPendulum([SVector(cos(2π*i/N), sin(2π*i/N)) for i in 1:N])
740+
p = [γ, d, α, ω]
741+
ds = ContinuousDynamicalSystem(m, u, p)
742+
end

0 commit comments

Comments
 (0)