+1 vote
578 views
Hi, I am trying to change the relative amounts of two electricity flows at the beginning of my system. I want them to automatically update with the changing grid power, so at some points hydro may provide a higher percentage of power compared to gas.

What is the general code I need for this. I have the UUID's of the two flows. How do I search for the two flows using olca, and change the flow amounts in the product system?

Sorry if this seems basic, you don't have to write full code, just an idea of the commands that I will need.

Thanks,

Matt
in openLCA by (170 points)

1 Answer

0 votes
by (5.3k points)

Having the UUIDs of the two flows won't do you much good. In the background, the amount of each flow going into a process is stored in a separate table in the database: tbl_exchanges. Each of these exchange entries contain a reference to a flow and the process that calls that flow. What you're actually looking to do is change the amount of the exchange. That being said, the way you see the exchanges is  through the process class: https://github.com/GreenDelta/olca-ipc.py/blob/ac121e6ceca335ee50a91cc0ca1c232831029734/olca/schema.py#L3063

I'm not sure whether you'll need to save any changes you make to the exchanges to the database before calculating - I've not tried to use this approach directly.

process_ref = olca_client.find(olca.Process,"process_name")
process = olca_client.get(olca.Process,uid=process_ref.id)
exchanges = process.exchanges #This returns a list of olca.Exchange. 
...