-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added DAE mesh * Updated all DAE problems and the SDC-DAE sweeper * Updated playgrounds with new DAE datatype * Adapted tests * Minor changes * Black.. :o * Added DAEMesh only to semi-explicit DAEs + update for FI-SDC and ProblemDAE.py * Black :D * Removed unnecessary approx_solution hook + replaced by LogSolution hook * Update WSCC9 problem class * Removed unnecessary comments * Removed test_misc.py * Removed registering of newton_tol from child classes * Update test_problems.py * Rename error hook class for logging global error in differential variable(s) * Added MultiComponentMesh - @brownbaerchen + @tlunet + @pancetta Thank ugit add pySDC/implementations/datatype_classes/MultiComponentMesh.py * Updated stuff with new version of DAE data type * (Hopefully) faster test for WSCC9 * Test for DAEMesh * Renaming * ..for DAEMesh.py * Bug fix * Another bug fix.. * Preparation for PDAE stuff (?) * Changes + adapted first test for PDAE stuff * Commented out test_WSCC9_SDC_detection() - too long runtime * Minor changes for test_DAEMesh.py * Extended test for DAEMesh - credits for @brownbaerchen * Test for HookClass_DAE.py * Update for DAEMesh + tests * 🎉 - speed up test a bit (at least locally..) * Forgot to enable other tests again * Removed if-else-statements for mesh type * View for unknowns in implSysFlatten
- Loading branch information
Showing
18 changed files
with
471 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from pySDC.implementations.datatype_classes.mesh import MultiComponentMesh | ||
|
||
|
||
class DAEMesh(MultiComponentMesh): | ||
r""" | ||
Datatype for DAE problems. The solution of the problem can be splitted in the differential part | ||
and in an algebraic part. | ||
This data type can be used for the solution of the problem itself as well as for its derivative. | ||
""" | ||
|
||
components = ['diff', 'alg'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,82 @@ | ||
from pySDC.core.Hooks import hooks | ||
|
||
|
||
class approx_solution_hook(hooks): | ||
class LogGlobalErrorPostStepDifferentialVariable(hooks): | ||
""" | ||
Hook class to add the approximate solution to the output generated by the sweeper after each time step | ||
Hook class to log the error to the output generated by the sweeper after | ||
each time step. | ||
""" | ||
|
||
def __init__(self): | ||
""" | ||
Initialization routine for the custom hook | ||
""" | ||
super(approx_solution_hook, self).__init__() | ||
|
||
def post_step(self, step, level_number): | ||
""" | ||
Default routine called after each step | ||
Args: | ||
step: the current step | ||
level_number: the current level number | ||
r""" | ||
Default routine called after each step. | ||
Parameters | ||
---------- | ||
step : pySDC.core.Step | ||
Current step. | ||
level_number : pySDC.core.level | ||
Current level number. | ||
""" | ||
|
||
super(approx_solution_hook, self).post_step(step, level_number) | ||
super().post_step(step, level_number) | ||
|
||
# some abbreviations | ||
L = step.levels[level_number] | ||
P = L.prob | ||
|
||
# TODO: is it really necessary to recompute the end point? Hasn't this been done already? | ||
L.sweep.compute_end_point() | ||
|
||
# compute and save errors | ||
# Note that the component from which the error is measured is specified here | ||
upde = P.u_exact(step.time + step.dt) | ||
e_global_differential = abs(upde.diff - L.uend.diff) | ||
|
||
self.add_to_stats( | ||
process=step.status.slot, | ||
time=L.time + L.dt, | ||
level=L.level_index, | ||
iter=step.status.iter, | ||
sweep=L.status.sweep, | ||
type='approx_solution', | ||
value=L.uend, | ||
type='e_global_differential_post_step', | ||
value=e_global_differential, | ||
) | ||
|
||
|
||
class error_hook(hooks): | ||
class LogGlobalErrorPostStepAlgebraicVariable(hooks): | ||
""" | ||
Hook class to add the approximate solution to the output generated by the sweeper after each time step | ||
Logs the global error in the algebraic variable | ||
""" | ||
|
||
def __init__(self): | ||
""" | ||
Initialization routine for the custom hook | ||
""" | ||
super(error_hook, self).__init__() | ||
|
||
def post_step(self, step, level_number): | ||
""" | ||
Default routine called after each step | ||
Args: | ||
step: the current step | ||
level_number: the current level number | ||
r""" | ||
Default routine called after each step. | ||
Parameters | ||
---------- | ||
step : pySDC.core.Step | ||
Current step. | ||
level_number : pySDC.core.level | ||
Current level number. | ||
""" | ||
|
||
super(error_hook, self).post_step(step, level_number) | ||
super().post_step(step, level_number) | ||
|
||
# some abbreviations | ||
L = step.levels[level_number] | ||
P = L.prob | ||
|
||
# TODO: is it really necessary to recompute the end point? Hasn't this been done already? | ||
L.sweep.compute_end_point() | ||
|
||
# compute and save errors | ||
# Note that the component from which the error is measured is specified here | ||
upde = P.u_exact(step.time + step.dt) | ||
err = abs(upde[0] - L.uend[0]) | ||
# err = abs(upde[4] - L.uend[4]) | ||
e_global_algebraic = abs(upde.alg - L.uend.alg) | ||
|
||
self.add_to_stats( | ||
process=step.status.slot, | ||
time=L.time + L.dt, | ||
level=L.level_index, | ||
iter=step.status.iter, | ||
sweep=L.status.sweep, | ||
type='error_post_step', | ||
value=err, | ||
type='e_global_algebraic_post_step', | ||
value=e_global_algebraic, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.