oemof / DHNx

District heating system optimisation and simulation models
MIT License
27 stars 12 forks source link

Node fork-0 not definied #61

Closed phuismann closed 3 years ago

phuismann commented 3 years ago

I tried to create my own DHN from GIS data by adding Forks, Pipes and Consumers to ThermalNetwork(), but it seems like the associated lat, lon is not passed to the class. Checking with is_consistent() gives me Node fork-0 not defined even tho it's available in thermal_network.components.forks.

I also tried is_consistent() on the example shown here https://dhnx.readthedocs.io/en/latest/examples.html and it returns Node producer-0 not defined.

Is it a bug or is something missing in the tutorial?

joroeder commented 3 years ago

Thank you for your issue.

Yes, there is a bug in the example. The from_node, to_node must be named producers, forks and consumers - so with the "s":

from dhnx.network import ThermalNetwork

thermal_network = ThermalNetwork()

thermal_network.add('Producer', id=0, lat=50, lon=10)

thermal_network.add('Consumer', id=0, lat=50, lon=10)

thermal_network.add('Pipe', id=0, from_node='producers-0', to_node='consumers-0')

print("Is consistent: ", thermal_network.is_consistent())

print(thermal_network)

# returns
# dhnx.network.ThermalNetwork object with these components
#  * 1 producers
#  * 1 consumers
#  * 1 pipes

print(thermal_network.components.pipes)

# returns
#        from_node     to_node
#    0  producer-0  consumer-0

Do you want to perform an network optimisation or a simulation? If you check the structure of the input data of the simulation or optimisation examples respectivly, your GIS output should have the same structure as the input of the examples. In future, further functionalities should be added to directly import via osmnx or other libraries eg street data and directly process the strucute for DHNx (see also #54 ) - contributions are very welcome :)

phuismann commented 3 years ago

Thank you works now!

For starters, I'm interested in network optimisation, but simulation will be on the agenda as well eventually.

I'll be happy to contribute!

joroeder commented 3 years ago

If you are interested in the development, you can join the next oemof dev meeting, or especially the DHNx session I just put into the wiki as topic https://github.com/oemof/oemof/wiki/Meeting-December-2020-(online) - the exact time of each session will come soon hopefully 😉