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
2e17d521
Commit
2e17d521
authored
Oct 5, 2022
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Outsourced run command for SM rule 'approximate_solution' into script.
parent
9b0bacf0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/approximate_solution.py
+39
-0
39 additions, 0 deletions
scripts/approximate_solution.py
workflows/approximation.smk
+10
-23
10 additions, 23 deletions
workflows/approximation.smk
with
49 additions
and
23 deletions
scripts/approximate_solution.py
0 → 100644
+
39
−
0
View file @
2e17d521
# -*- coding: utf-8 -*-
"""
Script to approximate solution with Discontinuous Galerkin.
@author: Laura C. Kühle
"""
import
sys
import
time
from
tcd.DG_Approximation
import
DGScheme
def
main
()
->
None
:
"""
Approximate solution.
"""
with
open
(
str
(
snakemake
.
log
[
0
]),
'
w
'
,
encoding
=
'
utf-8
'
)
as
logfile
:
sys
.
stdout
=
logfile
sys
.
stderr
=
logfile
tic
=
time
.
perf_counter
()
if
len
(
snakemake
.
input
)
>
0
:
snakemake
.
params
[
'
dg_params
'
][
'
detector_config
'
][
'
model_state
'
]
=
\
snakemake
.
input
[
0
]
print
(
snakemake
.
params
[
'
dg_params
'
])
dg_scheme
=
DGScheme
(
**
snakemake
.
params
[
'
dg_params
'
])
dg_scheme
.
approximate
(
data_file
=
snakemake
.
params
[
'
plot_dir
'
]
+
'
/
'
+
snakemake
.
wildcards
[
'
scheme
'
])
toc
=
time
.
perf_counter
()
print
(
f
'
Time:
{
toc
-
tic
:
0.4
f
}
s
'
)
if
__name__
==
'
__main__
'
:
if
"
snakemake
"
in
locals
():
main
()
else
:
print
(
'
Not Defined.
'
)
This diff is collapsed.
Click to expand it.
workflows/approximation.smk
+
10
−
23
View file @
2e17d521
...
@@ -3,21 +3,22 @@ import time
...
@@ -3,21 +3,22 @@ import time
from scripts.tcd import Initial_Condition
from scripts.tcd import Initial_Condition
from scripts.tcd import Quadrature
from scripts.tcd import Quadrature
from scripts.tcd.DG_Approximation import DGScheme
from scripts.tcd.Plotting import plot_approximation_results
from scripts.tcd.Plotting import plot_approximation_results
configfile: 'config.yaml'
configfile: 'config.yaml'
PLOTS = ['error', 'exact_and_approx', 'semilog_error', 'shock_tube']
PLOTS = ['error', 'exact_and_approx', 'semilog_error', 'shock_tube']
DIR = config['data_dir']
DIR = config['data_dir']
SCHEMES = config['schemes']
SCHEMES = config['schemes']
rule all:
rule all:
input:
input:
expand(DIR + '/fig/{plot}/{scheme}.pdf', plot=PLOTS,
expand(DIR + '/fig/{plot}/{scheme}.pdf', plot=PLOTS, scheme=SCHEMES)
scheme=SCHEMES)
default_target: True
default_target: True
def get_ANN_model(wildcards):
def get_ANN_model(wildcards):
if config['schemes'][wildcards.scheme]['detector'] == \
if config['schemes'][wildcards.scheme]['detector'] == \
'ArtificialNeuralNetwork':
'ArtificialNeuralNetwork':
...
@@ -25,6 +26,7 @@ def get_ANN_model(wildcards):
...
@@ -25,6 +26,7 @@ def get_ANN_model(wildcards):
wildcards.scheme]['detector_config']['model_state']
wildcards.scheme]['detector_config']['model_state']
return []
return []
rule approximate_solution:
rule approximate_solution:
input:
input:
get_ANN_model
get_ANN_model
...
@@ -35,24 +37,9 @@ rule approximate_solution:
...
@@ -35,24 +37,9 @@ rule approximate_solution:
plot_dir = DIR + '/fig'
plot_dir = DIR + '/fig'
log:
log:
DIR+'/log/approximate_solution/{scheme}.log'
DIR+'/log/approximate_solution/{scheme}.log'
run:
script:
with open(str(log), 'w') as logfile:
'../scripts/approximate_solution.py'
sys.stdout = logfile
sys.stderr = logfile
tic = time.perf_counter()
if len(input) > 0:
params.dg_params['detector_config']['model_state'] = input
print(params.dg_params)
dg_scheme = DGScheme(**params.dg_params)
dg_scheme.approximate(
data_file=params.plot_dir+'/'+wildcards.scheme)
toc = time.perf_counter()
print(f'Time: {toc - tic:0.4f}s')
rule plot_approximation_results:
rule plot_approximation_results:
input:
input:
...
...
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