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

Removed use of 'DGScheme' from ANN data generation.

parent 97f6c885
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,14 @@ import os
import time
import numpy as np
import DG_Approximation
from DG_Approximation import do_initial_projection
from projection_utils import Mesh
from Quadrature import Gauss
from Basis_Function import OrthonormalLegendre
basis_list = [OrthonormalLegendre(pol_deg) for pol_deg in range(5)]
quadrature_list = [Gauss({'num_nodes': pol_deg+1}) for pol_deg in range(5)]
class TrainingDataGenerator:
......@@ -204,14 +211,20 @@ class TrainingDataGenerator:
# Calculate basis coefficients for stencil
polynomial_degree = np.random.randint(1, high=5)
dg_scheme = DG_Approximation.DGScheme(
'NoDetection', polynomial_degree=polynomial_degree,
num_grid_cells=self._stencil_length, left_bound=left_bound,
right_bound=right_bound, quadrature='Gauss',
quadrature_config={'num_eval_points': polynomial_degree+1})
input_data[i] = dg_scheme.build_training_data(
adjustment, self._stencil_length, self._add_reconstructions,
initial_condition)
basis = basis_list[polynomial_degree]
mesh = Mesh(num_grid_cells=self._stencil_length, num_ghost_cells=2,
left_bound=left_bound, right_bound=right_bound)
projection = do_initial_projection(
initial_condition=initial_condition, mesh=mesh,
basis=basis,
quadrature=quadrature_list[polynomial_degree],
adjustment=adjustment)
input_data[i] = basis.calculate_cell_average(
projection=projection[:, 1:-1],
stencil_length=self._stencil_length,
add_reconstructions=self._add_reconstructions)
count += 1
if count % 1000 == 0:
......
......@@ -16,8 +16,10 @@ TODO: Ask whether all quadratures depend on freely chosen num_nodes
Urgent:
TODO: Replace getter with property attributes for quadrature -> Done
TODO: Rename eval_points in Quadrature to nodes -> Done
TODO: Improve docstring for quadrature
TODO: Remove use of DGScheme from ANN_Data_Generator
TODO: Improve docstring for quadrature -> Done
TODO: Ensure repeatable output through seeds and deterministic models -> Done
TODO: Remove use of DGScheme from ANN_Data_Generator -> Done
TODO: Remove unnecessary instance variables from TrainingDataGenerator
TODO: Find error in centering for ANN training
TODO: Adapt TCD from Soraya
(Dropbox->...->TEST_troubled-cell-detector->Troubled_Cell_Detector)
......@@ -178,8 +180,8 @@ class DGScheme:
left_bound=kwargs.pop('left_bound', -1),
right_bound=kwargs.pop('right_bound', 1),
num_ghost_cells=2)
print(len(self._mesh.cells))
print(type(self._mesh.cells))
# print(len(self._mesh.cells))
# print(type(self._mesh.cells))
# Throw an error if there are extra keyword arguments
if len(kwargs) > 0:
......@@ -284,43 +286,6 @@ class DGScheme:
# Set additional necessary config parameters
self._limiter_config['cell_len'] = self._mesh.cell_len
def build_training_data(self, adjustment, stencil_length,
add_reconstructions, initial_condition=None):
"""Builds training data set.
Initializes projection and calculates cell averages and
reconstructions for it.
Parameters
----------
adjustment : float
Extent of adjustment of each evaluation point in x-direction.
stencil_length : int
Size of training data array.
add_reconstructions: bool
Flag whether reconstructions of the middle cell are included.
initial_condition : InitialCondition object, optional
Initial condition used for calculation.
Default: None (i.e. instance variable).
Returns
-------
ndarray
Matrix containing cell averages and reconstructions for initial
projection.
"""
if initial_condition is None:
initial_condition = self._init_cond
projection = do_initial_projection(
initial_condition=initial_condition, mesh=self._mesh,
basis=self._basis, quadrature=self._quadrature,
adjustment=adjustment)
return self._basis.calculate_cell_average(
projection=projection[:, 1:-1], stencil_length=stencil_length,
add_reconstructions=add_reconstructions)
def do_initial_projection(initial_condition, mesh, basis, quadrature,
adjustment=0):
......
data_dir: 'model-Mar14'
data_dir: 'model-Jun03'
random_seed: 1234
# Parameter for Approximation with Troubled Cell Detection
Approximation:
plot_dir: 'fig-Mar14'
plot_dir: 'fig-Jun03'
schemes:
Separation_Test:
......@@ -36,7 +36,7 @@ Approximation:
quadrature: 'Gauss'
quadrature_config:
num_eval_points: 12
num_nodes: 12
update_scheme: 'SSPRK3'
Test_Run:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment