# Tide-influenced Turbidity Current

## Formulation

A layer-averaged model for a turbidity current and an upper ambient water layer is described herein. Let $t$ and $x$ be time and streamwise bed-attached coordinate. Mass conservation equations of two layers take the form: 

\begin{equation}
\frac{\partial h_a}{\partial t} + \frac{\partial h_a U_a}{\partial x} = - e_w \left|U_t - U_a \right| \tag{1}\label{eq:cont_ha}
\end{equation}

\begin{equation}
\frac{\partial h_t}{\partial t} + \frac{\partial h_t U_t}{\partial x} = e_w \left|U_t - U_a \right| \tag{2}\label{eq:cont_ht}
\end{equation}

where $h_a$ and $h_t$ are thickness of layers of an ambient water and a turbidity current respectively. The parameter $e_w$ denotes the entrainment rate of ambient water to a turbidity current. $U_t$ and $U_a$ are velocities of an ambient water layer and a turbidity current.

Momentum equations of two layers are:

\begin{equation}
\frac{\partial h_a U_a}{\partial t} + \frac{\partial h_a U_a^{2}}{\partial x} = -g h_a \frac{\partial \eta}{\partial x} - g h_a \frac{\partial \left(h_a + h_t \right)}{\partial x} - 2 \nu \frac{U_a -  U_t}{h_a + h_t} \tag{3}\label{eq:momentum_Ua}
\end{equation}

\begin{equation}
\frac{\partial h_t U_t}{\partial t} + \frac{\partial h_t U_t^{2}}{\partial x} = - (1 + RC)gh_t \frac{\partial \eta}{\partial x} - g h_t \frac{\partial \left( h_a + h_t \right)}{\partial x} -RCgh_t \frac{ \partial h_t}{\partial x} + 2 \nu \frac{U_a - U_t}{h_a + h_t} - C_f U_t \left|U_t\right| \tag{4}\label{eq:momentum_Ut}
\end{equation}

where $\eta$ indicates the bed elevation. $R(=(\rho_s - \rho_f)/\rho_f)$ denotes submerged specific density of sediment particles ($\rho_s$ and $\rho_f$ are density of sediment and water), and $\nu$ is kinematic viscosity of water (assuming $RC << 1$). The parameters $C_f$ and $g$ denotes bed friction coefficient and gravity acceleraton respectively. The parameter $C$ is concentration of suspended sediment in a layer of a turbidity current, and the mass conservation of suspended sediment takes the form:

\begin{equation}
\frac{\partial C h_t}{\partial t} + \frac{\partial U_t C h_t}{\partial x} = w_s \left( e_s - r_0 C \right) \tag{5}\label{eq:cont_C}
\end{equation}

where $w_s$ is the settling velocity of sediment particle, and $r_0$ is a ratio of near-bed to layer-averaged concentration. The parameter $e_s$ indicates the rate of sediment entrainment from the bed.

From equations \eqref{eq:cont_ha}, \eqref{eq:cont_ht}, \eqref{eq:momentum_Ua}, \eqref{eq:momentum_Ut} and \eqref{eq:cont_C}, we obtain

\begin{equation}
\frac{\partial h_a}{\partial t} + U_a \frac{\partial h_a}{\partial x} = - e_w \left|U_t - U_a \right| - h_a \frac{\partial U_a}{\partial x} \equiv G_{ha} \tag{6}\label{eq:cont_ha_cip}
\end{equation}

\begin{equation}
\frac{\partial h_t}{\partial t} + U_t \frac{\partial h_t}{\partial x} = e_w \left|U_t - U_a \right| - h_t \frac{\partial U_t}{\partial x} \equiv G_{ht} \tag{7}\label{eq:cont_ht_cip}
\end{equation}

\begin{equation}
\frac{\partial U_a}{\partial t} + U_a \frac{\partial U_a}{\partial x} = -g \frac{\partial \eta}{\partial x} - g \frac{\partial \left(h_a + h_t \right)}{\partial x} - \frac{2 \nu}{h_a} \left(\frac{U_a -  U_t}{h_a + h_t}\right) + \frac{e_w \left|U_t - U_a \right| U_a}{h_a} \equiv G_{Ua} \tag{8}\label{eq:momentum_Ua_cip}
\end{equation}

\begin{equation}
\frac{\partial U_t}{\partial t} + U_t \frac{\partial U_t}{\partial x} = - (1 + RC)g\frac{\partial \eta}{\partial x} - g \frac{\partial \left( h_a + h_t \right)}{\partial x} -RCg\frac{ \partial h_t}{\partial x} + \frac{2 \nu}{h_t} \left( \frac{U_a - U_t}{h_a + h_t} \right) - \frac{C_f U_t \left|U_t\right|}{h_t} - \frac{e_w \left|U_t - U_a \right| U_t}{h_t} \equiv G_{Ut} \tag{9}\label{eq:momentum_Ut_cip}
\end{equation}

\begin{equation}
\frac{\partial C}{\partial t} + U_t \frac{\partial C}{\partial x} = \frac{1}{h} \left\{ w_s \left( e_s - r_0 C \right) - e_w C \left|U_t - U_a \right| \right\} \equiv G_{C} \tag{10}\label{eq:cont_C_cip}
\end{equation}

where $G_{ha}, G_{ht}, G_{Ua}, G_{Ut}, G_{C}$ are non-advective terms of the two-layer shallow water equation system. We write the two layers sytem under the compact form:

\begin{equation}
\frac{\partial \boldsymbol{f}}{\partial t} + \boldsymbol{U} \frac{\partial \boldsymbol{f}}{\partial x} = \boldsymbol{G} \tag{11}\label{eq:compact_system}
\end{equation}

where
\begin{equation}
\boldsymbol{f}=(h_a, h_t, U_a, U_t, C)^{T}, \boldsymbol{U}=(U_a, U_t, U_a, U_t, U_t), \boldsymbol{G}=(G_{ha}, G_{ht}, G_{Ua}, G_{Ut}, G_{C})^{T}
\end{equation}

## Numerical solution

Equation \eqref{eq:compact_system} can be solved numerically by CIP method. In this methodology, the equation \eqref{eq:compact_system} is split into advection and non-advection phases. The advection phase takes the form:

\begin{equation}
\frac{\partial \boldsymbol{f}}{\partial t} + \boldsymbol{U} \frac{\partial \boldsymbol{f}}{\partial x} = 0 \tag{12}\label{eq:cip_advection_f}
\end{equation}

\begin{equation}
\frac{\partial \left(\partial_x \boldsymbol{f}\right)}{\partial t} + \boldsymbol{U} \frac{\partial  \left(\partial_x \boldsymbol{f}\right)}{\partial x} = 0 \tag{13}\label{eq:cip_advection_df}
\end{equation}

These equations are descretized as:

\begin{equation}
f_i^{*} = a \xi^3 + b \xi^2 + \partial_x f^{n} \xi + f_i \tag{14}\label{eq:cip_adv_scheme}
\end{equation}

\begin{equation}
\partial_x f_i^{*} = 3 a \xi^2 + 2 b \xi + \partial_x f^{n} \tag{15}\label{eq:cip_adv_scheme_dif}
\end{equation}

where $\xi= -U \Delta t$. The coefficients $a$ and $b$ are defined as:

\begin{equation}
a = \frac{\partial_x f_i^n + \partial_x f_{iup}^n}{D^2} + \frac{2 \left(f_i^n - f_{iup}^n \right)}{D^3} \tag{16}\label{cip_adv_coeff_a}
\end{equation}

\begin{equation}
b = \frac{3 \left(f_{iup}^n - f_i^n\right)}{D^2} - \frac{2 \partial_x f_i^n + \partial_x f_{iup}^n }{D} \tag{17}\label{cip_adv_coeff_b}
\end{equation}

where $iup$ denotes the upstream grid of the $i$th grid, and $D$ is

\begin{equation}
D = \begin{cases}
- \Delta x & (U_i > 0) \\
\Delta x & (U_i < 0)
\end{cases} \tag{18}\label{cip_D}
\end{equation}

After the calculation of the advection phase, the non-advection phase is calculated by:

\begin{equation}
\frac{\partial \boldsymbol{f}}{\partial t} = G \tag{19}
\end{equation}

\begin{equation}
\frac{\partial \left(\partial_x \boldsymbol{f}\right)}{\partial t} = \partial_x G - \frac{\partial f}{\partial x} \frac{\partial U}{\partial x} \tag{20}
\end{equation}

These equations are descretized as:

\begin{equation}
f_i^{n+1} = f^* + G_i \Delta t \tag{21}
\end{equation}

\begin{equation}
\partial_x f_i^{n + 1} = \partial_x f^* + \frac{f_{i + 1}^{n+1} - f_{i-1}^{n + 1}}{2 \Delta x} - \frac{f_{i + 1}^{*} - f_{i-1}^{n*}}{2 \Delta x} - \left( \frac{\partial U}{\partial x} \right)_i \partial_x f^*  \tag{22}
\end{equation}




```python
from tideturb import Grid, TwoLayerTurbidityCurrent
from matplotlib import pyplot as plt

grid = Grid(number_of_grids=200, spacing=20.0)
grid.eta = grid.x * -0.05
tc = TwoLayerTurbidityCurrent(
    grid=grid,
    turb_vel=2.0,
    ambient_vel=0.3,
    turb_thick=5.0,
    ambient_thick=100.0,
    concentration=0.01,
    Ds=80*10**-6,
    alpha=0.5,
    implicit_repeat_num=5,
    )
steps = 50
for i in range(steps):
    # tc.plot(ylim_velocity=[-0.5, 8.0], ylim_concentration=[0, 9.0])
    # plt.savefig('test11/tidal_ebb_{:04d}'.format(i))
    tc.run_one_step(dt=100.0)
    print("", end='\r')
    print('{:.1f}% finished.'.format(i / steps * 100), end='\r')

tc.plot(ylim_velocity=[-0.5, 8.0], ylim_concentration=[0, 9.0])
# plt.savefig('test11/tidal_ebb_{:04d}'.format(i))
plt.show() 
tc.save('test12_5000sec')

```

    98.0% finished.

    /home/naruse/anaconda3/lib/python3.6/site-packages/matplotlib/figure.py:445: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
      % get_backend())



```python
from tideturb import Grid, TwoLayerTurbidityCurrent
import matplotlib as mpl
# mpl.use('Agg')
import matplotlib.pyplot as plt
import tideturb
import numpy as np
import pickle

tc = tideturb.load_model('test12_5000sec')
steps = 12
# offset = 50
periodicity = 12 * 3600
for i in range(steps):
    # tc.plot(ylim_velocity=[-0.5, 8.0], ylim_concentration=[0, 9.0])
    # plt.savefig('test11_cycle/tidal_cycle_{:04d}'.format(i))
    for j in range(36):
        tc.ambient_vel = 0.3 * np.sin((i * 3600 + j * 100) / periodicity * 2 * np.pi + 0.5 * np.pi)
        tc.U_link_temp[0, 0] = tc.ambient_vel
        tc.U_link_temp[0, 1] = tc.ambient_vel
        tc.run_one_step(dt=100.0)
    tc.save('test12_cycle_{:0=2}h'.format(i))
    print("", end='\r')
    print('{:.1f}% finished.'.format(i / steps * 100), end='\r')

# tc.plot(ylim_velocity=[-0.5, 8.0], ylim_concentration=[0, 9.0])
# plt.savefig('test11_cycle/tidal_cycle_{:04d}'.format(i))
plt.show()
tc.save('test12_cycle_12hrs')
```

    91.7% finished.


```python
from tideturb import Grid, TwoLayerTurbidityCurrent
from matplotlib import pyplot as plt
import numpy as np

grid = Grid(number_of_grids=100, spacing=40.0)
grid.eta = grid.x * -0.05

C = np.linspace(0.006, 0.015, 30)
velocity = np.linspace(1.5, 2.5, 30)
vel_difference = np.zeros([len(velocity), len(C)])

for i in range(len(velocity)):
    for j in range(len(C)):
        tc1 = TwoLayerTurbidityCurrent(
            grid=grid,
            turb_vel=velocity[i],
            ambient_vel=0.3,
            turb_thick=5.0,
            ambient_thick=100.0,
            concentration=C[j],
            Ds=80*10**-6,
            alpha=0.5,
            implicit_repeat_num=5,
        )
        tc1.run_one_step(dt=3000)
        plt.close(tc1.fig)
        
        tc2 = TwoLayerTurbidityCurrent(
            grid=grid,
            turb_vel=velocity[i],
            ambient_vel=-0.3,
            turb_thick=5.0,
            ambient_thick=100.0,
            concentration=C[j],
            Ds=80*10**-6,
            alpha=0.5,
            implicit_repeat_num=5,
        )
        tc2.run_one_step(dt=3000)
        plt.close(tc2.fig)

        vel_difference[i][j] = tc1.U_node[1][-1] - tc2.U_node[1][-1]
        print("", end='\r')
        print('{:.1f}% finished.'.format((i * len(C) + j + 1) / (len(C) * len(velocity)) * 100), end='\r')

print(vel_difference)
np.savetxt('vel_difference4.txt', vel_difference, delimiter=',')
```

    [[ 1.67553697e-02  2.04528849e-03 -2.13336859e-02 -3.92631066e-02
      -5.03579013e-02 -5.64753047e-02 -6.01815366e-02 -6.31804350e-02
      -6.76992399e-02 -8.27539357e-02 -1.29821513e-01 -2.24908740e-01
      -3.24605963e-01 -3.52185120e-01 -3.15732888e-01 -2.34236046e-01
      -2.32577550e-01 -3.02061751e-01 -4.34000939e-01 -2.71201961e-01
       6.29298729e-02  7.77410601e-02  9.20932326e-02  1.10539708e-01
       1.34650764e-01  1.66752963e-01  2.11245175e-01  2.76604538e-01
       3.75484327e-01  5.75596527e-01]
     [ 1.48006098e-02 -4.73205635e-03 -2.82634940e-02 -4.48598233e-02
      -5.51446920e-02 -6.14138037e-02 -6.68661481e-02 -7.65740912e-02
      -1.06100643e-01 -1.77571367e-01 -2.80862884e-01 -3.46695973e-01
      -3.30772986e-01 -2.75228584e-01 -2.39512915e-01 -2.82362465e-01
      -3.97130822e-01 -3.34359836e-01  5.39608048e-02  6.95909987e-02
       8.17879578e-02  9.74218492e-02  1.22579904e-01  1.49541739e-01
       1.86858325e-01  2.40110699e-01  3.21784685e-01  4.63206132e-01
       7.75067837e-01  1.80424823e+00]
     [ 1.10414629e-02 -1.24794483e-02 -3.58545973e-02 -5.17062387e-02
      -6.18642988e-02 -7.11431720e-02 -9.13669523e-02 -1.44329594e-01
      -2.39042166e-01 -3.28352687e-01 -3.41372877e-01 -3.08147158e-01
      -2.54222506e-01 -2.63955914e-01 -3.54975138e-01 -3.68889268e-01
       4.51169023e-02  6.46064216e-02  7.51996357e-02  8.88137937e-02
       1.06395989e-01  1.29380303e-01  1.59834042e-01  2.02035753e-01
       2.74275773e-01  3.76774600e-01  5.72586351e-01  1.10308874e+00
       2.47083246e+00  3.28862489e+00]
     [ 5.53821445e-03 -2.11673077e-02 -4.47152353e-02 -6.11411592e-02
      -7.75607778e-02 -1.10162028e-01 -1.84695030e-01 -2.89526214e-01
      -3.42924565e-01 -3.31469371e-01 -2.82831629e-01 -2.56759778e-01
      -3.10566425e-01 -4.02544281e-01  2.05853764e-02  5.89285036e-02
       6.80572972e-02  8.00246667e-02  9.56158124e-02  1.15335006e-01
       1.40978811e-01  1.75629204e-01  2.24630658e-01  2.98832641e-01
       4.24411621e-01  6.87420750e-01  1.65894373e+00  2.91206517e+00
       3.45773520e+00  3.64205163e+00]
     [-2.99735849e-03 -3.19859077e-02 -5.71797684e-02 -8.42654343e-02
      -1.35874248e-01 -2.30702482e-01 -3.20510785e-01 -3.39883453e-01
      -3.15562492e-01 -2.65798487e-01 -2.73760222e-01 -3.72661486e-01
      -5.98338910e-02  5.39312231e-02  6.15512021e-02  7.12661970e-02
       8.41860692e-02  1.00964320e-01  1.22794121e-01  1.51750655e-01
       1.91757135e-01  2.48430565e-01  3.37337151e-01  4.97732928e-01
       8.83833534e-01  2.10528891e+00  3.12525769e+00  3.52730655e+00
       3.63127410e+00  3.35068590e+00]
     [-1.45083992e-02 -4.81294104e-02 -8.75605123e-02 -1.59697354e-01
      -2.63540331e-01 -3.29393233e-01 -3.30367903e-01 -2.84078086e-01
      -2.56952799e-01 -3.16460022e-01 -2.22893911e-01  4.44438091e-02
       5.32182827e-02  6.21441235e-02  7.42054234e-02  8.84582051e-02
       1.06398012e-01  1.29892885e-01  1.61503615e-01  2.05443617e-01
       2.70848402e-01  3.77845685e-01  5.86976065e-01  1.17532633e+00
       2.55439329e+00  3.30651091e+00  3.58119788e+00  3.55752123e+00
       3.04213614e+00  1.97474079e+00]
     [-3.29313455e-02 -8.65374924e-02 -1.77120605e-01 -2.77426774e-01
      -3.19662240e-01 -2.99947166e-01 -2.52588849e-01 -2.65881184e-01
      -2.80095442e-01  2.70528896e-02  4.80543963e-02  5.24963596e-02
       6.16898411e-02  7.40449035e-02  9.00571092e-02  1.10355006e-01
       1.37088628e-01  1.71205294e-01  2.19758142e-01  2.93611212e-01
       4.19251094e-01  6.85229513e-01  1.54949395e+00  2.85410313e+00
       3.42387709e+00  3.59791691e+00  3.45161725e+00  2.65762020e+00
       1.67983389e+00  1.14428021e+00]
     [-7.59951045e-02 -1.75256552e-01 -2.71762898e-01 -2.93314280e-01
      -2.46467303e-01 -2.27678709e-01 -2.69609763e-01 -3.98809467e-02
       4.67974697e-02  4.96575416e-02  5.51112796e-02  6.39821609e-02
       7.49629521e-02  9.11446279e-02  1.12415943e-01  1.40525571e-01
       1.78695311e-01  2.33391207e-01  3.17719034e-01  4.65705440e-01
       8.09425662e-01  1.94436054e+00  3.04945550e+00  3.48772127e+00
       3.57839254e+00  3.27872453e+00  2.27984241e+00  1.46040019e+00
       1.02478213e+00  7.71930186e-01]
     [-1.54614962e-01 -2.46627888e-01 -2.25375848e-01 -1.89403911e-01
      -2.12650676e-01 -1.03332072e-01  4.67997036e-02  4.96208865e-02
       5.25386631e-02  5.84424292e-02  6.77204952e-02  7.91809636e-02
       9.50404998e-02  1.15506810e-01  1.44152385e-01  1.84801813e-01
       2.44340995e-01  3.39393342e-01  5.14730739e-01  9.68654112e-01
       2.28651976e+00  3.19098315e+00  3.52556031e+00  3.52926500e+00
       3.02907308e+00  1.96593640e+00  1.29220352e+00  9.29612459e-01
       7.12409388e-01  5.69297016e-01]
     [-1.87995486e-01 -1.51197591e-01 -1.50044658e-01 -1.10957590e-01
       3.99206791e-02  4.89964571e-02  4.97983983e-02  5.45381049e-02
       6.24092461e-02  7.18263303e-02  8.40825233e-02  1.00900061e-01
       1.22539629e-01  1.51112899e-01  1.92615952e-01  2.55655901e-01
       3.61287535e-01  5.68537793e-01  1.16627061e+00  2.54981580e+00
       3.28911367e+00  3.54225214e+00  3.45037190e+00  2.72524269e+00
       1.72029073e+00  1.16115129e+00  8.51859198e-01  6.61495413e-01
       5.33637305e-01  4.42669660e-01]
     [-8.98977212e-02 -8.92777506e-02  1.69253328e-02  5.22037630e-02
       4.88351979e-02  5.04046898e-02  5.56097247e-02  6.37364274e-02
       7.48755816e-02  8.93934148e-02  1.06683465e-01  1.29349769e-01
       1.61054199e-01  2.05926025e-01  2.73866761e-01  3.87435999e-01
       6.29907894e-01  1.40892531e+00  2.74838883e+00  3.35171881e+00
       3.52185157e+00  3.30230124e+00  2.39628302e+00  1.52873640e+00
       1.05662962e+00  7.88154712e-01  6.18723122e-01  5.03006935e-01
       4.19656286e-01  3.57021503e-01]
     [-7.20435670e-03  6.16422972e-02  5.34243408e-02  4.85259326e-02
       5.11078074e-02  5.68777190e-02  6.54107230e-02  7.67587540e-02
       9.15491348e-02  1.11056026e-01  1.37019759e-01  1.70523200e-01
       2.18571634e-01  2.94065615e-01  4.26406125e-01  7.22912549e-01
       1.69758796e+00  2.89937603e+00  3.39097889e+00  3.47967399e+00
       3.09447445e+00  2.06726033e+00  1.34134415e+00  9.57920967e-01
       7.32117014e-01  5.81972119e-01  4.76381648e-01  3.99341252e-01
       3.41076931e-01  2.95445876e-01]
     [ 7.38179618e-02  5.67588766e-02  5.08940248e-02  5.27621766e-02
       5.78993570e-02  6.69762925e-02  7.87839192e-02  9.40904219e-02
       1.14050379e-01  1.40729572e-01  1.77985446e-01  2.32666850e-01
       3.15762772e-01  4.66164167e-01  8.29965968e-01  2.01224005e+00
       3.05317958e+00  3.43342289e+00  3.41525659e+00  2.81599546e+00
       1.79760861e+00  1.20139001e+00  8.75588977e-01  6.74291316e-01
       5.42533155e-01  4.48362555e-01  3.80833403e-01  3.26723128e-01
       2.83844032e-01  2.49490514e-01]
     [ 6.28142278e-02  5.49897002e-02  5.51438403e-02  6.03804968e-02
       6.91787500e-02  8.04764958e-02  9.64793196e-02  1.17232219e-01
       1.45019960e-01  1.83781098e-01  2.41135963e-01  3.34424410e-01
       5.12223251e-01  9.69651008e-01  2.28282769e+00  3.15977991e+00
       3.46219353e+00  3.36751790e+00  2.57183012e+00  1.59374095e+00
       1.08611032e+00  8.03446173e-01  6.27704923e-01  5.09113384e-01
       4.23399808e-01  3.59101305e-01  3.09954957e-01  2.70859540e-01
       2.40384238e-01  2.13886825e-01]
     [ 5.86039242e-02  5.82418726e-02  6.39817210e-02  7.17558753e-02
       8.35374357e-02  9.95242434e-02  1.20089709e-01  1.49208668e-01
       1.89980462e-01  2.50879843e-01  3.51239558e-01  5.48472938e-01
       1.11878996e+00  2.51304472e+00  3.25100438e+00  3.47508326e+00
       3.27913094e+00  2.33991567e+00  1.46975033e+00  1.01190732e+00
       7.48447607e-01  5.88836788e-01  4.79102308e-01  4.00784014e-01
       3.41922309e-01  2.96042555e-01  2.59065757e-01  2.29390723e-01
       2.04584201e-01  1.84142079e-01]
     [ 6.12579987e-02  6.67371220e-02  7.51567296e-02  8.75966438e-02
       1.02781270e-01  1.24470814e-01  1.52739535e-01  1.96008087e-01
       2.60938712e-01  3.69913624e-01  5.92486543e-01  1.28473783e+00
       2.66482235e+00  3.31222638e+00  3.47604895e+00  3.16056830e+00
       2.12150726e+00  1.35028849e+00  9.46519068e-01  7.12094905e-01
       5.61766728e-01  4.56431265e-01  3.82460102e-01  3.26774522e-01
       2.82899627e-01  2.48394549e-01  2.20469793e-01  1.96992396e-01
       1.77282037e-01  1.60802055e-01]
     [ 6.87287967e-02  7.82103817e-02  9.10576880e-02  1.07270377e-01
       1.29897795e-01  1.59744339e-01  2.04125673e-01  2.70886274e-01
       3.89962595e-01  6.43543562e-01  1.48463757e+00  2.80514103e+00
       3.35778781e+00  3.45430030e+00  3.00061728e+00  1.92634472e+00
       1.24726761e+00  8.87632129e-01  6.74650135e-01  5.36138579e-01
       4.39620974e-01  3.68750459e-01  3.14488591e-01  2.72572592e-01
       2.39583610e-01  2.12640460e-01  1.89977649e-01  1.71313315e-01
       1.55402839e-01  1.41666874e-01]
     [ 8.00865367e-02  9.36872726e-02  1.11875665e-01  1.35131781e-01
       1.69142949e-01  2.13687518e-01  2.85926391e-01  4.15060235e-01
       7.04150643e-01  1.70905979e+00  2.92854854e+00  3.39517477e+00
       3.41981199e+00  2.80217092e+00  1.74963492e+00  1.15442254e+00
       8.34266600e-01  6.40276695e-01  5.11987311e-01  4.21707564e-01
       3.55230808e-01  3.04402544e-01  2.64266327e-01  2.32000061e-01
       2.05608820e-01  1.84298376e-01  1.66270722e-01  1.50924864e-01
       1.37565383e-01  1.26013644e-01]
     [ 9.56611224e-02  1.14279643e-01  1.39636956e-01  1.74905710e-01
       2.23794568e-01  3.05368360e-01  4.45315812e-01  7.87434316e-01
       1.95322695e+00  3.03694250e+00  3.42192508e+00  3.36345072e+00
       2.57365733e+00  1.59225762e+00  1.07039363e+00  7.83440583e-01
       6.06954091e-01  4.89040670e-01  4.04736807e-01  3.42078892e-01
       2.93851053e-01  2.55856605e-01  2.25264720e-01  2.00076834e-01
       1.79055660e-01  1.61312175e-01  1.46593886e-01  1.33971282e-01
       1.22961589e-01  1.13337872e-01]
     [ 1.16831848e-01  1.42702549e-01  1.79319860e-01  2.34025436e-01
       3.20678942e-01  4.79498919e-01  9.06602064e-01  2.20698884e+00
       3.14491894e+00  3.43106552e+00  3.26942918e+00  2.32434118e+00
       1.44828453e+00  9.92814665e-01  7.36254372e-01  5.75205425e-01
       4.65973598e-01  3.87631487e-01  3.29102730e-01  2.83617760e-01
       2.47510331e-01  2.18276578e-01  1.94273061e-01  1.74280566e-01
       1.57354660e-01  1.42859682e-01  1.30287311e-01  1.19680278e-01
       1.10415860e-01  1.02192401e-01]
     [ 1.46197346e-01  1.83972087e-01  2.40879250e-01  3.35100411e-01
       5.20590953e-01  1.02974287e+00  2.49332715e+00  3.24857453e+00
       3.46089264e+00  3.17481516e+00  2.05372441e+00  1.31088184e+00
       9.18612570e-01  6.90660236e-01  5.44491606e-01  4.43824823e-01
       3.70868557e-01  3.15850911e-01  2.73053980e-01  2.39029933e-01
       2.11343167e-01  1.88463819e-01  1.69307867e-01  1.53086408e-01
       1.39247988e-01  1.27244140e-01  1.16779381e-01  1.07585178e-01
       9.96911473e-02  9.26896397e-02]
     [ 1.89129321e-01  2.48621251e-01  3.48799893e-01  5.51678659e-01
       1.18364410e+00  2.65215738e+00  3.32859939e+00  3.48305179e+00
       3.01665453e+00  1.89780959e+00  1.21495907e+00  8.42918045e-01
       6.45089022e-01  5.13959593e-01  4.21922250e-01  3.54172066e-01
       3.02795710e-01  2.62535696e-01  2.30364335e-01  2.04148211e-01
       1.82476932e-01  1.64220640e-01  1.48708877e-01  1.35482123e-01
       1.23982544e-01  1.13971417e-01  1.05207756e-01  9.74436018e-02
       9.04624725e-02  8.44477203e-02]
     [ 2.57511497e-01  3.64850033e-01  5.90336769e-01  1.34522965e+00
       2.79614867e+00  3.40195797e+00  3.47726093e+00  2.86797954e+00
       1.73369722e+00  1.11325611e+00  7.99468165e-01  6.12169621e-01
       4.81386605e-01  3.99269344e-01  3.37368039e-01  2.89643705e-01
       2.52009746e-01  2.21711944e-01  1.96810262e-01  1.76250740e-01
       1.58924370e-01  1.44251463e-01  1.31600804e-01  1.20658540e-01
       1.11068433e-01  1.02618737e-01  9.51455906e-02  8.85233943e-02
       8.25661684e-02  7.72137623e-02]
     [ 3.83144078e-01  6.36945125e-01  1.54875599e+00  2.93200277e+00
       3.44818860e+00  3.45628714e+00  2.68617075e+00  1.59876685e+00
       1.04338864e+00  7.51065433e-01  5.75318730e-01  4.61973619e-01
       3.72516069e-01  3.18943836e-01  2.75727810e-01  2.41194110e-01
       2.12922267e-01  1.89547023e-01  1.70062767e-01  1.53644569e-01
       1.39609731e-01  1.27505597e-01  1.17041020e-01  1.07935966e-01
       9.98947864e-02  9.27689492e-02  8.64279252e-02  8.07263900e-02
       7.55886227e-02  7.09937513e-02]
     [ 7.20115454e-01  1.84237020e+00  3.07025737e+00  3.48709067e+00
       3.40641127e+00  2.46452417e+00  1.47198796e+00  9.81000052e-01
       7.11612973e-01  5.51798073e-01  4.38827807e-01  3.63282698e-01
       3.07895570e-01  2.59519357e-01  2.29089974e-01  2.03271707e-01
       1.81783201e-01  1.63730850e-01  1.48335145e-01  1.35019283e-01
       1.23501288e-01  1.13489849e-01  1.04788932e-01  9.70255346e-02
       9.02399591e-02  8.41641279e-02  7.87809048e-02  7.38680072e-02
       6.94245037e-02  6.53667222e-02]
     [ 2.10734176e+00  3.19431493e+00  3.52696991e+00  3.33668609e+00
       2.23817249e+00  1.35016529e+00  9.17299559e-01  6.75751600e-01
       5.24330981e-01  4.21212528e-01  3.50065742e-01  2.93903590e-01
       2.53678260e-01  2.21881902e-01  1.92503313e-01  1.73195374e-01
       1.56678636e-01  1.42331532e-01  1.30011836e-01  1.19272158e-01
       1.09900135e-01  1.01635342e-01  9.42541561e-02  8.77361083e-02
       8.18889292e-02  7.66874453e-02  7.19531431e-02  6.77273527e-02
       6.38607719e-02  6.03032763e-02]
     [ 3.30176673e+00  3.52763096e+00  3.14607655e+00  1.96081506e+00
       1.22063086e+00  8.50494064e-01  6.37019537e-01  4.99869098e-01
       4.05542091e-01  3.35880091e-01  2.83415840e-01  2.44660778e-01
       2.12819553e-01  1.88124146e-01  1.68125674e-01  1.48837607e-01
       1.36032173e-01  1.24635100e-01  1.14573776e-01  1.05792621e-01
       9.81095055e-02  9.12107211e-02  8.51100660e-02  7.95479567e-02
       7.45833732e-02  7.00611241e-02  6.59922656e-02  6.23766989e-02
       5.89936415e-02  5.59102997e-02]
     [ 3.53196232e+00  2.94759693e+00  1.74689369e+00  1.10701387e+00
       7.81495520e-01  5.91345669e-01  4.67680159e-01  3.81298866e-01
       3.20168293e-01  2.73397713e-01  2.35925204e-01  2.05512019e-01
       1.81524260e-01  1.61902695e-01  1.45931436e-01  1.32471272e-01
       1.19084650e-01  1.10147155e-01  1.01958946e-01  9.45985611e-02
       8.79785014e-02  8.20891226e-02  7.67509645e-02  7.19986807e-02
       6.77766664e-02  6.38966941e-02  6.04252394e-02  5.72513592e-02
       5.42642922e-02  5.16174863e-02]
     [ 2.64246333e+00  1.54246950e+00  1.00448919e+00  7.23013563e-01
       5.53489871e-01  4.41909246e-01  3.63678269e-01  3.06010359e-01
       2.61971579e-01  2.27669659e-01  1.98860116e-01  1.75238314e-01
       1.57541485e-01  1.40493117e-01  1.27612641e-01  1.16594285e-01
       1.04343330e-01  9.74444038e-02  9.08966267e-02  8.49809267e-02
       7.96569969e-02  7.48026838e-02  7.04696190e-02  6.63620506e-02
       6.27876581e-02  5.94104764e-02  5.62810549e-02  5.34694219e-02
       5.08492717e-02  4.84557226e-02]
     [ 1.35449725e+00  9.08485859e-01  6.65463948e-01  5.15796353e-01
       4.15263643e-01  3.43656956e-01  2.90560204e-01  2.49795105e-01
       2.17657735e-01  1.91785675e-01  1.70338980e-01  1.51858994e-01
       1.35881666e-01  1.23944752e-01  1.12524048e-01  1.03434956e-01
       9.54993223e-02  8.64305556e-02  8.13053667e-02  7.64256792e-02
       7.18869683e-02  6.77618655e-02  6.41181571e-02  6.08078547e-02
       5.78276350e-02  5.49758761e-02  5.25148072e-02  5.01257044e-02
       4.79070543e-02  4.57095239e-02]]



```python
from matplotlib import pyplot as plt
import numpy as np

X, Y = np.meshgrid(C * 100, velocity)
Z = np.loadtxt('vel_difference4.txt', delimiter=',')
cont=plt.contour(X, Y, Z, 5, vmin=-1,vmax=3, colors=['black'])
cont.clabel(fmt='%1.1f', fontsize=14)
plt.xlabel('Concentration', fontsize=24)
plt.ylabel('Velocity', fontsize=24)
plt.pcolormesh(X,Y,Z, cmap='cool') #カラー等高線図
pp=plt.colorbar (orientation="vertical") # カラーバーの表示 
pp.set_label("Amplitude of velocity fluctuation (m/s)",  fontsize=14)
plt.savefig('result_map.svg')
# im = plt.imshow(vel_difference, aspect='auto', extent=[C[0]*100, C[-1]*100, velocity[-1], velocity[0]], interpolation='bicubic')
# ax = plt.gca()
# ax.invert_yaxis()
# ax.set_xlabel('Concentration (%)')
# ax.set_ylabel('Velocity (m/s)')
# plt.colorbar(im)
# plt.show()
# plt.savefig('testimage.svg')
```


```python
print(C)
print(velocity)
a = np.array([[0,1,0],[1,0,0],[0,0,1],[0,0,0]])
plt.imshow(a)
```


```python
import tideturb

tc_org = tideturb.load_model('test09_5000sec')
tc_org.axM.plot(tc_org.grid.x, tc_org.U_node[1, :])
tc_org.axL.plot(tc_org.grid.x, tc_org.h_node[1, :])
tc_org.axR.plot(tc_org.grid.x, tc_org.C_node[1, :])
U = tc_org.U_node[1, -1]
h = tc_org.h_node[1, -1]
C = tc_org.C_node[1, -1]
Fr = U / np.sqrt(1.65 * 9.81 * C * h)
print(Fr)
```

b48eb08aa462dc65e669852715c987430a42e587
ipynb
Jupyter Notebook
tide_influenced_turbidity_currents_v1.ipynb
narusehajime/tideturb
caaeb7543bb9895706a9d8f39f25346ab585dc66
MIT
tide_influenced_turbidity_currents_v1.ipynb
narusehajime/tideturb
caaeb7543bb9895706a9d8f39f25346ab585dc66
MIT
tide_influenced_turbidity_currents_v1.ipynb
narusehajime/tideturb
caaeb7543bb9895706a9d8f39f25346ab585dc66
MIT
Qwen/Qwen-72B
1. YES
2. YES