Ok, so here is a somewhat simple numerical scheme, that shows conceptual properties of your system. It is analogous to (explicit) Euler's method. It can be easily generalized to an analogous implicit Euler-like method.
You are given:
The functions h(x)
, f(x)
, tau_sx(x, t)
, tau_sy(x, t)
and tau_by(x, t)
The constants g
and rho
You are looking for :
The functions V(x, t)
and eta(x, t)
that satisfy the pair of differential equations above.
To be able to find solutions to this problem, you need to be given:
V(x, 0) = V0(x)
and eta(0, t) = eta0(t)
Assume your domain is [0, L] X [0, T]
, where x
in [0, L]
and t
in [0, T]
. Discretize the domain as follows: choose M
and N
positive integers and let dx = L / M
and dt = T / N
. Then consider only the finite set of points x = m dx
and t = n dt
for any integers m = 0, 1, ..., M
and n = 0, 1, ..., N
.
I am going to restrict all functions on the finite set of points defined above and use the following notation for an arbitrary function funct
:
funct(x, t) = funct[m, n]
and funct(x) = funct[m]
for any x = m dx
and t = n dt
.
Then, the system of differential equations can be discretized as
g*(h[m] + eta[m,n])*(eta[m+1, n] - eta[m,n])/dx = f[m]*(h[m] + eta[m,n])*V[m,n] + tau_sx[m,n]/rho
(V[m, n+1] - V[m,n])/dt = (tau_sy[m,n] - tau_by[m,n])/(rho*(h[m] + eta[m,n]))
Solve for eta[m+1,n]
and V[m,n+1]
eta[m+1,n] = eta[m,n] + f[m]*V[m,n]*dx/g + tau_sx[m,n]*dx/(g*rho*(h[m] + eta[m,n]))
V[m,n+1] = V[m,n] + (tau_sy[m,n] - tau_by[m,n])*dt/(rho*(h[m] + eta[m,n]))
For simplicity, I am going to abbreviate the right hand sides of the equations above as
eta[m+1,n] = F_eta(m, n, eta[m,n], V[m,n])
V[m,n+1] = F_V(m, n, eta[m,n], V[m,n])
that is, something like
def F_eta(m, n, eta[m,n], V[m,n]):
return eta[m,n] + f[m]*V[m,n]*dx/g + tau_sx[m,n]*dx/(g*rho*(h[m] + eta[m,n]))
def F_V(m, n, eta[m,n], V[m,n]):
return V[m,n] + (tau_sy[m,n] - tau_by[m,n])*dt/(rho*(h[m] + eta[m,n]))
From the boundary conditions, we know
eta[0,n] = eta0[n] = eta0(n*dt)
and
V[m,0] = V0[m] = V0(m*dx)
as input, for m = 0,..., M
and n = 0,..., N
.
for n in range(N):
for m in range(M):
eta[m+1,n] = F_eta(m, n, eta[m,n], V[m,n])
V[m,n+1] = F_V(m, n, eta[m,n], V[m,n])
(you have to tweak these loops to reach the rightmost and the upper boundary points, but the philosophy stays the same)
Basically, you follow the pattern: generate the etas along the horizontal x axis and at the same time you generate a V one layer up. Then you move up to the next horizontal level.
o --eta--> o --eta--> o --eta--> o --eta--> o
| | | | |
V V V V V
| | | | |
o --eta--> o --eta--> o --eta--> o --eta--> o