Skip to main content
Tweeted twitter.com/StackSciComp/status/1545150669862174720
added 209 characters in body
Source Link

My question is how to keep track of the "mass" being advected out of a model domain, for the 1-D advection equation, and an upwind differencing scheme. Following is the background

Consider the continuity equation

$$\frac{\partial u}{\partial t} + \frac{\partial \Phi}{\partial x} = 0$$

Suppose the flux $\Phi$ is given by an advective term

$$\Phi = a u$$

Suppose $a = 0.01x$, and we are considering only $x>0$. Therefore, $a > 0$, so the wave is traveling in the positive $x$ direction. I can discretize the spatial derivative with a first order upwind scheme. $j$ is grid cell centers, and $j-1/2$ is the left edge of the grid cell.

$$\frac{\partial \Phi}{\partial x}|_j \approx \frac{\Phi_{j} - \Phi_{j-1/2}}{\frac{1}{2}\Delta x}$$

$$= \frac{a_{j} u_j - a_{j-1/2} u_{j-1/2}}{\frac{1}{2}\Delta x}$$

I replace $u_{j-1/2}$ with the averge of the grid cell neighbors ($\frac{u_{j-1} + u_{j}}{2}$)

$$= \frac{a_j u_j - a_{j-1/2} \frac{u_{j-1} + u_{j}}{2}}{\frac{1}{2}\Delta x}$$

So, using the method of lines, I've now turned the PDE into a system of ODEs,

$$\frac{\partial u_j}{\partial t} = - \frac{2 a_j u_j - a_{j-1/2} u_j - a_{j-1/2} u_{j-1}}{\Delta x} \tag{1}$$

Now we can consider the left boundary ($j = 1$)

$$\frac{\partial \Phi}{\partial x}|_1 = \frac{\Phi_{1} - \Phi_{1/2}}{\frac{1}{2}\Delta x}$$

Here, $\Phi_{1/2} = \Phi_\text{in}$ is the "flux" entering the left side of the model domain. The left boundary is then given by

$$\frac{\partial u_1}{\partial t} = \frac{-2 a_1 u_1}{\Delta x} + \frac{2 \Phi_\text{in}}{\Delta x} \tag{2}$$

Equations (1) and (2) describe a system of ODEs which can be evolved forward in time. I have done this for an initial condition of $u_j = 0$, and $\Phi = 0.1$ for the domain $x = [0,100]$. The model reaches the following steady state:

results

Mass is being advected out of the right side of the model domain. How do I figure out this mass flux? The mass flux out should be the same as $\Phi_\text{in} = 0.1$, for flux conservation. Any other relevant tips for understanding/checking mass conservation in these scenarios is appreciated.

I would have thought $\Phi_\text{out} = u_na_n$, where $n$ is the right most grid cell, but this is $\approx 0.105$. So, mass is not quite being conserved, or I'm not computing $\Phi_\text{out}$ properly.

Thanks!

My question is how to keep track of the "mass" being advected out of a model domain, for the 1-D advection equation, and an upwind differencing scheme. Following is the background

Consider the continuity equation

$$\frac{\partial u}{\partial t} + \frac{\partial \Phi}{\partial x} = 0$$

Suppose the flux $\Phi$ is given by an advective term

$$\Phi = a u$$

Suppose $a = 0.01x$, and we are considering only $x>0$. Therefore, $a > 0$, so the wave is traveling in the positive $x$ direction. I can discretize the spatial derivative with a first order upwind scheme. $j$ is grid cell centers, and $j-1/2$ is the left edge of the grid cell.

$$\frac{\partial \Phi}{\partial x}|_j \approx \frac{\Phi_{j} - \Phi_{j-1/2}}{\frac{1}{2}\Delta x}$$

$$= \frac{a_{j} u_j - a_{j-1/2} u_{j-1/2}}{\frac{1}{2}\Delta x}$$

I replace $u_{j-1/2}$ with the averge of the grid cell neighbors ($\frac{u_{j-1} + u_{j}}{2}$)

$$= \frac{a_j u_j - a_{j-1/2} \frac{u_{j-1} + u_{j}}{2}}{\frac{1}{2}\Delta x}$$

So, using the method of lines, I've now turned the PDE into a system of ODEs,

$$\frac{\partial u_j}{\partial t} = - \frac{2 a_j u_j - a_{j-1/2} u_j - a_{j-1/2} u_{j-1}}{\Delta x} \tag{1}$$

Now we can consider the left boundary ($j = 1$)

$$\frac{\partial \Phi}{\partial x}|_1 = \frac{\Phi_{1} - \Phi_{1/2}}{\frac{1}{2}\Delta x}$$

Here, $\Phi_{1/2} = \Phi_\text{in}$ is the "flux" entering the left side of the model domain. The left boundary is then given by

$$\frac{\partial u_1}{\partial t} = \frac{-2 a_1 u_1}{\Delta x} + \frac{2 \Phi_\text{in}}{\Delta x} \tag{2}$$

Equations (1) and (2) describe a system of ODEs which can be evolved forward in time. I have done this for an initial condition of $u_j = 0$, and $\Phi = 0.1$ for the domain $x = [0,100]$. The model reaches the following steady state:

results

Mass is being advected out of the right side of the model domain. How do I figure out this mass flux? The mass flux out should be the same as $\Phi_\text{in} = 0.1$, for flux conservation. Any other relevant tips for understanding/checking mass conservation in these scenarios is appreciated.

Thanks!

My question is how to keep track of the "mass" being advected out of a model domain, for the 1-D advection equation, and an upwind differencing scheme. Following is the background

Consider the continuity equation

$$\frac{\partial u}{\partial t} + \frac{\partial \Phi}{\partial x} = 0$$

Suppose the flux $\Phi$ is given by an advective term

$$\Phi = a u$$

Suppose $a = 0.01x$, and we are considering only $x>0$. Therefore, $a > 0$, so the wave is traveling in the positive $x$ direction. I can discretize the spatial derivative with a first order upwind scheme. $j$ is grid cell centers, and $j-1/2$ is the left edge of the grid cell.

$$\frac{\partial \Phi}{\partial x}|_j \approx \frac{\Phi_{j} - \Phi_{j-1/2}}{\frac{1}{2}\Delta x}$$

$$= \frac{a_{j} u_j - a_{j-1/2} u_{j-1/2}}{\frac{1}{2}\Delta x}$$

I replace $u_{j-1/2}$ with the averge of the grid cell neighbors ($\frac{u_{j-1} + u_{j}}{2}$)

$$= \frac{a_j u_j - a_{j-1/2} \frac{u_{j-1} + u_{j}}{2}}{\frac{1}{2}\Delta x}$$

So, using the method of lines, I've now turned the PDE into a system of ODEs,

$$\frac{\partial u_j}{\partial t} = - \frac{2 a_j u_j - a_{j-1/2} u_j - a_{j-1/2} u_{j-1}}{\Delta x} \tag{1}$$

Now we can consider the left boundary ($j = 1$)

$$\frac{\partial \Phi}{\partial x}|_1 = \frac{\Phi_{1} - \Phi_{1/2}}{\frac{1}{2}\Delta x}$$

Here, $\Phi_{1/2} = \Phi_\text{in}$ is the "flux" entering the left side of the model domain. The left boundary is then given by

$$\frac{\partial u_1}{\partial t} = \frac{-2 a_1 u_1}{\Delta x} + \frac{2 \Phi_\text{in}}{\Delta x} \tag{2}$$

Equations (1) and (2) describe a system of ODEs which can be evolved forward in time. I have done this for an initial condition of $u_j = 0$, and $\Phi = 0.1$ for the domain $x = [0,100]$. The model reaches the following steady state:

results

Mass is being advected out of the right side of the model domain. How do I figure out this mass flux? The mass flux out should be the same as $\Phi_\text{in} = 0.1$, for flux conservation. Any other relevant tips for understanding/checking mass conservation in these scenarios is appreciated.

I would have thought $\Phi_\text{out} = u_na_n$, where $n$ is the right most grid cell, but this is $\approx 0.105$. So, mass is not quite being conserved, or I'm not computing $\Phi_\text{out}$ properly.

Thanks!

Source Link

How can I check mass conservation when solving the advection equation using an upwind scheme?

My question is how to keep track of the "mass" being advected out of a model domain, for the 1-D advection equation, and an upwind differencing scheme. Following is the background

Consider the continuity equation

$$\frac{\partial u}{\partial t} + \frac{\partial \Phi}{\partial x} = 0$$

Suppose the flux $\Phi$ is given by an advective term

$$\Phi = a u$$

Suppose $a = 0.01x$, and we are considering only $x>0$. Therefore, $a > 0$, so the wave is traveling in the positive $x$ direction. I can discretize the spatial derivative with a first order upwind scheme. $j$ is grid cell centers, and $j-1/2$ is the left edge of the grid cell.

$$\frac{\partial \Phi}{\partial x}|_j \approx \frac{\Phi_{j} - \Phi_{j-1/2}}{\frac{1}{2}\Delta x}$$

$$= \frac{a_{j} u_j - a_{j-1/2} u_{j-1/2}}{\frac{1}{2}\Delta x}$$

I replace $u_{j-1/2}$ with the averge of the grid cell neighbors ($\frac{u_{j-1} + u_{j}}{2}$)

$$= \frac{a_j u_j - a_{j-1/2} \frac{u_{j-1} + u_{j}}{2}}{\frac{1}{2}\Delta x}$$

So, using the method of lines, I've now turned the PDE into a system of ODEs,

$$\frac{\partial u_j}{\partial t} = - \frac{2 a_j u_j - a_{j-1/2} u_j - a_{j-1/2} u_{j-1}}{\Delta x} \tag{1}$$

Now we can consider the left boundary ($j = 1$)

$$\frac{\partial \Phi}{\partial x}|_1 = \frac{\Phi_{1} - \Phi_{1/2}}{\frac{1}{2}\Delta x}$$

Here, $\Phi_{1/2} = \Phi_\text{in}$ is the "flux" entering the left side of the model domain. The left boundary is then given by

$$\frac{\partial u_1}{\partial t} = \frac{-2 a_1 u_1}{\Delta x} + \frac{2 \Phi_\text{in}}{\Delta x} \tag{2}$$

Equations (1) and (2) describe a system of ODEs which can be evolved forward in time. I have done this for an initial condition of $u_j = 0$, and $\Phi = 0.1$ for the domain $x = [0,100]$. The model reaches the following steady state:

results

Mass is being advected out of the right side of the model domain. How do I figure out this mass flux? The mass flux out should be the same as $\Phi_\text{in} = 0.1$, for flux conservation. Any other relevant tips for understanding/checking mass conservation in these scenarios is appreciated.

Thanks!