Skip to content

Commit

Permalink
Update saveat
Browse files Browse the repository at this point in the history
With ClimaTimeSteppers 0.8.2, you cannot pass saveat as a scalar.
  • Loading branch information
ph-kev committed Feb 10, 2025
1 parent a1c6470 commit f36a69a
Show file tree
Hide file tree
Showing 38 changed files with 68 additions and 47 deletions.
14 changes: 10 additions & 4 deletions docs/tutorials/introduction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ function heat_fd_tendency!(dydt, y, α, t)
end

heat_fd_prob = ODEProblem(heat_fd_tendency!, y0, (0.0, 5.0), 0.1)
heat_fd_sol = solve(heat_fd_prob, SSPRK33(), dt = 0.1, saveat = 0.25)
heat_fd_sol =
solve(heat_fd_prob, SSPRK33(), dt = 0.1, saveat = collect(0.0:0.25:5.0))
#----------------------------------------------------------------------------

anim = Plots.@animate for u in heat_fd_sol.u
Expand All @@ -417,7 +418,8 @@ end
y0 = exp.(.-(coord.y .^ 2 .+ coord.x .^ 2) ./ 2)

heat_cg_prob = ODEProblem(heat_cg_tendency!, y0, (0.0, 5.0), 0.1)
heat_cg_sol = solve(heat_cg_prob, SSPRK33(), dt = 0.1, saveat = 0.5)
heat_cg_sol =
solve(heat_cg_prob, SSPRK33(), dt = 0.1, saveat = collect(0.0:0.5:5.0))
#----------------------------------------------------------------------------

anim = Plots.@animate for u in heat_cg_sol.u
Expand Down Expand Up @@ -535,8 +537,12 @@ end
#----------------------------------------------------------------------------

shallow_water_prob = ODEProblem(shallow_water_tendency!, y0, (0.0, 20.0))
@time shallow_water_sol =
solve(shallow_water_prob, SSPRK33(), dt = 0.05, saveat = 1.0)
@time shallow_water_sol = solve(
shallow_water_prob,
SSPRK33(),
dt = 0.05,
saveat = collect(0.0:1.0:20.0),
)
anim = Plots.@animate for u in shallow_water_sol.u
Plots.plot(u.ρθ, clim = (-1, 1))
end
Expand Down
2 changes: 1 addition & 1 deletion examples/bickleyjet/bickleyjet_cg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ sol = solve(
prob,
SSPRK33(),
dt = 0.02,
saveat = 1.0,
saveat = collect(0.0:1.0:80.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/bickleyjet/bickleyjet_cg_invariant_hypervisc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ sol = solve(
prob,
SSPRK33(),
dt = 0.02,
saveat = 1.0,
saveat = collect(0.0:1.0:80.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/bickleyjet/bickleyjet_cg_unsmesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ sol = solve(
prob,
SSPRK33(),
dt = 0.02,
saveat = 1.0,
saveat = collect(0.0:1.0:80.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/bickleyjet/bickleyjet_dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ sol = solve(
prob,
SSPRK33(),
dt = 0.02,
saveat = 1.0,
saveat = collect(0.0:1.0:200.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
)
Expand Down
8 changes: 4 additions & 4 deletions examples/column/advect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,31 +119,31 @@ sol1 = solve(
prob1,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):10.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
sol2 = solve(
prob2,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):10.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
sol3 = solve(
prob3,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):10.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
sol4 = solve(
prob4,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):10.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/column/advect_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 10000 * Δt,
saveat = collect(t₀:(10000 * Δt):t₁),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/column/bb_fct_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ for (i, stretch_fn) in enumerate(stretch_fns)
prob,
ExplicitAlgorithm(SSP33ShuOsher()),
dt = Δt,
saveat = Δt,
saveat = collect(t₀:Δt:t₁),
progress = true,
adaptive = false,
progress_message = (dt, u, p, t) -> t,
Expand Down
2 changes: 1 addition & 1 deletion examples/column/ekman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 600, # save 10 min
saveat = collect(0.0:600:(60 * 60 * 50)), # save 10 min
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/column/fct_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ for (i, stretch_fn) in enumerate(stretch_fns)
prob,
SSPRK33(),
dt = Δt,
saveat = Δt,
saveat = collect(t₀:Δt:t₁),
progress = true,
adaptive = false,
progress_message = (dt, u, p, t) -> t,
Expand Down
2 changes: 1 addition & 1 deletion examples/column/heat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):10.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/column/hydrostatic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 60 * 60, # save every hour
saveat = collect(0.0:(60 * 60):(60 * 60 * 24 * ndays)), # save every hour
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/column/hydrostatic_discrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 60 * 60, # save every hour
saveat = collect(0.0:(60 * 60):(60 * 60 * 24 * ndays)), # save every hour
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/column/hydrostatic_ekman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 600, # save every hour
saveat = collect(0.0:600:(60 * 60)), # save every hour
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
8 changes: 4 additions & 4 deletions examples/column/step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,31 +121,31 @@ sol1 = solve(
prob1,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):5.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
sol2 = solve(
prob2,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):5.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
sol3 = solve(
prob3,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):5.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
sol4 = solve(
prob4,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = collect(0.0:(10 * Δt):5.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/column/tvd_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ for (i, stretch_fn) in enumerate(stretch_fns)
prob,
ExplicitAlgorithm(SSP33ShuOsher()),
dt = Δt,
saveat = Δt,
saveat = [t₀:Δt:t₁..., t₁],
)

q_final = sol.u[end].q
Expand Down
2 changes: 1 addition & 1 deletion examples/column/vanleer_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ for (i, stretch_fn) in enumerate(stretch_fns)
prob,
ExplicitAlgorithm(SSP33ShuOsher()),
dt = Δt,
saveat = Δt,
saveat = [t₀:Δt:t₁..., t₁],
)

q_final = sol.u[end].q
Expand Down
2 changes: 1 addition & 1 deletion examples/column/wave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 10 * Δt,
saveat = [0.0:(10 * Δt):(4 * pi)..., 4 * pi],
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
7 changes: 6 additions & 1 deletion examples/column/zalesak_fct_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ for (i, stretch_fn) in enumerate(stretch_fns)
(t₀, t₁),
parameters,
)
sol = solve(prob, ExplicitAlgorithm(SSP33ShuOsher()), dt = Δt, saveat = Δt)
sol = solve(
prob,
ExplicitAlgorithm(SSP33ShuOsher()),
dt = Δt,
saveat = collect(t₀:Δt:t₁),
)

q_final = sol.u[end].q
q_analytic = pulse.(z, t₁, z₀, zₕ, z₁)
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/box/bubble_3d_invariant_rhoe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ function bubble_3d_invariant_ρe(ARGS, comms_ctx, ::Type{FT}) where {FT}
prob,
SSPRK33(),
dt = Δt,
saveat = 10.0,
saveat = [0.0:10.0:(sim_params.t_int)..., sim_params.t_int],
progress = true,
progress_message = (dt, u, p, t) -> t,
internalnorm = (u, t) -> norm(u),
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/box/bubble_3d_invariant_rhotheta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ sol = solve(
prob,
SSPRK33(),
dt = Δt,
saveat = 1.0,
saveat = [0.0, 1.0],
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/box/bubble_3d_rhotheta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ integrator = init(
prob,
SSPRK33(),
dt = Δt,
saveat = 50.0,
saveat = [0.0, 1.0],
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/box/limiters_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ for (k, horz_ne) in enumerate(horz_ne_seq)
prob,
CTS.ExplicitAlgorithm(CTS.SSP33ShuOsher()),
dt = dt,
saveat = 0.99 * 80 * dt,
saveat = [0.0:(0.99 * 80 * dt):end_time..., end_time],
)

q_final = sol.u[end].ρq ./ sol.u[end].ρ
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ problem = SciMLBase.ODEProblem(
integrator = SciMLBase.init(
problem,
ode_algo;
saveat = dt_save_to_sol == 0 ? [] : dt_save_to_sol,
saveat = dt_save_to_sol == 0 ? [] : collect(t_start:dt_save_to_sol:t_end),
callback = callback,
dt = dt,
adaptive = false,
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/plane/bubble_2d_invariant_rhoe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ integrator = init(
prob,
SSPRK33(),
dt = Δt,
saveat = 10.0,
saveat = collect(0.0:10.0:1200.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/plane/density_current_2d_flux_form.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ integrator = init(
prob,
SSPRK33(),
dt = Δt,
saveat = 50.0,
saveat = collect(0.0:50.0:900.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/plane/density_current_2dinvariant_rhoe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ integrator = init(
prob,
SSPRK33(),
dt = Δt,
saveat = 10.0,
saveat = collect(0.0:10.0:timeend),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/plane/isothermal_channel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ integrator = init(
prob,
SSPRK33(),
dt = Δt,
saveat = 30.0,
saveat = collect(0.0:30.0:15000.0),
progress = true,
progress_message = (dt, u, p, t) -> t,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/plane/topo_agnesi_nh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ integrator = init(
prob,
SSPRK33(),
dt = Δt,
saveat = 1800.0,
saveat = collect(0.0:1800.0:timeend),
progress = true,
progress_message = (dt, u, p, t) -> t,
callback = dss_callback,
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/plane/topo_schar_nh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ integrator = init(
prob,
SSPRK33(),
dt = Δt,
saveat = 500.0,
saveat = collect(0.0:500.0:timeend),
progress = true,
progress_message = (dt, u, p, t) -> t,
callback = dss_callback,
Expand Down
7 changes: 6 additions & 1 deletion examples/hybrid/sphere/deformation_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,12 @@ function run_deformation_flow(use_limiter, fct_op, dt)
(0, t_end),
cache,
)
sol = solve(problem, ode_algorithm; dt, saveat = t_end / 2)
sol = solve(
problem,
ode_algorithm;
dt,
saveat = collect(0.0:(t_end / 2):t_end),
)
if !(cache.limiter isa Nothing)
@show cache.limiter.rtol
Limiters.print_convergence_stats(cache.limiter)
Expand Down
7 changes: 6 additions & 1 deletion examples/hybrid/sphere/hadley_circulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ prob = ODEProblem(
(0.0, T),
parameters,
)
sol = solve(prob, ExplicitAlgorithm(SSP33ShuOsher()), dt = dt, saveat = dt)
sol = solve(
prob,
ExplicitAlgorithm(SSP33ShuOsher()),
dt = dt,
saveat = collect(0.0:dt:T),
)

q1_error =
norm(sol.u[end].ρq1 ./ ρ .- sol.u[1].ρq1 ./ ρ) / norm(sol.u[1].ρq1 ./ ρ)
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid/sphere/nonhydrostatic_gravity_wave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ sol = solve(
prob,
SSPRK33(),
dt = dt,
saveat = dt,
saveat = collect(0:dt:time_end),
progress = true,
adaptive = false,
progress_message = (dt, u, p, t) -> t,
Expand Down
Loading

0 comments on commit f36a69a

Please sign in to comment.