Skip to content

Commit

Permalink
add heat-diff artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Dec 1, 2023
1 parent 6369659 commit fc095e5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ steps:

- label: "heat-diffusion"
command: "julia --color=yes --project=experiments/ClimaCore/ experiments/ClimaCore/heat-diffusion/run.jl"
artifact_paths: "heat-diffusion/images/*"
artifact_paths: "experiments/ClimaCore/output/heat-diffusion_artifacts/*"
agents:
slurm_mem: 20GB

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ function eisenman_seaice_init(
thermo_params = thermo_params,
dss_buffer = ClimaCore.Spaces.create_dss_buffer(ClimaCore.Fields.zeros(space)),
)
problem = ODEProblem(ode_function, Y, FT.(tspan), cache)
integrator = init(problem, ode_algo, dt = FT(dt), saveat = FT(saveat), adaptive = false)
problem = ODEProblem(ode_function, Y, Float64.(tspan), cache)
integrator = init(problem, ode_algo, dt = Float64(dt), saveat = Float64(saveat), adaptive = false)

sim = EisenmanIceSimulation(params, Y, space, integrator)
@warn name(sim) *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function ice_init(::Type{FT}; tspan, saveat, dt, space, area_fraction, thermo_pa
ode_algo = CTS.ExplicitAlgorithm(stepper)
ode_function = CTS.ClimaODEFunction(T_exp! = ice_rhs!, dss! = weighted_dss_slab!)

problem = ODEProblem(ode_function, Y, FT.(tspan), (; additional_cache..., params = params))
integrator = init(problem, ode_algo, dt = FT(dt), saveat = FT(saveat), adaptive = false)
problem = ODEProblem(ode_function, Y, Float64.(tspan), (; additional_cache..., params = params))
integrator = init(problem, ode_algo, dt = Float64(dt), saveat = Float64(saveat), adaptive = false)

sim = PrescribedIceSimulation(params, Y, space, integrator)

Expand Down
4 changes: 2 additions & 2 deletions experiments/AMIP/modular/components/ocean/slab_ocean_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ function ocean_init(
ode_algo = CTS.ExplicitAlgorithm(stepper)
ode_function = CTS.ClimaODEFunction(T_exp! = slab_ocean_rhs!, dss! = weighted_dss_slab!)

problem = ODEProblem(ode_function, Y, FT.(tspan), cache)
integrator = init(problem, ode_algo, dt = FT(dt), saveat = FT(saveat), adaptive = false)
problem = ODEProblem(ode_function, Y, Float64.(tspan), cache)
integrator = init(problem, ode_algo, dt = Float64(dt), saveat = Float64(saveat), adaptive = false)

sim = SlabOceanSimulation(params, Y, space, integrator)

Expand Down
33 changes: 17 additions & 16 deletions experiments/AMIP/modular/coupler_driver_modular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ run_name = config_dict["run_name"]
energy_check = config_dict["energy_check"]
const FT = config_dict["FLOAT_TYPE"] == "Float64" ? Float64 : Float32
land_sim_name = "bucket"
t_end = Int(time_to_seconds(config_dict["t_end"]))
tspan = (Int(0), t_end)
Δt_cpl = Int(config_dict["dt_cpl"])
saveat = time_to_seconds(config_dict["dt_save_to_sol"])
t_end = Float64(time_to_seconds(config_dict["t_end"]))
t_start = 0.0
tspan = (t_start, t_end)
Δt_cpl = Float64(config_dict["dt_cpl"])
saveat = Float64(time_to_seconds(config_dict["dt_save_to_sol"]))
date0 = date = DateTime(config_dict["start_date"], dateformat"yyyymmdd")
mono_surface = config_dict["mono_surface"]
hourly_checkpoint = config_dict["hourly_checkpoint"]
Expand Down Expand Up @@ -233,18 +234,18 @@ if mode_name == "amip"
## land
land_sim = bucket_init(
FT,
FT.(tspan),
tspan,
config_dict["land_domain_type"],
config_dict["land_albedo_type"],
config_dict["land_temperature_anomaly"],
comms_ctx,
REGRID_DIR;
dt = FT(Δt_cpl),
dt = Δt_cpl,
space = boundary_space,
saveat = FT(saveat),
saveat = saveat,
area_fraction = land_fraction,
date_ref = date0,
t_start = FT(0),
t_start = t_start,
)

## ocean
Expand Down Expand Up @@ -331,18 +332,18 @@ elseif mode_name in ("slabplanet", "slabplanet_aqua", "slabplanet_terra")
## land
land_sim = bucket_init(
FT,
FT.(tspan),
tspan,
config_dict["land_domain_type"],
config_dict["land_albedo_type"],
config_dict["land_temperature_anomaly"],
comms_ctx,
REGRID_DIR;
dt = FT(Δt_cpl),
dt = Δt_cpl,
space = boundary_space,
saveat = FT(saveat),
saveat = saveat,
area_fraction = land_fraction,
date_ref = date0,
t_start = FT(0),
t_start = t_start,
)

## ocean
Expand Down Expand Up @@ -377,18 +378,18 @@ elseif mode_name == "slabplanet_eisenman"
## land
land_sim = bucket_init(
FT,
FT.(tspan),
tspan,
config_dict["land_domain_type"],
config_dict["land_albedo_type"],
config_dict["land_temperature_anomaly"],
comms_ctx,
REGRID_DIR;
dt = FT(Δt_cpl),
dt = Δt_cpl,
space = boundary_space,
saveat = FT(saveat),
saveat = saveat,
area_fraction = land_fraction,
date_ref = date0,
t_start = FT(0),
t_start = t_start,
)

## ocean
Expand Down
26 changes: 8 additions & 18 deletions experiments/ClimaCore/heat-diffusion/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ import SciMLBase: step!, ODEProblem, init

using Logging: global_logger
using TerminalLoggers: TerminalLogger

using RecursiveArrayTools

using Statistics

# Load utilities for coupling
Expand Down Expand Up @@ -307,16 +305,13 @@ ENV["GKSwstype"] = "nul"
import Plots
Plots.GRBackend()

show_plots = isdefined(Main, :SHOWPLOTS) ? SHOWPLOTS : true

path = joinpath(dirname(@__FILE__), "images/")
mkpath(path);
ARTIFACTS_DIR = joinpath(pkg_dir, "experiments/ClimaCore/output/heat-diffusion_artifacts")
mkpath(ARTIFACTS_DIR)

# - Vertical profile at start and end
t0_ = parent(sol_atm.u[1].T_atm)[:, 1];
tend_ = parent(sol_atm.u[end].T_atm)[:, 1];
z_centers = parent(Fields.coordinate_field(center_space_atm))[:, 1];
show_plots ?
Plots.png(
Plots.plot(
[t0_ tend_],
Expand All @@ -327,9 +322,8 @@ Plots.png(
ylabel = "z (m)",
linewidth = 2,
),
joinpath(path, "heat-diffusion_f1.png"),
) : nothing
# ![](images/heat-diffusion_f1.png)
joinpath(ARTIFACTS_DIR, "heat-diffusion_f1.png"),
)

# - Conservation: absolute "energy" of both models with time
# convert to the same units (analogous to energy conservation, assuming that is both domains density=1 and thermal capacity=1)
Expand All @@ -338,7 +332,6 @@ atm_sum_u_t =
[sum(parent(u.T_atm)[:]) for u in sol_atm.u] .* (parameters.zmax_atm - parameters.zmin_atm) ./ parameters.n;
v1 = lnd_sfc_u_t .- lnd_sfc_u_t[1];
v2 = atm_sum_u_t .- atm_sum_u_t[1];
show_plots ?
Plots.png(
Plots.plot(
sol_lnd.t,
Expand All @@ -348,14 +341,12 @@ Plots.png(
ylabel = "pseudo-energy (J / m2)",
linewidth = 2,
),
joinpath(path, "heat-diffusion_f2.png"),
) : nothing
# ![](images/heat-diffusion_f2.png)
joinpath(ARTIFACTS_DIR, "heat-diffusion_f2.png"),
)

# - Conservation: relative error with time
total = atm_sum_u_t + lnd_sfc_u_t;
rel_error = abs.(total .- total[1]) / mean(total);
show_plots ?
Plots.png(
Plots.plot(
sol_lnd.t,
Expand All @@ -366,9 +357,8 @@ Plots.png(
title = "Total Energy Conservation",
linewidth = 2,
),
joinpath(path, "heat-diffusion_f3.png"),
) : nothing
# ![](images/heat-diffusion_f3.png)
joinpath(ARTIFACTS_DIR, "heat-diffusion_f3.png"),
)

#src # - Animation
#src anim = Plots.@animate for u in sol_atm.u
Expand Down

0 comments on commit fc095e5

Please sign in to comment.