Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working Example of Solving RLCircuit and Microgrid with Jacobians #1

Merged
merged 46 commits into from
May 3, 2024

Conversation

reid-g
Copy link
Collaborator

@reid-g reid-g commented Feb 26, 2024

  • Added Jacobian Composing
  • Added IDA solving with Jacobians using KLU
  • Added basic circuit components
    • Added resistor, capacitor, voltage source, and inductor
    • Residuals and jacobians for each
  • Added components for microgrid:
    • Added Microgrid DiscreteGenerate, line, load, and bus
    • Residuals and jacobians for each
  • Working examples with verifications

@reid-g reid-g added the enhancement New feature or request label Feb 26, 2024
@reid-g reid-g requested a review from pelesh February 26, 2024 22:42
@reid-g reid-g self-assigned this Feb 26, 2024
@pelesh
Copy link
Collaborator

pelesh commented Mar 11, 2024

The branch composer-dev fails to build due to apparent CMake bug. The build fails with a message:

ld: library 'suitesparseconfig' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Solver/Dynamic/libgridkit_solvers_dyn.0.0.7.dylib] Error 1
...

The library is there on the build line, but there are also flags like -lsuitesparseconfig, which are (1) duplicates and (2) don't have library path specified. Removing these flags manually fixes the local problem. Appropriate changes need to be made in the CMake functions. See verbose output on the linker line:

[ 60%] Linking CXX shared library libgridkit_solvers_dyn.dylib
cd /Users/55y/src/gridkit/build-clang/Solver/Dynamic && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/solvers_dyn_shared.dir/link.txt --verbose=1
/opt/local/bin/clang++ -Wall -O0 -g -DDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -dynamiclib -Wl,-headerpad_max_install_names -current_version 0.0.7 -o libgridkit_solvers_dyn.0.0.7.dylib -install_name @rpath/libgridkit_solvers_dyn.0.dylib CMakeFiles/solvers_dyn_obj_shared.dir/Ida.cpp.o  -lsuitesparseconfig -lklu -lamd -lcolamd /Users/55y/local/sundials-clang/lib/libsundials_nvecserial.6.1.1.dylib /Users/55y/local/sundials-clang/lib/libsundials_idas.5.1.1.dylib /Users/55y/local/sundials-clang/lib/libsundials_sunlinsolklu.4.1.1.dylib /Users/55y/local/sundials-clang/lib/libsundials_sunmatrixsparse.4.1.1.dylib /opt/local/lib/libklu.dylib /opt/local/lib/libamd.dylib /opt/local/lib/libcolamd.dylib /opt/local/lib/libbtf.dylib /opt/local/lib/libsuitesparseconfig.dylib 

Copy link
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

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

Need to fix build issue with SuiteSparse libraries.

@pelesh
Copy link
Collaborator

pelesh commented Mar 11, 2024

@balos1, it seems to me this issue is coming somewhere from SUNDIALS configuration. I am linking GridKit to SUNDIALS v6.1.1 on my Macbook.

Copy link
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

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

Great work and many helpful tests added to verify implementations.

There are a few things that need to be done before composer-dev branch is ready to merge:

  • The branch needs to be rebased with respect to develop.
  • Indentation in the code does not follow the GridKit coding style. I suggest fixing the indentation first, because this will make rebasing easier.
  • Bug in CMake that affects linking to KLU needs fixing.
  • Adjoint sensitivity test fails. Needs investigating.
  • Might be good to rename classes named "discrete generator" to "distributed generator".
  • It seems that finding Ipopt is broken in this branch. Needs fixing.

@pelesh
Copy link
Collaborator

pelesh commented Mar 12, 2024

@balos1, it seems to me this issue is coming somewhere from SUNDIALS configuration. I am linking GridKit to SUNDIALS v6.1.1 on my Macbook.

I stand corrected, this issue originates in GridKit. See above.

pelesh and others added 12 commits March 12, 2024 13:15
Parse load data from the input file.

Check load data when testing Matpower parser.

Do not store load data in bus data structure.

Changed names and order of template parameters in power system data structures.

More intuitieve data structures names

Changed names of data structures to distinguish Matpower specific
data and general power system description data.

Pass correct scalar and real types to derived bus classes.

Add generator base and slack classes.

Classes compile correctly, not tested yet.

Infrastructure for adding buses and generators to power flow models

Add steady-state generator models and factory. Constructors now read
directly from GenData and BusData structures. Updated Bus classes
accordingly. Usage example provided in Grid3BusSys app.

Supporting infrastructure for Loads and Branches

Expanded methods for adding components to the power system grid. Includes
new constructors for loads and branches, as well as methods for accessing
buses through their IDs.

Updated Parsing Example

Fixed Memory Errors in KinSol and SystemSteadyStateModel

+Clean valgrind output

Prototype Example of Creating a RL Circuit

+Add hypergraph representation
+Added Model form with appropiate indexing
+Added Resistors, Capacitor, Inductor, and VoltageSource Component Models

Add capability to build power flow models from Matpower input files

Use more realistic test passing criterion

Release 0.0.7 updates
+Added InductionMotor, Linear Transformer, and SynchronousMachine
+Changes to PowerElectronicsModel
+ Basic COO Sparse Matrix Implmentation
+ Discrete Generator Component
+ Resistor Jacobian
+ Capacitor Jacobian
+ Voltage Source Jacobian
+ Inductor Jacobian
+ Testing for Sparse Jacobian and Discrete Generator
…rices

+Matrix Assembly
+Refactored COO Matrix
+COO can return CSR Data format
+ Cmake configurations for Sundials and SuiteSparse
+ Jacobian Assembly for components
+ Working RL Circuit example utilizing assembly techniques
 - Added MicrogridBusDQ
 - Added MicrogridLine
 - Added MicrogridLoad
 - Updated DiscreteGenerator
 - Added Output Testing for DG
 - Added Microgrid Assmebly Example
 - Updated Capacitor, Inductor, and Voltage residuals
 - Updated RLCircuit Example
 - "grounded" the rotor difference in reference
 - Comparing agianst reference from MATLAB
 - Updated name of generator
 - Some formatting updates
@pelesh pelesh mentioned this pull request Apr 9, 2024
@pelesh pelesh mentioned this pull request Apr 9, 2024
* Merge Ida Fix

* Fixed Whitespace Editor Changes

* Tabs to Spaces Ida.cpp
reid-g and others added 19 commits April 10, 2024 15:52
+ Basic COO Sparse Matrix Implmentation
+ Discrete Generator Component
+ Resistor Jacobian
+ Capacitor Jacobian
+ Voltage Source Jacobian
+ Inductor Jacobian
+ Testing for Sparse Jacobian and Discrete Generator
…rices

+Matrix Assembly
+Refactored COO Matrix
+COO can return CSR Data format
+ Cmake configurations for Sundials and SuiteSparse
+ Jacobian Assembly for components
+ Working RL Circuit example utilizing assembly techniques
 - Added MicrogridBusDQ
 - Added MicrogridLine
 - Added MicrogridLoad
 - Updated DiscreteGenerator
 - Added Output Testing for DG
 - Added Microgrid Assmebly Example
 - Updated Capacitor, Inductor, and Voltage residuals
 - Updated RLCircuit Example
 - "grounded" the rotor difference in reference
 - Comparing agianst reference from MATLAB
 - Updated name of generator
 - Some formatting updates
 - Fixed SpMatTest
 - Updates on rebase
* Merge Ida Fix

* Fixed Whitespace Editor Changes

* Tabs to Spaces Ida.cpp
 - Update format
 - Fixed casting warnings
Copy link
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

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

This is partial review flagging some minor issues in the code just to move them out of way. A more detailed code review is needed to check models.

reid-g added 3 commits April 16, 2024 16:17
 - Updated Comments to respect current models
 - Fixed valgrind errors in ida.cpp. Note: there is still more but seg faults are happening from frees
 - Removed this-> with usings for formatting
 - Added using for Jac to components which did not have
Copy link
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

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

Major issues addressed, all tests pass.

@pelesh pelesh merged commit 753aecc into develop May 3, 2024
@pelesh pelesh deleted the composer-dev branch March 14, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants