-
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.
* Bug is fixed and added new code * new code for the table * Edits in markdown file * some edits in test * Bugs fix * Codecov * I cleaned up my code and separated classes to make it easier to work with. It is not ready yet; if Codecov fails, I will include more tests. * forgot black * flake8 * bug fix * Edits codes according to the comments * Edited codes according to the comments in the GitHub * Defined new function in stability_simulation.py to check stability for given points and excluded codecov function that generates a table. * small edits for codecov * removed no cover
- Loading branch information
1 parent
2d391ff
commit a22818f
Showing
16 changed files
with
1,043 additions
and
927 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
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
67 changes: 0 additions & 67 deletions
67
pySDC/projects/Second_orderSDC/dampedharmonic_oscillator_run_stability.py
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
pySDC/projects/Second_orderSDC/harmonic_oscillator_params.py
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,36 @@ | ||
import numpy as np | ||
from pySDC.implementations.problem_classes.HarmonicOscillator import harmonic_oscillator | ||
from pySDC.implementations.sweeper_classes.boris_2nd_order import boris_2nd_order | ||
|
||
|
||
def get_default_harmonic_oscillator_description(): | ||
""" | ||
Routine to compute modules of the stability function | ||
Returns: | ||
description (dict): A dictionary containing parameters for the damped harmonic oscillator problem | ||
""" | ||
|
||
# Initialize level parameters | ||
level_params = {'restol': 1e-16, 'dt': 1.0} | ||
|
||
# Initialize problem parameters for the Damped harmonic oscillator problem | ||
problem_params = {'k': 0, 'mu': 0, 'u0': np.array([1, 1])} | ||
|
||
# Initialize sweeper parameters | ||
sweeper_params = {'quad_type': 'GAUSS', 'num_nodes': 3, 'do_coll_update': True, 'picard_mats_sweep': True} | ||
|
||
# Initialize step parameters | ||
step_params = {'maxiter': 5} | ||
|
||
# Fill description dictionary for easy step instantiation | ||
description = { | ||
'problem_class': harmonic_oscillator, | ||
'problem_params': problem_params, | ||
'sweeper_class': boris_2nd_order, | ||
'sweeper_params': sweeper_params, | ||
'level_params': level_params, | ||
'step_params': step_params, | ||
} | ||
|
||
return description |
27 changes: 27 additions & 0 deletions
27
pySDC/projects/Second_orderSDC/harmonic_oscillator_run_points.py
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,27 @@ | ||
import numpy as np | ||
from pySDC.projects.Second_orderSDC.harmonic_oscillator_params import get_default_harmonic_oscillator_description | ||
from pySDC.projects.Second_orderSDC.stability_simulation import compute_and_generate_table | ||
|
||
|
||
if __name__ == '__main__': | ||
''' | ||
This script generates table for the given points to compare in what quadrature type, | ||
number of nodes and number of iterations the SDC iteration is stable or not. | ||
Additional parameter: | ||
To save the table set: save_points_table=True | ||
Change filename: points_table_filename='FILENAME' by default: './data/point_table.txt' | ||
''' | ||
# Get default parameters for the harmonic osicillator problem | ||
description = get_default_harmonic_oscillator_description() | ||
# Additonal params to compute stability points | ||
helper_params = { | ||
'quad_type_list': ('GAUSS', 'LOBATTO'), | ||
'Num_iter': (2, 2), | ||
'num_nodes_list': np.arange(3, 6, 1), | ||
'max_iter_list': np.arange(2, 10, 1), | ||
} | ||
|
||
points = ((1, 100), (3, 100), (10, 100)) | ||
# Iterate through points and perform stability check | ||
for ii in points: | ||
compute_and_generate_table(description, helper_params, ii, check_stability_point=True) |
29 changes: 29 additions & 0 deletions
29
pySDC/projects/Second_orderSDC/harmonic_oscillator_run_stab_interval.py
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,29 @@ | ||
import numpy as np | ||
from pySDC.projects.Second_orderSDC.harmonic_oscillator_params import get_default_harmonic_oscillator_description | ||
from pySDC.projects.Second_orderSDC.stability_simulation import compute_and_generate_table | ||
|
||
|
||
if __name__ == '__main__': | ||
''' | ||
To compute maximum stable values for SDC and Picard iterations for the purely oscillatory case with | ||
no damping (mu=0) | ||
Additional parameter: | ||
To save the table set: save_interval_file=True | ||
Change filename: interval_filename='FILENAME' by default: './data/stab_interval.txt' | ||
Output: | ||
it generates to compare with different values of M (number of nodes) and K (maximal number of iterations) | ||
''' | ||
# Ger default parameters | ||
description = get_default_harmonic_oscillator_description() | ||
# Additional parameters to compute stability interval on the kappa | ||
helper_params = { | ||
'quad_type_list': ('GAUSS',), | ||
'Num_iter': (2000, 1), | ||
'num_nodes_list': np.arange(2, 7, 1), | ||
'max_iter_list': np.arange(1, 11, 1), | ||
} | ||
|
||
points = ((100, 1e-10),) | ||
# Iterate through points and perform stability check | ||
for ii in points: | ||
compute_and_generate_table(description, helper_params, ii, compute_interval=True) |
26 changes: 26 additions & 0 deletions
26
pySDC/projects/Second_orderSDC/harmonic_oscillator_run_stability.py
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,26 @@ | ||
from pySDC.projects.Second_orderSDC.harmonic_oscillator_params import get_default_harmonic_oscillator_description | ||
from pySDC.projects.Second_orderSDC.stability_simulation import StabilityImplementation | ||
|
||
|
||
if __name__ == '__main__': | ||
""" | ||
To implement Stability region for the Harmonic Oscillator problem | ||
Run for | ||
SDC stability region: model_stab.run_SDC_stability() | ||
Picard stability region: model_stab.run_Picard_stability() | ||
Runge-Kutta-Nzström stability region: model_run_RKN_stability() | ||
To implement spectral radius of iteration matrix | ||
Run: | ||
Iteration matrix of SDC method: model_stab.run_Ksdc() | ||
Iteration matrix of Picard method: model_stab.run_Kpicard() | ||
""" | ||
# Execute the stability analysis for the damped harmonic oscillator | ||
description = get_default_harmonic_oscillator_description() | ||
model_stab = StabilityImplementation(description, kappa_max=30, mu_max=30, Num_iter=(200, 200)) | ||
|
||
model_stab.run_SDC_stability() | ||
model_stab.run_Picard_stability() | ||
model_stab.run_RKN_stability() | ||
model_stab.run_Ksdc() | ||
# model_stab.run_Kpicard() |
Oops, something went wrong.