Skip to content

Governor (GovernorTgov1) Source and Unit Test#151

Merged
pelesh merged 12 commits into
developfrom
lukel/phasor_tgov1_code_dev
Jun 25, 2025
Merged

Governor (GovernorTgov1) Source and Unit Test#151
pelesh merged 12 commits into
developfrom
lukel/phasor_tgov1_code_dev

Conversation

@lukelowry

@lukelowry lukelowry commented Jun 23, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR contains the following changes to implement the TGOV1 governor. The scope of this PR is limited to the unit-tests, cmake edits, TGOV1 data structure, and class implementation of TGOV1. Non-abstracted accessor functions are added to Genrou for proof of concept.

Proposed changes

  • Relevant Source Cmake files in PhasorDynamics source (and relevant sub folders)
  • Data structure for TGOV1, stored here as done in GENROU.
  • Source and header files for TGOV1
  • Declaration of speed and torque accessors in Genrou header
  • Definition of speed and torque accesses in Genrou source

For unit test:

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.

Further comments

Implementation style should be reviewed as this is the first code PR to GridKit.

Initial implementation had more abstraction, but it has since been removed as the scope became too large.

There are additional changes required to the Genrou class for a functional example to be obtained. Since that implementation is dependent on the changes in this PR, this should be performed once this PR is resolved.

@lukelowry lukelowry requested review from abirchfield and pelesh June 23, 2025 22:04
@lukelowry lukelowry self-assigned this Jun 23, 2025

@abirchfield abirchfield 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.

Two small comments, otherwise I think it is ready for merging. There is still more to do before this is usable in a complete simulation, but that is what the next PR will be for.

Comment thread src/Model/PhasorDynamics/Governor/GovernorTgov1/TurbineGov.cpp Outdated
Comment thread src/Model/PhasorDynamics/Governor/GovernorTgov1/TurbineGov.cpp Outdated
@lukelowry

lukelowry commented Jun 24, 2025

Copy link
Copy Markdown
Collaborator Author

Relevant changes made. Awaiting further review from @abirchfield and @pelesh.

@abirchfield abirchfield self-requested a review June 24, 2025 21:57
@pelesh

pelesh commented Jun 24, 2025

Copy link
Copy Markdown
Collaborator

The code does not build correctly:

[  7%] Linking CXX shared library libgridkit_phasor_dynamics_governortgov1.dylib
Undefined symbols for architecture x86_64:
  "GridKit::PhasorDynamics::Genrou<double, long>::getSpeed()", referenced from:
      GridKit::PhasorDynamics::Governor::Tgov1<double, long>::evaluateResidual() in Tgov1.cpp.o
  "GridKit::PhasorDynamics::Genrou<double, long>::getTorque()", referenced from:
      GridKit::PhasorDynamics::Governor::Tgov1<double, long>::initialize() in Tgov1.cpp.o
  "GridKit::PhasorDynamics::Genrou<double, unsigned long>::getSpeed()", referenced from:
      GridKit::PhasorDynamics::Governor::Tgov1<double, unsigned long>::evaluateResidual() in Tgov1.cpp.o
  "GridKit::PhasorDynamics::Genrou<double, unsigned long>::getTorque()", referenced from:
      GridKit::PhasorDynamics::Governor::Tgov1<double, unsigned long>::initialize() in Tgov1.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [src/Model/PhasorDynamics/Governor/Tgov1/libgridkit_phasor_dynamics_governortgov1.0.1.0.dylib] Error 1
make[1]: *** [src/Model/PhasorDynamics/Governor/Tgov1/CMakeFiles/phasor_dynamics_governortgov1_shared.dir/all] Error 2
make: *** [all] Error 2

The linking error is because Tgov1 uses pointer to a machine to access machine's methods. For this code to work, the Tgov1 object needs to be linked to any generator object it might be connected to. This is most likely unsustainable.

I see two possible paths forward:

  1. Implement machine base class and have Tgov1 interface with the base class rather than specific implementation. The base class would in that case need to anticipate any signal port that machine might need.
  2. Implement signal bus and have governors connect to machines through those. This is a more robust solution imho.

@lukelowry

Copy link
Copy Markdown
Collaborator Author

I will make a simple SignalBus class inheriting from BusBase as a starting point for the SignalBus framework.

@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.

Looks good! I fixed a build bug and some compiler warnings in #152. Please review and possibly merge to lukel/phasor_tgov1_code_dev branch.

I also left a couple of minor suggestions to consider.

Comment thread src/Model/PhasorDynamics/Governor/Tgov1/CMakeLists.txt
Comment thread src/Model/PhasorDynamics/Governor/Tgov1/Tgov1.cpp Outdated
Comment thread src/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp Outdated
Comment thread tests/UnitTests/PhasorDynamics/GovernorTgov1Tests.hpp
Comment thread src/Model/PhasorDynamics/Governor/Tgov1/Tgov1.cpp Outdated
lukelowry and others added 5 commits June 25, 2025 10:03
Co-authored-by: pelesh <peless@ornl.gov>
* Fix build bug and a compiler warnings.

* Apply pre-commmit fixes

* Apply pre-commmit fixes

---------

Co-authored-by: pelesh <pelesh@users.noreply.github.com>
Co-authored-by: lukelowry <lukelowry@users.noreply.github.com>
@lukelowry

Copy link
Copy Markdown
Collaborator Author

Build bug branch merged, and suggestions applied. No build errors on my end. Awaiting further review from @pelesh and @abirchfield . Once this is merged I will implement a SignalBus before other connected models (i.e., exciter) are implemented.

@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.

All outstanding items have been addressed.

@pelesh pelesh merged commit 1f74574 into develop Jun 25, 2025
4 checks passed
@lukelowry lukelowry deleted the lukel/phasor_tgov1_code_dev branch June 25, 2025 16:00
WiktoriaZielinskaORNL pushed a commit that referenced this pull request Jul 23, 2025
* governor model additions and cmake

* add: accessor functions for genrou speed and torque

* add: unit test files and cmake

* edit: Governor Namespace and floating point arithmetic fix


---------

Co-authored-by: pelesh <pelesh@users.noreply.github.com>
Co-authored-by: lukelowry <lukelowry@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants