Skip to content

Commit

Permalink
Merge pull request #406 from CliMA/js/unpack
Browse files Browse the repository at this point in the history
rm UnPack dep
  • Loading branch information
juliasloan25 authored Nov 23, 2023
2 parents 91b142d + 0eb210f commit 60c616b
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 33 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
ArtifactWrappers = "0.2"
Expand All @@ -37,5 +36,4 @@ SciMLBase = "1, 2"
StaticArrays = "1"
SurfaceFluxes = "0.8"
Thermodynamics = "0.9, 0.10, 0.11"
UnPack = "1"
julia = "1.8"
2 changes: 1 addition & 1 deletion docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ uuid = "d934ef94-cdd4-4710-83d6-720549644b70"
version = "0.3.11"

[[deps.ClimaLSM]]
deps = ["ArtifactWrappers", "CFTime", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "Dates", "DocStringExtensions", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics", "UnPack"]
deps = ["ArtifactWrappers", "CFTime", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "Dates", "DocStringExtensions", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics"]
path = ".."
uuid = "7884a58f-fab6-4fd0-82bb-ecfedb2d8430"
version = "0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion experiments/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ uuid = "d934ef94-cdd4-4710-83d6-720549644b70"
version = "0.3.11"

[[deps.ClimaLSM]]
deps = ["ArtifactWrappers", "CFTime", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "Dates", "DocStringExtensions", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics", "UnPack"]
deps = ["ArtifactWrappers", "CFTime", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "Dates", "DocStringExtensions", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics"]
path = ".."
uuid = "7884a58f-fab6-4fd0-82bb-ecfedb2d8430"
version = "0.4.0"
Expand Down
1 change: 0 additions & 1 deletion src/ClimaLSM.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module ClimaLSM
using UnPack
using DocStringExtensions

using ClimaCore
Expand Down
2 changes: 1 addition & 1 deletion src/integrated/pond_soil_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function LandHydrology{FT}(;
SW <: Pond.AbstractSurfaceWaterModel{FT},
}

@unpack precip = land_args
(; precip) = land_args

sources = ()
surface_runoff = PrognosticRunoff{FT}(precip)
Expand Down
5 changes: 2 additions & 3 deletions src/standalone/Bucket/Bucket.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Bucket
using UnPack
using DocStringExtensions
using Thermodynamics
using Dates
Expand Down Expand Up @@ -437,7 +436,7 @@ Creates the compute_exp_tendency! function for the bucket model.
"""
function make_compute_exp_tendency(model::BucketModel{FT}) where {FT}
function compute_exp_tendency!(dY, Y, p, t)
@unpack κ_soil, ρc_soil, σS_c, W_f = model.parameters
(; κ_soil, ρc_soil, σS_c, W_f) = model.parameters

#Currently, the entire surface is assumed to be
# snow covered entirely or not at all.
Expand All @@ -452,7 +451,7 @@ function make_compute_exp_tendency(model::BucketModel{FT}) where {FT}

# The below is NOT CORRECT if we want the snow
# cover fraction to be intermediate between 0 and 1.
@unpack turbulent_energy_flux, R_n, evaporation = p.bucket
(; turbulent_energy_flux, R_n, evaporation) = p.bucket
F_sfc = @. (R_n + turbulent_energy_flux) # Eqn (15)

_T_freeze = LSMP.T_freeze(model.parameters.earth_param_set)
Expand Down
1 change: 0 additions & 1 deletion src/standalone/Snow/Snow.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Snow

using UnPack
using DocStringExtensions
import ...Parameters as LSMP
export SnowParameters
Expand Down
1 change: 0 additions & 1 deletion src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Biogeochemistry
using ClimaLSM
using UnPack
using DocStringExtensions
using ClimaCore
import ...Parameters as LSMP
Expand Down
31 changes: 11 additions & 20 deletions src/standalone/Soil/Biogeochemistry/co2_parameterizations.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using UnPack

export volumetric_air_content, co2_diffusivity, microbe_source

Expand All @@ -19,20 +18,12 @@ function microbe_source(
Csom::FT,
params::SoilCO2ModelParameters{FT},
) where {FT}
@unpack α_sx,
Ea_sx,
kM_sx,
kM_o2,
ν,
D_liq,
p_sx,
D_oa,
O2_a,
earth_param_set = params
(; α_sx, Ea_sx, kM_sx, kM_o2, ν, D_liq, p_sx, D_oa, O2_a, earth_param_set) =
params
R = FT(LSMP.gas_constant(earth_param_set))
Vmax = α_sx * exp(-Ea_sx / (R * T_soil)) # Maximum potential rate of respiration
Sx = p_sx * Csom * D_liq * θ_l^3 # All soluble substrate, kgC m⁻³
MM_sx = Sx / (kM_sx + Sx) # Availability of substrate factor, 0-1
MM_sx = Sx / (kM_sx + Sx) # Availability of substrate factor, 0-1
O2 = D_oa * O2_a * ((ν - θ_l)^(FT(4 / 3))) # Oxygen concentration
MM_o2 = O2 / (kM_o2 + O2) # Oxygen limitation factor, 0-1
R_sm = Vmax * MM_sx * MM_o2 # Respiration, kg C m⁻³ s⁻¹
Expand All @@ -44,9 +35,9 @@ end
volumetric_air_content(θ_w::FT,
params::SoilCO2ModelParameters{FT}
) where {FT}
Computes the volumetric air content (`θ_a`) in the soil,
which is related to the total soil porosity (`ν`) and
Computes the volumetric air content (`θ_a`) in the soil,
which is related to the total soil porosity (`ν`) and
volumetric soil water content (`θ_w = θ_l+θ_i`).
"""
function volumetric_air_content(
Expand All @@ -67,11 +58,11 @@ end
Computes the diffusivity of CO₂ within the soil (D).
First, D0 is computed using the temperature within the soil (`T_soil` in K) and
First, D0 is computed using the temperature within the soil (`T_soil` in K) and
pressure at the surface of the soil (`P_sfc` in Pa), using reference
values of `T_ref` and `P_ref` (273 K and 101325 Pa). Here, `θ_a` is the
volumetric air content and `θ_a100` is the volumetric air content
at a soil water potential of
values of `T_ref` and `P_ref` (273 K and 101325 Pa). Here, `θ_a` is the
volumetric air content and `θ_a100` is the volumetric air content
at a soil water potential of
100cm, and b is the pore size distribution of the soil.
"""
function co2_diffusivity(
Expand All @@ -80,7 +71,7 @@ function co2_diffusivity(
P_sfc::FT,
params::SoilCO2ModelParameters{FT},
) where {FT}
@unpack D_ref, θ_a100, b, ν, earth_param_set = params
(; D_ref, θ_a100, b, ν, earth_param_set) = params
T_ref = FT(LSMP.T_0(earth_param_set))
P_ref = FT(LSMP.P_ref(earth_param_set))
θ_a = volumetric_air_content(θ_w, params)
Expand Down
1 change: 0 additions & 1 deletion src/standalone/SurfaceWater/Pond.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Pond
using ClimaLSM
using ClimaCore
using UnPack
using DocStringExtensions
import ClimaCore: Fields

Expand Down
2 changes: 1 addition & 1 deletion src/standalone/Vegetation/Canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ function ClimaLSM.make_update_aux(
ϑ_l = Y.canopy.hydraulics.ϑ_l
fa = p.canopy.hydraulics.fa

#unpack parameters
# unpack parameters
area_index = p.canopy.hydraulics.area_index
LAI = area_index.leaf
RAI = area_index.root
Expand Down

0 comments on commit 60c616b

Please sign in to comment.