Skip to content
Snippets Groups Projects
Commit 87f1987b authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Reworked code to ensure termination of Burgers' equation with Sine function.

parent d4d8d59b
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ 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
TODO: Ask why the zero-entry of the boundary matrix is chosen for Burgers
TODO: Ask about reasoning behind height_adjustment and stretch_factor
Urgent:
TODO: Mark Burgers' equation as inviscid -> Done
......@@ -33,21 +33,29 @@ TODO: Move height adjustment and stretch factor into implicit solver
function -> Done
TODO: Enable choice of equation -> Done
TODO: Ensure termination of Burgers with DiscontinuousConstant function -> Done
TODO: Ensure termination of Burgers with Sine function
TODO: Rework burgers_volume_integral()
TODO: Ensure termination of Burgers with Sine function -> Done
TODO: Vectorize 'rarefaction_wave()'
TODO: Vectorize 'burgers_volume_integral()'
TODO: Vectorize 'burgers_local_Lax_Friedrich()'
TODO: Vectorize 'burgers_boundary_matrix()'
TODO: Vectorize '_calculate_boundary_points()'
TODO: Try to extract calculation of matrices for the volume integral and flux
for Burgers
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: Add height_adjustment and stretch_factor if sensible
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
TODO: Test Burgers
TODO: Test Burgers (and fix bugs)
TODO: Rework Burgers for speed-up and better structure
TODO: Add initialization to Burgers
TODO: Use cfl_number for updating, not just time (equation-related?)
Critical, but not urgent:
TODO: Ensure property variables are used if sensible
TODO: Make sure TCs are reported as ndarray
TODO: Make sure that the cell indices are the same over all TCDs
TODO: Combine ANN workflows if feasible
......
......@@ -48,6 +48,10 @@ Approximation:
equation: 'Burgers'
detector: 'Theoretical'
init_cond: 'DiscontinuousConstant'
Burgers_Sine:
equation: 'Burgers'
detector: 'Boxplot'
init_cond: 'Sine'
# Parameter for Training Data Generation
ANN_Data:
......
......@@ -103,6 +103,7 @@ class DGScheme:
# Save approximation-specific data in dictionary
approx_stats = {**self._detector.create_data_dict(projection),
**self._equation.create_data_dict(),
'equation': self._equation.name,
'time_history': time_history,
'troubled_cell_history': troubled_cell_history}
......
......@@ -77,6 +77,11 @@ class Equation(ABC):
self._reset()
@property
def name(self) -> str:
"""Return string of class name."""
return self.__class__.__name__
@property
def basis(self) -> Basis:
"""Return basis."""
......@@ -481,10 +486,10 @@ class Burgers(Equation):
# return grid, exact
exact = []
if self._init_cond.__name__ == 'Sine':
if self._init_cond.get_name() == 'Sine':
# u(x,t) = u(x - u0*time, 0)
exact = self.implicit_burgers_solver(grid, mesh)
elif self._init_cond.__name__ == 'DiscontinuousConstant':
elif self._init_cond.get_name() == 'DiscontinuousConstant':
# u(x,t) = u(x - u0*time, 0)
exact = self.rarefaction_wave(grid)
......@@ -520,8 +525,12 @@ class Burgers(Equation):
Code adapted from DG code by Hesthaven.
"""
# Temporary fix until further clarification
height_adjustment = 0
stretch_factor = 1
# Shock speed = 1/2*(left+right values)
sspeed = self._init_cond._height_adjustment
sspeed = height_adjustment
uexact = np.zeros(np.size(grid_values))
# initialize values
......@@ -575,8 +584,7 @@ class Burgers(Equation):
burgers_exact = uexact.reshape((1, np.size(grid_values)))
return self._init_cond._height_adjustment + \
self._init_cond._stretch_factor * burgers_exact
return height_adjustment + stretch_factor * burgers_exact
@enforce_boundary()
def update_right_hand_side(self, projection: ndarray) -> ndarray:
......
......@@ -17,7 +17,7 @@ from .Quadrature import Quadrature
from .Initial_Condition import InitialCondition
from .Basis_Function import Basis, OrthonormalLegendre
from .projection_utils import calculate_approximate_solution
from .Equation import Equation, LinearAdvection
from .Equation import Equation, LinearAdvection, Burgers
from .Mesh import Mesh
from .encoding_utils import decode_ndarray
......@@ -344,11 +344,18 @@ def plot_approximation_results(data_file: str, directory: str, plot_name: str,
mesh = Mesh(**approx_stats['mesh'])
print(list(approx_stats.keys()))
if approx_stats['equation'] == 'LinearAdvection':
approx_stats['equation'] = LinearAdvection(
quadrature=quadrature, init_cond=init_cond, basis=basis, mesh=mesh,
final_time=approx_stats['final_time'],
wave_speed=approx_stats['wave_speed'],
cfl_number=approx_stats['cfl_number'])
else:
approx_stats['equation'] = Burgers(
quadrature=quadrature, init_cond=init_cond, basis=basis, mesh=mesh,
final_time=approx_stats['final_time'],
wave_speed=approx_stats['wave_speed'],
cfl_number=approx_stats['cfl_number'])
for key in ['basis', 'mesh', 'final_time', 'wave_speed', 'cfl_number']:
approx_stats.pop(key, None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment