It seems that you made some small mistakes when typing in the equation, for example, -σ * sqrt(y^2+ρ^2ϕ^2)+ρ^2ϕ/y
should be -(σ * sqrt(y^2+ρ^2ϕ^2)*y+ρ^2ϕ)/y
. However, I think that the major source of confusion is to do with how an ODE is passed to DifferentialEquations.
ODEProblem
expects an equation of the form:
\frac{du}{dt}=f(t,u)
which is a little different to the equation that you are solving, which is in phase space. To get your equation into the form that ODEProblem
wants, you have to multiply both sides of the equation by \frac{d\phi}{dt}.
Doing so, you will end with the system of equations:
\frac{d\phi}{dt}=\dot{\phi},
\frac{d\dot{\phi}}{dt}=-(\sqrt{12\pi}(\dot{\phi}^2+m^2\phi^2)^\frac{1}{2}\dot{\phi}+m^2\phi).
This equation can be passed to ODEProblem
as follows:
using DifferentialEquations
using Plots
using ParameterizedFunctions
# EDIT The system has been changed as described above.
attrac = @ode_def begin
dϕ = ϕ_dot
dϕ_dot = -σ*sqrt(ϕ_dot^2+ρ^2*ϕ^2)*ϕ_dot-ρ^2*ϕ
end σ ρ
u0 = [1.0,0.0] # initial conditions
tspan = (0.0,10.0) # timespan
p = [sqrt(12π),1.0] # parameters --EDIT-- Set σ=sqrt(12π) and ρ=1.
prob = ODEProblem(attrac, u0, tspan, p)
sol = solve(prob,alg=Trapezoid(),abstol=1e-10,reltol=1e-10) # --EDIT-- changed the algorithm and set low tolerances
plot(sol,vars=(1,2),leg=false)
I got a bit carried away and did the multiple curve example too.
using DifferentialEquations
using Plots
using ParameterizedFunctions
using LaTeXStrings
fig = plot(leg=false,xlabel=L"\phi",ylabel=L"\dot{\phi}")
for u0 in [[[x,1.0] for x in range(-1,stop=0.5,length=5)];
[[x,-1.0] for x in range(-0.5,stop=1,length=5)]]
prob = ODEProblem(attrac, u0, tspan, p)
sol = solve(prob,alg=Trapezoid(),abstol=1e-10,reltol=1e-10)
plot!(fig,sol,vars=(1,2),xlim=(-1,1),ylim=(-1,1),color=:black,w=1.5)
end
fig
EDIT
To get LaTeX to match the phi with the one in the example figure that you posted, use \varphi