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

Remove FT. from Biogeochemistry #676

Merged
merged 4 commits into from
Jul 2, 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
10 changes: 4 additions & 6 deletions src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,12 @@ This has been written so as to work with Differential Equations.jl.
"""
function ClimaLand.make_update_aux(model::SoilCO2Model)
function update_aux!(p, Y, t)
# get FT to enforce types of variables not stored directly in `p`
FT = eltype(Y.soilco2.C)
params = model.parameters
z = model.domain.fields.z
T_soil = FT.(soil_temperature(model.driver.met, p, Y, t, z))
θ_l = FT.(soil_moisture(model.driver.met, p, Y, t, z))
Csom = FT.(soil_SOM_C(model.driver.soc, p, Y, t, z))
P_sfc = FT.(air_pressure(model.driver.atmos, p, Y, t))
T_soil = soil_temperature(model.driver.met, p, Y, t, z)
θ_l = soil_moisture(model.driver.met, p, Y, t, z)
Csom = soil_SOM_C(model.driver.soc, p, Y, t, z)
P_sfc = air_pressure(model.driver.atmos, p, Y, t)
θ_w = θ_l

p.soilco2.D .= co2_diffusivity.(T_soil, θ_w, P_sfc, Ref(params))
Expand Down
15 changes: 9 additions & 6 deletions src/standalone/Vegetation/canopy_energy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,19 @@ function make_compute_exp_tendency(
# area index on the LHF, as ac_canopy [J/m^2/K]
# is per unit area plant.

net_energy_flux = @. -p.canopy.radiative_transfer.LW_n -
p.canopy.radiative_transfer.SW_n +
p.canopy.energy.shf +
p.canopy.energy.lhf - p.canopy.energy.fa_energy_roots

# To prevent dividing by zero, change AI" to
# "max(AI, eps(FT))"
c_per_ground_area =
@. ac_canopy * max(area_index.leaf + area_index.stem, eps(FT))
@. dY.canopy.energy.T = -net_energy_flux / c_per_ground_area

# d(energy.T) = - net_energy_flux / specific_heat_capacity
@. dY.canopy.energy.T =
-(
-p.canopy.radiative_transfer.LW_n -
p.canopy.radiative_transfer.SW_n +
p.canopy.energy.shf +
p.canopy.energy.lhf - p.canopy.energy.fa_energy_roots
) / c_per_ground_area
end
return compute_exp_tendency!
end
Expand Down
Loading