Skip to content

Instantly share code, notes, and snippets.

@antonior92
Created December 9, 2017 13:30
Show Gist options
  • Save antonior92/5e3b21d41b9d9bcbcc0507419c2adf71 to your computer and use it in GitHub Desktop.
Save antonior92/5e3b21d41b9d9bcbcc0507419c2adf71 to your computer and use it in GitHub Desktop.
using DifferentialEquations
using Plots
plotlyjs()
function kuramoto_pair_aux(t, θ, params, dθ)
w1, w2, k = params
dθ[1] = w1 - k*sin(θ[2] - θ[1])
dθ[2] = w2 - k*sin(θ[1] - θ[2])
end
kuramoto_pair = ParameterizedFunction(kuramoto_pair_aux, [1.0, 2.0, 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
kuramoto_pair.params = [w1, w2, k]
# 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