From fc095e5de6613339f8252b32a73f231cb1dc07df Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Fri, 1 Dec 2023 13:24:40 -0800 Subject: [PATCH] add heat-diff artifacts --- .buildkite/pipeline.yml | 2 +- .../components/ocean/eisenman_seaice_init.jl | 4 +-- .../components/ocean/prescr_seaice_init.jl | 4 +-- .../components/ocean/slab_ocean_init.jl | 4 +-- .../AMIP/modular/coupler_driver_modular.jl | 33 ++++++++++--------- experiments/ClimaCore/heat-diffusion/run.jl | 26 +++++---------- 6 files changed, 32 insertions(+), 41 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 3a79997035..14166e0fc6 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -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 diff --git a/experiments/AMIP/modular/components/ocean/eisenman_seaice_init.jl b/experiments/AMIP/modular/components/ocean/eisenman_seaice_init.jl index 64ad47e5d7..35488bf2d0 100644 --- a/experiments/AMIP/modular/components/ocean/eisenman_seaice_init.jl +++ b/experiments/AMIP/modular/components/ocean/eisenman_seaice_init.jl @@ -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) * diff --git a/experiments/AMIP/modular/components/ocean/prescr_seaice_init.jl b/experiments/AMIP/modular/components/ocean/prescr_seaice_init.jl index e0fb56f439..7b9d596882 100644 --- a/experiments/AMIP/modular/components/ocean/prescr_seaice_init.jl +++ b/experiments/AMIP/modular/components/ocean/prescr_seaice_init.jl @@ -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) diff --git a/experiments/AMIP/modular/components/ocean/slab_ocean_init.jl b/experiments/AMIP/modular/components/ocean/slab_ocean_init.jl index 44752c2bee..080485ca58 100644 --- a/experiments/AMIP/modular/components/ocean/slab_ocean_init.jl +++ b/experiments/AMIP/modular/components/ocean/slab_ocean_init.jl @@ -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) diff --git a/experiments/AMIP/modular/coupler_driver_modular.jl b/experiments/AMIP/modular/coupler_driver_modular.jl index 5b3d5302c9..a16060dc35 100644 --- a/experiments/AMIP/modular/coupler_driver_modular.jl +++ b/experiments/AMIP/modular/coupler_driver_modular.jl @@ -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"] @@ -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 @@ -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 @@ -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 diff --git a/experiments/ClimaCore/heat-diffusion/run.jl b/experiments/ClimaCore/heat-diffusion/run.jl index d830011c48..d27405f105 100644 --- a/experiments/ClimaCore/heat-diffusion/run.jl +++ b/experiments/ClimaCore/heat-diffusion/run.jl @@ -96,9 +96,7 @@ import SciMLBase: step!, ODEProblem, init using Logging: global_logger using TerminalLoggers: TerminalLogger - using RecursiveArrayTools - using Statistics # Load utilities for coupling @@ -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_], @@ -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) @@ -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, @@ -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, @@ -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