Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pySDC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
atml-ati
pySDC
Commits
9808c30c
Unverified
Commit
9808c30c
authored
11 months ago
by
Lisa Wimmer
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Added integrate method with adaption of tests (#460)
parent
eab6284f
No related branches found
No related tags found
No related merge requests found
Pipeline
#203412
passed
11 months ago
Stage: benchmark
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pySDC/projects/DAE/sweepers/RungeKuttaDAE.py
+29
-4
29 additions, 4 deletions
pySDC/projects/DAE/sweepers/RungeKuttaDAE.py
pySDC/projects/DAE/tests/test_RungeKuttaDAE.py
+6
-6
6 additions, 6 deletions
pySDC/projects/DAE/tests/test_RungeKuttaDAE.py
with
35 additions
and
10 deletions
pySDC/projects/DAE/sweepers/RungeKuttaDAE.py
+
29
−
4
View file @
9808c30c
...
@@ -102,6 +102,31 @@ class RungeKuttaDAE(RungeKutta):
...
@@ -102,6 +102,31 @@ class RungeKuttaDAE(RungeKutta):
lvl
.
status
.
unlocked
=
True
lvl
.
status
.
unlocked
=
True
lvl
.
status
.
updated
=
True
lvl
.
status
.
updated
=
True
def
integrate
(
self
):
r
"""
Returns the solution by integrating its gradient (fundamental theorem of calculus) at each collocation node.
``level.f`` stores the gradient of solution ``level.u``.
Returns
-------
me : list of lists
Integral of the gradient at each collocation node.
"""
# get current level and problem
lvl
=
self
.
level
prob
=
lvl
.
prob
# integrate RHS over all collocation nodes
me
=
[]
for
m
in
range
(
1
,
self
.
coll
.
num_nodes
+
1
):
# new instance of dtype_u, initialize values with 0
me
.
append
(
prob
.
dtype_u
(
prob
.
init
,
val
=
0.0
))
for
j
in
range
(
1
,
self
.
coll
.
num_nodes
+
1
):
me
[
-
1
]
+=
lvl
.
dt
*
self
.
coll
.
Qmat
[
m
,
j
]
*
lvl
.
f
[
j
]
return
me
def
update_nodes
(
self
):
def
update_nodes
(
self
):
r
"""
r
"""
Updates the values of solution ``u`` and their gradient stored in ``f``.
Updates the values of solution ``u`` and their gradient stored in ``f``.
...
@@ -130,10 +155,10 @@ class RungeKuttaDAE(RungeKutta):
...
@@ -130,10 +155,10 @@ class RungeKuttaDAE(RungeKutta):
lvl
.
time
+
lvl
.
dt
*
self
.
coll
.
nodes
[
m
+
1
],
lvl
.
time
+
lvl
.
dt
*
self
.
coll
.
nodes
[
m
+
1
],
)
)
# Update numerical solution
- update value only at last node
# Update numerical solution
lvl
.
u
[
-
1
][:]
=
lvl
.
u
[
0
]
integral
=
self
.
integrate
()
for
j
in
range
(
1
,
M
+
1
):
for
m
in
range
(
M
):
lvl
.
u
[
-
1
][:]
+
=
lvl
.
dt
*
self
.
coll
.
Qmat
[
-
1
,
j
]
*
lvl
.
f
[
j
][:]
lvl
.
u
[
m
+
1
][:]
=
lvl
.
u
[
0
][:]
+
integral
[
m
][:]
self
.
du_init
=
prob
.
dtype_f
(
lvl
.
f
[
-
1
])
self
.
du_init
=
prob
.
dtype_f
(
lvl
.
f
[
-
1
])
...
...
This diff is collapsed.
Click to expand it.
pySDC/projects/DAE/tests/test_RungeKuttaDAE.py
+
6
−
6
View file @
9808c30c
...
@@ -153,10 +153,10 @@ def testOrderAccuracySemiExplicitIndexOne(sweeper_name):
...
@@ -153,10 +153,10 @@ def testOrderAccuracySemiExplicitIndexOne(sweeper_name):
assert
np
.
isclose
(
assert
np
.
isclose
(
orderDiff
,
expectedOrderDiff
[
sweeper_name
],
atol
=
1e0
orderDiff
,
expectedOrderDiff
[
sweeper_name
],
atol
=
1e0
),
f
"
Expected order
{
expectedOrderDiff
[
sweeper_name
]
}
in differential variable, got
{
orderDiff
}
"
),
f
"
SE index-1 case:
Expected order
{
expectedOrderDiff
[
sweeper_name
]
}
in differential variable
for
{
sweeper_name
}
, got
{
orderDiff
}
"
assert
np
.
isclose
(
assert
np
.
isclose
(
orderAlg
,
expectedOrderAlg
[
sweeper_name
],
atol
=
1e0
orderAlg
,
expectedOrderAlg
[
sweeper_name
],
atol
=
1e0
),
f
"
Expected order
{
expectedOrderAlg
[
sweeper_name
]
}
in algebraic variable, got
{
orderAlg
}
"
),
f
"
SE index-1 case:
Expected order
{
expectedOrderAlg
[
sweeper_name
]
}
in algebraic variable
for
{
sweeper_name
}
, got
{
orderAlg
}
"
@pytest.mark.base
@pytest.mark.base
...
@@ -238,10 +238,10 @@ def testOrderAccuracySemiExplicitIndexTwo(sweeper_name):
...
@@ -238,10 +238,10 @@ def testOrderAccuracySemiExplicitIndexTwo(sweeper_name):
assert
np
.
isclose
(
assert
np
.
isclose
(
orderDiff
,
expectedOrderDiff
[
sweeper_name
],
atol
=
1e0
orderDiff
,
expectedOrderDiff
[
sweeper_name
],
atol
=
1e0
),
f
"
Expected order
{
expectedOrderDiff
[
sweeper_name
]
}
in differential variable, got
{
orderDiff
}
"
),
f
"
SE index-2 case:
Expected order
{
expectedOrderDiff
[
sweeper_name
]
}
in differential variable
for
{
sweeper_name
}
, got
{
orderDiff
}
"
assert
np
.
isclose
(
assert
np
.
isclose
(
orderAlg
,
expectedOrderAlg
[
sweeper_name
],
atol
=
1e0
orderAlg
,
expectedOrderAlg
[
sweeper_name
],
atol
=
1e0
),
f
"
Expected order
{
expectedOrderAlg
[
sweeper_name
]
}
in algebraic variable, got
{
orderAlg
}
"
),
f
"
SE index-2 case:
Expected order
{
expectedOrderAlg
[
sweeper_name
]
}
in algebraic variable
for
{
sweeper_name
}
, got
{
orderAlg
}
"
@pytest.mark.base
@pytest.mark.base
...
@@ -281,7 +281,7 @@ def testOrderAccuracyFullyImplicitIndexTwo(sweeper_name):
...
@@ -281,7 +281,7 @@ def testOrderAccuracyFullyImplicitIndexTwo(sweeper_name):
level_params
=
description
[
'
level_params
'
]
level_params
=
description
[
'
level_params
'
]
t0
,
Tend
=
0.0
,
2.0
t0
,
Tend
=
0.0
,
2.0
dt_list
=
np
.
logspace
(
-
1.7
,
-
1.0
,
num
=
7
)
dt_list
=
dt_list
=
np
.
logspace
(
-
2.5
,
-
1.0
,
num
=
7
)
errors
=
np
.
zeros
(
len
(
dt_list
))
errors
=
np
.
zeros
(
len
(
dt_list
))
for
i
,
dt
in
enumerate
(
dt_list
):
for
i
,
dt
in
enumerate
(
dt_list
):
...
@@ -302,4 +302,4 @@ def testOrderAccuracyFullyImplicitIndexTwo(sweeper_name):
...
@@ -302,4 +302,4 @@ def testOrderAccuracyFullyImplicitIndexTwo(sweeper_name):
assert
np
.
isclose
(
assert
np
.
isclose
(
order
,
expectedOrder
[
sweeper_name
],
atol
=
1e0
order
,
expectedOrder
[
sweeper_name
],
atol
=
1e0
),
f
"
Expected order
{
expectedOrder
[
sweeper_name
]
}
in differential variable, got
{
order
}
"
),
f
"
FI index-2 case:
Expected order
{
expectedOrder
[
sweeper_name
]
}
in differential variable
for
{
sweeper_name
}
, got
{
order
}
"
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