Skip to content

Commit

Permalink
increased tf to 2 years
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Dec 14, 2024
1 parent ad148aa commit 89437d9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
34 changes: 15 additions & 19 deletions docs/tutorials/standalone/Soil/evaporation_modified.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ e = rh * esat
q = FT(0.622 * e / (101325 - 0.378 * e))
K_sat = FT(225.1 / 3600 / 24 / 1000)
# precip = (t) -> min(-(K_sat/18) * sin(2*pi*t/(86400*3)), 0)
precip = (t) -> min((K_sat/0.1) * (sin(2*pi*t/(86400))+0.9), 0)
precip = (t) -> min((K_sat / 0.1) * (sin(2 * pi * t / (86400)) + 0.9), 0)
T_atmos = (t) -> T_air
u_atmos = (t) -> 1.0
q_atmos = (t) -> q
Expand Down Expand Up @@ -246,19 +246,25 @@ data_e = ref_soln_E_350mm[:, 2];
outdir = joinpath(@__DIR__, "jacobian_van_g_evap_Ss1e-1")
!ispath(outdir) && mkdir(outdir)
S = [
Array(parent(ClimaLand.top_center_to_surface((sol.u[k].soil.ϑ_l .- θ_r) ./.- θ_r))))[1] for k in 1:length(sol.t)
Array(
parent(
ClimaLand.top_center_to_surface(
(sol.u[k].soil.ϑ_l .- θ_r) ./.- θ_r),
),
),
)[1] for k in 1:length(sol.t)
];

θ_i = [
Array(parent(ClimaLand.top_center_to_surface(sol.u[k].soil.θ_i)))[1] for k in 1:length(sol.t)
Array(parent(ClimaLand.top_center_to_surface(sol.u[k].soil.θ_i)))[1] for
k in 1:length(sol.t)
];

T = [
Array(parent(ClimaLand.top_center_to_surface(sv.saveval[k].soil.T)))[1] for k in 1:length(sol.t)
];
P_liq = [
Array(parent(sv.saveval[k].drivers.P_liq))[1] for k in 1:length(sol.t)
Array(parent(ClimaLand.top_center_to_surface(sv.saveval[k].soil.T)))[1]
for k in 1:length(sol.t)
];
P_liq = [Array(parent(sv.saveval[k].drivers.P_liq))[1] for k in 1:length(sol.t)];

fig = Figure(size = (800, 400))
ax = Axis(
Expand All @@ -271,23 +277,13 @@ CairoMakie.lines!(ax, sol.t ./ 3600 ./ 24, FT.(S))
save(joinpath(outdir, "evaporation_lehmann2008_fig8b_water.png"), fig);

fig = Figure(size = (800, 400))
ax = Axis(
fig[1, 1],
xlabel = "Day",
ylabel = "temp",
title = "temp in soil",
)
ax = Axis(fig[1, 1], xlabel = "Day", ylabel = "temp", title = "temp in soil")
CairoMakie.lines!(ax, sol.t ./ 3600 ./ 24, FT.(T))
save(joinpath(outdir, "evaporation_lehmann2008_fig8b_temp.png"), fig);


fig = Figure(size = (800, 400))
ax = Axis(
fig[1, 1],
xlabel = "Day",
ylabel = "precip/evap",
title = "precip",
)
ax = Axis(fig[1, 1], xlabel = "Day", ylabel = "precip/evap", title = "precip")
CairoMakie.xlims!(minimum(data_dates), sol.t[end] ./ 3600 ./ 24)
CairoMakie.lines!(
ax,
Expand Down
2 changes: 1 addition & 1 deletion experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ end
function setup_and_solve_problem(; greet = false)

t0 = 0.0
tf = 60 * 60.0 * 24 * 365
tf = 60 * 60.0 * 24 * 365 * 2
Δt = 450.0
nelements = (101, 15)
if greet
Expand Down
2 changes: 1 addition & 1 deletion experiments/long_runs/soil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ end
function setup_and_solve_problem(; greet = false)

t0 = 0.0
tf = 60 * 60.0 * 24 * 365
tf = 60 * 60.0 * 24 * 365 * 2
Δt = 450.0
nelements = (101, 15)
if greet
Expand Down
6 changes: 4 additions & 2 deletions src/shared_utilities/implicit_timestepping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ function ImplicitEquationJacobian(Y::ClimaCore.Fields.FieldVector)
# These are the off-diagonal terms in the Jacobian matrix
# Here, we take the convention that each pair has order (T_x, y) to produce ∂T_x/∂y as above
off_diagonal_pairs = ((@name(soil.ρe_int), @name(soil.ϑ_l)),)
available_off_diagonal_pairs =
MatrixFields.unrolled_filter(pair -> all(is_in_Y.(pair)),off_diagonal_pairs)
available_off_diagonal_pairs = MatrixFields.unrolled_filter(
pair -> all(is_in_Y.(pair)),
off_diagonal_pairs,
)
implicit_off_diagonals = MatrixFields.unrolled_map(
pair ->
(pair[1], pair[2]) =>
Expand Down
14 changes: 6 additions & 8 deletions src/standalone/Soil/energy_hydrology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function ClimaLand.make_compute_jacobian(model::EnergyHydrology{FT}) where {FT}
# The derivative of the residual with respect to the prognostic variable
∂ϑres∂ϑ = matrix[@name(soil.ϑ_l), @name(soil.ϑ_l)]
∂ρeres∂ρe = matrix[@name(soil.ρe_int), @name(soil.ρe_int)]
∂ρeres∂ϑ = matrix[@name(soil.ρe_int), @name(soil.ϑ_l)]
∂ρeres∂ϑ = matrix[@name(soil.ρe_int), @name(soil.ϑ_l)]
# If the top BC is a `MoistureStateBC`, add the term from the top BC
# flux before applying divergence
if haskey(p.soil, :dfluxBCdY)
Expand Down Expand Up @@ -376,16 +376,14 @@ function ClimaLand.make_compute_jacobian(model::EnergyHydrology{FT}) where {FT}
end
@. ∂ρeres∂ϑ =
-dtγ * (
divf2c_matrix()
MatrixFields.DiagonalMatrixRow(
divf2c_matrix() MatrixFields.DiagonalMatrixRow(
-interpc2f_op(
volumetric_internal_energy_liq(
p.soil.T,
model.parameters.earth_param_set,
) * p.soil.K,
)
)
gradc2f_matrix() MatrixFields.DiagonalMatrixRow(
),
) gradc2f_matrix() MatrixFields.DiagonalMatrixRow(
ClimaLand.Soil.dψdϑ(
hydrology_cm,
Y.soil.ϑ_l,
Expand All @@ -395,9 +393,9 @@ function ClimaLand.make_compute_jacobian(model::EnergyHydrology{FT}) where {FT}
),
)
) - (I,)





@. ∂ρeres∂ρe =
-dtγ * (
divf2c_matrix()
Expand Down

0 comments on commit 89437d9

Please sign in to comment.