oemof / DHNx

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

Fix/no bidirectional consumer connection #63

Closed joroeder closed 3 years ago

joroeder commented 3 years ago

Bug: If the setting bidirectional_pipes=True is selected, also the connecting line to the building was created as bidirectional.

This only matters if a source or a storage is added at the consumers.

This PR fixes the issue.

joroeder commented 3 years ago

Thank you for reviewing!

However, the different handling for different cases is now somehow hard-coded within the if-else statements. I do not understand the code that much that I could come up with an idea, but this may be worth thinking.

The reason is that it should be possible to have the option of using bidirectional pipelines, which means a bidirectional flow in solph, or not. If not, two pipelines in each direction are created. Maybe, this if else statment is not needed, because in solph a bidirecitonal flow directly sets the min attribute to -1. This would be a new issue for further improvment (#70)

To make the code more readable and maintainable, it would certainly help to refactor it in a way that avoids the nested if else statements in optimization_dhs_nodes.py

Yes, thats a good idea. I refactored the q.