Skip to content

Commit

Permalink
fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Jul 12, 2024
1 parent eadfba1 commit 8074709
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
4 changes: 2 additions & 2 deletions experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ function setup_and_solve_problem(; greet = false)
# to set up for both CPU/GPU at the same time
t0 = 0.0
tf = 60 * 60.0 * 6
Δt = 900.0
Δt = 1800.0
nelements = (101, 15)
if greet
@info "Run: Global RichardsModel"
@info "Run: Global Land Model"
@info "Resolution: $nelements"
@info "Timestep: $Δt s"
@info "Duration: $(tf - t0) s"
Expand Down
10 changes: 4 additions & 6 deletions src/shared_utilities/implicit_timestepping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ function ImplicitEquationJacobian(Y::ClimaCore.Fields.FieldVector)
is_in_Y(var) = MatrixFields.has_field(Y, var)

# Define the implicit and explicit variables of any model we use
implicit_names = (@name(soil.ϑ_l), @name(soil.ρe_int), @name(canopy.energy.T))
explicit_names = (
@name(soilco2.C),
@name(soil.θ_i),
@name(canopy.hydraulics.ϑ_l),
)
implicit_names =
(@name(soil.ϑ_l), @name(soil.ρe_int), @name(canopy.energy.T))
explicit_names =
(@name(soilco2.C), @name(soil.θ_i), @name(canopy.hydraulics.ϑ_l))

# Filter out the variables that are not in this model's state, `Y`
available_implicit_vars =
Expand Down
12 changes: 6 additions & 6 deletions src/standalone/Vegetation/Canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,11 @@ function make_compute_imp_tendency(
end

"""
make_update_jacobian(canopy::CanopyModel)
ClimaLand.make_compute_jacobian(canopy::CanopyModel)
Creates and returns the update_jacobian! for the `CanopyModel`.
Creates and returns the compute_jacobian! for the `CanopyModel`.
"""
function make_update_jacobian(
function ClimaLand.make_compute_jacobian(
canopy::CanopyModel{
FT,
<:AutotrophicRespirationModel,
Expand All @@ -659,16 +659,16 @@ function make_update_jacobian(
) where {FT}
components = canopy_components(canopy)
update_jacobian_list = map(
x -> make_update_jacobian(getproperty(canopy, x), canopy),
x -> make_compute_jacobian(getproperty(canopy, x), canopy),
components,
)
function update_jacobian!(W, Y, p, dtγ, t)
function compute_jacobian!(W, Y, p, dtγ, t)
for f! in update_jacobian_list
f!(W, Y, p, dtγ, t)
end

end
return update_jacobian!
return compute_jacobian!
end


Expand Down
8 changes: 4 additions & 4 deletions src/standalone/Vegetation/component_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function ClimaLand.make_compute_exp_tendency(
end

"""
ClimaLand.make_compute_exp_tendency(component::AbstractCanopyComponent, canopy)
ClimaLand.make_compute_imp_tendency(component::AbstractCanopyComponent, canopy)
Creates the compute_imp_tendency!(dY,Y,p,t) function for the canopy `component`.
Expand All @@ -161,9 +161,9 @@ function ClimaLand.make_compute_imp_tendency(
end


function make_update_jacobian(component::AbstractCanopyComponent, canopy)
function update_jacobian!(W, Y, p, dtγ, t) end
return update_jacobian!
function make_compute_jacobian(component::AbstractCanopyComponent, canopy)
function compute_jacobian!(W, Y, p, dtγ, t) end
return compute_jacobian!
end

"""
Expand Down
8 changes: 3 additions & 5 deletions test/standalone/Vegetation/canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,10 @@ for FT in (Float32, Float64)
set_initial_cache!(p, Y, t0)
exp_tendency! = make_exp_tendency(canopy)
imp_tendency! = ClimaLand.make_imp_tendency(canopy)
tendency_jacobian! = ClimaLand.make_tendency_jacobian(canopy)
jacobian! = ClimaLand.make_jacobian(canopy)
# set up jacobian info
jac_kwargs = (;
jac_prototype = ImplicitEquationJacobian(Y),
Wfact = tendency_jacobian!,
)
jac_kwargs =
(; jac_prototype = ImplicitEquationJacobian(Y), Wfact = jacobian!)

dY = similar(Y)
exp_tendency!(dY, Y, p, t0)
Expand Down

0 comments on commit 8074709

Please sign in to comment.