Closed dennisYatunin closed 7 months ago
Attention: 26 lines
in your changes are missing coverage. Please review.
Comparison is base (
1dc23bb
) 93.04% compared to head (eccb2ae
) 90.98%.
Files | Patch % | Lines |
---|---|---|
src/states.jl | 0.00% | 25 Missing :warning: |
src/relations.jl | 0.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR adds a method to every user-facing
ThermodynamicState
constructor, in which all input arguments are promoted to the same number type. In addition,q_vap_saturation_generic
is given a new method that promotes its input arguments.With only three exceptions, every function from
Thermodynamics.jl
that gets called while computing the precomputed quantities and implicit tendencies ofClimaAtmos.jl
only takes two input arguments: a parameter set and aThermodynamicState
. The exceptions areThermodynamicState
s, where some inputs can be prescribed by the conditions att = 0
orz = 0
while others depend on the prognostic statetotal_specific_enthalpy(param_set, ts, e_tot)
, wherets
ande_tot
both depend on the prognostic stateq_vap_saturation_generic(param_set, T, ρ, phase)
, whereT
is prescribed by the conditions atz = 0
whileρ
depends on the prognostic state in the bottom elementSo, this PR constitutes the minimum set of additions to
Thermodynamics.jl
that will enable us to use automatic differentiation inClimaAtmos.jl
, which involves replacing values in the prognostic state with numbers of typeForwardDiff.Dual
.This is a simpler alternative to #197, which I'm going to close for now. In the future, we may want to come back to the changes in that PR, since they are much more generalizable. That is, they will not require to continue adding new methods to every function that relies on promotion during automatic differentiation in other repositories. The downside to those changes is that they would allow developers to silently introduce
Float32
/Float64
type instabilities within internal functions, and we would probably want to add more unit tests to ensure that those are avoided.