diff --git a/Plotting.py b/Plotting.py index 87c06211251857fb7dcb3c3183c12c5965136e25..0c62c0cd231fd4c14f160c26c17f069325a679a7 100644 --- a/Plotting.py +++ b/Plotting.py @@ -118,7 +118,7 @@ def plot_shock_tube(num_grid_cells: int, troubled_cell_history: list, current_cells = troubled_cell_history[pos] for cell in current_cells: plt.plot(cell, time_history[pos], 'k.') - plt.xlim((0, num_grid_cells // 2)) + plt.xlim((0, num_grid_cells)) plt.xlabel('Cell') plt.ylabel('Time') plt.title('Shock Tubes') diff --git a/Troubled_Cell_Detector.py b/Troubled_Cell_Detector.py index 6f4cb596056ed437637df005b4fd5ae15c36ad46..7a637c377440bc9a90a752c878d3ca0cb409a717 100644 --- a/Troubled_Cell_Detector.py +++ b/Troubled_Cell_Detector.py @@ -3,7 +3,8 @@ @author: Laura C. Kühle, Soraya Terrab (sorayaterrab) TODO: Adjust TCs for wavelet detectors (sliding window over all cells instead - of every second) + of every second) -> Done +TODO: Replace num_coarse_grid_cells with mesh TODO: Introduce Adjusted Outer Fence method in Boxplot using global_mean TODO: Introduce overlapping cell for adjacent folds in Boxplot TODO: Introduce lower/upper extreme outliers in Boxplot @@ -244,8 +245,7 @@ class WaveletDetector(TroubledCellDetector): List of indices for all detected troubled cells. """ - multiwavelet_coeffs = self._calculate_wavelet_coeffs( - projection[:, 1: -1]) + multiwavelet_coeffs = self._calculate_wavelet_coeffs(projection) return self._get_cells(multiwavelet_coeffs, projection) def _calculate_wavelet_coeffs(self, projection): @@ -263,10 +263,10 @@ class WaveletDetector(TroubledCellDetector): """ output_matrix = [] - for i in range(self._num_coarse_grid_cells): + for i in range(self._mesh.num_grid_cells): new_entry = 0.5*( - projection[:, 2*i] @ self._wavelet_projection_left - + projection[:, 2*i+1] @ self._wavelet_projection_right) + projection[:, i] @ self._wavelet_projection_left + + projection[:, i+1] @ self._wavelet_projection_right) output_matrix.append(new_entry) return np.transpose(np.array(output_matrix)) @@ -377,12 +377,12 @@ class Boxplot(WaveletDetector): """ indexed_coeffs = [[multiwavelet_coeffs[0, i], i] - for i in range(self._num_coarse_grid_cells)] + for i in range(self._mesh.num_grid_cells)] - if self._num_coarse_grid_cells < self._fold_len: - self._fold_len = self._num_coarse_grid_cells + if self._mesh.num_grid_cells < self._fold_len: + self._fold_len = self._mesh.num_grid_cells - num_folds = self._num_coarse_grid_cells//self._fold_len + num_folds = self._mesh.num_grid_cells//self._fold_len troubled_cells = [] for fold in range(num_folds): @@ -466,9 +466,9 @@ class Theoretical(WaveletDetector): troubled_cells = [] max_avg = np.sqrt(0.5) \ * max(1, max(abs(projection[0][cell+1]) - for cell in range(self._num_coarse_grid_cells))) + for cell in range(self._mesh.num_grid_cells))) - for cell in range(self._num_coarse_grid_cells): + for cell in range(self._mesh.num_grid_cells): if self._is_troubled_cell(multiwavelet_coeffs, cell, max_avg): troubled_cells.append(cell)