hyveopt package

Subpackages

Submodules

hyveopt.components module

class hyveopt.components.CustomAttribute[source]

Bases: ABC

abstract copy() Self[source]
abstract classmethod from_dict(input)[source]
abstract to_dict() dict[source]
class hyveopt.components.ESS(index: int = None, name: str = None, gain: Gain = None, pnom_kW: float = None, soc_nom_kWh: float = None)[source]

Bases: GainComponent

Energy storage system component. It considers a fixed rate of charge and fixed efficiency.

Attributes:

pnom_kW: float

Nominal active power (kW).

soc_nom_kWh: float

Nominal state of charge (kWh).

gain: Gain
pnom_kW: float = None
soc_nom_kWh: float = None
class hyveopt.components.Electrolizer(index: int = None, name: str = None, gain: Gain = None, pnom_kW: float = None, pmin_pu: float = None, pmax_pu: float = None)[source]

Bases: GainComponent

Represents a hydrogen electrolizer.

Attributes:

pnom_kW: float

Nominal

pmin_pu: float

Minimum power consumption in per unit.

pmax_pu: float

Maximum power consumption in per unit.

pmax_pu: float
pmin_pu: float
pnom_kW: float
class hyveopt.components.Gain(breakpoints: List[float], slopes: List[float], intercepts: List[float])[source]

Bases: CustomAttribute

copy() Self[source]
property domain
from_dict(input: Dict[str, List[float]])[source]
piecewise_linear(x)[source]

Evaluate a piecewise linear function.

Parameters:
  • x (array_like) – Input array.

  • breakpoints (list or array_like) – Breakpoints of the piecewise function.

  • slopes (list or array_like) – Slopes of the linear pieces.

  • intercepts (list or array_like) – Intercepts of the linear pieces.

Returns:

np.ndarray – Output array where each element is the result of the piecewise linear function.

to_dict() Dict[source]
class hyveopt.components.GainComponent(index: int = None, name: str = None, gain: hyveopt.components.Gain = None)[source]

Bases: Component

gain: Gain
class hyveopt.components.PVSystem(index: int = None, name: str = None, gain: hyveopt.components.Gain = None, snom_KVA: float = None, solar_irradiance: shilps.components.TSParameter = None)[source]

Bases: GainComponent

gain: Gain
snom_KVA: float = None
solar_irradiance: TSParameter = None
class hyveopt.components.PlantTemplate(name: str = None, batteries: Dict[int, TemplateESS] = None, electrolizers: Dict[int, TemplateElectrolizer] = None, pv_systems: Dict[int, TemplatePVSystem] = None)[source]

Bases: Entity

Template for a hydrogen plant.

tsnames() List[str][source]

Return the time series names of the problem data.

Returns:

  • List[str], the time series names.

class hyveopt.components.Range(min: float, max: float)[source]

Bases: CustomAttribute

copy() Self[source]
classmethod from_dict(input: Dict[str, float])[source]
max: float
min: float
to_dict() dict[source]
class hyveopt.components.TemplateESS(index: int = None, name: str = None, gain: Gain = None, pnom_kW: Range = None, soc_nom_kWh: Range = None)[source]

Bases: ESS

Template storage system component. It considers a fixed rate of charge and fixed efficiency.

Attributes:

pnom_kW: float

Nominal active power (kW).

soc_nom_kWh: float

Nominal state of charge (kWh).

efficiency: float

Round-trip efficiency.

gain: Gain
pnom_kW: Range = None
soc_nom_kWh: Range = None
class hyveopt.components.TemplateElectrolizer(index: int = None, name: str = None, gain: Gain = None, pnom_kW: float | List[float] = None, pmin_pu: float = None, pmax_pu: float = None)[source]

Bases: Electrolizer

Represents a hydrogen electrolizer with fixed efficiency.

Attributes:

pnom_kW: float

Nominal

pmin_pu: float

Minimum power consumption in per unit.

pmax_pu: float

Maximum power consumption in per unit.

pmax_pu: float
pmin_pu: float
pnom_kW: float | List[float]
class hyveopt.components.TemplatePVSystem(index: int = None, name: str = None, gain: Gain = None, snom_KVA: float = None, solar_irradiance: TSParameter = None, snom_MVA: Range = None, inv_cost: float = None)[source]

Bases: PVSystem

Template for a PVSystem component.

gain: Gain
inv_cost: float = None
snom_MVA: Range = None

hyveopt.constants module

class hyveopt.constants.Constants[source]

Bases: object

ANTOINE_COEFFICIENTS_WATER = {'A': 8.07131, 'B': 1730.63, 'C': 233.426}
F = 96485
R = 8.314
hyveopt.constants.celsius_to_kelvin(celsius)[source]

hyveopt.datasets module

hyveopt.datasets.generate_green_hydrogen_price_series(start_price=5.0, length=100, trend=-0.02, volatility=0.1)[source]

Generates a time series for green hydrogen prices with a downward trend and random fluctuations.

Parameters: - start_price (float): Initial price of green hydrogen per kg. - length (int): Number of time steps (e.g., days or months) for the time series. - trend (float): Long-term trend (negative for decreasing prices). - volatility (float): Magnitude of random fluctuations around the trend.

Returns: - pd.DataFrame: A DataFrame containing the generated time series.

hyveopt.degradation module

hyveopt.electrochemistry module

hyveopt.electrochemistry.membrane_conductivity(T_kelvin, lambda_mem)[source]

Calculate the membrane conductivity.

Parameters: - T_kelvin: Temperature in Kelvin - lambda_mem: Humidification of the membrane

Returns: - Membrane conductivity in S/cm

hyveopt.electrochemistry.membrane_resistance(delta_mem, T_celsius, lambda_mem)[source]

Calculate the membrane resistance.

Parameters: - delta_mem: Thickness of the membrane in cm - T_celsius: Temperature in degrees Celsius - lambda_mem: Humidification of the membrane

Returns: - Membrane resistance in ohms

hyveopt.electrochemistry.nernst_potential(T_celsius, P_H2, P_O2, P_H2O)[source]

Calculate the Nernst potential.

Parameters: - T_celsius: Temperature in degrees Celsius - P_H2: Partial pressure of hydrogen in bar - P_O2: Partial pressure of oxygen in bar - P_H2O: Partial pressure of water in bar

Returns: - Nernst potential in volts

hyveopt.electrochemistry.standard_reversible_voltage(T_kelvin)[source]

Calculate the standard reversible voltage as a function of temperature.

Parameters: - T_kelvin: Temperature in Kelvin

Returns: - Standard reversible voltage in volts

hyveopt.mass_transport module

hyveopt.pdata module

class hyveopt.pdata.CustomAttribute[source]

Bases: ABC

abstract copy() Self[source]
abstract classmethod from_dict(input)[source]
abstract to_dict() dict[source]
class hyveopt.pdata.ESS(index: int = None, name: str = None, gain: Gain = None, pnom_kW: float = None, soc_nom_kWh: float = None)[source]

Bases: GainComponent

Energy storage system component. It considers a fixed rate of charge and fixed efficiency.

Attributes:

pnom_kW: float

Nominal active power (kW).

soc_nom_kWh: float

Nominal state of charge (kWh).

gain: Gain
pnom_kW: float = None
soc_nom_kWh: float = None
class hyveopt.pdata.EconomicData(index: int = None, name: str = None, inv_cost_per_kw: float = None)[source]

Bases: Component

Economic data for a hydrogen plant.

index: int
inv_cost_per_kw: float = None
name: str
class hyveopt.pdata.Electrolizer(index: int = None, name: str = None, gain: Gain = None, pnom_kW: float = None, pmin_pu: float = None, pmax_pu: float = None)[source]

Bases: GainComponent

Represents a hydrogen electrolizer.

Attributes:

pnom_kW: float

Nominal

pmin_pu: float

Minimum power consumption in per unit.

pmax_pu: float

Maximum power consumption in per unit.

pmax_pu: float
pmin_pu: float
pnom_kW: float
class hyveopt.pdata.Gain(breakpoints: List[float], slopes: List[float], intercepts: List[float])[source]

Bases: CustomAttribute

copy() Self[source]
property domain
from_dict(input: Dict[str, List[float]])[source]
piecewise_linear(x)[source]

Evaluate a piecewise linear function.

Parameters: x : array_like

Input array.

breakpointslist or array_like

Breakpoints of the piecewise function.

slopeslist or array_like

Slopes of the linear pieces.

interceptslist or array_like

Intercepts of the linear pieces.

Returns: np.ndarray

Output array where each element is the result of the piecewise linear function.

to_dict() Dict[source]
class hyveopt.pdata.GainComponent(index: int = None, name: str = None, gain: hyveopt.pdata.Gain = None)[source]

Bases: Component

gain: Gain
class hyveopt.pdata.PVSystem(index: int = None, name: str = None, gain: hyveopt.pdata.Gain = None, snom_KVA: float = None, solar_irradiance: shilps.components.TSParameter = None)[source]

Bases: GainComponent

gain: Gain
snom_KVA: float = None
solar_irradiance: TSParameter = None
class hyveopt.pdata.PlantTemplate(name: str = None, batteries: Dict[int, TemplateESS] = None, electrolizers: Dict[int, TemplateElectrolizer] = None, pv_systems: Dict[int, TemplatePVSystem] = None, location: tuple = None)[source]

Bases: Entity

Template for a hydrogen plant.

tsnames() List[str][source]

Return the time series names of the problem data.

Returns:

  • List[str], the time series names.

class hyveopt.pdata.Range(min: float, max: float)[source]

Bases: CustomAttribute

copy() Self[source]
classmethod from_dict(input: Dict[str, float])[source]
max: float
min: float
to_dict() dict[source]
class hyveopt.pdata.TemplateESS(index: int = None, name: str = None, gain: Gain = None, pnom_kW: Range = None, soc_nom_kWh: Range = None, inv_cost_per_kw: float = None, bat_kw_to_kwh: float = None)[source]

Bases: ESS

Template storage system component. It considers a fixed rate of charge and fixed efficiency.

Attributes:

pnom_kW: float

Nominal active power (kW).

soc_nom_kWh: float

Nominal state of charge (kWh).

efficiency: float

Round-trip efficiency.

bat_kw_to_kwh: float = None
gain: Gain
inv_cost_per_kw: float = None
pnom_kW: Range = None
soc_nom_kWh: Range = None
class hyveopt.pdata.TemplateElectrolizer(index: int = None, name: str = None, gain: Gain = None, pnom_kW: float | List[float] = None, pmin_pu: float = None, pmax_pu: float = None, inv_cost_per_kw: float = None)[source]

Bases: Electrolizer

Represents a hydrogen electrolizer with fixed efficiency.

Attributes:

pnom_kW: float

Nominal

pmin_pu: float

Minimum power consumption in per unit.

pmax_pu: float

Maximum power consumption in per unit.

inv_cost_per_kw: float = None
pmax_pu: float
pmin_pu: float
pnom_kW: float | List[float]
class hyveopt.pdata.TemplatePVSystem(index: int = None, name: str = None, gain: Gain = None, snom_KVA: float = None, solar_irradiance: TSParameter = None, snom_MVA: Range = None, inv_cost_per_kw: float = None)[source]

Bases: PVSystem

Template for a PVSystem component.

gain: Gain
inv_cost_per_kw: float = None
snom_MVA: Range = None

hyveopt.plant_design module

class hyveopt.plant_design.HydrogenPlantDesign(plant_template: PlantTemplate, time_config: TimeConfig, tsdata: DataTimeSeries)[source]

Bases: ModelPlantDesign

class SolverParams(feas_tol: float = 1e-06, max_iter: int = 100)[source]

Bases: object

feas_tol: float = 1e-06
max_iter: int = 100
add_constraint(nameindex, func)[source]
add_variables(name: str, sets: tuple, lb: float = None, ub: float = None)[source]
check_constraints(x)[source]
compute_rhs(x=None)[source]
display_variables()[source]
eval_fobj()[source]
get_constraint(nameindex)[source]
get_constraints_names()[source]
optimize()[source]
update()[source]
validate()[source]
class hyveopt.plant_design.ModelPlantDesign(plant_template)[source]

Bases: ABC

abstract optimize()[source]

hyveopt.shilps_api module

hyveopt.skeleton module

This is a skeleton file that can serve as a starting point for a Python console script. To run this script uncomment the following lines in the [options.entry_points] section in setup.cfg:

console_scripts =
     fibonacci = hyveopt.skeleton:run

Then run pip install . (or pip install -e . for editable mode) which will install the command fibonacci inside your current environment.

Besides console scripts, the header (i.e. until _logger…) of this file can also be used as template for Python modules.

Note:

This file can be renamed depending on your needs or safely removed if not needed.

References:
hyveopt.skeleton.fib(n)[source]

Fibonacci example function

Args:

n (int): integer

Returns:

int: n-th Fibonacci number

hyveopt.skeleton.main(args)[source]

Wrapper allowing fib() to be called with string arguments in a CLI fashion

Instead of returning the value from fib(), it prints the result to the stdout in a nicely formatted message.

Args:
args (List[str]): command line parameters as list of strings

(for example ["--verbose", "42"]).

hyveopt.skeleton.parse_args(args)[source]

Parse command line parameters

Args:
args (List[str]): command line parameters as list of strings

(for example ["--help"]).

Returns:

argparse.Namespace: command line parameters namespace

hyveopt.skeleton.run()[source]

Calls main() passing the CLI arguments extracted from sys.argv

This function can be used as entry point to create console scripts with setuptools.

hyveopt.skeleton.setup_logging(loglevel)[source]

Setup basic logging

Args:

loglevel (int): minimum loglevel for emitting messages

hyveopt.thermodynamics module

hyveopt.thermodynamics.antoine_pressure(temp_celsius: float, A: float, B: float, C: float)[source]

Calculate the saturation pressure using the Antoine equation.

Parameters: - temp_celsius: Temperature in degrees Celsius - A: Antoine coefficient A - B: Antoine coefficient B - C: Antoine coefficient C

Returns: - Saturation pressure in bar

hyveopt.thermodynamics.partial_pressure_estimator_H2(P_total, temp_celsius)[source]

Estimate the partial pressure of H2 from the total pressure and temperature.

Parameters: - P_total: Total pressure in bar - temp_celsius: Temperature in degrees Celsius

Returns: - Partial pressure of H2 in bar

hyveopt.thermodynamics.partial_pressure_estimator_O2(P_total, temp_celsius)[source]

Estimate the partial pressure of O2 from the total pressure and temperature.

Parameters: - P_total: Total pressure in bar - temp_celsius: Temperature in degrees Celsius

Returns: - Partial pressure of O2 in bar

hyveopt.utils module

hyveopt.utils.compute_financial_metrics(cashflows: array, discount_rate: float)[source]

Computes common financial metrics including NPV, IRR, and Payback Period.

Parameters: - cashflows: np.array of cashflows where the first value is the initial investment (negative)

and subsequent values are returns.

  • discount_rate: The discount rate as a decimal (e.g., 0.1 for 10%).

Returns: - A dictionary containing NPV, IRR, and Payback Period.

hyveopt.utils.plot_scenarios_with_confidence(matrix, time_range, xlabel='Hour of Day', ylabel='Value')[source]

Plot multiple time series (scenarios) over a time range, with the average and confidence interval.

Args: - matrix (numpy.ndarray): 2D array of shape (n_scenarios, time_range). - time_range (array-like): Time range (e.g., array of hours of the day). - xlabel (str): Label for the x-axis. - ylabel (str): Label for the y-axis.

Returns: - fig: Handle to the generated figure.

Module contents