Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review #388

Merged
merged 16 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pySDC/projects/Second_orderSDC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ If you utilize it, either in whole or in part, for a publication, please provide

## Reproducing Figures from the Publication

- **Fig. 1:** Execute `dampedharmonic_oscillator_run_stability.py` while setting `kappa_max=18` and `mu_max=18`.
- **Fig. 2:** Run `dampedharmonic_oscillator_run_stability.py` with the following configurations:
- **Fig. 1:** Execute `harmonic_oscillator_run_stability.py` while setting `kappa_max=18` and `mu_max=18`.
- **Fig. 2:** Run `harmonic_oscillator_run_stability.py` with the following configurations:
- Set `kappa_max=30` and `mu_max=30`.
- Adjust `maxiter` to 1, 2, 3, or 4 and execute each individually.
- **Table 1:** Execute `dampedharmonic_socillator_run_stab_interval.py`:
- **Table 1:** Execute `harmonic_socillator_run_stab_interval.py`:
- To save the results set: `save_file=True`

- Use the script `dampedharmonic_oscillator_run_points.py` to create a table based on given $(\kappa, \mu)$ points. This table assists in determining suitable values for `M`, `K`, and `quadrature nodes` to ensure stability in the SDC method.
- Use the script `harmonic_oscillator_run_points.py` to create a table based on given $(\kappa, \mu)$ points. This table assists in determining suitable values for `M`, `K`, and `quadrature nodes` to ensure stability in the SDC method.
- To save the results set: `save_file=True`

- **Fig. 3:** Run `penningtrap_run_error.py` (Run local convergence: `conv.run_local_error()`) with `dt=0.015625/4` and `axes=(0,)`.
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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
from pySDC.projects.Second_orderSDC.penningtrap_Simulation import Stability_implementation


def dampedharmonic_oscillator_params():

def harmonic_oscillator_params():
Copy link
Contributor

@brownbaerchen brownbaerchen Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about a more descriptive function name such as get_default_harmonic_oscillator_description?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

"""
Routine to compute modules of the stability function

Expand Down Expand Up @@ -35,23 +35,3 @@ def dampedharmonic_oscillator_params():
}

return description


if __name__ == '__main__':
"""
Damped harmonic oscillator as a test problem for the stability plot:
x' = v
v' = -kappa * x - mu * v
kappa: spring constant
mu: friction
Source: https://beltoforion.de/en/harmonic_oscillator/
"""
# Execute the stability analysis for the damped harmonic oscillator
description = dampedharmonic_oscillator_params()
Stability = Stability_implementation(description, kappa_max=30, mu_max=30, Num_iter=(200, 200))

Stability.run_SDC_stability()
Stability.run_Picard_stability()
Stability.run_RKN_stability()
Stability.run_Ksdc()
# Stability.run_Kpicard
16 changes: 16 additions & 0 deletions pySDC/projects/Second_orderSDC/harmonic_oscillator_run_points.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import numpy as np
from pySDC.projects.Second_orderSDC.harmonic_oscillator_params import harmonic_oscillator_params
from pySDC.projects.Second_orderSDC.stability_simulation import compute_and_check_stability

if __name__ == '__main__':
# Define lists for the number of nodes and maximum iterations
description=harmonic_oscillator_params()
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)}
description['helper_params']=helper_params
points=((1, 100), (3, 100), (10, 100))
# Iterate through points and perform stability check
for ii in points:
compute_and_check_stability(description, ii, check_stability=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import numpy as np
from pySDC.projects.Second_orderSDC.harmonic_oscillator_params import harmonic_oscillator_params
from pySDC.projects.Second_orderSDC.stability_simulation import compute_and_check_stability

if __name__ == '__main__':
# Define lists for the number of nodes and maximum iterations
description=harmonic_oscillator_params()
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)}
description['helper_params']=helper_params
points=((100, 1e-10),)
# Iterate through points and perform stability check
for ii in points:
compute_and_check_stability(description, ii, compute_interval=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pySDC.projects.Second_orderSDC.harmonic_oscillator_params import harmonic_oscillator_params
from pySDC.projects.Second_orderSDC.stability_simulation import StabilityImplementation


if __name__ == '__main__':
"""
Damped harmonic oscillator as a test problem for the stability plot:
x' = v
v' = -kappa * x - mu * v
kappa: spring constant
mu: friction
Source: https://beltoforion.de/en/harmonic_oscillator/
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this function tell us about the harmonic oscillator? I am not wondering what the harmonic oscillator does, but what this file is about. The documentation of the harmonic oscillator should go into the harmonic oscillator problem class and nowhere else.

# Execute the stability analysis for the damped harmonic oscillator
description = harmonic_oscillator_params()
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
Loading
Loading