Minimize LCOH of PEM-Elctrolyzer

Hi everyone.

I am new in optimization modeling. Currently I am working on a model to minimize the LCOH of a PEM electrolyser. The consideration should be independent of the demand and the hydrogen price and only dependent on the quantity produced and the electricity prices.
The annualized investment costs, the efficiency, the variable costs due to hourly electricity prices and the size of the electrolyser are given. Hourly prices are to be used to decide the hours of production. The idea is that capex and opex are distributed over the quantity produced and the LCOH decreases up to a marginal price p.
In my current code I do not yet know how to integrate the investment costs in such a way that they have an influence on the production decision. This means that production always takes place when the electricity price is negative.
In the next step, the start-up behavior and load ramps should be considered in a possible partial load mode.
If you have any idea how to do this let me now :slight_smile:

from oemof import solph
import pandas as pd

 # test values for electricity prices in €/MWh
el_prices =[-5.17, -1.07, -1.47, -5.08, -4.49, -5.4, -5.02, -1.3, -1.44, -1.09, -1.07, -1.07, -0.79, -0.27, 0.85, 23.53, 36.54, 46.03, 55.57, 54.95, 49.23, 44.99, 45.96, 35.0, 57.91, 51.67, 52.93, 44.09, 50.08, 69.72, 105.08, 140.64, 145.98, 147.05, 145.61, 143.35, 144.38, 143.76, 148.2, 155.34, 162.89, 170.0, 174.74, 164.46, 153.0, 141.67, 134.91, 124.22, 130.01, 120.0]

# Annahmen und Konstanten
investment_cost_ely = 1500  # Beispiel-Fixkosten in Euro/kw
power_ely = 1000  # Beispiel-Leistung des Elektrolyseurs in kW
conversion_factor = 0.6  # Beispiel-Wirkungsgrad des Elektrolyseurs
number_years = 20
interest_rate = 0.06

#annualized capex
a = (((1+interest_rate)**number_years)*interest_rate)/(((1+interest_rate)**number_years)-1)

annualized_cost = investment_cost_ely * power_ely * a

# Create Energysystem with time steps with length of list of prices
es = solph.EnergySystem(timeindex=solph.create_time_index(2023, number=len(el_prices)-1))

b_electricity = solph.Bus("b_el")
b_hydrogen = solph.Bus("b_h2")

#power source
spotmarket = solph.components.Source(
    outputs={b_electricity: solph.Flow(variable_costs=el_prices)} 

hydrogen_sink = solph.components.Sink(
    "hydrogen demand",
    inputs={b_hydrogen: solph.Flow()}

electrolyzer = solph.components.Converter(
        b_electricity: solph.Flow()
    outputs={b_hydrogen: solph.Flow(min=0.25, nonconvex=solph.NonConvex(), nominal_value=power_ely*0.6)},
    conversion_factors={b_hydrogen: 0.6}

    b_hydrogen, b_electricity,
    spotmarket, hydrogen_sink, 

Thanks in advance

Hi Luca,

what exactly is your question/issue? On top of that, your example code is not actually working, the df variable you are using is never defined. Can you create a minimal working version.



Hi Francesco,

sorry I forgot to change the df variable but its done now.

The question is how can I integrate the investment costs in such a way that they influence how many hours are produced?
If I did not produce any hours, I would only have the investment costs as LCOH.
If I only produced at negative prices, the LCOH would fall.
However, I believe that there are other hours with positive prices at which it is worth producing, because although the variable costs increase, the costs are spread over a larger quantity produced.
Every hour would have to be checked: If I produce this additional hour at price x, will the LCOH decrease? If yes, produce, if not, do not produce.