Coverage for pySDC/helpers/setup_helper.py: 100%
19 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
1def generate_description(problem_class, **kwargs):
2 """
3 Generate a description object that you can use to run pySDC based on a problem class and various input.
4 This function does not set any additional defaults, but distributes the values to where they belong.
6 Args:
7 problem_class (pySDC.Problem): A problem class
9 Returns:
10 dict: A description object for running pySDC
11 """
12 from pySDC.core.level import _Pars as level_params
13 from pySDC.core.step import _Pars as step_params
15 description = {
16 'level_params': {},
17 'problem_params': {},
18 'sweeper_params': {},
19 'problem_class': problem_class,
20 'step_params': {},
21 'sweeper_class': kwargs.get('sweeper_class', problem_class.get_default_sweeper_class()),
22 'convergence_controllers': {},
23 }
25 problem_keys = problem_class.__init__.__code__.co_varnames
26 level_keys = level_params({}).__dict__.keys()
27 sweeper_keys = description['sweeper_class']({'num_nodes': 1, 'quad_type': 'RADAU-RIGHT'}).params.__dict__.keys()
28 step_keys = step_params({}).__dict__.keys()
30 # TODO: add convergence controllers
31 for key, val in kwargs.items():
32 if key in problem_keys:
33 description['problem_params'][key] = val
34 elif key in level_keys:
35 description['level_params'][key] = val
36 elif key in sweeper_keys:
37 description['sweeper_params'][key] = val
38 elif key in step_keys:
39 description['step_params'][key] = val
40 elif key == 'sweeper_class':
41 pass
42 else:
43 raise ValueError(f'Don\'t know what parameter \"{key}\" is for!')
45 return description