A Python implementation of the Discontinuous Galerkin (DG) method for solving one-dimensional scalar hyperbolic conservation laws.
Reference: Shu, Chi-Wang. “Discontinuous Galerkin Methods: General Approach and Stability.” (2008).
import numpy as np import matplotlib.pyplot as plt from numpy.polynomial import legendre import pandas as pd plt.rcParams.update( { "savefig.dpi": 300, "figure.autolayout": True, "text.usetex": True, "font.family": "serif", "font.serif": ["Times New Roman"], "pdf.fonttype": 42, "ps.fonttype": 42, "font.size": 14, "axes.labelsize": 14, "axes.titlesize": 14, "xtick.labelsize": 14, "ytick.labelsize": 14, "legend.fontsize": 14, "lines.linewidth": 1.0, "lines.markersize": 5, "axes.linewidth": 1.0, "lines.markerfacecolor": "none", "lines.markeredgecolor": "auto", "xtick.direction": "in", "ytick.direction": "in", "legend.facecolor": "white", "legend.edgecolor": "black", "legend.framealpha": 1.0, } ) 1. Burgers Equation Consider the scalar conservation law $$u_t + f(u)_x = 0$$with the flux function $f(u) = \frac{u^2}{2}$, which yields the inviscid Burgers equation: ...