{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Advection using TVD Flux Limiters\n", "## CH EN 6355 - Computational Fluid Dynamics\n", "**Prof. Tony Saad (www.tsaad.net)
" ] }, { "cell_type": "markdown", "metadata": { "variables": { "1 + k": {}, "1 - k": {} } }, "source": [ "Here, we will implement the k-scheme or kappa-schemes for advection. It is easiest to implement this scheme since for different values of k, we recover all sorts of high-order flux approximations. We will assume a positive advecting velocity for illustration purposes.\n", "\n", "We are solving the constant speed advection equation given by\n", "\$$\n", "u_t = - c u_x = - F_x;\\quad F = cu\n", "\$$\n", "We will use a simple Forward Euler explicit method. Using a finite volume integration, we get\n", "\$$\n", "u_i^{n+1} = u_i^n - \\frac{\\Delta t}{\\Delta x} (F_{i+\\tfrac{1}{2}}^n - F_{i-\\tfrac{1}{2}}^n)\n", "\$$\n", "Our TVD formulation is based on a finite volume discretization with face values for the dependent variable given by:\n", "\$$\n", "{\\phi _f} = {\\phi _{\\rm{C}}} + {1 \\over 2}\\psi ({r_f})\\left( {{\\phi _{\\rm{D}}} - {\\phi _{\\rm{C}}}} \\right)\n", "\$$\n", "where $\\psi$ is the limiter function." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "%matplotlib inline\n", "%config InlineBackend.figure_format = 'svg'\n", "import matplotlib.pyplot as plt\n", "import matplotlib.animation as animation\n", "plt.rcParams['animation.html'] = 'html5'\n", "from matplotlib import cm" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "def step(x,x0):\n", " x0 = 0.6\n", " x1 = 0.8\n", " result = x - x0\n", " result[x-x1x1] = 0.0 \n", " return result\n", "\n", "def gaussian(x,x0):\n", " s = 0.08\n", " s = s*s\n", " result = np.exp( -(x-x0)**2/s)\n", " return result" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n" ], "text/plain": [ "