ehub_model

Provides a class for encapsulating an energy hub model.

class energy_hub.ehub_model.EHubModel(*, excel=None, request=None, big_m=99999, max_carbon=None)[source]

Represents a black-box Energy Hub.

calc_investment_cost()[source]

A constraint for calculating the investment cost.

calc_maintenance_cost()[source]

A constraint for calculating the maintenance cost.

calc_operating_cost()[source]

A constraint for calculating the total operating cost.

calc_total_carbon()[source]

A constraint for calculating the total carbon produced.

calc_total_cost()[source]

A constraint for calculating the total cost.

capacity_bounds()[source]

Ensure the capacities are within their given bounds.

compile()[source]

Build all the constraints and variables of the model.

property constraints

The list of constraints on the model.

energy_balance(t, stream)[source]

Ensure the loads and exported energy is below the produced energy.

Parameters:
  • t – A time step

  • stream – An output stream

max_carbon_level()[source]

Constraint to set a max carbon cap.

property objective

The objective “function” of the model.

recompile()[source]

Clear all constraints and variables then compile again.

solve(solver_settings: dict | None = None, is_verbose: bool = False)[source]

Solve the model.

Parameters:
  • solver_settings – The config options for the solver

  • is_verbose – Makes it so the solver prints everything

Returns:

The results

storage_balance(t, storage)[source]

Calculate the current storage level from the previous level.

Parameters:
  • t – A time step

  • storage – A storage

storage_charge_rate(t, storage)[source]

Ensure the charge rate of a storage is below it’s maximum rate.

Parameters:
  • t – A time step

  • storage – A storage

storage_discharge_rate(t, storage)[source]

Ensure the discharge rate of a storage is below it’s maximum rate.

Parameters:
  • t – A time step

  • storage – A storage

storage_input_positive(t, storage)[source]

Energy to storage should be positive.

storage_is_installed(storage)[source]

Set binary to 1 if capacity of storage is > 0. :param storage: A storage

storage_is_installed_2(storage)[source]

Set binary to 1 if capacity of storage is > 0. :param storage: A storage

storage_level_above_minimum(t, storage)[source]

Ensure the storage level is above it’s minimum level.

Parameters:
  • t – A time step

  • storage – A storage

storage_level_below_capacity(t, storage)[source]

Ensure the storage’s level is below the storage’s capacity.

Parameters:
  • t – A time step

  • storage – A storage

storage_level_positive(t, storage)[source]

Storages’ levels should be above zero.

storage_looping(storage)[source]

Ensure that the storage level at the beginning is equal to it’s end level.

storage_output_positive(t, storage)[source]

Energy from the storages should be positive.

tech_export_positive(t, stream)[source]

Energy exported should be positive.

tech_import_positive(t, stream)[source]

Energy exported should be positive.

tech_input_below_capacity(t, tech)[source]

Ensure the energy input by a tech is less than its capacity.

Parameters:
  • t – A time step

  • tech – A converter

tech_input_positive(t, tech)[source]

Energy input to tech should be positive.

tech_is_installed(tech)[source]

Set binary to 1 if capacity of tech is > 0. :param tech: A converter

tech_is_installed_2(tech)[source]

Set binary to 1 if capacity of tech is > 0. :param tech: A converter

tech_is_on(t, disp, out)[source]

Set binary to on if tech is active.

Parameters:
  • t – A time step

  • disp – A dispatch tech

  • out – An output energy stream

tech_is_on_2(t, disp, out)[source]

Set binary to on if tech is active.

Parameters:
  • t – A time step

  • disp – A dispatch tech

  • out – An output energy stream

tech_part_loads(t, disp, out)[source]
Parameters:
  • t – A time step

  • disp – A dispatch tech

  • out – An output energy stream

exception energy_hub.ehub_model.InfeasibleConstraintError(constraint_name: str | None = None, arguments: tuple | None = None)[source]

A constraint will always be false.