Skip to content

Commit 5101fe9

Browse files
committed
Format
1 parent fe2cb1b commit 5101fe9

File tree

6 files changed

+48
-45
lines changed

6 files changed

+48
-45
lines changed

ext/CreateParametersExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ function TwoStreamParameters(
628628
ρ_leaf = FT.(ρ_leaf)
629629
τ_leaf = FT.(τ_leaf)
630630
end
631-
631+
632632
if (isnothing(spectral_discretization))
633633
spectral_discretization = TwoBandSpectralDiscretization{FT}()
634634
end

src/standalone/Vegetation/Canopy.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ function ClimaLand.make_update_aux(
457457
p.canopy.radiative_transfer.G .= compute_G(G_Function, θs)
458458
RT = canopy.radiative_transfer
459459
banded_sw_d = (sw_d) -> sw_d .* RT.parameters.spectral_discretization.I
460-
@. SW_d.= banded_sw_d(p.drivers.SW_d)
460+
@. SW_d .= banded_sw_d(p.drivers.SW_d)
461461
K = p.canopy.radiative_transfer.K
462462
@. K = extinction_coeff(p.canopy.radiative_transfer.G, θs)
463463
DOY =
@@ -489,7 +489,10 @@ function ClimaLand.make_update_aux(
489489
)
490490

491491
# Extract PAR radiation from radiative transfer output
492-
get_PAR = (rt) -> sum(map(x -> x.abs, rt) .* spectral_discretization.PAR_proportions)
492+
get_PAR =
493+
(rt) -> sum(
494+
map(x -> x.abs, rt) .* spectral_discretization.PAR_proportions,
495+
)
493496
faPAR = get_PAR.(p.canopy.radiative_transfer.rt)
494497

495498

@@ -558,7 +561,8 @@ function ClimaLand.make_update_aux(
558561

559562
# Update Rd, An, Vcmax25 (if applicable to model) in place
560563
Vcmax25 = p.canopy.photosynthesis.Vcmax25
561-
get_par_d = (sw_d) -> sum(sw_d .* spectral_discretization.PAR_proportions)
564+
get_par_d =
565+
(sw_d) -> sum(sw_d .* spectral_discretization.PAR_proportions)
562566
par_d = get_par_d.(SW_d)
563567
update_photosynthesis!(
564568
Rd,

src/standalone/Vegetation/canopy_parameterizations.jl

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,11 @@ function compute_fractional_absorbances!(
9999
) where {FT}
100100
RTP = RT.parameters
101101
if typeof(RTP.ρ_leaf) <: Tuple
102-
@. p.canopy.radiative_transfer.rt = canopy_sw_rt_beer_lambert(
103-
RTP.Ω,
104-
(RTP.ρ_leaf,),
105-
LAI,
106-
K,
107-
(α_soil,),
108-
)
102+
@. p.canopy.radiative_transfer.rt =
103+
canopy_sw_rt_beer_lambert(RTP.Ω, (RTP.ρ_leaf,), LAI, K, (α_soil,))
109104
else
110-
@. p.canopy.radiative_transfer.rt = canopy_sw_rt_beer_lambert(
111-
RTP.Ω,
112-
RTP.ρ_leaf,
113-
LAI,
114-
K,
115-
(α_soil,),
116-
)
105+
@. p.canopy.radiative_transfer.rt =
106+
canopy_sw_rt_beer_lambert(RTP.Ω, RTP.ρ_leaf, LAI, K, (α_soil,))
117107
end
118108
end
119109

@@ -205,7 +195,10 @@ function canopy_sw_rt_beer_lambert(
205195
AR = (1 .- ρ_leaf) .* (1 - exp(-K * LAI * Ω)) .* (1 .- α_soil)
206196
TR = exp(-K * LAI * Ω)
207197
RR = FT(1) .- AR .- TR .* (1 .- α_soil)
208-
return ntuple(i -> (; abs = AR[i], refl = RR[i], trans = TR), length(ρ_leaf))
198+
return ntuple(
199+
i -> (; abs = AR[i], refl = RR[i], trans = TR),
200+
length(ρ_leaf),
201+
)
209202
end
210203

211204
"""
@@ -269,8 +262,8 @@ function canopy_sw_rt_two_stream(
269262
c = ω .* β
270263
d = ω .* β₀ .* μ̄ .* K
271264
f = ω .* μ̄ .* K .* (1 .- β₀)
272-
h = .√(b.^2 .- c.^2) ./ μ̄
273-
σ = (μ̄ * K)^2 .+ c.^2 .- b.^2
265+
h = .√(b .^ 2 .- c .^ 2) ./ μ̄
266+
σ = (μ̄ * K)^2 .+ c .^ 2 .- b .^ 2
274267

275268
u₁ = b .- c ./ α_soil
276269
u₂ = b .- c .* α_soil
@@ -303,11 +296,15 @@ function canopy_sw_rt_two_stream(
303296
# h coefficients for direct downward flux
304297
h₄ = .-f .* p₃ .- c .* d
305298
h₅ =
306-
-1 ./ d₂ .*
307-
(h₄ .* (u₂ .+ μ̄ .* h) ./.* s₁) .+ (u₃ .- h₄ ./ σ .* (u₂ .- μ̄ .* K)) .* s₂)
299+
-1 ./ d₂ .* (
300+
h₄ .* (u₂ .+ μ̄ .* h) ./.* s₁) .+
301+
(u₃ .- h₄ ./ σ .* (u₂ .- μ̄ .* K)) .* s₂
302+
)
308303
h₆ =
309-
1 ./ d₂ .*
310-
(h₄ ./ σ .* (u₂ .- μ̄ .* h) .* s₁ .+ (u₃ .- h₄ ./ σ .* (u₂ .- μ̄ .* K)) .* s₂)
304+
1 ./ d₂ .* (
305+
h₄ ./ σ .* (u₂ .- μ̄ .* h) .* s₁ .+
306+
(u₃ .- h₄ ./ σ .* (u₂ .- μ̄ .* K)) .* s₂
307+
)
311308

312309
# h coefficients for diffuse upward flux
313310
h₇ = c .* (u₁ .- μ̄ .* h) ./ (d₁ .* s₁)
@@ -342,12 +339,10 @@ function canopy_sw_rt_two_stream(
342339

343340
# Compute the direct fluxes into/out of the layer
344341
I_dir_up =
345-
h₁ .* exp.(-K * L * Ω) ./ σ .+
346-
h₂ .* exp.(.-h .* L .* Ω) .+
342+
h₁ .* exp.(-K * L * Ω) ./ σ .+ h₂ .* exp.(.-h .* L .* Ω) .+
347343
h₃ .* exp.(h .* L .* Ω)
348344
I_dir_dn =
349-
h₄ .* exp.(-K * L * Ω) ./ σ .+
350-
h₅ .* exp.(.-h .* L .* Ω) .+
345+
h₄ .* exp.(-K * L * Ω) ./ σ .+ h₅ .* exp.(.-h .* L .* Ω) .+
351346
h₆ .* exp.(h .* L .* Ω)
352347

353348
# Add collimated radiation to downard flux
@@ -372,7 +367,8 @@ function canopy_sw_rt_two_stream(
372367

373368

374369
# Add radiation absorbed in the layer to total absorbed radiation
375-
F_abs = F_abs .+ (1 - frac_diff) .* I_dir_abs .+ (frac_diff) .* I_dif_abs
370+
F_abs =
371+
F_abs .+ (1 - frac_diff) .* I_dir_abs .+ (frac_diff) .* I_dif_abs
376372

377373
# Save input/output values to compute energy balance of next layer
378374
I_dir_up_prev = I_dir_up
@@ -387,7 +383,14 @@ function canopy_sw_rt_two_stream(
387383
# Convert fractional absorption into absorption and return
388384
# Ensure floating point precision is correct (it may be different for PAR)
389385
F_trans = (1 .- F_abs .- F_refl) ./ (1 .- α_soil)
390-
return ntuple(i -> (; abs = FT(F_abs[i]), refl = FT(F_refl[i]), trans = FT(F_trans[i])), length(ρ_leaf))
386+
return ntuple(
387+
i -> (;
388+
abs = FT(F_abs[i]),
389+
refl = FT(F_refl[i]),
390+
trans = FT(F_trans[i]),
391+
),
392+
length(ρ_leaf),
393+
)
391394
end
392395

393396
"""

src/standalone/Vegetation/ground_drivers.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ function PrescribedGroundConditions(
5656
)),
5757
ψ::Function = t -> 0.0,
5858
T::Function = t -> 298.0,
59-
spectral_discretization::AbstractSpectralDiscretization = ClimaLand.TwoBandSpectralDiscretization{FT}(),
59+
spectral_discretization::AbstractSpectralDiscretization = ClimaLand.TwoBandSpectralDiscretization{
60+
FT,
61+
}(),
6062
α_ground::Tuple = FT.((0.2, 0.4)),
6163
ϵ = FT(0.99),
6264
)

src/standalone/Vegetation/radiation.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ ClimaLand.auxiliary_vars(model::Union{BeerLambertModel, TwoStreamModel}) =
160160
ClimaLand.auxiliary_types(
161161
model::Union{BeerLambertModel{FT}, TwoStreamModel{FT}},
162162
) where {FT} = (
163-
NTuple{
164-
length(model.parameters.spectral_discretization.λ) - 1,
165-
FT,
166-
},
163+
NTuple{length(model.parameters.spectral_discretization.λ) - 1, FT},
167164
NTuple{
168165
length(model.parameters.spectral_discretization.λ) - 1,
169166
NamedTuple{(:abs, :refl, :trans), Tuple{FT, FT, FT}},

test/standalone/Vegetation/canopy_model.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,8 @@ end
578578
mechanism_cases = (FT(1), mechanism_field)
579579
rooting_cases = (FT(0.5), fill(FT(0.5), domain.space.surface))
580580
# test default values as field
581-
ρ_leaf_cases = (
582-
(FT(0.1), FT(0.1)),
583-
fill((FT(0.1), FT(0.1)), domain.space.surface),
584-
)
581+
ρ_leaf_cases =
582+
((FT(0.1), FT(0.1)), fill((FT(0.1), FT(0.1)), domain.space.surface))
585583
ld_cases = (FT(0.5), fill(FT(0.5), domain.space.surface))
586584
zipped_params = zip(
587585
g1_cases,
@@ -1178,10 +1176,8 @@ end
11781176
rooting_cases = (FT(0.5), fill(FT(0.5), domain.space.surface))
11791177
ρ_leaf_cases =
11801178
(FT.((0.1, 0.45)), fill(FT.((0.1, 0.45)), domain.space.surface))
1181-
τ_leaf_cases = (
1182-
FT.((0.05, 0.25)),
1183-
fill(FT.((0.05, 0.25)), domain.space.surface),
1184-
)
1179+
τ_leaf_cases =
1180+
(FT.((0.05, 0.25)), fill(FT.((0.05, 0.25)), domain.space.surface))
11851181
χl_cases = (FT(0.1), fill(FT(0.1), domain.space.surface))
11861182
zipped_params = zip(
11871183
Ω_cases,
@@ -1428,7 +1424,8 @@ end
14281424
)
14291425
get_abs = (rt) -> map(x -> x.abs, rt)
14301426
@test all(
1431-
Array(parent(get_abs.(p.canopy.radiative_transfer.rt))) .== FT(0),
1427+
Array(parent(get_abs.(p.canopy.radiative_transfer.rt))) .==
1428+
FT(0),
14321429
)
14331430
@test all(
14341431
Array(parent(p.canopy.autotrophic_respiration.Ra)) .==

0 commit comments

Comments
 (0)