Hi,
I am trying to write a function to calculate the total emissions of my energy system with oemof. I have started from the function in the repository:
emission_limit
because I want to know also the total amount. I characterized the flows that I want to include in the calculation with the attribute ‘emission’, and formulated it as:
def emission_tot(om,flows=None):
if flows is None:
flows = {}
for (i, o) in om.flows:
if hasattr(om.flows[i, o], 'emission'):
flows[(i, o)] = om.flows[i, o]
else:
for (i, o) in flows:
if not hasattr(flows[i, o], 'emission'):
raise ValueError(('Flow with source: {0} and target: {1} '
'has no attribute emission.').format(i.label, o.label))
return sum(om.flow[i, o, t]*om.timeincrement[t]*om.flows[i, o].emission
for (i, o) in flows
for t in om.TIMESTEPS)
om.emission_tot = emission_tot.__call__(om)
but if I call it as:
global_emissions = emission_tot(om, flows=None)
I get the summation expression, but I can’t evaluate it. I imagine it is an issue of pyomo language, but I can’t find the way to get the result of the expression.
Do you have any suggestion?
Thanks!