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

Snow fix #424

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ end
get_field(sim::ClimaAtmosSimulation, ::Val{:radiative_energy_flux}) =
Fields.level(sim.integrator.p.ᶠradiation_flux, half)
get_field(sim::ClimaAtmosSimulation, ::Val{:liquid_precipitation}) =
sim.integrator.p.col_integrated_rain .+ sim.integrator.p.col_integrated_snow # all fallen snow melts for now
get_field(sim::ClimaAtmosSimulation, ::Val{:snow_precipitation}) = sim.integrator.p.col_integrated_snow .* FT(0)
sim.integrator.p.col_integrated_rain .* CAP.ρ_cloud_liq(params) #.+ sim.integrator.p.col_integrated_snow .* CAP.ρ_cloud_liq(params) # all fallen snow melts for now
get_field(sim::ClimaAtmosSimulation, ::Val{:snow_precipitation}) = sim.integrator.p.col_integrated_snow .* CAP.ρ_cloud_liq(params) #.* FT(0) # kg^3/m^2/s

get_field(sim::ClimaAtmosSimulation, ::Val{:turbulent_energy_flux}) =
Geometry.WVector.(sim.integrator.p.sfc_conditions.ρ_flux_h_tot)
get_field(sim::ClimaAtmosSimulation, ::Val{:turbulent_moisture_flux}) =
Geometry.WVector.(sim.integrator.p.sfc_conditions.ρ_flux_q_tot)
Geometry.WVector.(sim.integrator.p.sfc_conditions.ρ_flux_q_tot) # kg/m^2/s

get_field(sim::ClimaAtmosSimulation, ::Val{:thermo_state_int}) = Spaces.level(sim.integrator.p.ᶜts, 1)

Expand Down
2 changes: 1 addition & 1 deletion experiments/AMIP/modular/components/land/bucket_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function bucket_init(
anomaly_tropics = false
hs_sfc = false
Y.bucket.T = map(coords.subsurface) do coord
T_sfc_0 = FT(285.0)
T_sfc_0 = FT(275.0)
radlat = coord.lat / FT(180) * pi
ΔT = FT(0)
if anomaly == true
Expand Down
10 changes: 6 additions & 4 deletions experiments/AMIP/modular/components/land/bucket_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,18 @@ function update_field!(sim::BucketSimulation, ::Val{:turbulent_energy_flux}, fie
end
function update_field!(sim::BucketSimulation, ::Val{:turbulent_moisture_flux}, field)
ρ_liq = (LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set))
parent(sim.integrator.p.bucket.evaporation) .= parent(field ./ ρ_liq)
parent(sim.integrator.p.bucket.evaporation) .= parent(field ./ ρ_liq) # m^3/m^2/s
end
function update_field!(sim::BucketSimulation, ::Val{:radiative_energy_flux}, field)
parent(sim.integrator.p.bucket.R_n) .= parent(field)
end
function update_field!(sim::BucketSimulation, ::Val{:liquid_precipitation}, field)
parent(sim.integrator.p.bucket.P_liq) .= parent(field)
ρ_liq = (LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set))
parent(sim.integrator.p.bucket.P_liq) .= parent(field ./ ρ_liq) # m^3/m^2/s
end
function update_field!(sim::BucketSimulation, ::Val{:snow_precipitation}, field)
parent(sim.integrator.p.bucket.P_snow) .= parent(field)
ρ_liq = (LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set))
parent(sim.integrator.p.bucket.P_snow) .= parent(field ./ ρ_liq) # m^3/m^2/s
end

function update_field!(sim::BucketSimulation, ::Val{:air_density}, field)
Expand All @@ -124,7 +126,7 @@ function update_turbulent_fluxes_point!(sim::BucketSimulation, fields::NamedTupl
(; F_turb_energy, F_turb_moisture) = fields
sim.integrator.p.bucket.turbulent_energy_flux[colidx] .= F_turb_energy
sim.integrator.p.bucket.evaporation[colidx] .=
F_turb_moisture ./ LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set)
F_turb_moisture ./ LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set) # m^3 / m^2 / s
return nothing
end

Expand Down
13 changes: 12 additions & 1 deletion experiments/AMIP/modular/coupler_driver_modular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if isinteractive()
parsed_args["rad"] = "gray" #hide
parsed_args["energy_check"] = true #hide
parsed_args["mode_name"] = "slabplanet" #hide
parsed_args["t_end"] = "10days" #hide
parsed_args["t_end"] = "20days" #hide
parsed_args["dt_save_to_sol"] = "3600secs" #hide
parsed_args["dt_cpl"] = 200 #hide
parsed_args["dt"] = "200secs" #hide
Expand All @@ -89,6 +89,7 @@ if isinteractive()
parsed_args["precip_model"] = "0M" #hide
parsed_args["job_id"] = "interactive_debug_run"
parsed_args["monthly_checkpoint"] = true
parsed_args["FLOAT_TYPE"] = "Float64"
end

## read in some parsed command line arguments
Expand Down Expand Up @@ -520,6 +521,16 @@ function solve_coupler!(cs)
update_model_sims!(cs.model_sims, cs.fields, turbulent_fluxes)

## step sims
# buffer = land_sim.integrator.p.dss_buffer_2d
# land_ρ_sfc = land_sim.integrator.p.bucket.ρ_sfc # get_field(land_sim, Val(:ρ_sfc))
# ClimaCore.Spaces.weighted_dss!(land_ρ_sfc, buffer)

# land_T_sfc = land_sim.integrator.p.bucket.T_sfc
# ClimaCore.Spaces.weighted_dss!(land_T_sfc, buffer)

# land_q_sfc = land_sim.integrator.p.bucket.q_sfc
# ClimaCore.Spaces.weighted_dss!(land_q_sfc, buffer)

step_model_sims!(cs.model_sims, t)

## exchange combined fields and (if specified) calculate fluxes using combined states
Expand Down
15 changes: 10 additions & 5 deletions src/ConservationChecker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,15 @@ function check_conservation!(
FT = eltype(coupler_sim.surface_fractions.land)

# save atmos
push!(cc.ρq_tot_atmos, sum(atmos_sim.integrator.u.c.ρq_tot))
push!(cc.ρq_tot_atmos, sum(atmos_sim.integrator.u.c.ρq_tot)) # kg (∫kg of water per m^3 dV)


# save land
if land_sim !== nothing
ρ_cloud_liq = ClimaLSM.LSMP.ρ_cloud_liq(land_sim.model.parameters.earth_param_set)
water_content =
@. (land_sim.integrator.u.bucket.σS + land_sim.integrator.u.bucket.W + land_sim.integrator.u.bucket.Ws) # m^3 water / land area / layer height
parent(water_content) .= parent(water_content .* surface_fractions.land) * ρ_cloud_liq # kg / land area / layer height
@. (land_sim.integrator.u.bucket.σS + land_sim.integrator.u.bucket.W + land_sim.integrator.u.bucket.Ws) # m^3 water / land area
parent(water_content) .= parent(water_content .* surface_fractions.land) * ρ_cloud_liq # kg / land area
push!(cc.ρq_tot_land, sum(water_content)) # kg (∫ water_content dV)
else
push!(cc.ρq_tot_land, FT(0))
Expand Down Expand Up @@ -295,7 +296,7 @@ function plot_global_conservation(
) where {FT}
times = collect(1:length(cc.ρq_tot_atmos)) * coupler_sim.Δt_cpl
diff_ρe_tot_atmos = (cc.ρq_tot_atmos .- cc.ρq_tot_atmos[1])
diff_ρe_tot_slab = (cc.ρq_tot_land .- cc.ρq_tot_land[1]) * FT(1e3)
diff_ρe_tot_slab = (cc.ρq_tot_land .- cc.ρq_tot_land[1])
diff_ρe_tot_slab_seaice = (cc.ρq_tot_seaice .- cc.ρq_tot_seaice[1])
diff_ρe_tot_slab_ocean = (cc.ρq_tot_ocean .- cc.ρq_tot_ocean[1])

Expand All @@ -305,7 +306,7 @@ function plot_global_conservation(
Plots.plot!(times_days, diff_ρe_tot_slab_seaice[1:length(times_days)], label = "seaice")
Plots.plot!(times_days, diff_ρe_tot_slab_ocean[1:length(times_days)], label = "ocean")

tot = @. cc.ρq_tot_atmos + cc.ρq_tot_land * FT(1e3) + cc.ρq_tot_seaice + cc.ρq_tot_ocean
tot = @. cc.ρq_tot_atmos + cc.ρq_tot_land + cc.ρq_tot_seaice + cc.ρq_tot_ocean

Plots.plot!(times_days, tot .- tot[1], label = "tot", xlabel = "time [days]", ylabel = "water(t) - water(t=0) [kg]")
Plots.savefig(figname1)
Expand All @@ -320,3 +321,7 @@ function plot_global_conservation(
end

end # module