Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Celsius instead of Kelvin to avoid rounding errors at low-precision #85

Open
white-alistair opened this issue May 27, 2022 · 3 comments
Labels
low precision 🚂 Low precision arithmetics, rounding, 32 or 16-bit.

Comments

@white-alistair
Copy link
Member

Copying @milankl's comment from PR #82:

I mean rewriting the entire model such that temperature uses ˚C instead of Kelvin. I expect everything to work very similar, instead of probably radiation, where somewhere the Stefan-Boltzmann ~T^4 should appear. We could then convert from ˚C to Kelvin therein. But from a precision point-of-view using Kelvin is awful as you'll hit massive rounding errors in the time integration, e.g. T = 300K, tendency dT = 0.1K

julia> T = Float16(300)
Float16(300.0)

julia> dT = Float16(0.1)
Float16(0.1)

julia> T+dT
Float16(300.0)

julia> T2 = Float16(300-273.15)
Float16(26.84)

julia> T2+dT
Float16(26.94)

In Kelvin you can't resolve the increment, but in ˚C you can.

Having said that, we obviously do the time stepping in spectral space, meaning that we'd only have that problem on the l=m=0 mode which we could also solve with compensated summation, but I think in general, we should try to use ˚C if possible. If it turns out that ˚C is a bad idea then we can still revert back.

@white-alistair white-alistair added the low precision 🚂 Low precision arithmetics, rounding, 32 or 16-bit. label May 27, 2022
@milankl
Copy link
Member

milankl commented Aug 15, 2022

With #123 this should become much easier as we can define tempC and tempK for a given column and use both within the parametrizations. Given that the tendencies in ˚C and Kelvin are the same, we then are left with the question whether we can carry temperature in ˚C around in the dynamics...

@milankl
Copy link
Member

milankl commented Mar 15, 2023

Most parts in the dynamical core now use the temperature anomaly anyway, so maybe less of an issue. Hoskins and Burridge 1975 normalise temperature by $a^2\Omega^2/R$ ($a$ radius, $R$ gas constant) which might be another option

@milankl
Copy link
Member

milankl commented May 9, 2023

Btw, IFS uses virtual temperature as prognostic variable, maybe that's a good idea too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low precision 🚂 Low precision arithmetics, rounding, 32 or 16-bit.
Projects
None yet
Development

No branches or pull requests

2 participants