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
be18f1be
You need to sign in or sign up before continuing.
Commit
be18f1be
authored
Jan 19, 2022
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Generalize output for 'approximate_solution' rule.
parent
91c37f00
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
DG_Approximation.py
+2
-8
2 additions, 8 deletions
DG_Approximation.py
Snakefile
+8
-28
8 additions, 28 deletions
Snakefile
config.yaml
+2
-1
2 additions, 1 deletion
config.yaml
with
12 additions
and
37 deletions
DG_Approximation.py
+
2
−
8
View file @
be18f1be
...
...
@@ -206,19 +206,13 @@ class DGScheme(object):
# Plot exact/approximate results, errors, shock tubes and any detector-dependant plots
self
.
_detector
.
plot_results
(
projection
,
troubled_cell_history
,
time_history
)
def
save_plots
(
self
):
def
save_plots
(
self
,
plot_name
):
"""
Saves plotted results.
Sets plot directory, if not already existing, and saves plots generated during the last
approximation.
"""
name
=
self
.
_init_cond
.
get_name
()
+
'
__
'
+
self
.
_detector
.
get_name
()
+
'
__
'
\
+
self
.
_limiter
.
get_name
()
+
'
__
'
+
self
.
_update_scheme
.
get_name
()
+
'
__
'
\
+
self
.
_quadrature
.
get_name
()
+
'
__final_time_
'
+
str
(
self
.
_final_time
)
\
+
'
__wave_speed_
'
+
str
(
self
.
_wave_speed
)
+
'
__number_of_cells_
'
\
+
str
(
self
.
_num_grid_cells
)
+
'
__polynomial_degree_
'
+
str
(
self
.
_polynomial_degree
)
# Set paths for plot files if not existing already
if
not
os
.
path
.
exists
(
self
.
_plot_dir
):
os
.
makedirs
(
self
.
_plot_dir
)
...
...
@@ -230,7 +224,7 @@ class DGScheme(object):
os
.
makedirs
(
self
.
_plot_dir
+
'
/
'
+
identifier
)
plt
.
figure
(
identifier
)
plt
.
savefig
(
self
.
_plot_dir
+
'
/
'
+
identifier
+
'
/
'
+
name
+
'
.pdf
'
)
plt
.
savefig
(
self
.
_plot_dir
+
'
/
'
+
identifier
+
'
/
'
+
plot_
name
+
'
.pdf
'
)
def
_reset
(
self
):
"""
Resets instance variables.
"""
...
...
This diff is collapsed.
Click to expand it.
Snakefile
+
8
−
28
View file @
be18f1be
...
...
@@ -8,6 +8,7 @@ import numpy as np
configfile: 'config.yaml'
PLOTS = ['error', 'exact_and_approx', 'semilog_error', 'shock_tube']
DIR = config['data_directory']
MODELS = config['models']
if config['random_seed'] is not None:
...
...
@@ -17,38 +18,18 @@ rule all:
input:
expand(DIR+'/trained models/model__{model}.pt', model=MODELS),
DIR+'/model evaluation/classification_accuracy/' + '_'.join(MODELS.keys()) + '.pdf',
config['dg_parameter']['plot_dir'] + '/error/' + 'Sine__ArtificialNeuralNetwork__' +
'ModifiedMinMod0__SSPRK3__Gauss12__final_time_1__wave_speed_1__' +
'number_of_cells_32__polynomial_degree_2.pdf'
expand(config['plot_dir'] + '/{plot}/' + config['plot_name'] + '.pdf', plot=PLOTS)
rule approximate_solution:
input:
config['dg_parameter']['detector_config']['model_state']
if config['dg_parameter']['detector'] == 'ArtificialNeuralNetwork' else ''
output:
error=config['dg_parameter']['plot_dir'] + '/error/' + 'Sine__ArtificialNeuralNetwork__' +
'ModifiedMinMod0__SSPRK3__Gauss12__final_time_1__wave_speed_1__' +
'number_of_cells_32__polynomial_degree_2.pdf'
expand(config['plot_dir'] + '/{plot}/' + config['plot_name'] + '.pdf', plot=PLOTS)
params:
# plot_dir=config['plot_dir'],
# wave_speed=config['wave_speed'],
# polynomial_degree=config['polynomial_degree'],
# cfl_number=config['cfl_number'],
# num_grid_cells=config['num_grid_cells'],
# final_time=config['final_time'],
# left_bound=config['left_bound'],
# right_bound=config['right_bound'],
# verbose=config['verbose'],
# detector=config['detector'],
# detector_config=config['detector_config'],
# init_cond=config['init_cond'],
# init_config=config['init_config'],
# limiter=config['limiter'],
# limiter_config=config['limiter_config'],
# quadrature=config['quadrature'],
# quadrature_config=config['quadrature_config'],
# update_scheme=config['update_scheme']
dg_params=config['dg_parameter']
dg_params=config['dg_parameter'],
plot_dir=config['plot_dir'],
plot_name=config['plot_name']
log:
DIR+'/log/approximate_solution.log'
run:
...
...
@@ -56,11 +37,10 @@ rule approximate_solution:
tic = timeit.default_timer()
print(params.dg_params)
# dg_scheme = DGScheme(**params)
dg_scheme = DGScheme(**params.dg_params)
dg_scheme = DGScheme(plot_dir=params.plot_dir, **params.dg_params)
dg_scheme.approximate()
dg_scheme.save_plots()
dg_scheme.save_plots(
params.plot_name
)
toc = timeit.default_timer()
print('Time:',toc-tic)
...
...
This diff is collapsed.
Click to expand it.
config.yaml
+
2
−
1
View file @
be18f1be
...
...
@@ -2,8 +2,9 @@ data_directory: "Snakemake-Test"
random_seed
:
1234
# Parameter for Approximation with Troubled Cell Detection
dg_parameter
:
plot_name
:
'
DG_Test'
plot_dir
:
'
testing'
dg_parameter
:
wave_speed
:
1
polynomial_degree
:
2
cfl_number
:
0.2
...
...
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