Conversation
|
The approach looks reasonable to me. This is intended to replace |
Yes, that is correct. |
superwhiskers
left a comment
There was a problem hiding this comment.
overall design looks good. just some minor comments
|
Why not Also I have had more success with a basic cosim by interfacing across a Branch instead of a Bus, do we have a broader spec/plan for our cosim goals? |
Co-authored-by: superwhiskers <whiskerdev@protonmail.com>
These are not voltage/current dependant current/voltage sources. These simply convert variables to signals to communicate with other apps (GridKit-based or otherwise).
We need ports for the system to connect to other systems from external apps. A bus-like object seems more natural way to create such objects imho. See also discussion in #546. |
Description
Created bus-like objects in Phasor Dynamics module that convert currents and voltages to signals. This is needed for co-simulations where co-simulated objects communicate through signal connection with the co-simulation platform or with each other.
The assumption baked in these objects is that all co-simulated parts have completed their computations and updated their local voltage and current values (and pushed them to co-simulation platform, if connected in that way).
This is still draft, would appreciate feedback from reviewers before finalizing.
Closes #354
Proposed changes
Two new classes derived from
PhasorDynamics::BusBase, each in its own subdirectory underGridKit/Model/PhasorDynamics/Bus/and compiled into the existingphasor_dynamics_buslibrary:BusSignalVoltageOutkeeps the voltage components as its two algebraic variables and publishes them onSignalOutportsvrandvi.SignalInportsirandiiset its residualsf_[0]andf_[1]before other injection currents are summed into those two residuals. The Enzyme build adds unit Jacobian entries in the signal variable columns.BusSignalVoltageInis the mirror image. ItsVr()andVi()readSignalInportsvrandvidirectly by const reference, so the bus stores no voltage and never modifies it. The sums of current injections from attached components are published onSignalOutportsirandii. LikeBusInfinite, it contributes no unknowns or equations.Supporting changes:
BusData::BusTypegainsSIGNAL_VOLTAGE_OUTandSIGNAL_VOLTAGE_IN.SignalNode::read()andSignalIn::readSignal()return a const reference instead of a value. All existing callers copy or cast the result, so behavior is unchanged.Out of scope: the JSON parser,
BusFactoryandSystemModeldo not yet create these bus types, sinceBusDatahas no signal ID maps. The port structs already provide aconnect()taking enum-to-signal-ID maps for that follow-up.Checklist
-Wall -Wpedantic -Wconversion -Wextra.Further comments
I used minimalist approach as far as changing
Bus*classes goes. Specific suggestions how to refactor these will be discussed in separate issues. See also #462.BusSignalVoltageInhas zero size, so its residual vector is bound to an empty slice of system storage and cannot hold the current sums. They live in member variables thatIr()andIi()expose and that the outlet ports are linked to, which is the same arrangementBusInfiniteuses. The published sums are complete only after all attached components have evaluated their residuals, so consumers of those signals must be evaluated after them; this is documented in the header and README.BusBaserequires non-constVr()/Vi()returning a mutable reference, and components read buses through non-const pointers.BusSignalVoltageIndelegates those overloads to the const versions and documents that callers must not write through them. Making the voltage accessors truly read-only would require changingBusBaseand every component, which is deliberately left out of this PR.Verified on macOS with GCC (Enzyme off) and Clang 18 (Enzyme on); all 25 PhasorDynamics unit tests pass in both configurations.
🤖 Generated with Claude Code