6  1-D Burgers’ Equation

A fundamental PDE & convection-diffusion equation.

\[\frac{\partial u}{\partial t} + u \frac{\partial u}{\partial x} = \nu\frac{\partial^2 u}{\partial x^2}\]

Previously, convection eq’n:

\[\frac{\partial u}{\partial t} + u\frac{\partial u}{\partial x} = 0\]

and diffusion eq’n:

\[\frac{\partial u}{\partial t} = \nu\frac{\partial^2 u}{\partial x^2}\]

combining discretized equations from previous steps

\[\frac{u_i^{n+1} - u_i^n}{\Delta t} + u_i^n\frac{u_i^n - u_{i-1}^n}{\Delta x} = \nu\frac{u_{i+1}^n + u_{i-1}^n - 2u_i^n}{\Delta x^2}\]

rearranging the above results:

\[u_i^{n+1} = u_i^n - u_i^n \frac{\Delta t}{\Delta x}(u_i^n - u_{i-1}^n) + \nu\frac{\Delta t}{\Delta x^2}(u_{i+1}^n + u_{i-1}^n - 2u_i^n)\]

6.1 Initials & Boundary Conditions

6.1.1 Initial Conditions

\[u = -\frac{2\nu}{\phi}\frac{\partial \phi}{\partial x} + 4\]

\[\phi = \exp\bigg(\frac{-(x - 4t)^2}{4\nu(t + 1)}\bigg) + \exp\bigg(\frac{-(x - 4t - 2\pi)^2}{4\nu(t + 1)}\bigg)\]

6.1.2 Boundary Condition

\[u(0) = u(2\pi)\]

This is called a periodic boundary condition.

Testing Burgers’ Eqn: note: currently not using adding equation very organically, so we need to refactor.

(one-d/burgers-u {:t 1.0 :x 4.0 :nu 3.0})
3.4917066

Working on generating lambdify-ed function:

(def nx 101)
(def nt 100)
(def nu 0.07)
(def dx (* 2.0 PI (/ 1 (- nx 1))))
(def dt (* dx nu))
(def x-start 0)
(def x-end (* 2.0 PI))
(def init-params
  {:nx      nx
   :dx      dx
   :nt      nt
   :x-start x-start
   :x-end   x-end
   :nu      nu
   :dt      dt
   :mode    :burger})

Calculate u and plot:

[2.7665834, 2.810041, 2.8534985, 2.896956, 2.9404135, 2.9838707,
 3.027328, 3.0707853, 3.1142426, 3.1577, 3.2011576, 3.244615,
 3.2880726, 3.33153, 3.3749874, 3.4184446, 3.4619021, 3.5053596,
 3.5488172, 3.5922744, 3.6357317, 3.679189, 3.7226465, 3.766104,
 3.8095615, 3.853019, 3.8964763, 3.9399338, 3.983391, 4.0268483,
 4.070306, 4.113763, 4.1572204, 4.200678, 4.2441354, 4.2875924,
 4.33105, 4.3745074, 4.417965, 4.461422, 4.5048795, 4.548337,
 4.5917945, 4.635252, 4.6787095, 4.722167, 4.765624, 4.8090816,
 4.852539, 4.8959966, 4.939454, 4.982911, 5.026369, 5.0698266,
 5.1132836, 5.1567407, 5.200197, 5.2436533, 5.2871075, 5.3305573,
 5.3739967, 5.417413, 5.460777, 5.5040193, 5.546986, 5.5893273,
 5.630253, 5.667983, 5.6985307, 5.7130485, 5.6922836, 5.5961103,
 5.348928, 4.8410926, 4.01946, 3.0892584, 2.4052658, 2.0581272,
 1.9277661, 1.90015, 1.9154866, 1.9479402, 1.9871031, 2.028884,
 2.0716863, 2.1148875, 2.1582446, 2.2016628, 2.245105, 2.2885563,
 2.3320115, 2.375468, 2.418925, 2.4623823, 2.5058396, 2.5492969,
 2.5927541, 2.6362116, 2.679669, 2.7231262, 2.7665834]

^^“saw-tooth function”

6.2 Periodic Boundary Conditions

With periodic boundary conditions, when a point gets to the right-hand side of the frame, it wraps around back to the front of the frame.

Bringing the discretized equation from the above:

\[u_i^{n+1} = u_i^n - u_i^n \frac{\Delta t}{\Delta x}(u_i^n - u_{i-1}^n) + \nu\frac{\Delta t}{\Delta x^2}(u_{i+1}^n + u_{i-1}^n - 2u_i^n)\]

Drawing both analytical and computational results in the same plot:

source: notebooks/steps/step_04.clj