Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
b7f28556
Commit
b7f28556
authored
Jun 5, 2022
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
ANN_Data_Generator.py
+0
-7
0 additions, 7 deletions
ANN_Data_Generator.py
DG_Approximation.py
+10
-6
10 additions, 6 deletions
DG_Approximation.py
Initial_Condition.py
+11
-10
11 additions, 10 deletions
Initial_Condition.py
projection_utils.py
+1
-1
1 addition, 1 deletion
projection_utils.py
with
22 additions
and
24 deletions
ANN_Data_Generator.py
+
0
−
7
View file @
b7f28556
...
...
@@ -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
],
...
...
This diff is collapsed.
Click to expand it.
DG_Approximation.py
+
10
−
6
View file @
b7f28556
...
...
@@ -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
])
...
...
This diff is collapsed.
Click to expand it.
Initial_Condition.py
+
11
−
10
View file @
b7f28556
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
projection_utils.py
+
1
−
1
View file @
b7f28556
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment