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
317ab276
Commit
317ab276
authored
Sep 27, 2022
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Renamed 'adjustment' to 'shift'.
parent
2925b235
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
+5
-5
5 additions, 5 deletions
ANN_Data_Generator.py
DG_Approximation.py
+19
-13
19 additions, 13 deletions
DG_Approximation.py
Initial_Condition.py
+4
-4
4 additions, 4 deletions
Initial_Condition.py
Plotting.py
+6
-6
6 additions, 6 deletions
Plotting.py
with
34 additions
and
28 deletions
ANN_Data_Generator.py
+
5
−
5
View file @
317ab276
...
...
@@ -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
adjustmen
t to capture troubled cells
adjustmen
t
=
0
if
initial_condition
.
is_smooth
()
\
# Induce
shif
t to capture troubled cells
shif
t
=
0
if
initial_condition
.
is_smooth
()
\
else
mesh
.
non_ghost_cells
[
stencil_length
//
2
]
if
initial_condition
.
discontinuity_position
==
'
left
'
:
adjustmen
t
-=
mesh
.
cell_len
/
2
shif
t
-=
mesh
.
cell_len
/
2
elif
initial_condition
.
discontinuity_position
==
'
right
'
:
adjustmen
t
+=
mesh
.
cell_len
/
2
shif
t
+=
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
=
adjustmen
t
)
x_shift
=
shif
t
)
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
+
19
−
13
View file @
317ab276
...
...
@@ -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(
adjustmen
t, stencil_length, initial_condition=None)
build_training_data(
x_shif
t, stencil_length, initial_condition=None)
Builds training data set.
"""
...
...
@@ -310,7 +317,7 @@ class DGScheme:
def
do_initial_projection
(
initial_condition
,
mesh
,
basis
,
quadrature
,
adjustmen
t
=
0
):
x_shif
t
=
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
]
-
adjustmen
t
,
mesh
=
mesh
)
*
quadrature
.
nodes
[
point
]
-
x_shif
t
,
mesh
=
mesh
)
*
basis
.
basis
[
degree
].
subs
(
x
,
quadrature
.
nodes
[
point
])
*
quadrature
.
weights
[
point
]
...
...
This diff is collapsed.
Click to expand it.
Initial_Condition.py
+
4
−
4
View file @
317ab276
...
...
@@ -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
-------
...
...
This diff is collapsed.
Click to expand it.
Plotting.py
+
6
−
6
View file @
317ab276
...
...
@@ -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
adjustmen
t
=
-
(
len
(
model_names
)
//
2
)
*
step_len
shif
t
=
-
(
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
+
adjustmen
t
*
width
,
model_eval
,
width
,
label
=
measure
,
ax
.
bar
(
pos
+
shif
t
*
width
,
model_eval
,
width
,
label
=
measure
,
color
=
colors
[
measure
])
adjustmen
t
+=
step_len
shif
t
+=
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
=
[]
adjustmen
t
=
-
(
len
(
model_names
)
//
2
)
*
step_len
shif
t
=
-
(
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
+
adjustmen
t
*
width
,
boxplot
=
ax
.
boxplot
(
model_eval
,
positions
=
pos
+
shif
t
*
width
,
widths
=
width
,
meanline
=
True
,
showmeans
=
True
,
patch_artist
=
True
)
for
patch
in
boxplot
[
'
boxes
'
]:
patch
.
set
(
facecolor
=
colors
[
measure
])
boxplots
.
append
(
boxplot
)
adjustmen
t
+=
step_len
shif
t
+=
step_len
ax
.
set_xticks
(
pos
)
ax
.
set_xticklabels
(
model_names
,
rotation
=
50
,
ha
=
'
right
'
,
...
...
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
sign in
to comment