Skip to content

Instantly share code, notes, and snippets.

@antonior92
Created December 9, 2017 13:30
Show Gist options
  • Save antonior92/60e289955c3f1b36ddee2cea9f88d8cc to your computer and use it in GitHub Desktop.
Save antonior92/60e289955c3f1b36ddee2cea9f88d8cc to your computer and use it in GitHub Desktop.
using DifferentialEquations
using Plots
pyplot()
f = @ode_def_noinvjac KuramotoPair begin
dθ1 = w1 - k*sin(θ2 - θ1)
dθ2 = w2 - k*sin(θ1 - θ2)
end w1=>1.0 w2=>2.0 k=>1.0
# Simulation parameters
t0 = 0.0
tf = 500.0
tspan = (t0,tf)
# Oscillators parameters
k = 0.5
w1 = 1.0
w2 = 1.5
# Redefine parameters
f = KuramotoPair(k=k, w1=w1, w2=w2)
# Initial Conditions
θ0 = 2*pi*(randn(1,2))
# Factor Δw/2k
factor = abs(w1 - w2)/(2k)
# System simulation
prob = ODEProblem(f, θ0, tspan)
sol = solve(prob)
# Plot solution
plot(sol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment