Skip to content

Comments

Organizational Entities and financial flows between them#21

Open
jimrojerTNO wants to merge 10 commits intomainfrom
organizational-entities
Open

Organizational Entities and financial flows between them#21
jimrojerTNO wants to merge 10 commits intomainfrom
organizational-entities

Conversation

@jimrojerTNO
Copy link
Collaborator

This PR is still in draft state

This PR is meant to do the following:

  • Add the parsing of the isOwnedBy in ESDL and storing it in the parameters
  • Finding the points in the energy system where owners change and create cost/revenue variables for exchange of energy between the owners
  • For this we need to know which carrier they are exchanging and for that we need to know the carrier at every port, therefore a carrier_id parameter is added for each port type.
  • We need to be able to find how assets connect to each other, previously this was only saved in the constraints, but not in a readeable map, therefore the get_connections() method from the esdl parsing was added.
  • We assume that the cost/revenue is according to the price(-profile) for that carrier.

… now add variables and constriants for computing the profit on owner level
@KobusVanRooyen
Copy link
Collaborator

@jimrojerTNO create some comment block in creating revenue variables in financial mixin. Afterwards review Femke/Kobus

Copy link
Collaborator

@FJanssen-TNO FJanssen-TNO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commented some suggestion on how to generalise/improve the code, to speed it up and make less copies of code due to different commodities.
Maybe we should discuss this.

Comment on lines 199 to 220
ids = dict()
try:
carrier = asset.global_properties["carriers"][asset.in_ports[0].carrier.id]
id_number = carrier["id_number_mapping"]
port = f"{carrier['type'].capitalize()}In"
ids[port] = dict(carrier_id=id_number)
carrier = asset.global_properties["carriers"][asset.out_ports[0].carrier.id]
id_number = carrier["id_number_mapping"]
port = f"{carrier['type'].capitalize()}Out"
ids[port] = dict(carrier_id=id_number)
except:
try:
carrier = asset.global_properties["carriers"][asset.in_ports[0].carrier.id]
id_number = carrier["id_number_mapping"]
port = f"{carrier['type'].capitalize()}In"
ids[port] = dict(carrier_id=id_number)
except:
carrier = asset.global_properties["carriers"][asset.out_ports[0].carrier.id]
id_number = carrier["id_number_mapping"]
port = f"{carrier['type'].capitalize()}Out"
ids[port] = dict(carrier_id=id_number)
return ids
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add option for three ports (e.g. A/W HP with electric connection)

Comment on lines 221 to 238
else:
ids = dict()
for k in range(0, n):
try:
carrier = asset.global_properties["carriers"][asset.in_ports[0].carrier.id]
id_number = carrier["id_number_mapping"]
port = f"{carrier['type'].capitalize()}Conn[{k+1}]"
ids[port] = dict(carrier_id=id_number)
except:
pass
try:
carrier = asset.global_properties["carriers"][asset.out_ports[0].carrier.id]
id_number = carrier["id_number_mapping"]
port = f"{carrier['type'].capitalize()}Conn[{k+1}]"
ids[port] = dict(carrier_id=id_number)
except:
pass
return ids
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove as node carrier ids are set differently

Comment on lines +166 to +168
# This is something extra I created. It is a nested list in the form of:
# [[asset1.HeatIn, asset2.HeatOut], [asset3.HeatIn, asset4.HeatOut], ...]
conn = self.get_connections()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this list, you could potentially create a dict:
{"asset1.HeatIn": "asset2.HeatOut",
"asset3.HeatIn": "asset4.HeatOut"], ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and create asset_con_dict = {"asset1": ["asset2"], "asset3": ["asset4", "asset5"]}
which just states the asset and to which it conects, can be deducted from previous list/dict.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and a dict listing the asset ports for each asset:
asset_port_dict = {"asset1": [HeatIn, HeatOut], "asset2": ["HeatIn", "HeatOut"], "asset3": ["Primary.HeatIn", "Primary.HeatOut", "Secondary.HeatIn", "Secondary.HeatOut"], ....}

for asset in assets:
# This is something extra I created. It is a nested list in the form of:
# [[asset1.HeatIn, asset2.HeatOut], [asset3.HeatIn, asset4.HeatOut], ...]
conn = self.get_connections()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line could be before the assets loop

Comment on lines 170 to 189
for connection in conn:
# Here we check if our asset is in the connection hence we find a connected asset
if asset == connection[0].split(".")[0] or asset == connection[1].split(".")[0]:
other_asset = (
connection[0].split(".")[0]
if asset == connection[1].split(".")[0]
else connection[1].split(".")[0]
)
# This bit of code is used to go from for example:
# HeatExchanger.Secondary.HeatIn -> Secondary.HeatIn
temp = (
connection[1].split(".")[1:]
if asset == connection[1].split(".")[0]
else connection[0].split(".")[1:]
)
port = temp[0]
for x in temp[1:]:
port = port + "." + x

# Here we check that the connected asset is not also owned by the same entity.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be skipped and one could loop over the connected assets named other_asset from asset_con_dict[asset]

# to represent the cashflow associated with the energy exchanged between the two
# organizations.
if other_asset not in assets:
var_name = f"{asset}__revenue_{port}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible ports could now be retrieved from: asset_port_dict[asset]
looping over these possible ports (poss_port), one can check which port relates to this connection:
if conn[f"{asset}.{poss_port}].split(".")[0] == other_asset

var_name = f"{asset}__revenue_{port}"
nominal_power = None
carrier_name = None
for _id, attr in self.get_electricity_carriers().items():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially to generalise for commodities:
we could create a map commodity_var_map = {"heat": "Heat", "gas": "Q", "electricity": "Power"}
we could loop over the commodities = ["heat", "gas", "electricity"]

then a nested loop for this line could be done like:
for id, attr in getattr(self, f"get{commodity}_carriers")().items():

with the Power, Q and Heat replaced by commodity_var_map[commodity].

This can also be done for the ccreation of the variables line 119 to 147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants