Refactor Microgrid Examples to Facilitate Code Reuse - #551
Refactor Microgrid Examples to Facilitate Code Reuse#551abdourahmanbarry wants to merge 8 commits into
Conversation
| * @note Components are dynamically allocated and their pointers are stored | ||
| * in the corresponding network component vectors. | ||
| */ | ||
| inline void buildScaleMicrogridNetwork(ScaleMicrogridNetwork& network) |
There was a problem hiding this comment.
A few thoughts:
-
This should be a method on
ScaleMicrogridNetwork, not a function. -
This should probably just be done in the constructor. I don't see any reason to construct a
ScaleMicrogridNetworkwithout calling this after. -
This should be implemented in an implementation file, not
inlinein a header file.
There was a problem hiding this comment.
Updated for 1 and 2. I do not think 3 is necessary.
There was a problem hiding this comment.
3 may be helpful to build a shared library for this and link to it. That would also help with the #include and remove the need for target_include_directories(something PRIVATE {CMAKE_CURRENT_SOURCE_DIR}/..).
There was a problem hiding this comment.
cc @alexander-novo @nkoukpaizan I have added it as a library and removed the target_include_directories(something PRIVATE {CMAKE_CURRENT_SOURCE_DIR}/..). Let me know if it is still necessary to split it into header and implementation file.
| * @note This function only assembles the network into the system model. It | ||
| * does not call PowerElectronicsModel::allocate(). | ||
| */ | ||
| inline void assembleSystem(ScaleMicrogridNetwork& network, GridKit::PowerElectronicsModel<real_type, index_type>& sys_model) |
There was a problem hiding this comment.
Similarly to above, this should be a method and implemented in an implementation file.
There was a problem hiding this comment.
I think having this in a header file should be fine.
bd0a1b9 to
e59d353
Compare
8b19f1b to
44e9da0
Compare
Description
In this pull request, we separated the construction of the microgrid network from the examples to improve code reuse.
This is the first of four stacked pull requests that split PR #492 into smaller, more manageable chunks.
Proposed changes
Two functions,
buildScaleMicrogridNetworkandassembleSystem, were introduced to build the microgrid network and add the components of the network toSystemPowerElectronicsModel, respectively. These functions are then used to replace the network construction and the system model assembly code in all examples. This helps facilitate code reuse as more examples rely on this model.Checklist
-Wall -Wpedantic -Wconversion -Wextra.