shallow water 1 layer, issues with gradient
apatlpo opened this issue · comments
Hi,
I am trying to build upon KleinGordon in order to setup a 1 layer shallow water model:
https://github.com/apatlpo/shenfun_trial/blob/master/swater_1L/swater_1L.py
Unfortunately, the time rate of change of variables is very small at the moment and I suspect I am not normalizing correctly terms corresponding to g\partial_x h
.
In other terms, I am missing the A
term in the KleinGordon example.
If anybody has an idea, I would be most grateful.
Hi
I had a quick look and I see two issues. One is as you mention, you are missing division by A in rhs terms that are not using forward
, i.e., du_hat[:] = Cu*h_hat
and dv_hat[:] = Cv*h_hat
and dh_hat[:] = Chu*u_hat + Chv*v_hat
. Note that forward
here, with only Fourier bases, is just short for inner product divided by diagonal mass matrix, i.e., A. You can get A as A=inner(hh,hh_test)
or simply A=(2*np.pi)**2
. Second, you should expect min(du_hat)
and min(dh_hat)
to be zero, since these are in spectral space. What you ought to use is norms, like np.linalg.norm(u_hat)
.
Hope this helps.
Thanks a lot for this.
The principal bug was actually quite trivial (once spotted of course): line 174 was missing and messed up plotting.