bout_runners.parameters.default_parameters¶
Contains the class dealing with the default parameters.
Classes
|
Class which deals with the default parameters. |
-
class
bout_runners.parameters.default_parameters.
DefaultParameters
(bout_paths: Optional[bout_runners.parameters.bout_paths.BoutPaths] = None, settings_path: Optional[pathlib.Path] = None)[source]¶ Class which deals with the default parameters.
The default parameters are those set internally in BOUT++, or in the specified BOUT.inp file
Examples
The easiest way to use DefaultParameters is to run a script from the root directory of the project (i.e. where the Makefile and data directory are normally situated. The script can simply call
>>> DefaultParameters().get_default_parameters() {'global': {'append': False, 'async_send': False, ...}}
A more elaborate example where all the dependency objects are built manually:
Import dependencies
>>> from pathlib import Path >>> from bout_runners.executor.bout_paths import BoutPaths
Create the bout_paths object
>>> project_path = Path().joinpath('path', 'to', 'project') >>> bout_inp_src_dir = Path().joinpath('path', 'to', 'source', 'BOUT.inp') >>> bout_inp_dst_dir = Path().joinpath('path', 'to', 'destination', 'BOUT.inp') >>> bout_paths = BoutPaths(project_path=project_path, ... bout_inp_src_dir=bout_inp_src_dir, ... bout_inp_dst_dir=bout_inp_dst_dir)
Get the default parameters
>>> default_parameter = DefaultParameters(bout_paths=bout_paths) >>> default_parameter.get_default_parameters() {'global': {'append': False, 'async_send': False, ...}}
- Attributes
- self.__bout_pathsBoutPaths
Object for the BOUT++ paths
- self.__settings_pathNone or Path
Path to the BOUT.settings file
Methods
run_parameters_run()
Execute a run to obtain the default parameters.
get_default_parameters()
Return the default parameters from the settings file.
Set the member data.
If the settings_path is None, the constructor will call run_parameters_run to create a settings_path
- Parameters
- bout_pathsBoutPaths or None
Object containing the paths of the project Will only be used in the run_parameters_run call if the settings_path is not valid
- settings_pathNone or Path
Path to the up-to-date settings_path Will invoke run_parameters_run if set to None
Warning
There can be a potential mismatch between a user provided settings_path and the actual default values. This can occur if the user has updated BOUT.inp without updating the BOUT.settings file. It is therefore recommended to set settings_path to None unless the user is sure the BOUT.settings file pointed to by settings_path is up to date
Methods
Return the default parameters from the settings file.
get_test_executor
(bout_paths)Return the executor used for test (i.e.
run_parameters_run
(bout_paths)Execute a run to obtain the default parameters.
-
get_default_parameters
() → Dict[str, Dict[str, Union[int, float, bool, str]]][source]¶ Return the default parameters from the settings file.
- Returns
- default_parameters_dictdict
Dictionary containing the parameters given in BOUT.settings On the form
>>> {'section': {'parameter': 'value'}}
Notes
The section-less part of BOUT.settings will be renamed global
In the global section, the keys d and the directory to the BOUT.inp file will be removed
If the section all is present in BOUT.settings, the section will be renamed all_boundaries as all is a protected SQL keyword
The section run will be dropped due to bout_runners own run table
The string values will be stored using lowercase
-
static
get_test_executor
(bout_paths: bout_runners.parameters.bout_paths.BoutPaths) → bout_runners.runner.bout_run_executor.BoutRunExecutor[source]¶ Return the executor used for test (i.e. where nout=0).
- Parameters
- bout_pathsBoutPaths
Object containing the BOUT++ paths
- Returns
- executorBoutRunExecutor
Executor instantiated with the test set up
-
run_parameters_run
(bout_paths: Optional[bout_runners.parameters.bout_paths.BoutPaths]) → None[source]¶ Execute a run to obtain the default parameters.
A settings run executes the executable of the project with nout = 0 in order to capture all parameters used in the project
- Parameters
- bout_pathsBoutPaths
Object containing the paths of the project