flexops.costing.add_electricity_cost

flexops.costing.add_electricity_cost(*, block: Block, electrical_power, time_index: DatetimeIndex, dt_hours: float, tariff: DataFrame, dr_config: DRConfig | None = None, prorate: bool = True, decomposition_type: str | None = None, consumption_estimate: dict[str, float] | None = None) → OperatingCostHandles

Build EECO’s convex-relaxed in-objective electricity cost on block.

The single-utility electric builder. add_operating_cost() is the facility-level umbrella that wraps this and add_fuel_cost() onto one opex block; call this directly only when you want the electric leg alone.

Hands EECO the kW magnitudes, tariff, and timestep; EECO owns the math (energy cost, demand-charge epigraphs, kWh conversion). The returned total_operating_cost is a RELAXED proxy for the objective, not the reported bill — use evaluate_cost() post-solve for that. DR is containers-only in v0: dr_config is accepted and stored but builds NO DR constraints.

Parameters:
  • block – The Pyomo block to build cost expressions on.

  • electrical_power – Time-indexed aggregate-load Var/Expression carrying no units — a bare kW magnitude — indexed 0..N-1 to align with time_index order.

  • time_index – Naive pd.DatetimeIndex aligning to electrical_power.

  • dt_hours – Timestep length in hours; passed to EECO once for kW→kWh.

  • tariff – An EECO rate_data DataFrame (electric utility).

  • dr_config – Optional DR container (v0: no constraints built).

  • prorate – Prorate monthly demand and fixed charges to the horizon length (see monthly_scale_factor()).

  • decomposition_type – EECO’s net-power decomposition, e.g. "absolute_value", which splits power into non-negative imports and exports so a tariff’s export charges apply. None (default) skips it, as before. EECO documents which types are linear.

  • consumption_estimate – See add_operating_cost(); only the "electric" entry, if any, applies here.

Returns:

The OperatingCostHandles for the electric utility.

Raises: