@@ -139,20 +139,19 @@ end
139
139
140
140
141
141
"""
142
- Interfacer.get_field(atmos_sim ::ClimaAtmosSimulation, ::Val{:radiative_energy_flux_toa})
142
+ Interfacer.get_field(sim ::ClimaAtmosSimulation, ::Val{:radiative_energy_flux_toa})
143
143
144
144
Extension of Interfacer.get_field to get the net TOA radiation, which is a sum of the
145
145
upward and downward longwave and shortwave radiation.
146
146
"""
147
- function Interfacer. get_field (atmos_sim :: ClimaAtmosSimulation , :: Val{:radiative_energy_flux_toa} )
148
- FT = eltype (atmos_sim . integrator. u)
147
+ function Interfacer. get_field (sim :: ClimaAtmosSimulation , :: Val{:radiative_energy_flux_toa} )
148
+ FT = eltype (sim . integrator. u)
149
149
150
- if hasradiation (atmos_sim . integrator)
151
- face_space = axes (atmos_sim . integrator. u. f)
150
+ if hasradiation (sim . integrator)
151
+ face_space = axes (sim . integrator. u. f)
152
152
nz_faces = length (CC. Spaces. vertical_topology (face_space). mesh. faces)
153
153
154
- (; face_lw_flux_dn, face_lw_flux_up, face_sw_flux_dn, face_sw_flux_up) =
155
- atmos_sim. integrator. p. radiation. rrtmgp_model
154
+ (; face_lw_flux_dn, face_lw_flux_up, face_sw_flux_dn, face_sw_flux_up) = sim. integrator. p. radiation. rrtmgp_model
156
155
157
156
LWd_TOA = CC. Fields. level (CC. Fields. array2field (FT .(face_lw_flux_dn), face_space), nz_faces - CC. Utilities. half)
158
157
LWu_TOA = CC. Fields. level (CC. Fields. array2field (FT .(face_lw_flux_up), face_space), nz_faces - CC. Utilities. half)
@@ -165,8 +164,8 @@ function Interfacer.get_field(atmos_sim::ClimaAtmosSimulation, ::Val{:radiative_
165
164
end
166
165
end
167
166
168
- function Interfacer. get_field (atmos_sim :: ClimaAtmosSimulation , :: Val{:energy} )
169
- integrator = atmos_sim . integrator
167
+ function Interfacer. get_field (sim :: ClimaAtmosSimulation , :: Val{:energy} )
168
+ integrator = sim . integrator
170
169
p = integrator. p
171
170
172
171
@@ -179,7 +178,7 @@ function Interfacer.get_field(atmos_sim::ClimaAtmosSimulation, ::Val{:energy})
179
178
else
180
179
ᶜS_ρq_tot = p. precipitation. ᶜS_ρq_tot
181
180
end
182
- thermo_params = get_thermo_params (atmos_sim )
181
+ thermo_params = get_thermo_params (sim )
183
182
return integrator. u. c. ρe_tot .-
184
183
ᶜS_ρq_tot .* CA. e_tot_0M_precipitation_sources_helper .(Ref (thermo_params), ᶜts, ᶜΦ) .*
185
184
float (integrator. dt)
@@ -274,8 +273,8 @@ Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:turbulent_moisture_flux})
274
273
moisture_flux (sim. integrator. p. atmos. moisture_model, sim. integrator)
275
274
Interfacer. get_field (sim:: ClimaAtmosSimulation , :: Val{:thermo_state_int} ) =
276
275
CC. Spaces. level (sim. integrator. p. precomputed. ᶜts, 1 )
277
- Interfacer. get_field (atmos_sim :: ClimaAtmosSimulation , :: Val{:water} ) =
278
- ρq_tot (atmos_sim . integrator. p. atmos. moisture_model, atmos_sim . integrator)
276
+ Interfacer. get_field (sim :: ClimaAtmosSimulation , :: Val{:water} ) =
277
+ ρq_tot (sim . integrator. p. atmos. moisture_model, sim . integrator)
279
278
function Interfacer. update_field! (sim:: ClimaAtmosSimulation , :: Val{:surface_temperature} , field)
280
279
# note that this field is also being updated internally by the surface thermo state in ClimaAtmos
281
280
# if turbulent fluxes are calculated, to ensure consistency. In case the turbulent fluxes are not
@@ -361,33 +360,33 @@ function Interfacer.add_coupler_fields!(coupler_field_names, ::ClimaAtmosSimulat
361
360
push! (coupler_field_names, atmos_coupler_fields... )
362
361
end
363
362
364
- function FieldExchanger. update_sim! (atmos_sim :: ClimaAtmosSimulation , csf, turbulent_fluxes)
363
+ function FieldExchanger. update_sim! (sim :: ClimaAtmosSimulation , csf, turbulent_fluxes)
365
364
366
- u = atmos_sim . integrator. u
367
- p = atmos_sim . integrator. p
368
- t = atmos_sim . integrator. t
365
+ u = sim . integrator. u
366
+ p = sim . integrator. p
367
+ t = sim . integrator. t
369
368
370
369
# Perform radiation-specific updates
371
- if hasradiation (atmos_sim . integrator)
370
+ if hasradiation (sim . integrator)
372
371
! (p. atmos. insolation isa CA. IdealizedInsolation) && CA. set_insolation_variables! (u, p, t, p. atmos. insolation)
373
- Interfacer. update_field! (atmos_sim , Val (:surface_direct_albedo ), csf. surface_direct_albedo)
374
- Interfacer. update_field! (atmos_sim , Val (:surface_diffuse_albedo ), csf. surface_diffuse_albedo)
375
- Interfacer. update_field! (atmos_sim , Val (:surface_temperature ), csf. T_sfc)
372
+ Interfacer. update_field! (sim , Val (:surface_direct_albedo ), csf. surface_direct_albedo)
373
+ Interfacer. update_field! (sim , Val (:surface_diffuse_albedo ), csf. surface_diffuse_albedo)
374
+ Interfacer. update_field! (sim , Val (:surface_temperature ), csf. T_sfc)
376
375
end
377
376
378
377
if turbulent_fluxes isa FluxCalculator. PartitionedStateFluxes
379
- Interfacer. update_field! (atmos_sim , Val (:turbulent_fluxes ), csf)
378
+ Interfacer. update_field! (sim , Val (:turbulent_fluxes ), csf)
380
379
end
381
380
end
382
381
383
382
"""
384
- FluxCalculator.calculate_surface_air_density(atmos_sim ::ClimaAtmosSimulation, T_sfc::CC.Fields.Field)
383
+ FluxCalculator.calculate_surface_air_density(sim ::ClimaAtmosSimulation, T_sfc::CC.Fields.Field)
385
384
386
385
Extension for this function to calculate surface density.
387
386
"""
388
- function FluxCalculator. calculate_surface_air_density (atmos_sim :: ClimaAtmosSimulation , T_sfc:: CC.Fields.Field )
389
- thermo_params = get_thermo_params (atmos_sim )
390
- ts_int = Interfacer. get_field (atmos_sim , Val (:thermo_state_int ))
387
+ function FluxCalculator. calculate_surface_air_density (sim :: ClimaAtmosSimulation , T_sfc:: CC.Fields.Field )
388
+ thermo_params = get_thermo_params (sim )
389
+ ts_int = Interfacer. get_field (sim , Val (:thermo_state_int ))
391
390
FluxCalculator. extrapolate_ρ_to_sfc .(Ref (thermo_params), ts_int, Utilities. swap_space! (axes (ts_int. ρ), T_sfc))
392
391
end
393
392
@@ -519,18 +518,18 @@ function coupler_surface_setup(
519
518
end
520
519
521
520
"""
522
- get_new_cache(atmos_sim ::ClimaAtmosSimulation, csf)
521
+ get_new_cache(sim ::ClimaAtmosSimulation, csf)
523
522
524
523
Returns a new `p` with the updated surface conditions.
525
524
"""
526
- function get_new_cache (atmos_sim :: ClimaAtmosSimulation , csf)
527
- if hasmoisture (atmos_sim . integrator)
525
+ function get_new_cache (sim :: ClimaAtmosSimulation , csf)
526
+ if hasmoisture (sim . integrator)
528
527
csf_sfc = (csf. T_sfc, csf. z0m_sfc, csf. z0b_sfc, csf. beta, csf. q_sfc)
529
528
else
530
529
csf_sfc = (csf. T_sfc, csf. z0m_sfc, csf. z0b_sfc, csf. beta)
531
530
end
532
531
533
- p = atmos_sim . integrator. p
532
+ p = sim . integrator. p
534
533
535
534
coupler_sfc_setup = coupler_surface_setup (CoupledMoninObukhov (), p, csf_sfc... )
536
535
@@ -541,7 +540,7 @@ function get_new_cache(atmos_sim::ClimaAtmosSimulation, csf)
541
540
end
542
541
543
542
"""
544
- FluxCalculator.atmos_turbulent_fluxes_most!(atmos_sim ::ClimaAtmosSimulation, csf)
543
+ FluxCalculator.atmos_turbulent_fluxes_most!(sim ::ClimaAtmosSimulation, csf)
545
544
546
545
Computes turbulent surface fluxes using ClimaAtmos's `update_surface_conditions!` and
547
546
and the Monin Obukhov Similarity Theory. This
@@ -556,12 +555,12 @@ For debigging atmos, we can set the following atmos defaults:
556
555
csf.beta .= 1
557
556
csf = merge(csf, (;q_sfc = nothing))
558
557
"""
559
- function FluxCalculator. atmos_turbulent_fluxes_most! (atmos_sim :: ClimaAtmosSimulation , csf)
558
+ function FluxCalculator. atmos_turbulent_fluxes_most! (sim :: ClimaAtmosSimulation , csf)
560
559
561
- if isnothing (atmos_sim . integrator. p. sfc_setup) # trigger flux calculation if not done in Atmos internally
562
- new_p = get_new_cache (atmos_sim , csf)
563
- CA. SurfaceConditions. update_surface_conditions! (atmos_sim . integrator. u, new_p, atmos_sim . integrator. t)
564
- atmos_sim . integrator. p. precomputed. sfc_conditions .= new_p. precomputed. sfc_conditions
560
+ if isnothing (sim . integrator. p. sfc_setup) # trigger flux calculation if not done in Atmos internally
561
+ new_p = get_new_cache (sim , csf)
562
+ CA. SurfaceConditions. update_surface_conditions! (sim . integrator. u, new_p, sim . integrator. t)
563
+ sim . integrator. p. precomputed. sfc_conditions .= new_p. precomputed. sfc_conditions
565
564
end
566
565
end
567
566
@@ -590,28 +589,28 @@ function dss_state!(sim::ClimaAtmosSimulation)
590
589
end
591
590
592
591
"""
593
- FluxCalculator.water_albedo_from_atmosphere!(atmos_sim ::ClimaAtmosSimulation, direct_albedo::CC.Fields.Field, diffuse_albedo::CC.Fields.Field)
592
+ FluxCalculator.water_albedo_from_atmosphere!(sim ::ClimaAtmosSimulation, direct_albedo::CC.Fields.Field, diffuse_albedo::CC.Fields.Field)
594
593
595
594
Extension to calculate the water surface albedo from wind speed and insolation. It can be used for prescribed ocean and lakes.
596
595
"""
597
596
function FluxCalculator. water_albedo_from_atmosphere! (
598
- atmos_sim :: ClimaAtmosSimulation ,
597
+ sim :: ClimaAtmosSimulation ,
599
598
direct_albedo:: CC.Fields.Field ,
600
599
diffuse_albedo:: CC.Fields.Field ,
601
600
)
602
601
603
- Y = atmos_sim . integrator. u
604
- p = atmos_sim . integrator. p
605
- t = atmos_sim . integrator. t
602
+ Y = sim . integrator. u
603
+ p = sim . integrator. p
604
+ t = sim . integrator. t
606
605
607
- rrtmgp_model = atmos_sim . integrator. p. radiation. rrtmgp_model
606
+ rrtmgp_model = sim . integrator. p. radiation. rrtmgp_model
608
607
FT = eltype (Y)
609
608
λ = FT (0 ) # spectral wavelength (not used for now)
610
609
611
610
# update for current zenith angle
612
611
bottom_coords = CC. Fields. coordinate_field (CC. Spaces. level (Y. c, 1 ))
613
612
μ = CC. Fields. array2field (rrtmgp_model. cos_zenith, axes (bottom_coords))
614
- FT = eltype (atmos_sim . integrator. u)
613
+ FT = eltype (sim . integrator. u)
615
614
α_model = CA. RegressionFunctionAlbedo {FT} ()
616
615
617
616
# set the direct and diffuse surface albedos
0 commit comments