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

add ClimaLandSimulation struct #1199

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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: 3 additions & 1 deletion experiments/ClimaEarth/Manifest-v1.11.toml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ version = "0.2.12"

[[deps.ClimaLand]]
deps = ["ArtifactWrappers", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaUtilities", "Dates", "DocStringExtensions", "Insolation", "Interpolations", "LazyArtifacts", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics"]
git-tree-sha1 = "b8025e014a0642d7b468aa7c1df38f039cb3a742"
git-tree-sha1 = "c968f29638830c97e3fa0b0aeb305b81f2b0b69c"
repo-rev = "tr/support-coupling-LandModel"
repo-url = "https://github.com/CliMA/ClimaLand.jl.git"
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
version = "0.15.9"

Expand Down
84 changes: 3 additions & 81 deletions experiments/ClimaEarth/components/land/climaland_bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ClimaLand.Parameters as LP
import ClimaDiagnostics as CD
import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer
using NCDatasets
include("climaland_helpers.jl")

###
### Functions required by ClimaCoupler.jl for a SurfaceModelSimulation
Expand All @@ -26,21 +27,6 @@ struct BucketSimulation{M, D, I, A} <: Interfacer.LandModelSimulation
end
Interfacer.name(::BucketSimulation) = "BucketSimulation"

"""
get_new_cache(p, Y, energy_check)

Returns a new `p` with an updated field to store e_per_area if energy conservation
checks are turned on.
"""
function get_new_cache(p, Y, energy_check)
if energy_check
e_per_area_field = CC.Fields.zeros(axes(Y.bucket.W))
return merge(p, (; e_per_area = e_per_area_field))
else
return p
end
end

"""
bucket_init

Expand All @@ -49,7 +35,7 @@ Initializes the bucket model variables.
function BucketSimulation(
::Type{FT},
tspan::Tuple{TT, TT},
config::String,
domain_type::String,
albedo_type::String,
land_initial_condition::String,
land_temperature_anomaly::String,
Expand All @@ -65,12 +51,7 @@ function BucketSimulation(
surface_elevation,
use_land_diagnostics::Bool,
) where {FT, TT <: Union{Float64, ITime}}
if config != "sphere"
println(
"Currently only spherical shell domains are supported; single column set-up will be addressed in future PR.",
)
@assert config == "sphere"
end
@assert domain_type == "sphere" "Currently only spherical shell domains are supported; single column may be supported in the future."

α_snow = FT(0.8) # snow albedo
if albedo_type == "map_static" # Read in albedo from static data file (default type)
Expand Down Expand Up @@ -120,7 +101,6 @@ function BucketSimulation(

# Initial conditions with no moisture
Y, p, coords = CL.initialize(model)
p = get_new_cache(p, Y, energy_check)

# Get temperature anomaly function
T_functions = Dict("aquaplanet" => temp_anomaly_aquaplanet, "amip" => temp_anomaly_amip)
Expand Down Expand Up @@ -349,64 +329,6 @@ function Checkpointer.get_model_prog_state(sim::BucketSimulation)
return sim.integrator.u.bucket
end

"""
temp_anomaly_aquaplanet(coord)

Introduce a temperature IC anomaly for the aquaplanet case.
The values for this case follow the moist Held-Suarez setup of Thatcher &
Jablonowski (2016, eq. 6), consistent with ClimaAtmos aquaplanet.
"""
temp_anomaly_aquaplanet(coord) = 29 * exp(-coord.lat^2 / (2 * 26^2))

"""
temp_anomaly_amip(coord)

Introduce a temperature IC anomaly for the AMIP case.
The values used in this case have been tuned to align with observed temperature
and result in stable simulations.
"""
temp_anomaly_amip(coord) = 40 * cosd(coord.lat)^4

"""
make_land_domain(
atmos_boundary_space::CC.Spaces.SpectralElementSpace2D,
zlim::Tuple{FT, FT},
nelements_vert::Int,) where {FT}

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_land_domain(
atmos_boundary_space::CC.Spaces.SpectralElementSpace2D,
zlim::Tuple{FT, FT},
nelements_vert::Int,
) where {FT}
@assert zlim[1] < zlim[2]
depth = zlim[2] - zlim[1]

mesh = CC.Spaces.topology(atmos_boundary_space).mesh

radius = mesh.domain.radius
nelements_horz = mesh.ne
npolynomial = CC.Spaces.Quadratures.polynomial_degree(CC.Spaces.quadrature_style(atmos_boundary_space))
nelements = (nelements_horz, nelements_vert)
vertdomain = CC.Domains.IntervalDomain(
CC.Geometry.ZPoint(FT(zlim[1])),
CC.Geometry.ZPoint(FT(zlim[2]));
boundary_names = (:bottom, :top),
)

vertmesh = CC.Meshes.IntervalMesh(vertdomain, CC.Meshes.Uniform(), nelems = nelements[2])
verttopology = CC.Topologies.IntervalTopology(vertmesh)
vert_center_space = CC.Spaces.CenterFiniteDifferenceSpace(verttopology)
subsurface_space = CC.Spaces.ExtrudedFiniteDifferenceSpace(atmos_boundary_space, vert_center_space)
space = (; surface = atmos_boundary_space, subsurface = subsurface_space)

fields = CL.Domains.get_additional_domain_fields(subsurface_space)

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

"""
dss_state!(sim::BucketSimulation)

Expand Down
59 changes: 59 additions & 0 deletions experiments/ClimaEarth/components/land/climaland_helpers.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import ClimaCore as CC
import ClimaLand
"""
temp_anomaly_aquaplanet(coord)

Introduce a temperature IC anomaly for the aquaplanet case.
The values for this case follow the moist Held-Suarez setup of Thatcher &
Jablonowski (2016, eq. 6), consistent with ClimaAtmos aquaplanet.
"""
temp_anomaly_aquaplanet(coord) = 29 * exp(-coord.lat^2 / (2 * 26^2))

"""
temp_anomaly_amip(coord)

Introduce a temperature IC anomaly for the AMIP case.
The values used in this case have been tuned to align with observed temperature
and result in stable simulations.
"""
temp_anomaly_amip(coord) = 40 * cosd(coord.lat)^4

"""
make_land_domain(
atmos_boundary_space::CC.Spaces.SpectralElementSpace2D,
zlim::Tuple{FT, FT},
nelements_vert::Int,) where {FT}

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_land_domain(
atmos_boundary_space::CC.Spaces.SpectralElementSpace2D,
zlim::Tuple{FT, FT},
nelements_vert::Int,
) where {FT}
@assert zlim[1] < zlim[2]
depth = zlim[2] - zlim[1]

mesh = CC.Spaces.topology(atmos_boundary_space).mesh

radius = mesh.domain.radius
nelements_horz = mesh.ne
npolynomial = CC.Spaces.Quadratures.polynomial_degree(CC.Spaces.quadrature_style(atmos_boundary_space))
nelements = (nelements_horz, nelements_vert)
vertdomain = CC.Domains.IntervalDomain(
CC.Geometry.ZPoint(FT(zlim[1])),
CC.Geometry.ZPoint(FT(zlim[2]));
boundary_names = (:bottom, :top),
)

vertmesh = CC.Meshes.IntervalMesh(vertdomain, CC.Meshes.Uniform(), nelems = nelements[2])
verttopology = CC.Topologies.IntervalTopology(vertmesh)
vert_center_space = CC.Spaces.CenterFiniteDifferenceSpace(verttopology)
subsurface_space = CC.Spaces.ExtrudedFiniteDifferenceSpace(atmos_boundary_space, vert_center_space)
space = (; surface = atmos_boundary_space, subsurface = subsurface_space)

fields = ClimaLand.Domains.get_additional_coordinate_field_data(subsurface_space)

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