Adding Clima Thermodynamics#112
Conversation
Co-authored-by: Copilot <copilot@github.com>
…into ob/feature_clima_thermodyn
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
|
I now also see that there is an issue on the use of abbreviations in physical constants #111. Is this something to fix in this PR or not @bgroenks96 ? |
|
Hey @olivierbonte, I think this PR would be a good opportunity to resolve #111! I had also considered splitting up PhysicalConstants into separate types for thermodynamic vs material and hydraulic constants. What do you think about this? |
|
Alright! I'll try to address this soon I agree that splitting up the constants in categories makes sense, otherwise this one struct will get very large I think. Given the current set of properties, thermodynamic vs material makes sense to me. Any preferences for the naming of these structs? |
bgroenks96
left a comment
There was a problem hiding this comment.
Looks really great! Thanks a lot!
| @inline cp_v(c::PhysicalConstants) = c.cp_v | ||
| @inline LH_v0(c::PhysicalConstants) = c.Llg | ||
| @inline LH_s0(c::PhysicalConstants) = c.Lsg | ||
| @inline T_0(c::PhysicalConstants) = c.T_ref |
There was a problem hiding this comment.
Why is this T_0 and not T_ref? I guess you can also address this when updating the names to be fully spelled out.
| @inline saturation_vapor_pressure(T, a₁, a₂, a₃) = a₁ * exp(a₂ * T / (T + a₃)) | ||
| @inline function saturation_vapor_pressure(c::PhysicalConstants, T::NF) where {NF} | ||
| T_K = celsius_to_kelvin(c, T) | ||
| return if T <= zero(T) |
There was a problem hiding this comment.
I know this also isn't what the old code did, but maybe we should use ifelse here just to be safe (for Enzyme/GPU)?
As previously mentioned in #108, I thought Thermodynamics.jl could be a nice way to avoid reimplementation of a lot of the thermodynamics. This PR is an attempt at replacing some utilities by functions from Thermodynamics.jl.
To avoid the use of ClimaParams.jl,
PhysicalConstantsis defined as a subtype ofAbstractThermodynamicsParameters. This approach is inspired by the use of Thermodynamics.jl in NumericalEarth.jl for the atmospheric thermodynamics (see here).This PR also introduces specific heat capacity and air density as functions, not constants, consistent with the use in Thermodynamics.jl