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:

[3.982484, 4.0450406, 4.1075974, 4.170154, 4.232711, 4.2952676,
 4.3578243, 4.420381, 4.482938, 4.5454946, 4.6080513, 4.670608,
 4.733165, 4.7957215, 4.8582783, 4.920835, 4.983392, 5.045948,
 5.108505, 5.1710615, 5.2336183, 5.296175, 5.3587317, 5.4212885,
 5.483845, 5.546402, 5.6089587, 5.6715155, 5.734072, 5.796629,
 5.8591857, 5.9217424, 5.984299, 6.0468554, 6.109412, 6.171969,
 6.2345257, 6.2970824, 6.359639, 6.422196, 6.4847527, 6.5473094,
 6.609866, 6.672423, 6.734979, 6.797534, 6.860055, 6.9220233,
 6.9748416, 6.880349, 5.152262, 1.6489367, 1.0293779, 1.0453354,
 1.1050574, 1.1674429, 1.2299894, 1.2925454, 1.3551022, 1.4176589,
 1.4802157, 1.5427722, 1.6053289, 1.6678857, 1.7304426, 1.7929994,
 1.8555557, 1.9181124, 1.9806691, 2.0432258, 2.1057825, 2.1683393,
 2.230896, 2.2934527, 2.3560095, 2.4185662, 2.481123, 2.5436797,
 2.6062365, 2.6687932, 2.73135, 2.7939067, 2.8564634, 2.9190202,
 2.9815764, 3.0441332, 3.10669, 3.1692467, 3.2318034, 3.2943602,
 3.356917, 3.4194736, 3.4820304, 3.5445871, 3.6071439, 3.6697006,
 3.7322574, 3.794814, 3.8573709, 3.9199276, 3.9824843]

^^“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