def __init__(self, N, NV, NDIM, F, S=None, B=None, M=None, pars=None, stiff=False, stiff_guess=False, newton_guess=False, tol=1e-6, max_iter=50, max_size=1e16): self.N = N self.NV = NV self.NDIM = NDIM self.NT = N**(NDIM + 1) self.F = F self.S = S self.B = B self.M = M self.pars = pars self.max_iter = max_iter self.tol = tol self.max_size = max_size self.stiff = stiff if stiff_guess: self.initial_guess = stiff_initial_guess else: self.initial_guess = standard_initial_guess self.newton_guess = newton_guess basis = Basis(N) self.GAPS = basis.GAPS self.DERVALS = basis.DERVALS self.DG_W, self.DG_V, self.DG_U, self.DG_M, self.DG_D = galerkin_matrices( N, NV, NDIM, basis)
def plot_weno(wh, var, MPs=None): NDIM = int((wh.ndim - 1) / 2) shape = wh.shape[:NDIM] N = wh.shape[-2] NV = wh.shape[-1] basis = Basis(N) inds = [N * s for s in shape] x = zeros(inds) u = zeros(inds + [NV]) for i in range(shape[0]): ind = i * N for j in range(N): x[ind + j] = i + basis.NODES[j] u[ind + j] = wh[i, j] if var == 'density': plot_density(u, x=x) if var == 'energy': plot_energy(u, x=x) if var == 'velocity': plot_velocity(u, x=x) if var == 'pressure': plot_pressure(u, MPs, x=x)
def plot_dg(qh, var, t, MPs=None): n, _, _, N, _, NV = qh.shape basis = Basis(N) wh = zeros([n, 1, 1, N, NV]) for i in range(n): for j in range(N): for k in range(N): wh[i, 0, 0, j] += basis.ψ[k](t) * qh[i, 0, 0, k, j] plot_weno(wh, var, MPs)
def __init__(self, N, NV, NDIM, λc=1e5, λs=1, r=8, ε=1e-14): self.N = N self.NV = NV self.NDIM = NDIM self.Λ = [λs, λs, λc, λc] self.fN = int(floor((N - 1) / 2)) self.cN = int(ceil((N - 1) / 2)) self.r = r self.ε = ε basis = Basis(N) self.W = weno_matrices(N, basis.ψ) self.Σ = oscillation_indicator(N, basis.dψ)
def __init__(self, N, NV, NDIM, F, S=None, B=None, M=None, max_eig=None, pars=None, riemann_solver='rusanov', time_rec=True): self.N = N self.NV = NV self.NDIM = NDIM self.F = F self.S = S self.B = B self.M = M self.max_eig = max_eig self.pars = pars if riemann_solver == 'rusanov': self.D_FUN = D_RUS elif riemann_solver == 'roe': self.D_FUN = D_ROE elif riemann_solver == 'osher': self.D_FUN = D_OSH else: raise ValueError("Choice of 'riemann_solver' not recognised.\n" + "Choose from 'rusanov', 'roe', and 'osher'.") self.time_rec = time_rec basis = Basis(N) self.NODES = basis.NODES self.WGHTS = basis.WGHTS self.ENDVALS = basis.ENDVALS self.DERVALS = basis.DERVALS self.TN, self.WGHT, self.WGHT_END = quad_weights( N, NDIM, basis.WGHTS, time_rec)