pyrc.core.simulation#
- class Parameterization(parameters_tuples: list[tuple], pre_calculation_seconds=36000, initial_settings_dict: dict = <pyrc.core.settings.Settings object>, max_core_number=0, t_span=None)#
Bases:
SimulationClass to handle
RCNetworkcalculations that are quite similar but differ in one settings parameter.All calculations are run in parallel.
- Parameters:
parameters_tuples (list[tuple]) –
Defining the parameters for each simulation: for parameters in parameters_tuples:
network_type: type = parameters[0] settings_dict = parameters[1] network_parameters = parameters[2] t_span = parameters[3] name_add_on = parameters[4]
pre_calculation_seconds (int | float, optional) – How long the static calculation before the dynamic calculation should be.
initial_settings_dict (dict, optional) – The initial settings to use for the calculations. If not given, the initial ones from
core.settingsis used.max_core_number (int, optional) – An optional limit how many cores can be used for the calculations. 0 for no limit.
- __init__(parameters_tuples: list[tuple], pre_calculation_seconds=36000, initial_settings_dict: dict = <pyrc.core.settings.Settings object>, max_core_number=0, t_span=None)#
- Parameters:
parameters_tuples (list[tuple]) –
Defining the parameters for each simulation: for parameters in parameters_tuples:
network_type: type = parameters[0] settings_dict = parameters[1] network_parameters = parameters[2] t_span = parameters[3] name_add_on = parameters[4]
pre_calculation_seconds (int | float, optional) – How long the static calculation before the dynamic calculation should be.
initial_settings_dict (dict, optional) – The initial settings to use for the calculations. If not given, the initial ones from
core.settingsis used.max_core_number (int, optional) – An optional limit how many cores can be used for the calculations. 0 for no limit.
- get_parameters(parameters: tuple)#
Returns the first few parameters for the worker method.
- Parameters:
parameters (tuple) – The tuple out of self.parameters_tuples
- Returns:
The parameters as tuple.
- Return type:
tuple
- pre_create_jacobians()#
Pre-creates the jacobian matrices of all RCNetworks if not already found in pickle file.
This is useful to quickly generate all jacobian matrices outside the workers so that they only need to load the matrices and lambdify them.
- run()#
Run the simulation including pre-simulation with the passed network type.
- Parameters:
network_class (type(RCNetwork)) – The RCNetwork that is created for the simulation.
network_keyword_arguments (dict[str, Any]) – The keyword arguments for the RCNetwork object that is created.
t_span (tuple) – The t_span for the simulation: (start, end) in seconds. It should start at 0 (otherwise it can work but it’s not tested).
name_add_on (str, optional) – An add-on for the name to identify the name to the worker. If None, a random five digits integer is used (with leading zeros).
settings (Settings, optional) – The settings for the network and simulation. If None, the initial settings dict from the network is used.
pre_calculation_settings (Settings, optional) – The settings for the pre-calculation. Should only vary in the weather data start date. If None, the initial settings dict from the network is used, but with static calculation.
print_progress (bool, optional) – Whether to print some progress information during the simulation.
- class Simulation(network_class: type = None, network_keyword_arguments: dict[str, Any] = None, pre_calculation_seconds: int | float = 36000, t_span: tuple = None, name_add_on: str = None, settings: Settings = None, pre_calculation_settings: Settings = None, print_progress: bool = True, time_dependent_function: Callable | Any = None)#
Bases:
objectHandle one RC network simulation including pre-simulation.
The pre-simulation determines correct initial values for the network by calculating a time range before the real simulation. The pre-simulation can be done with varying weather data or just static simulation of the initial boundary conditions of the network. But because of the time dependent values of all capacities it is recommended to use the option with varying (realistic) boundary data.
The pre-simulation is saved as single initial values that can be loaded in. It is executed only once and then loaded in from file.
- run(network_class: type = None, network_keyword_arguments: dict[str, Any] = None, t_span: tuple = None, name_add_on: str = None, settings: Settings = None, pre_calculation_settings: Settings = None, print_progress: bool = None, time_dependent_function: Callable | Any = None)#
Run the simulation including pre-simulation with the passed network type.
- Parameters:
network_class (type(RCNetwork)) – The RCNetwork that is created for the simulation.
network_keyword_arguments (dict[str, Any]) – The keyword arguments for the RCNetwork object that is created.
t_span (tuple) – The t_span for the simulation: (start, end) in seconds. It should start at 0 (otherwise it can work but it’s not tested).
name_add_on (str, optional) – An add-on for the name to identify the name to the worker. If None, a random five digits integer is used (with leading zeros).
settings (Settings, optional) – The settings for the network and simulation. If None, the initial settings dict from the network is used.
pre_calculation_settings (Settings, optional) – The settings for the pre-calculation. Should only vary in the weather data start date. If None, the initial settings dict from the network is used, but with static calculation.
print_progress (bool, optional) – Whether to print some progress information during the simulation.