Skip to content

Commit e86fd76

Browse files
authored
Merge pull request #1511 from CliMA/js/f-rad
use update_turbulent_fluxes; don't area weight rad flux
2 parents 304590b + 1061ef8 commit e86fd76

File tree

8 files changed

+22
-39
lines changed

8 files changed

+22
-39
lines changed

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ ClimaCoupler.jl Release Notes
66

77
### ClimaCoupler features
88

9+
#### Use `update_turbulent_fluxes!` instead of `update_field!` for atmosphere PR[#1511](https://github.com/CliMA/ClimaCoupler.jl/pull/1511)
10+
Instead of using an `update_field!` method that dispatches on `::Val{:turbulent_fluxes}`
11+
to update turbulent fluxes in the atmosphere, we switch to using a function `update_turbulent_fluxes!`.
12+
This is consistent with what we do for surface models.
13+
14+
This PR also removes area fraction weighting in the default radiative flux update
15+
in FluxCalculator.jl.
16+
917
#### Replace `TD.PhaseEquil_ρTq` with `TD.PhaseNonEquil_ρTq` PR[#1506](https://github.com/CliMA/ClimaCoupler.jl/pull/1506)
1018
This should be more physically correct.
1119

experiments/ClimaEarth/components/atmosphere/climaatmos.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,7 @@ function Interfacer.update_field!(
452452
CC.Fields.field2array(temp_field_surface)'
453453
end
454454

455-
function Interfacer.update_field!(
456-
sim::ClimaAtmosSimulation,
457-
::Val{:turbulent_fluxes},
458-
fields,
459-
)
455+
function FluxCalculator.update_turbulent_fluxes!(sim::ClimaAtmosSimulation, fields)
460456
(; F_lh, F_sh, F_turb_moisture, F_turb_ρτxz, F_turb_ρτyz) = fields
461457
atmos_surface_space = get_surface_space(sim)
462458
temp_field_surface = sim.integrator.p.scratch.ᶠtemp_field_level

src/FieldExchanger.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ function update_sim!(atmos_sim::Interfacer.AtmosModelSimulation, csf)
195195
)
196196
Interfacer.update_field!(atmos_sim, Val(:emissivity), csf.emissivity)
197197
Interfacer.update_field!(atmos_sim, Val(:surface_temperature), csf)
198-
Interfacer.update_field!(atmos_sim, Val(:turbulent_fluxes), csf)
199198
return nothing
200199
end
201200

@@ -209,14 +208,8 @@ Updates the surface component model cache with the current coupler fields beside
209208
- `csf`: [NamedTuple] containing coupler fields.
210209
"""
211210
function update_sim!(sim::Interfacer.SurfaceModelSimulation, csf, area_fraction)
212-
FT = eltype(area_fraction)
213-
214211
# radiative fluxes
215-
Interfacer.update_field!(
216-
sim,
217-
Val(:radiative_energy_flux_sfc),
218-
FT.(area_fraction .* csf.F_radiative),
219-
)
212+
Interfacer.update_field!(sim, Val(:radiative_energy_flux_sfc), csf.F_radiative)
220213

221214
# precipitation
222215
Interfacer.update_field!(sim, Val(:liquid_precipitation), csf.P_liq)

src/FluxCalculator.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ function turbulent_fluxes!(csf, model_sims, thermo_params)
6868

6969
# Update the atmosphere with the fluxes across all surface models
7070
# The surface models have already been updated with the fluxes in `compute_surface_fluxes!`
71-
# TODO this should be `update_turbulent_fluxes` to match the surface models
72-
Interfacer.update_field!(atmos_sim, Val(:turbulent_fluxes), csf)
71+
FluxCalculator.update_turbulent_fluxes!(atmos_sim, csf)
7372
return nothing
7473
end
7574

@@ -188,11 +187,14 @@ function get_surface_params(atmos_sim::Interfacer.AtmosModelSimulation)
188187
end
189188

190189
"""
191-
update_turbulent_fluxes!(sim::Interfacer.SurfaceModelSimulation, fields::NamedTuple)
190+
update_turbulent_fluxes!(sim::Interfacer.ComponentModelSimulation, fields::NamedTuple)
192191
193-
Updates the fluxes in the surface model simulation `sim` with the fluxes in `fields`.
192+
Updates the fluxes in the simulation `sim` with the fluxes in `fields`.
193+
194+
For surface models, this should be the fluxes computed between the surface model and the atmosphere.
195+
For atmosphere models, this should be the area-weighted sum of fluxes across all surface models.
194196
"""
195-
function update_turbulent_fluxes!(sim::Interfacer.SurfaceModelSimulation, fields)
197+
function update_turbulent_fluxes!(sim::Interfacer.ComponentModelSimulation, fields)
196198
return error(
197199
"update_turbulent_fluxes! is required to be dispatched on $(nameof(sim)), but no method defined",
198200
)

src/Interfacer.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ update_field!(
275275
Val{:surface_direct_albedo},
276276
Val{:surface_diffuse_albedo},
277277
Val{:surface_temperature},
278-
Val{:turbulent_fluxes},
279278
},
280279
_,
281280
) = update_field_warning(sim, val)

test/field_exchanger_tests.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ Interfacer.update_field!(sim::TestAtmosSimulation, ::Val{:surface_temperature},
121121
Interfacer.update_field!(sim::TestAtmosSimulation, ::Val{:roughness_buoyancy}, field) =
122122
nothing
123123
Interfacer.update_field!(sim::TestAtmosSimulation, ::Val{:beta}, field) = nothing
124-
Interfacer.update_field!(sim::TestAtmosSimulation, ::Val{:turbulent_fluxes}, field) =
125-
nothing
126124

127125
#surface sim
128126
struct TestSurfaceSimulationLand{C} <: Interfacer.SurfaceModelSimulation

test/flux_calculator_tests.jl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,15 @@ Interfacer.get_field(sim::TestAtmos, ::Val{:liquid_precipitation}) =
4040
CC.Fields.zeros(axes(sim.integrator.T))
4141
Interfacer.get_field(sim::TestAtmos, ::Val{:snow_precipitation}) =
4242
CC.Fields.zeros(axes(sim.integrator.T))
43+
FieldExchanger.update_sim!(sim::TestAtmos, fields, _) = nothing
4344

44-
45-
function FieldExchanger.import_atmos_fields!(csf, sim::TestAtmos, atmos_sim)
46-
# update atmos properties in coupler fields needed to compute surface fluxes
47-
Interfacer.get_field!(csf.T_atmos, atmos_sim, Val(:air_temperature))
48-
Interfacer.get_field!(csf.q_atmos, atmos_sim, Val(:specific_humidity))
49-
Interfacer.get_field!(csf.ρ_atmos, atmos_sim, Val(:air_density))
50-
end
51-
52-
function FieldExchanger.update_sim!(sim::TestAtmos, fields, _)
45+
function FluxCalculator.update_turbulent_fluxes!(sim::TestAtmos, fields)
5346
(; F_turb_ρτxz, F_lh, F_sh, F_turb_moisture) = fields
5447
ρ_int = sim.integrator.ρ
5548
@. sim.integrator.p.energy_bc = F_lh + F_sh
5649
@. sim.integrator.p.ρq_tot_bc = F_turb_moisture
5750
@. sim.integrator.p.uₕ_bc = F_turb_ρτxz / ρ_int # x-component only for this test
51+
return nothing
5852
end
5953

6054
function get_thermo_params(sim::TestAtmos)
@@ -86,8 +80,6 @@ Interfacer.get_field(
8680
) = sim.integrator.p.α
8781
Interfacer.get_field(sim::TestOcean, ::Val{:emissivity}) = eltype(sim.integrator.T)(1)
8882

89-
FieldExchanger.import_atmos_fields!(csf, sim::TestOcean, atmos_sim) = nothing
90-
9183
function FluxCalculator.update_turbulent_fluxes!(sim::TestOcean, fields::NamedTuple)
9284
(; F_lh, F_sh) = fields
9385
@. sim.integrator.p.F_aero = F_lh + F_sh

test/interfacer_tests.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,8 @@ end
272272
sim = DummySimulation4(space)
273273

274274
# Test that update_field! gives correct warnings for unextended fields
275-
for value in (
276-
:emissivity,
277-
:surface_direct_albedo,
278-
:surface_diffuse_albedo,
279-
:surface_temperature,
280-
:turbulent_fluxes,
281-
)
275+
for value in
276+
(:emissivity, :surface_direct_albedo, :surface_diffuse_albedo, :surface_temperature)
282277
val = Val(value)
283278
@test_logs (
284279
:warn,

0 commit comments

Comments
 (0)