Skip to content

integrate co-simulation into phasor dynamics applications - #638

Open
superwhiskers wants to merge 1 commit into
sw/co-simulation-02from
sw/co-simulation-03
Open

superwhiskers wants to merge 1 commit into
sw/co-simulation-02from
sw/co-simulation-03

Conversation

@superwhiskers

Copy link
Copy Markdown
Collaborator

Description

integrates the co-simulation interface into the phasor dynamics applications

closes #469
closes #547

Proposed changes

  • add client/server modes to DynamicSimulation and ContingencyAnalysis
  • introduce simulation runners to coordinate events, interface solves, and
    monitor output
  • remove standalone co-simulation examples
  • add a partitioned ieee39 example
  • document co-simulation configuration and execution

Checklist

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • The CHANGELOG.md has been updated to reflect the changes. If this is a minor PR that is part of a larger fix already included in the file, state so.

@superwhiskers superwhiskers added this to the DataBroker Co-Sim milestone Nov 2, 2026
@superwhiskers superwhiskers self-assigned this Nov 2, 2026
@superwhiskers superwhiskers added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 2, 2026
@superwhiskers
superwhiskers added this pull request to stack #637 November 2, 2026 22:51
@read-the-docs-community

read-the-docs-community Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 GridKit | 🛠️ Build #35624037 | 📁 Comparing 9b4f0df against latest (9963c0d)

  🔍 Preview build  

100 files changed · + 46 added · ± 54 modified

+ Added

± Modified

@lukelowry lukelowry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial thoughts. I like the extraction of the application code

@@ -0,0 +1,167 @@
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this data go under examples/, for now, or atleast a subfolder of cases/PhasorDynamics/IEEE39/, since this seems specific to one possible co-simulation scenario

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. A README describing the example (and how the two split files relate to the full system) would also be helpful.

- add client/server modes to `DynamicSimulation` and `ContingencyAnalysis`
- introduce simulation runners to coordinate events, interface solves, and
  monitor output
- remove standalone co-simulation examples
- add a partitioned ieee39 example
- document co-simulation configuration and execution
@lukelowry

Copy link
Copy Markdown
Collaborator

I suppose it depends how this is intended to be consumed in other ORNL projects, but an alternative design could treat all DynamicSimulation instances as clients, and then we could have a non-participating observer acting as the server. Thoughts?

@pelesh

pelesh commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

I suppose it depends how this is intended to be consumed in other ORNL projects, but an alternative design could treat all DynamicSimulation instances as clients, and then we could have a non-participating observer acting as the server. Thoughts?

My understanding is that simulation instances are servers, delivering computation result per request of the cosim platform.

@hambrickjc, please chime in.

@pelesh pelesh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start!

A couple of requests to organize the code better:

  • In applications/PhasorDynamics directory create separate subdirectories for dynamic simulations, continegency analysis, cosimulations, and application utilities (code shared between all apps).
  • Have once class per file only.
  • Put utilities specific to an app in that app's directory.
  • Remove changes to Logger class as those appear to be only formatting changes. The "TODO" item there should be placed in an issue, not in the code.

Comment on lines +23 to +26
if(GRIDKIT_ENABLE_ZMQ)
target_link_libraries(DynamicSimulation PRIVATE GridKit::co_sim GridKit::solvers_steady)
target_link_libraries(ContingencyAnalysis PRIVATE GridKit::co_sim GridKit::solvers_steady)
endif()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a separate cosimulation application here? Conceptually, I don't think DynamicSimulation and ContingencyAnalysis themselves should link GridKit::co_sim and GridKit::solvers_steady.

@@ -0,0 +1,123 @@
#pragma once

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a header for the new files, with your name as the author and a short description of what the file does.

{
namespace PhasorDynamics
{
inline CoSim::RunResult runCoupledClientStudies(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some documentation for these functions would be helpful: what they do and how one will later use them.

Comment on lines +21 to +22
using NextCoupledStudy = std::function<std::optional<StudyData>()>;
using CompleteCoupledStudy = std::function<void(Testing::TestStatus)>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These alias names for std::function<> are not intuitive to me. I wouldn't be able to infer the type when NextCoupledStudy and CompleteCoupledStudy are later used. Some documentation would also help.

Comment on lines +15 to +18
```sh
sh /path/to/build/examples/PhasorDynamics/CoSimulation/run_cosim.sh \
--case ieee39
```

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we register in CMake to run these examples?

}

/// Parse command line options to a simulation application.
inline SimulationOptions parseSimulationOptions(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we supporting an input file as well, or only command line arguments? I prefer input files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simulation options should be specified in the *solver.json file. Command line options should override input file options.

@hambrickjc

Copy link
Copy Markdown
Collaborator

I suppose it depends how this is intended to be consumed in other ORNL projects, but an alternative design could treat all DynamicSimulation instances as clients, and then we could have a non-participating observer acting as the server. Thoughts?

My understanding is that simulation instances are servers, delivering computation result per request of the cosim platform.

@hambrickjc, please chime in.

I don't know that there's much of an established convention. For simple simulations, you might see more traditional client/server architectures. For more complex co-simulations, you might see a coordinator that manages everything and then the simulations instances are pub/sub. I would recommend staying as agnostic to the communication architecture as you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thoughts on how to design a generalized co-simulation Add a simple co-simulation example with GridKit apps operating as ZMQ client/server.

5 participants