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
ed40ed3f
Commit
ed40ed3f
authored
3 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Removed use of 'DGScheme' from ANN data generation.
parent
97f6c885
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ANN_Data_Generator.py
+22
-9
22 additions, 9 deletions
ANN_Data_Generator.py
DG_Approximation.py
+6
-41
6 additions, 41 deletions
DG_Approximation.py
config.yaml
+3
-3
3 additions, 3 deletions
config.yaml
with
31 additions
and
53 deletions
ANN_Data_Generator.py
+
22
−
9
View file @
ed40ed3f
...
...
@@ -7,7 +7,14 @@ import os
import
time
import
numpy
as
np
import
DG_Approximation
from
DG_Approximation
import
do_initial_projection
from
projection_utils
import
Mesh
from
Quadrature
import
Gauss
from
Basis_Function
import
OrthonormalLegendre
basis_list
=
[
OrthonormalLegendre
(
pol_deg
)
for
pol_deg
in
range
(
5
)]
quadrature_list
=
[
Gauss
({
'
num_nodes
'
:
pol_deg
+
1
})
for
pol_deg
in
range
(
5
)]
class
TrainingDataGenerator
:
...
...
@@ -204,14 +211,20 @@ class TrainingDataGenerator:
# Calculate basis coefficients for stencil
polynomial_degree
=
np
.
random
.
randint
(
1
,
high
=
5
)
dg_scheme
=
DG_Approximation
.
DGScheme
(
'
NoDetection
'
,
polynomial_degree
=
polynomial_degree
,
num_grid_cells
=
self
.
_stencil_length
,
left_bound
=
left_bound
,
right_bound
=
right_bound
,
quadrature
=
'
Gauss
'
,
quadrature_config
=
{
'
num_eval_points
'
:
polynomial_degree
+
1
})
input_data
[
i
]
=
dg_scheme
.
build_training_data
(
adjustment
,
self
.
_stencil_length
,
self
.
_add_reconstructions
,
initial_condition
)
basis
=
basis_list
[
polynomial_degree
]
mesh
=
Mesh
(
num_grid_cells
=
self
.
_stencil_length
,
num_ghost_cells
=
2
,
left_bound
=
left_bound
,
right_bound
=
right_bound
)
projection
=
do_initial_projection
(
initial_condition
=
initial_condition
,
mesh
=
mesh
,
basis
=
basis
,
quadrature
=
quadrature_list
[
polynomial_degree
],
adjustment
=
adjustment
)
input_data
[
i
]
=
basis
.
calculate_cell_average
(
projection
=
projection
[:,
1
:
-
1
],
stencil_length
=
self
.
_stencil_length
,
add_reconstructions
=
self
.
_add_reconstructions
)
count
+=
1
if
count
%
1000
==
0
:
...
...
This diff is collapsed.
Click to expand it.
DG_Approximation.py
+
6
−
41
View file @
ed40ed3f
...
...
@@ -16,8 +16,10 @@ TODO: Ask whether all quadratures depend on freely chosen num_nodes
Urgent:
TODO: Replace getter with property attributes for quadrature -> Done
TODO: Rename eval_points in Quadrature to nodes -> Done
TODO: Improve docstring for quadrature
TODO: Remove use of DGScheme from ANN_Data_Generator
TODO: Improve docstring for quadrature -> Done
TODO: Ensure repeatable output through seeds and deterministic models -> Done
TODO: Remove use of DGScheme from ANN_Data_Generator -> Done
TODO: Remove unnecessary instance variables from TrainingDataGenerator
TODO: Find error in centering for ANN training
TODO: Adapt TCD from Soraya
(Dropbox->...->TEST_troubled-cell-detector->Troubled_Cell_Detector)
...
...
@@ -178,8 +180,8 @@ class DGScheme:
left_bound
=
kwargs
.
pop
(
'
left_bound
'
,
-
1
),
right_bound
=
kwargs
.
pop
(
'
right_bound
'
,
1
),
num_ghost_cells
=
2
)
print
(
len
(
self
.
_mesh
.
cells
))
print
(
type
(
self
.
_mesh
.
cells
))
#
print(len(self._mesh.cells))
#
print(type(self._mesh.cells))
# Throw an error if there are extra keyword arguments
if
len
(
kwargs
)
>
0
:
...
...
@@ -284,43 +286,6 @@ class DGScheme:
# Set additional necessary config parameters
self
.
_limiter_config
[
'
cell_len
'
]
=
self
.
_mesh
.
cell_len
def
build_training_data
(
self
,
adjustment
,
stencil_length
,
add_reconstructions
,
initial_condition
=
None
):
"""
Builds training data set.
Initializes projection and calculates cell averages and
reconstructions for it.
Parameters
----------
adjustment : float
Extent of adjustment of each evaluation point in x-direction.
stencil_length : int
Size of training data array.
add_reconstructions: bool
Flag whether reconstructions of the middle cell are included.
initial_condition : InitialCondition object, optional
Initial condition used for calculation.
Default: None (i.e. instance variable).
Returns
-------
ndarray
Matrix containing cell averages and reconstructions for initial
projection.
"""
if
initial_condition
is
None
:
initial_condition
=
self
.
_init_cond
projection
=
do_initial_projection
(
initial_condition
=
initial_condition
,
mesh
=
self
.
_mesh
,
basis
=
self
.
_basis
,
quadrature
=
self
.
_quadrature
,
adjustment
=
adjustment
)
return
self
.
_basis
.
calculate_cell_average
(
projection
=
projection
[:,
1
:
-
1
],
stencil_length
=
stencil_length
,
add_reconstructions
=
add_reconstructions
)
def
do_initial_projection
(
initial_condition
,
mesh
,
basis
,
quadrature
,
adjustment
=
0
):
...
...
This diff is collapsed.
Click to expand it.
config.yaml
+
3
−
3
View file @
ed40ed3f
data_dir
:
'
model-
Mar14
'
data_dir
:
'
model-
Jun03
'
random_seed
:
1234
# Parameter for Approximation with Troubled Cell Detection
Approximation
:
plot_dir
:
'
fig-
Mar14
'
plot_dir
:
'
fig-
Jun03
'
schemes
:
Separation_Test
:
...
...
@@ -36,7 +36,7 @@ Approximation:
quadrature
:
'
Gauss'
quadrature_config
:
num_
eval_point
s
:
12
num_
node
s
:
12
update_scheme
:
'
SSPRK3'
Test_Run
:
...
...
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