Adding multiple activities with formulas containing only database parameters to a group (e.g. "all") causes an error because the dummy parameters created at activity level are not unique.
For example:
for activity in database:
for exchange in activity.exchanges():
if exchange.get('formula'):
bw2.parameters.add_exchanges_to_group("all", activity)
break
Because there are no activity level parameters specified, parameters.add_exchanges_to_group adds one called "__dummy__", then adds the exchanges to the ParameterizedExchange table.
This works first time around, but then fails for the second activity because "__dummy__" already exists in the group "all".
Original report by James Joyce (Bitbucket: pjamesjoyce, GitHub: pjamesjoyce).
Adding multiple activities with formulas containing only database parameters to a group (e.g. "all") causes an error because the dummy parameters created at activity level are not unique.
For example:
Because there are no activity level parameters specified,
parameters.add_exchanges_to_group
adds one called "__dummy__", then adds the exchanges to theParameterizedExchange
table.This works first time around, but then fails for the second activity because "__dummy__" already exists in the group "all".