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

Implemented argument check for unpacking of configs.

parent 640ce4df
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ TODO: Double-check everything! ...@@ -9,7 +9,7 @@ TODO: Double-check everything!
TODO: Replace loops with list comprehension if feasible TODO: Replace loops with list comprehension if feasible
TODO: Combine initial projection and approx solution somehow TODO: Combine initial projection and approx solution somehow
TODO: Investigate why there are no weights in approx calc TODO: Investigate why there are no weights in approx calc
TODO: Implement argument check for unpacking of all configs TODO: Implement argument check for unpacking of all configs -> Done
TODO: Change order of methods -> Done for Stability_Method TODO: Change order of methods -> Done for Stability_Method
TODO: Change code to not include self. but global variables; NO, do private \ TODO: Change code to not include self. but global variables; NO, do private \
or better protected instance variables instead or better protected instance variables instead
......
...@@ -35,6 +35,7 @@ class Sine(InitialCondition): ...@@ -35,6 +35,7 @@ class Sine(InitialCondition):
# Set name of function # Set name of function
self.function_name = 'Sine' self.function_name = 'Sine'
# Unpack necessary configurations
self.factor = config.pop('factor', 2) self.factor = config.pop('factor', 2)
def _get_point(self, x): def _get_point(self, x):
...@@ -66,6 +67,7 @@ class FourPeakWave(InitialCondition): ...@@ -66,6 +67,7 @@ class FourPeakWave(InitialCondition):
# Set name of function # Set name of function
self.function_name = 'FourPeakWave' self.function_name = 'FourPeakWave'
# Set additional necessary parameter
self.alpha = 10 self.alpha = 10
self.delta = 0.005 self.delta = 0.005
self.beta = np.log(2) / (36 * self.delta**2) self.beta = np.log(2) / (36 * self.delta**2)
...@@ -97,6 +99,7 @@ class Linear(InitialCondition): ...@@ -97,6 +99,7 @@ class Linear(InitialCondition):
# Set name of function # Set name of function
self.function_name = 'Linear' self.function_name = 'Linear'
# Unpack necessary configurations
self.factor = config.pop('factor', 1) self.factor = config.pop('factor', 1)
def _get_point(self, x): def _get_point(self, x):
...@@ -110,6 +113,7 @@ class LinearAbsolut(InitialCondition): ...@@ -110,6 +113,7 @@ class LinearAbsolut(InitialCondition):
# Set name of function # Set name of function
self.function_name = 'LinearAbsolut' self.function_name = 'LinearAbsolut'
# Unpack necessary configurations
self.factor = config.pop('factor', 1) self.factor = config.pop('factor', 1)
def _get_point(self, x): def _get_point(self, x):
...@@ -123,6 +127,7 @@ class DiscontinuousConstant(InitialCondition): ...@@ -123,6 +127,7 @@ class DiscontinuousConstant(InitialCondition):
# Set name of function # Set name of function
self.function_name = 'DiscontinuousConstant' self.function_name = 'DiscontinuousConstant'
# Unpack necessary configurations
self.x0 = config.pop('x0', 0) self.x0 = config.pop('x0', 0)
self.left_factor = config.pop('left_factor', 1) self.left_factor = config.pop('left_factor', 1)
self.right_factor = config.pop('right_factor', 0.5) self.right_factor = config.pop('right_factor', 0.5)
......
...@@ -18,6 +18,8 @@ class Limiter(object): ...@@ -18,6 +18,8 @@ class Limiter(object):
class NoLimiter(Limiter): class NoLimiter(Limiter):
def __init__(self, config): def __init__(self, config):
super().__init__(config)
# Set name of function # Set name of function
self.function_name = 'NoLimiter' self.function_name = 'NoLimiter'
...@@ -27,15 +29,14 @@ class NoLimiter(Limiter): ...@@ -27,15 +29,14 @@ class NoLimiter(Limiter):
class MinMod(Limiter): class MinMod(Limiter):
def __init__(self, config): def __init__(self, config):
# Unpack necessary parameter super().__init__(config)
# Unpack necessary configurations
self.erase_degree = config.pop('erase_degree', 0) self.erase_degree = config.pop('erase_degree', 0)
# Set name of function # Set name of function
self.function_name = 'MinMod' + str(self.erase_degree) self.function_name = 'MinMod' + str(self.erase_degree)
# Pop unnecessary parameter
config.pop('cell_len')
self.cell = 0 self.cell = 0
def apply(self, projection, cell): def apply(self, projection, cell):
...@@ -69,9 +70,10 @@ class MinMod(Limiter): ...@@ -69,9 +70,10 @@ class MinMod(Limiter):
class ModifiedMinMod(MinMod): class ModifiedMinMod(MinMod):
def __init__(self, config): def __init__(self, config):
super().__init__(config)
# Unpack necessary configurations # Unpack necessary configurations
self.cell_len = config.pop('cell_len') self.cell_len = config.pop('cell_len')
self.erase_degree = config.pop('erase_degree', 0)
self.mod_factor = config.pop('mod_factor', 0) self.mod_factor = config.pop('mod_factor', 0)
# Set name of function # Set name of function
......
...@@ -32,7 +32,7 @@ init_config['left_factor'] = 3 ...@@ -32,7 +32,7 @@ init_config['left_factor'] = 3
limiter_config = {} limiter_config = {}
limiter_config['mod_factor'] = 0 limiter_config['mod_factor'] = 0
limiter_config['erase_factor'] = 1 limiter_config['erase_degree'] = 0
quadrature_config = {} quadrature_config = {}
quadrature_config['num_eval_points'] = 12 # 12 quadrature_config['num_eval_points'] = 12 # 12
......
...@@ -28,6 +28,8 @@ class Quadrature(object): ...@@ -28,6 +28,8 @@ class Quadrature(object):
class Gauss(Quadrature): class Gauss(Quadrature):
def __init__(self, config): def __init__(self, config):
super().__init__(config)
# Unpack necessary configurations # Unpack necessary configurations
self.num_eval_points = config.pop('num_eval_points', 6) self.num_eval_points = config.pop('num_eval_points', 6)
......
...@@ -28,6 +28,8 @@ class TroubledCellDetector(object): ...@@ -28,6 +28,8 @@ class TroubledCellDetector(object):
class NoDetection(TroubledCellDetector): class NoDetection(TroubledCellDetector):
def __init__(self, config): def __init__(self, config):
super().__init__(config)
# Set name of function # Set name of function
self.function_name = 'NoDetection' self.function_name = 'NoDetection'
...@@ -37,6 +39,8 @@ class NoDetection(TroubledCellDetector): ...@@ -37,6 +39,8 @@ class NoDetection(TroubledCellDetector):
class WaveletDetector(TroubledCellDetector): class WaveletDetector(TroubledCellDetector):
def __init__(self, config): def __init__(self, config):
super().__init__(config)
# Unpack necessary configurations # Unpack necessary configurations
self.polynom_degree = config.pop('polynom_degree') self.polynom_degree = config.pop('polynom_degree')
self.num_coarse_grid_cells = config.pop('num_grid_cells')//2 self.num_coarse_grid_cells = config.pop('num_grid_cells')//2
...@@ -88,9 +92,6 @@ class Boxplot(WaveletDetector): ...@@ -88,9 +92,6 @@ class Boxplot(WaveletDetector):
self.fold_len = config.pop('fold_len', 16) self.fold_len = config.pop('fold_len', 16)
self.whisker_len = config.pop('whisker_len', 3) self.whisker_len = config.pop('whisker_len', 3)
# Pop unnecessary parameter
config.pop('cell_len')
def _get_cells(self, multiwavelet_coeffs, projection): def _get_cells(self, multiwavelet_coeffs, projection):
indexed_coeffs = [[multiwavelet_coeffs[0, i], i]for i in range(self.num_coarse_grid_cells)] indexed_coeffs = [[multiwavelet_coeffs[0, i], i]for i in range(self.num_coarse_grid_cells)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment