Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix McAte5 time dependence #2096

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/perform_step/symplectic_perform_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ end
kdu = f.f1(du, u, p, tnew)
du = du + dt * a5 * kdu

tnew = tnew + t + a5 * dt
tnew = tnew + a5 * dt
ku = f.f2(du, u, p, tnew)
u = u + dt * b6 * ku

Expand Down Expand Up @@ -625,7 +625,7 @@ end
f.f1(kdu, du, u, p, tnew)
@.. broadcast=false du=du + dt * a5 * kdu

tnew = tnew + t + a5 * dt
tnew = tnew + a5 * dt
f.f2(ku, du, u, p, tnew)
@.. broadcast=false u=u + dt * b6 * ku

Expand Down
26 changes: 26 additions & 0 deletions test/algconvergence/symplectic_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,29 @@ end
@test_throws ArgumentError solve(prob, alg(); dt = dt)
end
end

function motionfuncDirect1(dv,v,u,p,t)
# 1:Electron, 2: Be
ω_1,ω_2,γ,m_1,m_2,η,ω_d=p
dv[1]=-ω_1^2*u[1]*(1+η*cos(ω_d*t))-γ*u[2]/m_1
dv[2]=-ω_2^2*u[2]-γ*u[1]/m_2
end

function motionfuncDirect1(v,u,p,t)
# 1:Electron, 2: Be
ω_1,ω_2,γ,m_1,m_2,η,ω_d=p
[-ω_1^2*u[1]*(1+η*cos(ω_d*t))-γ*u[2]/m_1,-ω_2^2*u[2]-γ*u[1]/m_2]
end

param=[90386.15717208837, 3938.9288690708827, 8560.718748264337, 0.000544617021484666, 8.947079933513658, 0.7596480420227258, 78778.57738141765]
u0_direct=zeros(2) # mm, mm
v0_direct = [0.0, 135.83668926684385]
tspan=(0.0, 1.321179076090661)
prob_direct=SecondOrderODEProblem(motionfuncDirect1,v0_direct,u0_direct,tspan,param)
dt=2e-8
ref=solve(prob_direct,DPRKN12(),abstol=1e-12,reltol=1e-12,maxiters=1e7,saveat=0.01)

@testset "symplectic time-dependent $alg-$iip-$pa" for (alg, x, d) in ALGOS
sol=solve(prob_direct,alg,dt=dt,saveat=0.01)
@test maximum(ref-sol) < 1e-3
end
Loading