---
# System prepended metadata

title: '***Computational Hydraulics***'
tags: [HW5.1]

---

---
tags: HW5.1
---
# ***Computational Hydraulics***
## **Group 01:** N88071053 洪豪男 N88091011 黃彥鈞
## **HW5.1:** please derive the above formulation


**Sketch of the scheme**
![](https://i.imgur.com/FrAzMNe.png)

---

For nonlinear convection equation, we have

$\dfrac{\partial}{\partial t}u(x,t)+\dfrac{\partial}{\partial x}(f(x,t))=0 ,\quad\quad f=au$ 


* Integration over $[ x_{j+1/2,l}^n, x_{j+1/2,r}^n]\times[t_n,t_{n+1}]$ 

$\displaystyle\quad\quad
\int_{t_n}^{t_{n+1}}\int_{x_{j+1/2,l}^n}^{x_{j+1/2,r}^n} \Bigl\{\dfrac{\partial}{\partial t}u(x,t)+\dfrac{\partial}{\partial x}(f(x,t)) \Bigr\}{\rm d}x\,{\rm d}t= 0$


$\displaystyle\quad
\int_{x_{j+1/2,l}^n}^{x_{j+1/2,r}^n}\!\Bigl\{u(x,t_2) - u(x,t_1)\Bigr\}{\rm d}x +
\int_{t_n}^{t_{n+1}}\!\Bigl\{f(x_2,t) - 
f(x_1,t)\Bigr\}{\rm d}t=0$


$\displaystyle\quad
\int_{x_{j+1/2,l}^n}^{x_{j+1/2,r}^n}\!\!u(x,t_2){\rm d}x =  \int_{x_{j+1/2,l}^n}^{x_{j+1/2,r}^n}\!\!u(x,t_1){\rm d}x -
\int_{t_n}^{t_{n+1}}\!\Bigl\{
f(x_2,t) - f(x_1,t)\Bigr\}{\rm d}t$


$w_{j+1/2}^{n+1}\cdot\Delta x_{j+1/2}=w_{j+1/2}^{n}\cdot\Delta x_{j+1/2}-f\bigl(u^{n+1/2}_{j+1/2,r}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t$

* remark

$\quad\quad\Delta x_{j+1/2}=x_{j+1/2,r}^n-x_{j+1/2,l}^n
\\\quad\quad\quad\quad\quad=(x_{j+1/2}+a^n_{j+1/2}\cdot\Delta t)-(x_{j+1/2}-a^n_{j+1/2}\cdot\Delta t)
\\\quad\quad\quad\quad\quad=2 a^n_{j+1/2}\cdot\Delta t$


$w_{j+1/2}^{n+1}\cdot(2 a^n_{j+1/2}\cdot\Delta t)
\\=w_{j+1/2}^{n}\cdot(2 a^n_{j+1/2}\cdot\Delta t)-f\bigl(u^{n+1/2}_{j+1/2,r}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t
\\=\Bigl[u_j^n+(u_x)^{n}_{j}\cdot(\dfrac{\Delta x}{2}-\dfrac{a^n_{j+1/2}\cdot\Delta t}{2})\Bigr](a^n_{j+1/2}\cdot\Delta t)
\\+\Bigl[u_{j+1}^n-(u_x)^{n}_{j+1}\cdot(\dfrac{\Delta x}{2}-\dfrac{a^n_{j+1/2}\cdot\Delta t}{2})\Bigr](a^n_{j+1/2}\cdot\Delta t)
\\-
f\bigl(u^{n+1/2}_{j+1/2,r}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t$


$\begin{array}{rl}w_{j+1/2}^{n+1}=&\dfrac{u_j^n+u_{j+1}^n}{2}+
 \dfrac{\Delta x - a^{n}_{j+1/2}\Delta t}{4}\Bigl[(u_x)^{n}_{j}-(u_x)^{n}_{j+1}\Bigr]\\ &-\dfrac{1}{2a_{j+1/2}^{n}}\Bigl[f\bigl(u^{n+1/2}_{j+1/2,r}\bigr)- f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\Bigr]
 \end{array}$
 
 ---
 
 * Integration over $[ x_{j-1/2,l}^n, x_{j-1/2,r}^n]\times[t_n,t_{n+1}]$ 

$w_{j-1/2}^{n+1}=\dfrac{u_j^n+u_{j-1}^n}{2}+
 \dfrac{\Delta x - a^{n}_{j-1/2}\Delta t}{4}\Bigl[(u_x)^{n}_{j-1}-(u_x)^{n}_{j}\Bigr]\\\quad\quad\quad -\dfrac{1}{2a_{j-1/2}^{n}}\Bigl[f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)- f\bigl(u^{n+1/2}_{j-1/2,l}\bigr)\Bigr]$

 ---
 
 * Integration over $[ x_{j-1/2,r}^n, x_{j+1/2,l}^n]\times[t_n,t_{n+1}]$ 
 
$w_{j}^{n+1}\cdot\Delta x_j=w_{j}^{n}\cdot\Delta x_j-f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t$
 
* remark

$\quad\quad\Delta x_j=x_{j+1/2,l}^n-x_{j-1/2,r}^n
\\\quad\quad\quad\quad\quad=(x_{j+1/2}-a^n_{j+1/2}\cdot\Delta t)-(x_{j-1/2}+a^n_{j-1/2}\cdot\Delta t)
\\\quad\quad\quad\quad\quad=\Delta x -(a^n_{j+1/2}+a^n_{j-1/2})\Delta t$


$w_{j}^{n+1}\cdot[\Delta x -(a^n_{j+1/2}+a^n_{j-1/2})\Delta t]
\\=w_{j}^{n}\cdot[\Delta x -(a^n_{j+1/2}+a^n_{j-1/2})\Delta t]-f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t
\\=\Bigl[u_j^n+\dfrac{1}{2}(\dfrac{\Delta x}{2}-a^n_{j+1/2}\cdot\Delta t)(u_x)^{n}_{j}\Bigr](\dfrac{\Delta x}{2}-a^n_{j+1/2}\cdot\Delta t)
\\+\Bigl[u_j^n-\dfrac{1}{2}(\dfrac{\Delta x}{2}-a^n_{j-1/2}\cdot\Delta t)(u_x)^{n}_{j}\Bigr](\dfrac{\Delta x}{2}-a^n_{j-1/2}\cdot\Delta t)
\\-
f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t$

assume $\Delta x_{j_+}=\dfrac{\Delta x}{2}-a^n_{j+1/2}\cdot\Delta t\quad,\Delta x_{j_-}=\dfrac{\Delta x}{2}-a^n_{j-1/2}\cdot\Delta t$


$w_{j}^{n+1}\cdot[\Delta x -(a^n_{j+1/2}+a^n_{j-1/2})\Delta t]
\\=\Bigl[u_j^n+\dfrac{1}{2}\Delta x_{j_+}(u_x)^{n}_{j}\Bigr]\Delta x_{j_+}
+\Bigl[u_j^n-\dfrac{1}{2}\Delta x_{j_-}(u_x)^{n}_{j}\Bigr]\Delta x_{j_-}
-f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t
\\=u^n_j \Delta x_{j_+}+\dfrac{1}{2}(\Delta x_{j_+})^2(u_x)^{n}_{j}+u^n_j \Delta x_{j_-}-\dfrac{1}{2}(\Delta x_{j_-})^2(u_x)^{n}_{j}-f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t
\\=u^n_j(\Delta x_{j_+}+\Delta x_{j_-})+\dfrac{1}{2}(u_x)^{n}_{j}[(\Delta x_{j_+})^2-(\Delta x_{j_-})^2]-f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t
\\=u^n_j(\Delta x_{j_+}+\Delta x_{j_-})+\dfrac{1}{2}(u_x)^{n}_{j}[(\Delta x_{j_+}+\Delta x_{j_-})(\Delta x_{j_+}-\Delta x_{j_-})]-f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t
\\=u^n_j[\Delta x-(a^n_{j+1/2}+a^n_{j-1/2})\Delta t]+\dfrac{1}{2}(u_x)^{n}_{j}[\Delta x-(a^n_{j+1/2}+a^n_{j-1/2})\Delta t](a^n_{j-1/2}-a^n_{j+1/2})\Delta t
\\-f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)\cdot\Delta t + f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\cdot\Delta t$


$w_{j}^{n+1}=u^n_j+\dfrac{\Delta t}{2}(a^n_{j-1/2}-a^n_{j+1/2})(u_x)^{n}_{j}
-\dfrac{\Delta t}{\Delta x -(a^n_{j+1/2}+a^n_{j-1/2})\Delta t}[f\bigl(u^{n+1/2}_{j+1/2,l}\bigr)- f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)]$

assume $\lambda ={\Delta t}/{\Delta x}$


$w_{j}^{n+1}=u^n_j+\dfrac{\Delta t}{2}(a^n_{j-1/2}-a^n_{j+1/2})(u_x)^{n}_{j}
\\\quad\quad-\dfrac{\lambda}{1 -\lambda(a^n_{j+1/2}+a^n_{j-1/2})}[f\bigl(u^{n+1/2}_{j+1/2,l}\bigr) - f\bigl(u^{n+1/2}_{j-1/2,r}\bigr)\Bigr]$

 ---
 
 where $a^{n}_{j\pm1/2}$  are the maximal local speeds, $\lambda ={\Delta t}/{\Delta x}$ and
 $u^{n}_{j+1/2,l} :=u^{n}_{j} + \Delta x\, (u_x)^n_j \left(\dfrac{1}{2} - \lambda a^{n}_{j+1/2}\right)$
 
 $u^{n}_{j-1/2,r} := u^{n}_{j+1} - \Delta x\, (u_x)^n_{j+1} \left(\dfrac{1}{2} - \lambda a^{n}_{j+1/2}\right)$
 
 $u^{n+1/2}_{j+1/2,r} := u^{n}_{j+1/2,r} - \dfrac{\Delta t}{2}\, f_x\!\left(u^{n}_{j+1/2,r}\right)$
 
 $u^{n+1/2}_{j+1/2,l} := u^{n}_{j+1/2,l} - \dfrac{\Delta t}{2}\, f_x\!\left(u^{n}_{j+1/2,l}\right)$
 
 ---
 
* To obtain the cell averages over the original grid of the uniform, we consider the piecewise-linear reconstruction over the nonuniform cells at $t=t^{n+1}$ ,and then we project its averages back onto the original uniform grid. Hence, the required piecewise-linear approximation takes the form

$\quad\quad\begin{array}{rl}\tilde w(x,t^{n+1}):=&{\LARGE\Sigma} \biggl\{\Bigl[w^{n+1}_{j+1/2}+(u_x)^{n+1}_{j+1/2}\left(x-x_{j+1/2}\right)\Bigl]{\bf 1}_{\left[x^n_{j+1/2,l}\,,\,x^n_{j+1/2,r}\right]}\\ & \quad\quad +\,w^{n+1}_j{\bf 1}_{\left[x^n_{j-1/2,r}\,,\,x^n_{j+1/2,l}\right]}\biggr\}\end{array}$

* the spatial derivatives $u_x(x_{j+1/2},t^{n+1})$ are approximated by

$\quad\quad (u_x)^{n+1}_{j+1/2} = \dfrac{2}{\Delta x}\cdot\hbox{minmod}\left(\dfrac{w^{n+1}_{j+1}-w^{n+1}_{j+1/2}}{1+\lambda\left(a^n_{j+1/2}-a^n_{j+3/2}\right)}\,, \dfrac{w^{n+1}_{j+1/2}-w^{n+1}_{j}}{1+\lambda\left(a^n_{j+1/2}-a^n_{j-1/2}\right)}\right)$

* Fully discrete second-order central scheme

$\quad\quad\begin{array}{rl}
u^{n+1}_j & = \dfrac{1}{\Delta x}\displaystyle\int^{x_{j+1/2}}_{x_{j-1/2}}\tilde{w}(\xi\,,t)d\xi \\ &= 
\lambda a^n_{j-1/2}w^{n+1}_{j-1/2} 
+\Bigl[1 - \lambda\left(a^n_{j-1/2}+a^n_{j+1/2}\right)\Bigr]w^{n+1}_j\\
& \quad +\lambda a^n_{j+1/2}w^{n+1}_{j+1/2}+
\dfrac{\Delta x}{2}\Bigl[(\lambda a^n_{j-1/2})^2(u_x)^{n+1}_{j-1/2}-(\lambda a^n_{j+1/2})^2(u_x)^{n+1}_{j+1/2}\Bigr]
\end{array}$
