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

Renamed 'adjustment' to 'shift'.

parent 2925b235
No related branches found
No related tags found
No related merge requests found
......@@ -218,13 +218,13 @@ class TrainingDataGenerator:
mesh = self._mesh_list[int(np.random.randint(
3, high=12, size=1))-3].random_stencil(stencil_length)
# Induce adjustment to capture troubled cells
adjustment = 0 if initial_condition.is_smooth() \
# Induce shift to capture troubled cells
shift = 0 if initial_condition.is_smooth() \
else mesh.non_ghost_cells[stencil_length//2]
if initial_condition.discontinuity_position == 'left':
adjustment -= mesh.cell_len/2
shift -= mesh.cell_len/2
elif initial_condition.discontinuity_position == 'right':
adjustment += mesh.cell_len/2
shift += mesh.cell_len/2
# Calculate basis coefficients for stencil
polynomial_degree = np.random.randint(1, high=5)
......@@ -232,7 +232,7 @@ class TrainingDataGenerator:
initial_condition=initial_condition, mesh=mesh,
basis=self._basis_list[polynomial_degree],
quadrature=self._quadrature_list[polynomial_degree],
adjustment=adjustment)
x_shift=shift)
input_data[i] = self._basis_list[
polynomial_degree].calculate_cell_average(
projection=projection[:, 1:-1],
......
......@@ -21,19 +21,21 @@ TODO: Discuss descriptions (matrices, cfl number, right-hand side,
TODO: Discuss referencing info on SSPRK3
TODO: Discuss why the left_factor is not subtracted for the second
discontinuity for the two-sided Heaviside
TODO: Discuss order of addends for two-sided Heaviside
discontinuity for the two-sided Heaviside -> Done (is correct)
TODO: Discuss order of addends for two-sided Heaviside -> Done (change)
TODO: Discuss whether to enforce positive shift in the two-sided Heaviside
-> Done (change)
TODO: Discuss reasoning behind minimum mesh size of 2^5 instead of 2^3 for
training data
training data -> Done (closer to real application)
TODO: Discuss why basis degree can be as high as 6 if it is only defined up
to 4 so far (alternative calculation?)
to 4 so far -> Done (fine as we don't use wavelets)
TODO: Discuss whether domain other than [-1, 1] is in any way useful for
training
training -> Done (not)
Urgent:
TODO: Replace induce_adjustment() with margin
TODO: Rename 'adjustment' to 'shift'
TODO: Fix bug not using initial condition configs for training -> Done
TODO: Replace induce_adjustment() with margin -> Done
TODO: Rename 'adjustment' to 'shift' -> Done
TODO: Induce shift in IC class
TODO: Move plot_approximation_results() into plotting script
TODO: Improve file naming (e.g. use '.' instead of '__')
......@@ -49,6 +51,11 @@ TODO: Unify print commands (f vs no f)
TODO: Add method and error info to Mesh
TODO: Add use of discontinuity position to all ICs
TODO: Adjust definitions of each IC to be dependant on domain
TODO: Change maximum training degree to 6
TODO: Change minimum training mesh size to 2^5
TODO: Enforce shift to be positive for two-sided Heaviside
TODO: Remove option to choose training domain
TODO: Fix VisibleDeprecationWarning for ndarray encoding
Critical, but not urgent:
TODO: Introduce env files for each SM rule
......@@ -128,7 +135,7 @@ class DGScheme:
Approximates projection.
save_plots()
Saves plots generated during approximation process.
build_training_data(adjustment, stencil_length, initial_condition=None)
build_training_data(x_shift, stencil_length, initial_condition=None)
Builds training data set.
"""
......@@ -310,7 +317,7 @@ class DGScheme:
def do_initial_projection(initial_condition, mesh, basis, quadrature,
adjustment=0):
x_shift=0):
"""Calculates initial projection.
Calculates a projection at time step 0 and adds ghost cells on both
......@@ -326,9 +333,8 @@ def do_initial_projection(initial_condition, mesh, basis, quadrature,
Basis used for calculation.
quadrature: Quadrature object
Quadrature used for evaluation.
adjustment: float, optional
Extent of adjustment of each evaluation point in x-direction.
Default: 0.
x_shift: float, optional
Shift in x-direction for each evaluation point. Default: 0.
Returns
-------
......@@ -345,7 +351,7 @@ def do_initial_projection(initial_condition, mesh, basis, quadrature,
for degree in range(basis.polynomial_degree + 1):
new_row.append(np.float64(sum(initial_condition.calculate(
x=eval_point + mesh.cell_len/2
* quadrature.nodes[point] - adjustment, mesh=mesh)
* quadrature.nodes[point] - x_shift, mesh=mesh)
* basis.basis[degree].subs(
x, quadrature.nodes[point])
* quadrature.weights[point]
......
......@@ -247,9 +247,9 @@ class FourPeakWave(InitialCondition):
beta : float
Factor used for the Gaussian function.
a : float
Value for x-value adjustment for elliptic function.
Value for shift in x-direction for elliptic function.
z : float
Value for x-value adjustment for Gaussian function.
Value for shift in x-direction for Gaussian function.
Methods
-------
......@@ -317,7 +317,7 @@ class FourPeakWave(InitialCondition):
x : float
Evaluation point of function.
z : float
Value for x-value adjustment.
Value for shift in x-direction.
Returns
-------
......@@ -335,7 +335,7 @@ class FourPeakWave(InitialCondition):
x : float
Evaluation point of function.
a : float
Value for x-value adjustment.
Value for shift in x-direction .
Returns
-------
......
......@@ -189,13 +189,13 @@ def plot_classification_barplot(evaluation_dict: dict, colors: dict) -> None:
fig = plt.figure('barplot')
ax = fig.add_axes([0.15, 0.3, 0.6, 0.6])
step_len = 1
adjustment = -(len(model_names)//2)*step_len
shift = -(len(model_names)//2)*step_len
for measure in evaluation_dict:
model_eval = [evaluation_dict[measure][model]
for model in evaluation_dict[measure]]
ax.bar(pos + adjustment*width, model_eval, width, label=measure,
ax.bar(pos + shift*width, model_eval, width, label=measure,
color=colors[measure])
adjustment += step_len
shift += step_len
ax.set_xticks(pos)
ax.set_xticklabels(model_names, rotation=50, ha='right',
fontsize=font_size)
......@@ -226,19 +226,19 @@ def plot_classification_boxplot(evaluation_dict: dict, colors: dict) -> None:
ax = fig.add_axes([0.15, 0.3, 0.6, 0.6])
step_len = 1.5
boxplots = []
adjustment = -(len(model_names)//2)*step_len
shift = -(len(model_names)//2)*step_len
pos = np.arange(len(model_names))
width = 1/(5*len(model_names))
for measure in evaluation_dict:
model_eval = [evaluation_dict[measure][model]
for model in evaluation_dict[measure]]
boxplot = ax.boxplot(model_eval, positions=pos + adjustment*width,
boxplot = ax.boxplot(model_eval, positions=pos + shift*width,
widths=width, meanline=True, showmeans=True,
patch_artist=True)
for patch in boxplot['boxes']:
patch.set(facecolor=colors[measure])
boxplots.append(boxplot)
adjustment += step_len
shift += step_len
ax.set_xticks(pos)
ax.set_xticklabels(model_names, rotation=50, ha='right',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment