-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable modelling of cellular grid structures #912
Conversation
…(currently not working)
added plot of the energy system
…etween cells and corrected constraint creation (still not operative!)
…rBlock, adjusted example
…ctions) instead of cell specific CellConnector setup (One-to-Many/Many-to-One/Many-to-Many), renamed max_flow to max_power, linkage between CellConnectors is created by equating flows instead of input_flow/output_flow variables
…onstraint generation for cell connections
In case someone follows this PR, I want to provide a short status report. The example given in examples\cellular\cellular.py is working, as far as I have tested. More extensive testing still needs to be done and I anticipate a few problems:
Also, there are a lot of more or less current #TODO in the code, which I hope to resolve soon. If anyone has any questions or recommendations, feel free to reach out! I plan on atteding the upcoming oemof-meeting, so discussion in person is also possible. Edit: if anyone could tell me whether the bidirectional flow is working with all other flow-functionalities, that would be a great help! |
Hi @lensum, I'm not really into the topic, so please please forgive me my lack of understanding. I have a few questions:
If this is mostly about data analysis, we might just think about having something like balancing groups in post-processing. |
Hey @p-snft, no worries, these are exactly the kind of questions I was hoping for. You are correct that the results are the same. This is also reflected by the fact that the pyomo model is (currently) build "monolithic" (there is only one pyomo model which contains all cells). The benefits I nonetheless see are twofold:
Concerning the question |
Hey again @p-snft , I also updated the initial text. If I should just delete the old text instead (for a cleaner look), feel free to point that out to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lensum,
sorry, was meaning to look at this feature earlier and really liked your presentation at the user & dev meeting as well as the idea to allow for a decomposition of oemof.solph models by slightly re-arranging / ordering things.
Please find some comments of mine to dedicated code sections. Overall,
- I think, you could facilitate even a bit more (by using a list instead a dict for the energy_system) and
- I'm a bit sceptical towards adding a facade without any additional functionality inside oemof.solph.
Also, I think, simply dropping the sections that are crossed out in the original post would facilitate its readability.
Hey @jokochems, I implemented most of the suggested changes. Thanks a ton! I'm now working on satisfying the checks before I add tests. |
…ked and impossibly to create, respectively
|
All requirements for a pull request known to me are fulfilled, therefore I'm removing the "Draft" status. Also, I took the liberty to change the title of the documentation from "Welcome to oemof's documentation" to "Welcome to oemof solph's documentation". I did this because I seem to remember that the term "oemof" should no longer be used synonymously with "solph" and this rather prominent display bothered be somehow. |
Sure, I can have a look. But I'll leave the final decisions to @p-snft. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lensum,
to me everything looks good. I think, the tiny decrease in coverage can be ignored.
I left some minor comments in the docs with suggestions for slight rephrasing or additions. Also, I think introducing a new method in _models.Model
could help to avoid code duplication.
Overall, these are all optional aspects. I would be fine with it as it currently is and leave it up to @p-snft to decide.
Thanks a lot! Looking forward to your upcoming decomposition activities.
src/oemof/solph/_models.py
Outdated
self.discount_rate = 0.02 | ||
msg = ( | ||
f"By default, a discount_rate of {self.discount_rate} " | ||
f"is used for a multi-period model. " | ||
f"If you want to use another value, " | ||
f"you have to specify the `discount_rate` attribute." | ||
) | ||
warnings.warn(msg, debugging.SuspiciousUsageWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken, this is the same as above. Couldn't we add a tiny method for this that we call twice to avoid code duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the Idea but I think there is room for improvement. As we introduce new options in the API, I feel like these should be discussed first.
src/oemof/solph/_models.py
Outdated
@@ -45,7 +45,7 @@ class BaseModel(po.ConcreteModel): | |||
|
|||
Parameters | |||
---------- | |||
energysystem : EnergySystem object or list of EnergySystem objects | |||
energysystem : EnergySystem object or list of EnergySystem objects (experimental) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
energysystem : EnergySystem object or list of EnergySystem objects (experimental) | |
energysystem : EnergySystem object or (experimental) list of EnergySystem objects |
Maybe this way, to highlight that just the second option is experimental?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with that! It's easier to understand, indeed. I needed to shorten the line, so I deleted the of EnergySystem objects
after list
. It now reads energysystem : EnergySystem object or list (experimental)
and I would change it to energysystem : EnergySystem object or (experimental) list
. The explanation that the list needs to hold EnergySystem
objects moved into the text below.
Is that okay with you as well?
I apologize for the cumbersome discription.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. The line energysystem : EnergySystem object or (experimental) list
sounds reasonable. Maybe also add the keyword in the description, so it reads:
energysystem : EnergySystem object or (experimental) list
Object that holds the nodes of an oemof energy system graph.
Experimental: If a list is passed, the list needs to hold
EnergySystem objects and a cellular structure is assumed.
In this case, the first element needs to be the upmost energy cell
(structurally containing all other cells).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! The latest commit includes this change.
What it is about
I'm trying to enable the modelling (and subsequent optimization) of cellular grid structures in oemof-solph. The cellular grid is prominently supported/proposed by the VDE-ETG. It is similar to Multi-Microgrid structures, where the microgrids are allowed to exchange energy with each other, but in a cellular grid each cell can contain sub-cells, which can contain sub-cells themselves (and so on). So there are more "levels" possible than in a multi-microgrid structure.
As the structure of a multi-microgrid / low-level cellular grid offers itself to be disaggregated, I'd like to enable a method to solve the resulting problem in a distributed way (e.g. Dantzig-Wolfe). As of yet, this is not part of the pull request and I have little knowledge and no experience with distributed optimization.
What functionality does it implement?
The overall functionality is described above, but I will try and go into detail a little more by explaining the classes I added. The usage is also displayed in the new example called
cellular
.Model
Edit 2023-05-18: The model is now capable to handle cellular structures. Minor changes were necessary, mainly in the way how the
flows
andnodes
are collected from the energysystem. A dict can now be passed to theModel
-object under theenergysystem
keyword. This is the indication, that a cellular structure is to be optimized. Hint: There is still one large pyomo Model build for the whole cellular energy system. Not one per cell. This will change when and if I get the Dantzig-Wolfe reformulation working.Update 2023-06-22: As pointed out in the comments below, a
list
will be used instead of adict
to pass the cells to theModel
-class.Other comments and questions
oemof-network
and limited time on my hands. It might very well be, that there are simpler, better and more user-friendly ways to implement this. If you know them, I appreciate you pointing them out to me.Related Issues
I know that #840 was working on something similar, but to the best of my knowledge the development stopped.