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

update to ClimaLand v0.8 (name change) #608

Merged
merged 1 commit into from
Feb 9, 2024
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 Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ClimaAtmos = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
ClimaCoreTempestRemap = "d934ef94-cdd4-4710-83d6-720549644b70"
ClimaLSM = "7884a58f-fab6-4fd0-82bb-ecfedb2d8430"
ClimaLand = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
Expand All @@ -29,7 +29,7 @@ ClimaAtmos = "0.20"
ClimaComms = "0.5.6"
ClimaCore = "0.11.8"
ClimaCoreTempestRemap = "0.3"
ClimaLSM = "0.7"
ClimaLand = "0.8"
Dates = "1"
DocStringExtensions = "0.8, 0.9"
Insolation = "0.9"
Expand Down
58 changes: 29 additions & 29 deletions experiments/AMIP/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "583d53437ea883f44a3bef71d0af7d6b8d674ee0"
project_hash = "53fcf61882faa366d5cca56412a7ec1571e0a8c7"

[[deps.ADTypes]]
git-tree-sha1 = "41c37aa88889c171f1300ceac1313c06e891d245"
Expand Down Expand Up @@ -48,9 +48,9 @@ version = "2.3.0"

[[deps.ArgParse]]
deps = ["Logging", "TextWrap"]
git-tree-sha1 = "3102bce13da501c9104df33549f511cd25264d7d"
git-tree-sha1 = "d4eccacaa3a632e8717556479d45502af44b4c17"
uuid = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
version = "1.1.4"
version = "1.1.5"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -201,9 +201,9 @@ version = "0.1.2"

[[deps.CLIMAParameters]]
deps = ["DocStringExtensions", "TOML", "Test"]
git-tree-sha1 = "ccfac72eed3ccf27ad086564059cab9d64567c7d"
git-tree-sha1 = "cf4f5ee75576ae855eca7da064540ce40b9a04c1"
uuid = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
version = "0.8.5"
version = "0.8.6"

[[deps.CPUSummary]]
deps = ["CpuId", "IfElse", "PrecompileTools", "Static"]
Expand Down Expand Up @@ -266,9 +266,9 @@ version = "1.61.0"

[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra"]
git-tree-sha1 = "1287e3872d646eed95198457873249bd9f0caed2"
git-tree-sha1 = "ad25e7d21ce10e01de973cdc68ad0f850a953c52"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.20.1"
version = "1.21.1"
weakdeps = ["SparseArrays"]

[deps.ChainRulesCore.extensions]
Expand Down Expand Up @@ -309,22 +309,22 @@ uuid = "d934ef94-cdd4-4710-83d6-720549644b70"
version = "0.3.12"

[[deps.ClimaCoupler]]
deps = ["CLIMAParameters", "ClimaAtmos", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "ClimaLSM", "Dates", "DocStringExtensions", "Insolation", "JLD2", "NCDatasets", "Plots", "SciMLBase", "StaticArrays", "Statistics", "SurfaceFluxes", "TempestRemap_jll", "Thermodynamics"]
deps = ["CLIMAParameters", "ClimaAtmos", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "ClimaLand", "Dates", "DocStringExtensions", "Insolation", "JLD2", "NCDatasets", "Plots", "SciMLBase", "StaticArrays", "Statistics", "SurfaceFluxes", "TempestRemap_jll", "Thermodynamics"]
path = "../.."
uuid = "4ade58fe-a8da-486c-bd89-46df092ec0c7"
version = "0.1.0"

[[deps.ClimaLSM]]
[[deps.ClimaLand]]
deps = ["Adapt", "ArtifactWrappers", "CFTime", "CSV", "CUDA", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "DataFrames", "Dates", "DocStringExtensions", "Flux", "HTTP", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "StatsBase", "SurfaceFluxes", "Thermodynamics", "cuDNN"]
git-tree-sha1 = "63a82b4c5687899b69a362482e5990fd935bc0a5"
uuid = "7884a58f-fab6-4fd0-82bb-ecfedb2d8430"
version = "0.7.0"
git-tree-sha1 = "77a058f6962d15d3c4f259aa716a2e3e079a2ca8"
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
version = "0.8.0"

[[deps.ClimaTimeSteppers]]
deps = ["CUDA", "ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
git-tree-sha1 = "40edb50016a5db1a3862dd6e8f76e37c0fbf4f07"
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
git-tree-sha1 = "216385dda9966d820b484f399b90447f073893a6"
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
version = "0.7.15"
version = "0.7.16"

[[deps.CloseOpenIntervals]]
deps = ["Static", "StaticArrayInterface"]
Expand Down Expand Up @@ -417,9 +417,9 @@ version = "0.1.2"

[[deps.ConcurrentUtilities]]
deps = ["Serialization", "Sockets"]
git-tree-sha1 = "8cfa272e8bdedfa88b6aefbbca7c19f1befac519"
git-tree-sha1 = "9c4708e3ed2b799e6124b5673a712dda0b596a9b"
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
version = "2.3.0"
version = "2.3.1"

[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -806,9 +806,9 @@ version = "0.1.3"

[[deps.Functors]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "9a68d75d466ccc1218d0552a8e1631151c569545"
git-tree-sha1 = "166c544477f97bbadc7179ede1c1868e0e9b426b"
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
version = "0.4.5"
version = "0.4.7"

[[deps.Future]]
deps = ["Random"]
Expand Down Expand Up @@ -981,13 +981,13 @@ weakdeps = ["Unitful"]
InterpolationsUnitfulExt = "Unitful"

[[deps.IntervalSets]]
deps = ["Dates", "Random"]
git-tree-sha1 = "3d8866c029dd6b16e69e0d4a939c4dfcb98fac47"
git-tree-sha1 = "581191b15bcb56a2aa257e9c160085d0f128a380"
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
version = "0.7.8"
weakdeps = ["Statistics"]
version = "0.7.9"
weakdeps = ["Random", "Statistics"]

[deps.IntervalSets.extensions]
IntervalSetsRandomExt = "Random"
IntervalSetsStatisticsExt = "Statistics"

[[deps.InvertedIndices]]
Expand Down Expand Up @@ -1065,9 +1065,9 @@ version = "0.9.5"

[[deps.KrylovKit]]
deps = ["ChainRulesCore", "GPUArraysCore", "LinearAlgebra", "Printf"]
git-tree-sha1 = "1a5e1d9941c783b0119897d29f2eb665d876ecf3"
git-tree-sha1 = "5cebb47f472f086f7dd31fb8e738a8db728f1f84"
uuid = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
version = "0.6.0"
version = "0.6.1"

[[deps.LAME_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -1545,9 +1545,9 @@ version = "0.5.5+0"

[[deps.Optimisers]]
deps = ["ChainRulesCore", "Functors", "LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "34205b1204cc83c43cd9cfe53ffbd3b310f6e8c5"
git-tree-sha1 = "264b061c1903bc0fe9be77cb9050ebacff66bb63"
uuid = "3bd65402-5787-11e9-1adc-39752487f4e2"
version = "0.3.1"
version = "0.3.2"

[[deps.Opus_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -1946,9 +1946,9 @@ version = "0.1.15"

[[deps.Static]]
deps = ["IfElse"]
git-tree-sha1 = "f295e0a1da4ca425659c57441bcb59abb035a4bc"
git-tree-sha1 = "b366eb1eb68075745777d80861c6706c33f588ae"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
version = "0.8.8"
version = "0.8.9"

[[deps.StaticArrayInterface]]
deps = ["ArrayInterface", "Compat", "IfElse", "LinearAlgebra", "PrecompileTools", "Requires", "SparseArrays", "Static", "SuiteSparse"]
Expand Down
2 changes: 1 addition & 1 deletion experiments/AMIP/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
ClimaCorePlots = "cf7c7e5a-b407-4c48-9047-11a94a308626"
ClimaCoreTempestRemap = "d934ef94-cdd4-4710-83d6-720549644b70"
ClimaCoupler = "4ade58fe-a8da-486c-bd89-46df092ec0c7"
ClimaLSM = "7884a58f-fab6-4fd0-82bb-ecfedb2d8430"
ClimaLand = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
CloudMicrophysics = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand Down
2 changes: 1 addition & 1 deletion experiments/AMIP/cli_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function argparse_settings()
default = "PrescribedSurface"
"--atmos_config_file"
help = "A yaml file used to set the atmospheric model configuration. If nothing is specified, the default configuration is used."
# ClimaLSM specific
# ClimaLand specific
"--land_albedo_type"
help = "Access land surface albedo information from data file. [`function`, `map_static`, `map_temporal`]"
arg_type = String
Expand Down
24 changes: 12 additions & 12 deletions experiments/AMIP/components/land/bucket_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import Thermodynamics as TD
using Dates: DateTime
using ClimaComms: AbstractCommsContext

import ClimaLSM
using ClimaLSM.Bucket: BucketModel, BucketModelParameters, AbstractAtmosphericDrivers, AbstractRadiativeDrivers
import ClimaLSM.Bucket: BulkAlbedoTemporal, BulkAlbedoStatic, BulkAlbedoFunction
using ClimaLSM:
import ClimaLand
using ClimaLand.Bucket: BucketModel, BucketModelParameters, AbstractAtmosphericDrivers, AbstractRadiativeDrivers
import ClimaLand.Bucket: BulkAlbedoTemporal, BulkAlbedoStatic, BulkAlbedoFunction
using ClimaLand:
make_exp_tendency,
initialize,
make_set_initial_cache,
surface_evaporative_scaling,
CoupledRadiativeFluxes,
CoupledAtmosphere
import ClimaLSM.Parameters as LSMP
include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl"))
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"))

import ClimaCoupler.Interfacer: LandModelSimulation, get_field, update_field!, name
import ClimaCoupler.FieldExchanger: step!, reinit!
Expand All @@ -39,23 +39,23 @@ name(::BucketSimulation) = "BucketSimulation"
include("./bucket_utils.jl")

# TODO remove this function after ClimaLand v0.8.1 update
function ClimaLSM.turbulent_fluxes(atmos::CoupledAtmosphere, model::BucketModel, Y, p, t)
function ClimaLand.turbulent_fluxes(atmos::CoupledAtmosphere, model::BucketModel, Y, p, t)
# coupler has done its thing behind the scenes already
model_name = ClimaLSM.name(model)
model_name = ClimaLand.name(model)
model_cache = getproperty(p, model_name)
return model_cache.turbulent_fluxes
end


function ClimaLSM.initialize_drivers(a::CoupledAtmosphere{FT}, coords) where {FT}
function ClimaLand.initialize_drivers(a::CoupledAtmosphere{FT}, coords) where {FT}
keys = (:P_liq, :P_snow)
types = ([FT for k in keys]...,)
domain_names = ([:surface for k in keys]...,)
model_name = :drivers
# intialize_vars packages the variables as a named tuple,
# as part of a named tuple with `model_name` as the key.
# Here we just want the variable named tuple itself
vars = ClimaLSM.initialize_vars(keys, types, domain_names, coords, model_name)
vars = ClimaLand.initialize_vars(keys, types, domain_names, coords, model_name)
return vars.drivers
end

Expand Down Expand Up @@ -139,7 +139,7 @@ function bucket_init(
n_vertical_elements = 7
# Note that this does not take into account topography of the surface, which is OK for this land model.
# But it must be taken into account when computing surface fluxes, for Δz.
domain = make_lsm_domain(space, (-d_soil, FT(0.0)), n_vertical_elements)
domain = make_land_domain(space, (-d_soil, FT(0.0)), n_vertical_elements)
args = (params, CoupledAtmosphere{FT}(), CoupledRadiativeFluxes{FT}(), domain)
model = BucketModel{FT, typeof.(args)...}(args...)

Expand All @@ -166,7 +166,7 @@ function bucket_init(

exp_tendency! = make_exp_tendency(model)
ode_algo = CTS.ExplicitAlgorithm(stepper)
bucket_ode_function = CTS.ClimaODEFunction(T_exp! = exp_tendency!, dss! = ClimaLSM.dss!)
bucket_ode_function = CTS.ClimaODEFunction(T_exp! = exp_tendency!, dss! = ClimaLand.dss!)
prob = ODEProblem(bucket_ode_function, Y, tspan, p)
integrator = init(prob, ode_algo; dt = dt, saveat = saveat, adaptive = false)

Expand Down
36 changes: 18 additions & 18 deletions experiments/AMIP/components/land/bucket_utils.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
make_lsm_domain(
make_land_domain(
atmos_boundary_space::ClimaCore.Spaces.SpectralElementSpace2D,
zlim::Tuple{FT, FT},
nelements_vert::Int,) where {FT}

Creates the LSM Domain from the horizontal space of the atmosphere, and information
Creates the land model domain from the horizontal space of the atmosphere, and information
about the number of elements and extent of the vertical domain.
"""
function make_lsm_domain(
function make_land_domain(
atmos_boundary_space::ClimaCore.Spaces.SpectralElementSpace2D,
zlim::Tuple{FT, FT},
nelements_vert::Int,
Expand All @@ -32,39 +32,39 @@ function make_lsm_domain(
subsurface_space = ClimaCore.Spaces.ExtrudedFiniteDifferenceSpace(atmos_boundary_space, vert_center_space)
space = (; surface = atmos_boundary_space, subsurface = subsurface_space)

return ClimaLSM.Domains.SphericalShell{FT}(radius, depth, nothing, nelements, npolynomial, space)
return ClimaLand.Domains.SphericalShell{FT}(radius, depth, nothing, nelements, npolynomial, space)
end

# extensions required by Interfacer
get_field(sim::BucketSimulation, ::Val{:surface_temperature}) =
ClimaLSM.surface_temperature(sim.model, sim.integrator.u, sim.integrator.p, sim.integrator.t)
ClimaLand.surface_temperature(sim.model, sim.integrator.u, sim.integrator.p, sim.integrator.t)
get_field(sim::BucketSimulation, ::Val{:surface_humidity}) =
ClimaLSM.surface_specific_humidity(sim.model, sim.integrator.u, sim.integrator.p, sim.integrator.t)
ClimaLand.surface_specific_humidity(sim.model, sim.integrator.u, sim.integrator.p, sim.integrator.t)
get_field(sim::BucketSimulation, ::Val{:roughness_momentum}) = sim.model.parameters.z_0m
get_field(sim::BucketSimulation, ::Val{:roughness_buoyancy}) = sim.model.parameters.z_0b
get_field(sim::BucketSimulation, ::Val{:beta}) =
ClimaLSM.surface_evaporative_scaling(sim.model, sim.integrator.u, sim.integrator.p)
ClimaLand.surface_evaporative_scaling(sim.model, sim.integrator.u, sim.integrator.p)
get_field(sim::BucketSimulation, ::Val{:albedo}) =
ClimaLSM.surface_albedo(sim.model, sim.integrator.u, sim.integrator.p)
ClimaLand.surface_albedo(sim.model, sim.integrator.u, sim.integrator.p)
get_field(sim::BucketSimulation, ::Val{:area_fraction}) = sim.area_fraction
get_field(sim::BucketSimulation, ::Val{:air_density}) = sim.integrator.p.bucket.ρ_sfc

function update_field!(sim::BucketSimulation, ::Val{:turbulent_energy_flux}, field)
parent(sim.integrator.p.bucket.turbulent_fluxes.shf) .= parent(field)
end
function update_field!(sim::BucketSimulation, ::Val{:turbulent_moisture_flux}, field)
ρ_liq = (LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set))
ρ_liq = (LP.ρ_cloud_liq(sim.model.parameters.earth_param_set))
parent(sim.integrator.p.bucket.turbulent_fluxes.vapor_flux) .= parent(field ./ ρ_liq) # TODO: account for sublimation
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)
ρ_liq = (LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set))
ρ_liq = (LP.ρ_cloud_liq(sim.model.parameters.earth_param_set))
parent(sim.integrator.p.drivers.P_liq) .= parent(field ./ ρ_liq)
end
function update_field!(sim::BucketSimulation, ::Val{:snow_precipitation}, field)
ρ_ice = (LSMP.ρ_cloud_ice(sim.model.parameters.earth_param_set))
ρ_ice = (LP.ρ_cloud_ice(sim.model.parameters.earth_param_set))
parent(sim.integrator.p.drivers.P_snow) .= parent(field ./ ρ_ice)
end

Expand All @@ -81,7 +81,7 @@ function update_turbulent_fluxes_point!(sim::BucketSimulation, fields::NamedTupl
(; F_turb_energy, F_turb_moisture) = fields
sim.integrator.p.bucket.turbulent_fluxes.shf[colidx] .= F_turb_energy
sim.integrator.p.bucket.turbulent_fluxes.vapor_flux[colidx] .=
F_turb_moisture ./ LSMP.ρ_cloud_liq(sim.model.parameters.earth_param_set)
F_turb_moisture ./ LP.ρ_cloud_liq(sim.model.parameters.earth_param_set)
return nothing
end

Expand Down Expand Up @@ -126,8 +126,8 @@ function get_field(bucket_sim::BucketSimulation, ::Val{:energy})
end

e_per_area .+=
-LSMP.LH_f0(bucket_sim.model.parameters.earth_param_set) .*
LSMP.ρ_cloud_liq(bucket_sim.model.parameters.earth_param_set) .* bucket_sim.integrator.u.bucket.σS
-LP.LH_f0(bucket_sim.model.parameters.earth_param_set) .*
juliasloan25 marked this conversation as resolved.
Show resolved Hide resolved
LP.ρ_cloud_liq(bucket_sim.model.parameters.earth_param_set) .* bucket_sim.integrator.u.bucket.σS
return e_per_area
end

Expand All @@ -137,7 +137,7 @@ end
Extension of Interfacer.get_field that provides the total water contained in the bucket, including the liquid water in snow.
"""
function get_field(bucket_sim::BucketSimulation, ::Val{:water})
ρ_cloud_liq = ClimaLSM.LSMP.ρ_cloud_liq(bucket_sim.model.parameters.earth_param_set)
ρ_cloud_liq = ClimaLand.LP.ρ_cloud_liq(bucket_sim.model.parameters.earth_param_set)
return
@. (bucket_sim.integrator.u.bucket.σS + bucket_sim.integrator.u.bucket.W + bucket_sim.integrator.u.bucket.Ws) *
ρ_cloud_liq # kg water / m2
Expand All @@ -149,18 +149,18 @@ Returns the surface temperature of the earth, computed from the state u.
"""
function get_land_temp_from_state(land_sim, u)
# required by viz_explorer.jl
return ClimaLSM.surface_temperature(land_sim.model, u, land_sim.integrator.p, land_sim.integrator.t)
return ClimaLand.surface_temperature(land_sim.model, u, land_sim.integrator.p, land_sim.integrator.t)
end

"""
dss_state!(sim::BucketSimulation)

Perform DSS on the state of a component simulation, intended to be used
before the initial step of a run. This method acts on bucket land simulations.
The `dss!` function of ClimaLSM must be called because it uses either the 2D
The `dss!` function of ClimaLand must be called because it uses either the 2D
or 3D dss buffer stored in the cache depending on space of each variable in
`sim.integrator.u`.
"""
function dss_state!(sim::BucketSimulation)
ClimaLSM.dss!(sim.integrator.u, sim.integrator.p, sim.integrator.t)
ClimaLand.dss!(sim.integrator.u, sim.integrator.p, sim.integrator.t)
end
2 changes: 1 addition & 1 deletion experiments/AMIP/coupler_driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ SIC and assuming a 2m thickness of the ice.
In the `SlabPlanet` mode, all ocean and sea ice are dynamical models, namely thermal slabs, with different parameters.

### Land
If evolving, use `ClimaLSM.jl`'s bucket model.
If evolving, use `ClimaLand.jl`'s bucket model.
=#

@info mode_name
Expand Down
Loading
Loading