Dear openmod community,
I’m glad to be here.
I’m trying to implement a custom constraint for the share of renewable energy in my energy system consisting of pv battery and dieselGen using oemof. The following is a part of the code, where as seen the attribute „re_share“ in the components pv and dieselGen is added
bel_dc = solph.Bus(label = 'dc_electricity')
bel_ac = solph.Bus(label = 'ac_electricity')
pv = solph.Source(label='pv', outputs={bel_dc: solph.Flow(
fix=feedin["PV"],
investment=solph.Investment(ep_costs=cost_param.loc['Annuity_per_kW','pv'],
nonconvex = False,
existing = 0),
variable_costs=Comp_param['pv']['var'],
re_share=0.5
)})
dieselGen = solph.Transformer(label="diesel",
inputs={diesel_bus: solph.Flow()},
outputs={bel_ac: solph.Flow(
investment=solph.Investment(ep_costs=cost_param.loc['Annuity_per_kW','inverter'],
maximum=Peak_Demand,
minimum=0.3*Peak_Demand,
nonconvex=True),
variable_costs=Comp_param['diesel']['var'],
re_share=0.5
),
co2_bus: solph.Flow()},
conversion_factors={bel_ac: diesel_efficiency,
co2_bus:Diesel_co2_emission_factor
})
I build this function based on source code for oemof.solph.constraints.integral_limit but it didn’t not work. I’ still be a beginner and not familiar that much with the constraint concept in Oemof. Maybe you might have a better idea how to realise that! I will appreciate it!
def RE_sh_const(om,key,re_share):
pv_gen= sum(om.flow[pv,bel_dc,:])
fossil_gen = sum(om.flow[dieselGen,bel_ac,:])
RE_gen= pv_gen
total_gen = RE_gen + fossil_gen
limit_name= key
expr = (fossil_gen - (1 - re_share) * total_gen )
setattr(om,limit_name,expr)
setattr( om,limit_name + "_constraint",
po.Constraint(expr=(getattr(om, limit_name) <= 0)),)
return om
RE_sh_const(model,'re_share',0.5)
I’am grateful for any help!