Check, improve and document subcomponent handling
dinkelbachjan opened this issue · 4 comments
- Check that explicit subcomponent tasks are only defined when reasonable in terms of expected computational effort, otherwise let the subcomponent's pre- and poststep routines be handled by the supercomponent
- Every
SimPowerComp
has a vectormSubComponents
of subcomponents but most classes derived fromSimPowerComp
have their subcomponents as separate member variables, not utilizing this list.- Make use of
mSubComponents
to harmonize calling pre- and poststep routines, as for example shown here
- Make use of
- Document the different concepts of how to handle pre- and poststep routines of subcomponents
Classes which include subcomponents (changes in #141):
Class | Uses mSubComponents |
Pre- and Post-step called by parent? | Parent calls Pre- and Post-steps via mSubComponents ? |
Remarks |
---|---|---|---|---|
DP_Ph1_AvVoltageSourceInverterDQ | yes | yes | yes | - |
DP_Ph1_NetworkInjection | yes | yes | yes | - |
DP_Ph1_PiLine | yes | yes | yes | changed to utilize mSubComponents |
DP_Ph1_PQLoadCS | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
DP_Ph1_RxLine | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
DP_Ph1_RxLoad | yes | yes | yes | changed to utilize mSubComponents |
DP_Ph1_RxLoadSwitch | yes | yes | yes | changed to iterate over mSubComponents |
DP_Ph1_SVC | no | yes | no | Class is malformed, should not compile. Not making any changes... |
DP_Ph1_SynchronGeneratorIdeal | yes | yes | yes | changed to iterate over mSubComponents instead of only using comp. 0 |
DP_Ph1_SynchronGeneratorTrStab | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
DP_Ph1_Transformer | yes | yes | yes | - |
DP_Ph1_VoltageSourceRamp | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task. Also, why does this class exist at all? Can this not be handled by the normal VoltageSource + SignalGenerator? |
EMT_Ph1_VoltageSourceRamp | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task. Also, why does this class exist at all? Can this not be handled by the normal VoltageSource + SignalGenerator? |
EMT_Ph3_AvVoltageSourceInverterDQ | yes | yes | yes | - |
EMT_Ph3_NetworkInjection | yes | yes | yes | - |
EMT_Ph3_PiLine | yes | yes | yes | changed to utilize mSubComponents |
EMT_Ph3_RxLine | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
EMT_Ph3_RXLoad | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
EMT_Ph3_SynchronGeneratorIdeal | yes | yes | yes | changed to loop over all subcomponents |
EMT_Ph3_SynchronGeneratorTrStab | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
EMT_Ph3_Transformer | yes | yes | yes | - |
SP_Ph1_AvVoltageSourceInverterDQ | yes | yes | yes | - |
SP_Ph1_Load | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
SP_Ph1_NetworkInjection | yes | yes | yes | - |
SP_Ph1_PiLine | yes | yes | yes | changed to utilize mSubComponents |
SP_Ph1_RXLine | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
SP_Ph1_SolidStateTransformer | yes | has no tasks | has no tasks | changed to add subcomponents into list |
SP_Ph1_SynchronGeneratorTrStab | yes | yes | yes | changed to utilize mSubComponents and to call subtasks in parent task |
SP_Ph1_Transformer | yes | yes | yes | - |
In addition to the changes made in #141, I propose another way to further unify the behavior of components with subcomponents: By creating a shared superclass MNASimPowerComp that is derived from both SimPowerComp and MNAInterface, it becomes possible to extract the various MNA method calls on the subcomponents into this common superclass. This means that the parent components only register their subcomponents once (e. g. through addMNASubComponent
) and then only contain methods concerned with the MNA operations in the parent. The calls to the MNA methods of the child are handled by the superclass instead, drastically cutting down on the amount of duplicated code (especially the for (auto comp : mSubComponents)
loop) in the parent classes. The MNAPreStep
and MNAPostStep
classes contained in almost all parent components can also be merged into the common superclass. A first working example of this can be found in #144 (Comparison with #141 in subcomponents...unify-mna-subcomponents).
I would suggest that the new superclass is used only for components that are composed of subcomponents, e.g. PiLine
, while the simple components, e.g. Inductor
remain untouched. The new superclass could be explicitly called CompositePowerComp
. It handles the adding of subcomponents and the collection/arrangement of their mnaPreStep
and mnaPostStep
methods as you described. Any additional functionalities brought by the composite component class can be encapsulated in mnaParentPreStep
and mnaParentPostStep
, which are methods offered by CompositePowerComp
.
@m-mirz We are thinking of inserting a new class CompositePowerComp
as described above to unify the subcomponent handling. What do you think about that?