h2integrate.control.control_strategies.pyomo_controllers

Contents

h2integrate.control.control_strategies.pyomo_controllers#

Functions

dummy_function()

Dummy function used for setting OpenMDAO input/output defaults but otherwise unused.

Classes

HeuristicLoadFollowingController(**kwargs)

Operates the battery based on heuristic rules to meet the demand profile based power

HeuristicLoadFollowingControllerConfig(*, ...)

PyomoControllerBaseClass(**kwargs)

PyomoControllerBaseConfig(*, max_capacity, ...)

Configuration data container for Pyomo-based storage / dispatch controllers.

SimpleBatteryControllerHeuristic(**kwargs)

Fixes battery dispatch operations based on user input.

class h2integrate.control.control_strategies.pyomo_controllers.PyomoControllerBaseConfig(*, max_capacity, max_charge_percent, min_charge_percent, init_charge_percent, n_control_window, n_horizon_window, commodity_name, commodity_storage_units, tech_name, system_commodity_interface_limit)#

Configuration data container for Pyomo-based storage / dispatch controllers.

This class groups the fundamental parameters needed by derived controller implementations. Values are typically populated from the technology tech_config.yaml (merged under the "control" section).

Parameters:
  • max_capacity (float)

  • max_charge_percent (float)

  • min_charge_percent (float)

  • init_charge_percent (float)

  • n_control_window (int)

  • n_horizon_window (int)

  • commodity_name (str)

  • commodity_storage_units (str)

  • tech_name (str)

  • system_commodity_interface_limit (float | int | str | list[float])

max_capacity#

Physical maximum stored commodity capacity (inventory, not a rate). Units correspond to the base commodity units (e.g., kg, MWh).

Type:

float

max_charge_percent#

Upper bound on state of charge expressed as a fraction in [0, 1]. 1.0 means the controller may fill to max_capacity.

Type:

float

min_charge_percent#

Lower bound on state of charge expressed as a fraction in [0, 1]. 0.0 allows full depletion; >0 reserves minimum inventory.

Type:

float

init_charge_percent#

Initial state of charge at simulation start as a fraction in [0, 1].

Type:

float

n_control_window#

Number of consecutive timesteps processed per control action (rolling control / dispatch window length).

Type:

int

n_horizon_window#

Number of timesteps considered for look ahead / optimization horizon. May be >= n_control_window (used by predictive strategies).

Type:

int

commodity_name#

Base name of the controlled commodity (e.g., "hydrogen", "electricity"). Used to construct input/output variable names (e.g., f"{commodity_name}_in").

Type:

str

commodity_storage_units#

Units string for stored commodity rates (e.g., "kg/h", "MW"). Used for unit annotations when creating model variables.

Type:

str

tech_name#

Technology identifier used to namespace Pyomo blocks / variables within the broader OpenMDAO model (e.g., "battery", "h2_storage").

Type:

str

system_commodity_interface_limit#

Max interface (e.g. grid interface) flow used to bound dispatch (scalar or per-timestep list of length n_control_window).

Type:

float | int | str |list[float]

max_capacity: float#
max_charge_percent: float#
min_charge_percent: float#
init_charge_percent: float#
n_control_window: int#
n_horizon_window: int#
commodity_name: str#
commodity_storage_units: str#
tech_name: str#
system_commodity_interface_limit: float | int | str | list[float]#
h2integrate.control.control_strategies.pyomo_controllers.dummy_function()#

Dummy function used for setting OpenMDAO input/output defaults but otherwise unused.

Returns:

None -- empty output

class h2integrate.control.control_strategies.pyomo_controllers.PyomoControllerBaseClass(**kwargs)#
dummy_method(in1, in2)#

Dummy method used for setting OpenMDAO input/output defaults but otherwise unused.

Parameters:
  • in1 (any) -- dummy input 1

  • in2 (any) -- dummy input 2

Returns:

None -- empty output

setup()#

Register per-technology dispatch rule inputs and expose the solver callable.

Adds discrete inputs named 'dispatch_block_rule_function' (and variants suffixed with source tech names for cross-tech connections) plus a discrete output 'pyomo_dispatch_solver' that will hold the assembled callable after compute().

compute(inputs, outputs, discrete_inputs, discrete_outputs)#

Build Pyomo model blocks and assign the dispatch solver.

pyomo_setup(discrete_inputs)#

Create the Pyomo model, attach per-tech Blocks, and return dispatch solver.

Returns:

callable --

Function(performance_model, performance_model_kwargs, inputs, commodity_name)

executing rolling-window heuristic dispatch and returning: (total_out, storage_out, unmet_demand, unused_commodity, soc)

static dispatch_block_rule(block, t)#
initialize_parameters()#
update_time_series_parameters(start_time)#
Parameters:

start_time (int)

static _check_efficiency_value(efficiency)#

Checks efficiency is between 0 and 1. Returns fractional value

property blocks: Block#
property model: ConcreteModel#
class h2integrate.control.control_strategies.pyomo_controllers.SimpleBatteryControllerHeuristic(**kwargs)#

Fixes battery dispatch operations based on user input.

Currently, enforces available generation and grid limit assuming no battery charging from grid.

Enforces:
  • Available generation cannot be exceeded for charging.

  • Interface (grid / export) limit bounds discharge.

  • No grid charging (unless logic extended elsewhere).

setup()#

Initialize SimpleBatteryControllerHeuristic.

initialize_parameters()#

Initializes parameters.

update_time_series_parameters(start_time=0)#

Updates time series parameters.

Parameters:

start_time (int) -- The start time.

update_dispatch_initial_soc(initial_soc=None)#

Updates dispatch initial state of charge (SOC).

Parameters:

initial_soc (float, optional) -- Initial state of charge. Defaults to None.

set_fixed_dispatch(commodity_in, system_commodity_interface_limit)#
Sets charge and discharge amount of storage dispatch using fixed_dispatch attribute

and enforces available generation and charge/discharge limits.

Parameters:
  • commodity_in (list) -- commodity blocks.

  • system_commodity_interface_limit (list) -- Maximum flow rate of commodity through

  • interface (the system)

Raises:

ValueError -- If commodity_in or system_commodity_interface_limit length do not match fixed_dispatch length.

check_commodity_in_discharge_limit(commodity_in, system_commodity_interface_limit)#

Checks if commodity in and discharge limit lengths match fixed_dispatch length.

Parameters:
  • commodity_in (list) -- commodity blocks.

  • system_commodity_interface_limit (list) -- Maximum flow rate of commodity through

  • interface (the system)

Raises:
  • ValueError -- If commodity_in or system_commodity_interface_limit length does not

  • match fixed_dispatch length. --

_set_commodity_fraction_limits(commodity_in, system_commodity_interface_limit)#

Set storage charge and discharge fraction limits based on available generation and system interface capacity, respectively.

Parameters:
  • commodity_in (list) -- commodity blocks.

  • system_commodity_interface_limit (list) -- Maximum flow rate of commodity

  • interface (through the system)

NOTE: This method assumes that storage cannot be charged by the grid.

static enforce_power_fraction_simple_bounds(storage_fraction, minimum_soc, maximum_soc)#

Enforces simple bounds (0, .9) for battery power fractions.

Parameters:
  • storage_fraction (float) -- Storage fraction from heuristic method.

  • minimum_soc (float)

  • maximum_soc (float)

Returns:

storage_fraction (float) -- Bounded storage fraction.

Return type:

float

update_soc(storage_fraction, soc0)#

Updates SOC based on storage fraction threshold.

Parameters:
  • storage_fraction (float) -- Storage fraction from heuristic method. Below threshold is charging, above is discharging.

  • soc0 (float) -- Initial SOC.

Returns:

soc (float) -- Updated SOC.

Return type:

float

_heuristic_method(_)#

Executes specific heuristic method to fix storage dispatch.

_enforce_power_fraction_limits()#

Enforces storage fraction limits and sets _fixed_dispatch attribute.

_fix_dispatch_model_variables()#

Fixes dispatch model variables based on the fixed dispatch values.

_check_initial_soc(initial_soc)#

Checks initial state-of-charge.

Parameters:

initial_soc -- Initial state-of-charge value.

Returns:

float -- Checked initial state-of-charge.

property fixed_dispatch: list#

List of fixed dispatch.

Type:

list

property user_fixed_dispatch: list#

List of user fixed dispatch.

Type:

list

property storage_dispatch_commands: list#

Commanded dispatch including available commodity at current time step that has not been used to charge the battery.

property soc: list#

State-of-charge.

property charge_commodity: list#

Charge commodity.

property discharge_commodity: list#

Discharge commodity.

property initial_soc: float#

Initial state-of-charge.

property minimum_soc: float#

Minimum state-of-charge.

property maximum_soc: float#

Maximum state-of-charge.

property charge_efficiency: float#

Charge efficiency.

property discharge_efficiency: float#

Discharge efficiency.

property round_trip_efficiency: float#

Round trip efficiency.

class h2integrate.control.control_strategies.pyomo_controllers.HeuristicLoadFollowingControllerConfig(*, max_capacity, max_charge_percent, min_charge_percent, init_charge_percent, n_control_window, n_horizon_window, commodity_name, commodity_storage_units, tech_name, system_commodity_interface_limit, max_charge_rate, charge_efficiency=None, discharge_efficiency=None, include_lifecycle_count=False)#
Parameters:
  • max_capacity (float)

  • max_charge_percent (float)

  • min_charge_percent (float)

  • init_charge_percent (float)

  • n_control_window (int)

  • n_horizon_window (int)

  • commodity_name (str)

  • commodity_storage_units (str)

  • tech_name (str)

  • system_commodity_interface_limit (float | int | str | list[float])

  • max_charge_rate (int | float)

  • charge_efficiency (float)

  • discharge_efficiency (float)

  • include_lifecycle_count (bool)

max_charge_rate: int | float#
charge_efficiency: float#
discharge_efficiency: float#
include_lifecycle_count: bool#
class h2integrate.control.control_strategies.pyomo_controllers.HeuristicLoadFollowingController(**kwargs)#
Operates the battery based on heuristic rules to meet the demand profile based power

available from power generation profiles and power demand profile.

Currently, enforces available generation and grid limit assuming no battery charging from grid.

setup()#

Initialize HeuristicLoadFollowingController.

set_fixed_dispatch(commodity_in, system_commodity_interface_limit, commodity_demand)#
Sets charge and discharge power of battery dispatch using fixed_dispatch attribute

and enforces available generation and charge/discharge limits.

Parameters:
  • commodity_in (list) -- List of generated commodity in.

  • system_commodity_interface_limit (list) -- List of max flow rates through system interface (e.g. grid interface).

  • commodity_demand (list) -- The demanded commodity.

_heuristic_method(commodity_in, commodity_demand)#

Enforces storage fraction limits and sets _fixed_dispatch attribute. Sets the _fixed_dispatch based on commodity_demand and commodity_in.

Parameters:
  • commodity_in -- commodity generation profile.

  • commodity_demand -- Goal amount of commodity.