ClimaAtmos.jl
ClimaAtmos.jl copied to clipboard
Expose `SurfaceFluxes.surface_conditions`
It would be useful to access SurfaceFluxes.surface_conditions
in the cache, which would then allow extrapolation of the u profile to the surface (e.g. for surface albedo) and to separate energy fluxes (i.e., LHF, and SHF).
Does this also help us clean up this block in the surface_conditions
file ? (As of commit #99d2578 in main
)
68 # This is a hack for meeting the August 7th deadline. It is to ensure that the
69 # coupler will be able to construct an integrator before overwriting its surface
70 # conditions, but without throwing an error during the computation of
71 # precomputed quantities for diagnostic EDMF due to uninitialized surface
72 # conditions.
73 # TODO: Refactor the surface conditions API to avoid needing to do this.
74 function set_dummy_surface_conditions!(p)
75 (; params, atmos) = p
76 (; sfc_conditions) = p.precomputed
77 FT = eltype(params)
78 thermo_params = CAP.thermodynamics_params(params)
79 @. sfc_conditions.ustar = FT(0.2)
80 @. sfc_conditions.obukhov_length = FT(1e-4)
81 @. sfc_conditions.buoyancy_flux = FT(0)
82 if atmos.moisture_model isa DryModel
83 | @. sfc_conditions.ts = TD.PhaseDry_ρT(thermo_params, FT(1), FT(300))
84 else
85 | @. sfc_conditions.ts = TD.PhaseNonEquil_ρTq(
86 | | thermo_params,
87 | | FT(1),
88 | | FT(300),
89 | | TD.PhasePartition(FT(0)),
90 | )
91 | @. sfc_conditions.ρ_flux_q_tot = C3(FT(0))
92 end
93 @. sfc_conditions.ρ_flux_h_tot = C3(FT(0))
94 end
This issue is more about how lhf and shf are stored in atmos cache.
It would be nice to replace set_dummy_surface_conditions
with a set!
function that allows the user set up initial conditions (including the other variables) externally, as @glwagner suggested. Technically we don't need most of this as the turbulent fluxes are calculated and set in the coupler, but the initial sfc_conditions.ts might be needed by other parameterizations (e.g. radiation and EDMF). That said, radiation is a callback, and it shouldn't be run until the model is stepped, by which point we've already updated the sfc_conditions.ts based on our actual surfaces. With EDMF, I'm not 100% sure, since we're calculating some of the auxiliary variables in precomputed_quantities
.
@dennisYatunin do you know if we need set_dummy_surface_conditions
to get_simulation
when precomputing_arguments.sfc_setup = nothing
?
On set!
--- it could make sense to add this feature to ClimaCore
fields first, and then build it up to also apply to consistent atmos states, etc.