Mapped Controller

Controller

class pandaprosumer.controller.mapped.MappedController(container, basic_prosumer_object, order=0, level=0, in_service=True, index=None, drop_same_existing_ctrl=False, overwrite=False, name=None, matching_params=None, **kwargs)[source]

Base class for all prosumer controllers that are associated to an element and can be mapped.

Parameters:
  • container – The prosumer/net/energy_system object

  • basic_prosumer_object – The basic prosumer object

  • order – The order of the controller

  • level – The level of the controller

  • in_service – The in-service status of the controller

  • index – The index of the controller

  • drop_same_existing_ctrl – Whether to drop existing controllers of the same type

  • overwrite – Whether to overwrite existing controllers

  • name – The name of the controller

  • matching_params – Matching parameters for the controller

  • kwargs – Additional keyword arguments

control_step(container)[source]

Executes the control step for the controller.

Parameters:

container – The container object

finalize(container, result, result_fluid_mix=None)[source]

Function that should be called at the end of the control step of the controllers. Write the results of the controller in the result columns for mapping to other responder controllers and saving in result history to export to timeseries result data frame

Parameters:
  • container – The container (prosumer) object

  • result – The results of the controller

  • result_fluid_mix – The fluid mixture model (list of dictionaries)

finalize_control(container)[source]

Finalizes the step for the controller.

Parameters:
  • container – The container object

  • time – The current time step

finalize_step(container, time)[source]

Note

This method is ONLY being called during time-series simulation!

After each time step, this method is being called to clean things up or similar. The OutputWriter is a class specifically designed to store results of the loadflow. If the ControlHandler.output_writer got an instance of this class, it will be called before the finalize step.

initialize_control(container)[source]

Some controller require extended initialization in respect to the current state of the net (or their view of it). This method is being called after an initial loadflow but BEFORE any control strategies are being applied.

This method may be interesting if you are aiming for a global controller or if it has to be aware of its initial state.

is_converged(container)[source]

Check if controller already was applied

level_reset(container)[source]

Resets the level for the controller.

Parameters:

container – The container object

repair_control(container)[source]

Some controllers can cause net to not converge. In this case, they can implement a method to try and catch the load flow error by altering some values in net, for example load scaling. This method is being called in the except block in run_control. Either implement this in a controller that is likely to cause the error, or define a special “load flow police” controller for your use case

restore_init_state(container)[source]

Some controllers manipulate values in net and then restore them back to initial values, e.g. DistributedSlack. This method should be used for such a purpose because it is executed in the except block of run_control to make sure that the net condition is restored even if load flow calculation doesn’t converge

set_active(container, in_service)[source]

Sets the controller in or out of service

time_series_finalization(container)[source]

Finalizes the time series for the controller.

Parameters:

container – The container object

Returns:

List of finalizations

time_series_initialization(container)[source]

Initializes the time series for the controller.

Parameters:

container – The prosumer/net/energy_system object

Returns:

List of initializations

time_step(container, time)[source]

Executes the time step for the controller.

Parameters:
  • container – The container object

  • time – The current time step

Basic Controller

Controller

class pandaprosumer.controller.base.BasicProsumerController(container, basic_prosumer_object, order=0, level=0, in_service=True, index=None, drop_same_existing_ctrl=False, overwrite=False, name=None, matching_params=None, **kwargs)[source]

Base class for all prosumer controllers that can be part of a ‘get_t_m’ chain.

Parameters:
  • container – The prosumer object

  • basic_prosumer_object – The basic prosumer object

  • order – The order of the controller

  • level – The level of the controller

  • in_service – The in-service status of the controller

  • index – The index of the controller

  • drop_same_existing_ctrl – Whether to drop existing controllers of the same type

  • overwrite – Whether to overwrite existing controllers

  • name – The name of the controller

  • matching_params – Matching parameters for the controller

  • kwargs – Additional keyword arguments

control_step(prosumer)[source]

Executes the control step for the controller.

Parameters:

prosumer – The prosumer object

get_treturn_tab_c(prosumer)[source]

Calculates the feed temperature and mass flow to deliver as well as the expected return temperature in °C and kg/s.

Get the expected temperatures and mass flow of the responders (mapped downstream controllers)

Provide the maximal feed temperature Calculate the mass flows to feed to the other responders to provide the same power (assuming that the return temperature is not changed!) Calculate the return temperature as the average of the expected return temperatures weighted by the mass flows

Parameters:

prosumer – The prosumer object

Returns:

A Tuple (Feed temperature (float), Return Temperature (float), Mass Flow to deliver (np.array[float])

t_m_to_deliver(prosumer)[source]

Calculates the feed temperature and mass flow to deliver as well as the expected return temperature in °C and kg/s.

Get the expected temperatures and mass flow of the responders (mapped downstream controllers)

Provide the maximal feed temperature Calculate the mass flows to feed to the other responders to provide the same power (assuming that the return temperature is not changed!) Calculate the return temperature as the average of the expected return temperatures weighted by the mass flows

Parameters:

prosumer – The prosumer object

Returns:

A Tuple (Feed temperature (float), Return Temperature (float), Mass Flow to deliver (np.array[float])

t_m_to_deliver_for_t(prosumer, t_feed_c)[source]

For a given feed temperature in °C, Calculates the mass flow to deliver as well as the expected return temperature in °C and kg/s.

Used for the element directly connected to a District Heating Network (Heat Exchanger, Heat Pump) to assess what would be the required mass flow through the substation for a given feed temperature

For a given feed temperature in °C, calculate the required feed mass flow and the expected return temperature if this feed temperature is provided. This superclass method implement a default behavior that should normally be overridden in the subclasses if the model is dependent on the feed temperature.

Parameters:
  • prosumer – The prosumer object

  • t_feed_c – The feed temperature

Returns:

A Tuple (Feed temperature (float), Return Temperature (float), Mass Flow to deliver (np.array[float])

t_m_to_receive(prosumer)[source]

Return the expected received Feed temperature, return temperature and mass flow in °C and kg/s Call the function _t_m_to_receive_init that should normally be overridden in the subclasses, to get the expected temperatures and mass flow of the controller and calculate the required mass flow and feed temperature that should still be provided given the values already mapped in the input to provide the expected values

Parameters:

prosumer – The prosumer object

Returns:

A Tuple (Feed temperature, return temperature and mass flow)