Coverage for pySDC/projects/RDC/vanderpol_reference.py: 0%
35 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
1import numpy as np
4from pySDC.implementations.controller_classes.controller_nonMPI import controller_nonMPI
5from pySDC.implementations.problem_classes.Van_der_Pol_implicit import vanderpol
6from pySDC.implementations.sweeper_classes.generic_implicit import generic_implicit
9def main():
10 """
11 Van der Pol's oscillator reference solution
12 """
14 # set time parameters
15 t0 = 0.0
16 Tend = 10.0
18 # initialize level parameters
19 level_params = dict()
20 level_params['restol'] = 1e-12
21 level_params['dt'] = (Tend - t0) / 2000.0
23 # initialize sweeper parameters
24 sweeper_params = dict()
25 sweeper_params['quad_type'] = 'RADAU-RIGHT'
26 sweeper_params['num_nodes'] = 5
27 sweeper_params['QI'] = 'IE'
29 # initialize problem parameters
30 problem_params = dict()
31 problem_params['newton_tol'] = 1e-14
32 problem_params['newton_maxiter'] = 50
33 problem_params['mu'] = 10
34 problem_params['u0'] = (2.0, 0)
36 # initialize step parameters
37 step_params = dict()
38 step_params['maxiter'] = 50
40 # initialize controller parameters
41 controller_params = dict()
42 controller_params['logger_level'] = 20
44 # Fill description dictionary for easy hierarchy creation
45 description = dict()
46 description['problem_class'] = vanderpol
47 description['problem_params'] = problem_params
48 description['sweeper_class'] = generic_implicit
49 description['sweeper_params'] = sweeper_params
50 description['level_params'] = level_params
51 description['step_params'] = step_params
53 # instantiate the controller
54 controller_ref = controller_nonMPI(num_procs=1, controller_params=controller_params, description=description)
56 # get initial values on finest level
57 P = controller_ref.MS[0].levels[0].prob
58 uinit = P.u_exact(t0)
60 uend_ref, stats_ref = controller_ref.run(u0=uinit, t0=t0, Tend=Tend)
62 np.save('data/vdp_ref.npy', uend_ref)
65if __name__ == "__main__":
66 main()