CliMA / ClimateMachine.jl

Climate Machine: an Earth System Model that automatically learns from data
https://clima.github.io/ClimateMachine.jl/latest/
Other
453 stars 78 forks source link

Label implicitly solvable terms #1357

Open LenkaNovak opened 4 years ago

LenkaNovak commented 4 years ago

Some terms can be trivially solved implicitly

tapios commented 4 years ago

The issues here is this: We have relaxation terms in various equations (e.g., microphysics), which look like this:

𝝏f/𝝏t + ... = -(f - g)/𝜏

where f is some variable (e.g., an energy variable), g is another variable (or constant), and 𝜏 is a (short timescale). Because the relaxation timescale is short, introducing stiffness, we want to timestep this term implicitly. This is an easy term to treat implicitly because it does not involve spatial derivatives (i.e., the resulting linear system is diagonal).

For example, implicit Euler discretization gives

f_{t+1} = (f_t + (𝞓t/𝞽) g) / (1 + 𝞓t/𝞽).

How do we make this possible in our code? One challenge is that these terms are quite deep down (e.g., in microphysics code).

As we re-factor interfaces, we need to keep in mind that we want to be able to treat such terms implicitly.

trontrytel commented 4 years ago

An example of such term from our codebase is here:

https://clima.github.io/ClimateMachine.jl/latest/Theory/Atmos/Microphysics/#Cloud-water-condensation/evaporation-1

Implemented here:

https://github.com/CliMA/ClimateMachine.jl/blob/1171a998ca49b9e7a3efc92309ecfd4797110428/src/Atmos/Parameterizations/CloudPhysics/Microphysics.jl#L321-L354

I will setup a MWE with an LES type run that only uses the above as source terms and link it here.

@tapios - Thinking about making this particular term implicit, I'm not sure how to evaluate the liquid and ice specific humidities in equilibrium at t+1?