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

Fixed bug applying wrong boundary condition when generating ANN training data.

parent 706ad4de
No related branches found
No related tags found
No related merge requests found
......@@ -157,8 +157,6 @@ class TrainingDataGenerator:
# Create normalized input data
norm_input_matrix = self._normalize_data(input_matrix)
# print(input_matrix)
# print(norm_input_matrix)
return {'input_data.raw': input_matrix, 'output_data': output_matrix,
'input_data.normalized': norm_input_matrix}
......@@ -217,10 +215,6 @@ class TrainingDataGenerator:
adjustment = 0 if initial_condition.is_smooth() \
else mesh.non_ghost_cells[self._stencil_length//2]
initial_condition.induce_adjustment(-mesh.cell_len/3)
# print(initial_condition.is_smooth())
# print(mesh.interval_len, mesh.non_ghost_cells, mesh.cell_len)
# print(adjustment, -mesh.cell_len/3)
# print()
# Calculate basis coefficients for stencil
polynomial_degree = np.random.randint(1, high=5)
......@@ -229,7 +223,6 @@ class TrainingDataGenerator:
basis=self._basis_list[polynomial_degree],
quadrature=self._quadrature_list[polynomial_degree],
adjustment=adjustment)
# print(projection)
input_data[i] = self._basis_list[
polynomial_degree].calculate_cell_average(
projection=projection[:, 1:-1],
......
......@@ -12,13 +12,17 @@ TODO: Contemplate containing coarse mesh generation in Mesh
TODO: Contemplate extracting boundary condition from InitialCondition
TODO: Contemplate containing boundary condition in Mesh
TODO: Ask whether all quadratures depend on freely chosen num_nodes
TODO: Contemplate saving each IC separately
TODO: Contemplate saving training data for each IC separately
TODO: Contemplate removing TrainingDataGenerator class
Urgent:
TODO: Investigate self-referencing in classes
TODO: Investigate self-referencing in classes -> Done
TODO: Apply self-referencing in Mesh -> Done
TODO: Refactor random_stencil() -> Done
TODO: Fix bug applying wrong boundary condition when generating ANN
training data -> Done
TODO: Find errors in centering for ANN training -> Done
TODO: Remove stencil_length as instance variable
TODO: Find errors in centering for ANN training
TODO: Adapt TCD from Soraya
(Dropbox->...->TEST_troubled-cell-detector->Troubled_Cell_Detector)
TODO: Add TC condition to only flag cell if left-adjacent one is flagged as
......@@ -27,6 +31,8 @@ TODO: Move plot_approximation_results() into plotting script
TODO: Add verbose output
TODO: Improve file naming (e.g. use '.' instead of '__')
TODO: Check whether ghost cells are handled/set correctly
TODO: Unify use of 'length' and 'len' in naming
TODO: Unify use of 'initial_condition' and 'init_cond' in naming
TODO: Ensure uniform use of mesh and grid
Critical, but not urgent:
......@@ -44,7 +50,6 @@ TODO: Extract object initialization from DGScheme
TODO: Use cfl_number for updating, not just time
Currently not critical:
TODO: Unify use of 'length' and 'len' in naming
TODO: Replace loops with list comprehension if feasible
TODO: Replace loops/list comprehension with vectorization if feasible
TODO: Check whether 'projection' is always a ndarray
......@@ -319,10 +324,9 @@ def do_initial_projection(initial_condition, mesh, basis, quadrature,
for eval_point in mesh.non_ghost_cells:
new_row = []
for degree in range(basis.polynomial_degree + 1):
new_row.append(np.float64(sum(initial_condition.calculate(
mesh, eval_point + mesh.cell_len/2
x=eval_point + mesh.cell_len/2
* quadrature.nodes[point] - adjustment)
* basis.basis[degree].subs(
x, quadrature.nodes[point])
......
......@@ -77,18 +77,18 @@ class InitialCondition(ABC):
"""
pass
def calculate(self, mesh, x):
def calculate(self, x, mesh=None):
"""Evaluates function at given x-value.
Projects x-value into interval of the periodic function and evaluates
the function.
If a mesh is given, the x-value is projected into its periodic
interval before evaluating the function.
Parameters
----------
mesh : Mesh
Mesh for calculation.
x : float
Evaluation point of function.
mesh : Mesh, optional
Mesh for calculation. Default: None.
Returns
-------
......@@ -96,6 +96,7 @@ class InitialCondition(ABC):
Value of function evaluates at x-value.
"""
if mesh is not None:
left_bound, right_bound = mesh.bounds
while x < left_bound:
x += mesh.interval_len
......
......@@ -202,7 +202,7 @@ def calculate_exact_solution(
eval_values = []
for eval_point in eval_points:
new_entry = init_cond.calculate(mesh, eval_point
new_entry = init_cond.calculate(mesh=mesh, x=eval_point
- wave_speed * final_time
+ num_periods * mesh.interval_len)
eval_values.append(new_entry)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment