From cc566c8ef213cab074db6d1ddaeb5c1548af02d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=BChle=2C=20Laura=20Christine=20=28lakue103=29?= <laura.kuehle@uni-duesseldorf.de> Date: Fri, 12 May 2023 12:23:04 +0200 Subject: [PATCH] Enabled choice of equation. --- Snakefile | 8 ++++++-- config.yaml | 5 ++++- scripts/approximate_solution.py | 18 +++++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Snakefile b/Snakefile index e91491f..e5ddb4e 100644 --- a/Snakefile +++ b/Snakefile @@ -22,16 +22,20 @@ TODO: Contemplate using lambdify for basis TODO: Contemplate allowing vector input for ICs TODO: Discuss how wavelet details should be plotted +TODO: Ask why implicit solver is always over the interval [0,1] with 200 cells + Urgent: TODO: Mark Burgers' equation as inviscid -> Done TODO: Make sure CFL number is absolute value -> Done TODO: Make sure only ghost cells are limited for Dirichlet boundary -> Done TODO: Move height adjustment and stretch factor into implicit solver function -> Done +TODO: Enable choice of equation -> Done +TODO: Rework burgers_volume_integral() +TODO: Rework/refactor implicit solver +TODO: Add subclasses of Burgers (rarefaction and shock case) TODO: Check correctness of implicit solver (with burgex.f) TODO: Add Burgers class completely -TODO: Enable choice of equation -TODO: Add subclasses of Burgers (rarefaction and shock case) TODO: Ignore ghost domains by flagging all cells with it for extreme outlier TODO: Add functions to create each object from dict TODO: Initialize boundary config properly diff --git a/config.yaml b/config.yaml index 89bdfe0..83eceaa 100644 --- a/config.yaml +++ b/config.yaml @@ -1,4 +1,4 @@ -data_dir: 'Oct04' +data_dir: 'May12' random_seed: 1234 # Parameter for Approximation with Troubled Cell Detection @@ -44,6 +44,9 @@ Approximation: detector_config: fold_len: 16 init_cond: 'FourPeakWave' + Burgers: + equation: 'Burgers' + detector: 'Theoretical' # Parameter for Training Data Generation ANN_Data: diff --git a/scripts/approximate_solution.py b/scripts/approximate_solution.py index dbf9277..b7a06df 100644 --- a/scripts/approximate_solution.py +++ b/scripts/approximate_solution.py @@ -6,6 +6,7 @@ import sys import time +from tcd import Equation from tcd import Initial_Condition from tcd import Limiter from tcd import Quadrature @@ -14,7 +15,7 @@ from tcd import Update_Scheme from tcd.Basis_Function import OrthonormalLegendre from tcd.DG_Approximation import DGScheme from tcd.Mesh import Mesh -from tcd.Equation import LinearAdvection +# from tcd.Equation import LinearAdvection def main() -> None: @@ -84,15 +85,18 @@ def main() -> None: % init_name) init_cond = getattr(Initial_Condition, init_name)(config=init_config) - # Initialize linear advection equation + # Initialize equation after checking its legitimacy wave_speed = params.pop('wave_speed', 1) final_time = params.pop('final_time', 1) cfl_number = params.pop('cfl_number', 0.2) - equation = LinearAdvection(final_time=final_time, - cfl_number=cfl_number, - basis=basis, init_cond=init_cond, - quadrature=quadrature, - mesh=mesh, wave_speed=wave_speed) + + equation_name = params.pop('equation', 'LinearAdvection') + if not hasattr(Equation, equation_name): + raise ValueError('Invalid equation: "%s"' % equation_name) + equation = getattr(Equation, equation_name)( + final_time=final_time, cfl_number=cfl_number, basis=basis, + init_cond=init_cond, quadrature=quadrature, mesh=mesh, + wave_speed=wave_speed) # Initialize update scheme after checking its legitimacy scheme_name = params.pop('update_scheme', 'SSPRK3') -- GitLab