efficient IMEX
All we need to modify are the Jacobian terms for ϕ
.
From the IMEX preprint
Gm,j(gm,jϕ)=gm,j−Em,jϕ−gΔtA^j,jEmw+(gΔtA^j,j)2(1−μm,j)
which gets translated into (dicarding any terms that disappear under differentiation),
C1−∑(δϕ)−C2−C3−(gΔtAj,j)2μm,j
.
The tricky thing is that we are calculating this quantity at model interfaces, which means
and so we find
μk=21(dp3dk+1+dp3dk)pk+1−pk=(dp3di)−1p0[(p0−1ϕk+1−ϕkRdθv,k+1dp3dk+1)1−κ1−(p0−1ϕk−ϕk−1Rdθv,kdp3dk)1−κ1]=(dp3di)−1p0[(p0−1Rdθv,k+1dp3dk+1)1−κ1(ϕk+1−ϕk)1−κ1−(p0−1Rdθv,kdp3dk)1−κ1(ϕk−ϕk−1)1−κ1]
and so to make everything as easy to read as possible
∂ϕk+1[μk]=(dp3di)−1p0[(p0−1Rdθv,k+1dp3dk+1)1−κ1(ϕk+1−ϕk)1−κ1(1−κ)(ϕk+1−ϕk)1]=−dp3di,k+1(ϕk+1−ϕk)pk+1
which gives us the template
abc1JLJU,k=1JU,k=1JD,k=1JD,k=1=(1−κ)(Δtg(ϕ1))2=dp3dint,1a=Δϕ1p1=bk+1ck=2bkck=bkck=1−JU,1=1−JL,k−1−JU,k
where we can expand
bmcn=(1−κ)⋅dp3dint,m(Δtg(ϕm))2⋅Δϕnpn=(1−κ)⋅dp3dint,m(Δtg(ϕm))2⋅Δϕnpn
The trick comes from differentiating μ
with respect to ϕ
μ=dp3dint,kpk−pk+1=dp3dint,k+1ΔϕkRdTkdp3dk−Δϕk+1RdTk+1dp3dk+1
and thus
∂Δϕkμ=−dp3dint,k+1pk[Δϕk]−1
averaging
z1−z01∫z0z1(aa+z)2dz=a2(z−z0)1∫z0z1(a+z)2dz=a2(z−z0)1[3(a+z)3]z0z1=a2(z1−z0)1[3((a+z1)−(a+z0))((a+z1)2+(a+z0)2+(a+z0)(a+z1))]=3a2(z1−z0)(z1−z0)((a+z1)2+(a+z0)2+(a+z0)(a+z1))=31[(aa+z1)2+(aa+z0)2+(aa+z0)(aa+z1)]
With good averaging:
Let r^2(ϕiph,ϕimh)
be the energy-consistent average found above.
μiph=(R0ϕiph/g+R0)2Δπiphpip1−pi
with
ϕiph−ϕimh=(ϕiph/g+R0)2+(ϕiph/g+R0)(ϕimh/g+R0)+(ϕimh/g+R0)2R02RdΘip0κpiκ−1
We calculate the necessary partial derivatives ∂ϕiph+{−1,0,1}μiph
using symbolic differentiation
in This notebook
If we let
On interior points this gives:
∂ϕi−1/2μi+1/2=((Rdp0κΘir^i2)ϕi+1/2−ϕi−1/2)1/(κ−1)(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)r^i2)((ϕi−1/2−ϕi+1/2)∂ϕi−1/2[r^i2]−r^i2)r^i+1/22
∂ϕi+3/2μi+1/2=((Rdp0κΘi+1r^i+12(ϕi+3/2−ϕi+1/2))1/(κ−1)(πi+1/2(κ−1)(ϕi+1/2−ϕi+3/2)r^i+12((ϕi+3/2−ϕi+1/2)∂ϕi+3/2[r^i+12]−r^i+12)r^i+212
∂ϕi+1/2μi+1/2=(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)(ϕi+1/2−ϕi+3/2)r^i2r^i+12)((κ−1)(ϕi+1/2−ϕi−1/2)(ϕi+1/2−ϕi+3/2)(((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)−((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1))r^i2r^i+12∂ϕi+1/2[r^i+1/22]+(((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)(ϕi+1/2−ϕi+3/2)((ϕi−1/2−ϕi+1/2)∂ϕi+1/2[r^i2]+r^i2)r^i+12+((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1)(ϕi−1/2−ϕi+1/2)((ϕi+3/2−ϕi+1/2)∂ϕi+1/2[r^i+12]+r^i+12)r^i2)r^i+1/22)
We make the assumption that ∂ϕi+[][r^[]2]=0
∂ϕi−1/2μi+1/2=((Rdp0κΘir^i2)ϕi+1/2−ϕi−1/2)1/(κ−1)(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)r^i2)(−r^i2)r^i+1/22=−(Rdp0κΘir^i2ϕi+1/2−ϕi−1/2)1/(κ−1)πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)r^i+1/22
∂ϕi+3/2μi+1/2=((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1)(πi+1/2(κ−1)(ϕi+1/2−ϕi+3/2)r^i+12(−r^i+12)r^i+212=−(Rdp0κΘi+1r^i+12(ϕi+3/2−ϕi+1/2))1/(κ−1)πi+1/2(κ−1)(ϕi+1/2−ϕi+3/2)r^i+212
∂ϕi+1/2μi+1/2=(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)(ϕi+1/2−ϕi+3/2)r^i2r^i+12)((κ−1)(ϕi+1/2−ϕi−1/2)(ϕi+1/2−ϕi+3/2)(((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)−((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1))r^i2r^i+120+(((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)(ϕi+1/2−ϕi+3/2)((ϕi−1/2−ϕi+1/2)0+r^i2)r^i+12+((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1)(ϕi−1/2−ϕi+1/2)((ϕi+3/2−ϕi+1/2)0+r^i+12)r^i2)r^i+1/22)=(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)(ϕi+1/2−ϕi+3/2)r^i2r^i+12)((((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)(ϕi+1/2−ϕi+3/2)r^i2r^i+12+((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1)(ϕi−1/2−ϕi+1/2)r^i+12r^i2)r^i+1/22)=(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)(ϕi+1/2−ϕi+3/2))((((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)(ϕi+1/2−ϕi+3/2)+((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1)(ϕi−1/2−ϕi+1/2))r^i+1/22)=(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)(ϕi+1/2−ϕi+3/2))((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)(ϕi+1/2−ϕi+3/2)r^i+1/22+(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)(ϕi+1/2−ϕi+3/2))((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1)(ϕi−1/2−ϕi+1/2)r^i+1/22=πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)((Rdp0κΘir^i2)(ϕi+1/2−ϕi−1/2))1/(κ−1)r^i+1/22+πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)((Rdp0κΘi+1r^i+12)(ϕi+3/2−ϕi+1/2))1/(κ−1)r^i+1/22
This means that, discarding product-rule terms that should be quite small in typical simulations,
my IMEX routine should be nearly correct. Given the ridiculous additional computational expense of
calculating the product-rule terms, I would suggest omitting them from the operational analytic Jacobian,
leaving a comment noting that these terms were ommitted, and possibly adding a conditional that
uses the numerical Jacobian if the ratio of rearth/rearth0 is sufficiently small.
To determine what "sufficiently small" means, consider ε=∂z[(R0R0+z)2]=2R02R0+z
.
Assume that the model top is around 40 km. On a planet of Earth, ε≈0.0003
.
On a planet 100x smaller we see ε≈0.05
, which is still quite small considering that
an approximate Jacobian typically still gives (slower) convergence. Running HOMME with a 100x reduction is radius is
quite rare, in any case.
implementing the hell Jacobian:
∂ϕi−1/2μi+1/2=pi(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)r^i2)((ϕi−1/2−ϕi+1/2)∂ϕi−1/2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i+3/2−ϕi+1/2)∂ϕi+1/2[r^i+12]+r^i+12)r^i+1/22
so there are three new terms to calculate:
qkdkek=−(πi+1/2)(pi−pi+1)∂ϕi+1/2[r^i+1/22]=r^i2((ϕi−1/2−ϕi+1/2)∂ϕi+1/2[r^i2]+r^i2)=r^i+12((ϕi+3/2−ϕi+1/2)∂ϕi+1/2[r^i+12]+r^i+12)
Since these all depend on the interface value of ϕi+1/2
, we can't reuse any of this.
We make the definitions
abkck=1−κ(Δtg)2=Δπk+1/2a=Δϕkpk
and
(a2g2)2(ag+ϕi+1/2)(3a2g2)(3ag+ϕi−1/2+2ϕi+1/2)
Top boundary:
∂ϕ1/2μ1/2=−(21π1)(p1/2−p1)∂ϕ1/2[r^1/22]+(πi+1/2(κ−1)(ϕi−1/2−ϕi+1/2)r^i2)pi((ϕi−1/2−ϕi+1/2)∂ϕi+1/2[r^i2]+r^i2)r^i+1/22+(πi+1/2(κ−1)(ϕi+1/2−ϕi+3/2)r^i+12)pi+1((ϕi+3/2−ϕi+1/2)∂ϕi+1/2[r^i+12]+r^i+12)r^i+1/22