Skip to content

Gen classical #94

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

Closed
wants to merge 100 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
2dfcb16
Added implementation for the order 2 classical generator
abdourahmanbarry Apr 12, 2025
e417b79
Remove ClassicalGen implementation from GENROUwS into ClassicalGenerator
abdourahmanbarry Apr 13, 2025
5d78001
separate declaration and implementation of ClassicalGen into header …
abdourahmanbarry Apr 13, 2025
0019731
Added Unit tests for the ClassicalGen
abdourahmanbarry Apr 13, 2025
ac37d97
Added an example using the classical generator and 2 buses
abdourahmanbarry Apr 13, 2025
88d3bd3
Added a README.md for the classical Generator model
abdourahmanbarry Apr 28, 2025
fa970e1
Added initialization for the classical generator
abdourahmanbarry Apr 28, 2025
e2cc9e7
Added a test case for the classical generator initialization
abdourahmanbarry Apr 28, 2025
3643a3d
Updated latex alignment in README.md
abdourahmanbarry Apr 28, 2025
271b1ea
Edited some comments
abdourahmanbarry May 2, 2025
4d465cc
Updated the initial test case with simplified values
abdourahmanbarry May 2, 2025
03571ec
Changed parameters and formating of the output file
abdourahmanbarry May 2, 2025
c8deb13
Added a new test case to verify the residual for the intializaton is…
abdourahmanbarry May 3, 2025
31bba3a
Added comments and tighten tolerance to machine epsilon
abdourahmanbarry May 3, 2025
471e5f1
Tighten tolerance
abdourahmanbarry May 3, 2025
ffb25b2
Renamed files and folder of Classical Generator to GenClassical, and …
abdourahmanbarry May 7, 2025
395f432
Changed authors and class names
abdourahmanbarry May 7, 2025
dd256e3
Moved 2-bus classical generator example into the PhasorDynamics folder
abdourahmanbarry May 7, 2025
d46f645
Configured cmake files, renamed test files and updated the class name…
abdourahmanbarry May 7, 2025
577ad78
Remove 2-bus classical generator example from examples folder
abdourahmanbarry May 7, 2025
7cab7fa
Apply pre-commmit fixes
abdourahmanbarry May 3, 2025
a2709e2
changed the admittance values to capital letters
abdourahmanbarry May 8, 2025
ef68b77
removed source files from include directives
abdourahmanbarry May 9, 2025
d693f85
updated example to use iostream for file writing
abdourahmanbarry May 9, 2025
8ecb853
Applied proper formating
abdourahmanbarry May 9, 2025
37c1fa5
Fix rebasing issues.
pelesh May 9, 2025
5abda6b
Apply pre-commmit fixes
pelesh May 9, 2025
b39da89
Updated cmake file and gen2 example
abdourahmanbarry May 9, 2025
da2e024
Apply pre-commmit fixes
abdourahmanbarry May 9, 2025
071a54b
Fixed a failing test
abdourahmanbarry May 12, 2025
51a2990
Apply pre-commmit fixes
abdourahmanbarry May 12, 2025
0e5d81f
restructured include directives
abdourahmanbarry May 12, 2025
e830e4b
updated classical gen2 example
abdourahmanbarry May 18, 2025
6863f9d
update classical gen2 example
abdourahmanbarry May 18, 2025
0776048
Replaced with initial working implementation
abdourahmanbarry May 19, 2025
484fc49
updated 2-bus classical gen example
abdourahmanbarry May 19, 2025
6840edf
Added new tests to replace magic numbers
abdourahmanbarry May 19, 2025
edba039
Merge branch 'Gen_classical' of github.com:ORNL/GridKit into Gen_clas…
abdourahmanbarry May 19, 2025
8e16e9e
Apply pre-commmit fixes
abdourahmanbarry May 19, 2025
23f742f
Resolved merge conflict
abdourahmanbarry May 19, 2025
b9c5834
Apply pre-commmit fixes
abdourahmanbarry May 19, 2025
fa4bee2
Deleted Gen2Example from examples folder
abdourahmanbarry May 19, 2025
bcf3520
Deleted old ClassicalGenerator folder
abdourahmanbarry May 19, 2025
1049f64
Merge branch 'Gen_classical' of github.com:ORNL/GridKit into Gen_clas…
abdourahmanbarry May 19, 2025
25484bf
Added compiler flags
abdourahmanbarry May 19, 2025
00e5964
Removed a print statement from tests
abdourahmanbarry May 19, 2025
52effbc
Update src/Model/PhasorDynamics/SynchronousMachine/GenClassical/GenCl…
shakedregev May 19, 2025
a0de789
distributed negative sign in current injection to bus
abdourahmanbarry May 20, 2025
0f89a35
Addressed magic number issues
abdourahmanbarry May 20, 2025
8b25192
Apply pre-commmit fixes
abdourahmanbarry May 20, 2025
2f6b44f
Added implementation for the order 2 classical generator
abdourahmanbarry Apr 12, 2025
4ebad04
Remove ClassicalGen implementation from GENROUwS into ClassicalGenerator
abdourahmanbarry Apr 13, 2025
ff8251a
separate declaration and implementation of ClassicalGen into header …
abdourahmanbarry Apr 13, 2025
44cd5c1
Added Unit tests for the ClassicalGen
abdourahmanbarry Apr 13, 2025
75b3da4
Added an example using the classical generator and 2 buses
abdourahmanbarry Apr 13, 2025
bef9041
Added a README.md for the classical Generator model
abdourahmanbarry Apr 28, 2025
adfb7f6
Added initialization for the classical generator
abdourahmanbarry Apr 28, 2025
9871434
Added a test case for the classical generator initialization
abdourahmanbarry Apr 28, 2025
5bf6dee
Updated latex alignment in README.md
abdourahmanbarry Apr 28, 2025
0a8681d
Edited some comments
abdourahmanbarry May 2, 2025
9835382
Updated the initial test case with simplified values
abdourahmanbarry May 2, 2025
8a0c775
Changed parameters and formating of the output file
abdourahmanbarry May 2, 2025
b07af44
Added a new test case to verify the residual for the intializaton is…
abdourahmanbarry May 3, 2025
2b5aa04
Added comments and tighten tolerance to machine epsilon
abdourahmanbarry May 3, 2025
522e557
Tighten tolerance
abdourahmanbarry May 3, 2025
6797dc1
Renamed files and folder of Classical Generator to GenClassical, and …
abdourahmanbarry May 7, 2025
8a1bca3
Changed authors and class names
abdourahmanbarry May 7, 2025
8f569e5
Moved 2-bus classical generator example into the PhasorDynamics folder
abdourahmanbarry May 7, 2025
f9a84db
Configured cmake files, renamed test files and updated the class name…
abdourahmanbarry May 7, 2025
aab7ccc
Remove 2-bus classical generator example from examples folder
abdourahmanbarry May 7, 2025
9a5efaf
Apply pre-commmit fixes
abdourahmanbarry May 3, 2025
d9db286
changed the admittance values to capital letters
abdourahmanbarry May 8, 2025
88871da
removed source files from include directives
abdourahmanbarry May 9, 2025
afca8b3
updated example to use iostream for file writing
abdourahmanbarry May 9, 2025
cbdcac0
Applied proper formating
abdourahmanbarry May 9, 2025
6e045d4
Fix rebasing issues.
pelesh May 9, 2025
b29b8a9
Apply pre-commmit fixes
pelesh May 9, 2025
d6b5328
Updated cmake file and gen2 example
abdourahmanbarry May 9, 2025
b17b3f4
Apply pre-commmit fixes
abdourahmanbarry May 9, 2025
81757ef
Fixed a failing test
abdourahmanbarry May 12, 2025
6ea4315
restructured include directives
abdourahmanbarry May 12, 2025
01ea575
updated classical gen2 example
abdourahmanbarry May 18, 2025
824b9a5
update classical gen2 example
abdourahmanbarry May 18, 2025
b7ad497
Replaced with initial working implementation
abdourahmanbarry May 19, 2025
86a2783
updated 2-bus classical gen example
abdourahmanbarry May 19, 2025
7c35b25
Added new tests to replace magic numbers
abdourahmanbarry May 19, 2025
fc4e69f
Apply pre-commmit fixes
abdourahmanbarry May 12, 2025
84009f3
Apply pre-commmit fixes
abdourahmanbarry May 19, 2025
b036d61
Resolved merge conflict
abdourahmanbarry May 19, 2025
dba60f7
Deleted Gen2Example from examples folder
abdourahmanbarry May 19, 2025
5f3fbc9
Deleted old ClassicalGenerator folder
abdourahmanbarry May 19, 2025
561dac3
Apply pre-commmit fixes
abdourahmanbarry May 19, 2025
30bbd8e
Added compiler flags
abdourahmanbarry May 19, 2025
381c907
Removed a print statement from tests
abdourahmanbarry May 19, 2025
49ccdac
Update src/Model/PhasorDynamics/SynchronousMachine/GenClassical/GenCl…
shakedregev May 19, 2025
b43923b
distributed negative sign in current injection to bus
abdourahmanbarry May 20, 2025
054368a
Addressed magic number issues
abdourahmanbarry May 20, 2025
b8ce536
Apply pre-commmit fixes
abdourahmanbarry May 20, 2025
4675a99
Merge branch 'Gen_classical' of github.com:ORNL/GridKit into Gen_clas…
abdourahmanbarry Jun 2, 2025
0bf9a57
Increased interval of integration in Gen2example
abdourahmanbarry Jun 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(PACKAGE_VERSION_PATCH "0")
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")

# TODO: Probably beter to set a debug interface target
# set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wpedantic -Wconversion -Wextra -O0 -g -DDEBUG")

set(CMAKE_CXX_STANDARD 17)

Expand Down
1 change: 1 addition & 0 deletions examples/PhasorDynamics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(Example1)
add_subdirectory(Example2)
add_subdirectory(Gen2Example)
10 changes: 10 additions & 0 deletions examples/PhasorDynamics/Gen2Example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add_executable(gen2_example example.cpp)
target_link_libraries(gen2_example
GRIDKIT::phasor_dynamics_bus
GRIDKIT::phasor_dynamics_bus_fault
GRIDKIT::phasor_dynamics_branch
GRIDKIT::phasor_dynamics_classical_gen
GRIDKIT::solvers_dyn)
install(TARGETS gen2_example RUNTIME DESTINATION bin)

add_test(NAME GenClassicalTest1 COMMAND $<TARGET_FILE:gen2_example>)
124 changes: 124 additions & 0 deletions examples/PhasorDynamics/Gen2Example/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <fstream>
#include <iostream>
#include <math.h>
#include <sstream>
#include <time.h>

#include "Model/PhasorDynamics/Branch/Branch.hpp"
#include "Model/PhasorDynamics/Bus/Bus.hpp"
#include "Model/PhasorDynamics/Bus/BusInfinite.hpp"
#include "Model/PhasorDynamics/BusFault/BusFault.hpp"
#include "Model/PhasorDynamics/Load/Load.hpp"
#include "Model/PhasorDynamics/SynchronousMachine/GenClassical/GenClassical.hpp"
#include "Model/PhasorDynamics/SystemModel.hpp"
#include "Solver/Dynamic/Ida.hpp"

#define _CRT_SECURE_NO_WARNINGS

int main(int argc, char* argv[])
{
using namespace GridKit::PhasorDynamics;
using namespace AnalysisManager::Sundials;

std::cout << "Example 1 version GENERATION 2" << std::endl;

// bus voltages
double vr = 1.0;
double vi = 0.0;

// branch parameters
double R = 0.0; // line series resistance
double X = 0.1; // line series reactance
double G = 0.0; // line shunt conductance
double B = 0.0; // line shunt charging

// Generator parameters
double p0 = 1.0; // real power output
double q0 = 0.05013; // reactive power output
double H = 3.0; // Initia constant
double D = 0.0; // Damping coefficient
double Ra = 0.0; // Winding resistance
double Xdp = 0.2; // Machine reactance parameter

SystemModel<double, size_t> sys;
Bus<double, size_t> bus1(vr, vi);
BusInfinite<double, size_t> bus2(vr, vi);
Branch<double, size_t> branch(&bus1, &bus2, R, X, G, B);
GenClassical<double, size_t> gen(&bus1, 1, p0, q0, H, D, Ra, Xdp);

/* Connect everything together */
sys.addBus(&bus1);
sys.addBus(&bus2);
sys.addComponent(&branch);
sys.addComponent(&gen);
sys.allocate();
sys.initialize();

std::vector<std::vector<double>> outputData;

// callback for outputting solution
auto output_cb = [&](double t)
{
std::vector<double> yval;

yval.push_back(t);
for (auto val : sys.y())
{
yval.push_back(val);
}

outputData.push_back(yval);
};

output_cb(0);

/* Set up simulation */
Ida<double, size_t> ida(&sys);
ida.configureSimulation();

/* Run simulation */
double start = static_cast<double>(clock());
ida.initializeSimulation(0.0, false);
size_t nout = 200;
ida.runSimulation(10.0, nout, output_cb);

// write solution to file if the user passes in a file name
if (argc >= 2)
{
std::ofstream outfile(argv[1]);

if (!outfile)
{
std::cout << "ERROR writing to output file!" << std::endl;
}

outfile << "t";
for (int i = 0; i < sys.size(); ++i)
{
outfile << ",Y[" + std::to_string(i) + "]";
}
outfile << "\n";

for (auto y_tstep : outputData)
{
outfile << y_tstep[0];
for (int i = 1; i < y_tstep.size(); i++)
{
outfile << "," << y_tstep[i];
}
outfile << "\n";
}

outfile.close();
}
else
{
std::cout << "To print the solution, add a file name(eg:./gen2_example output.csv)" << std::endl;
}

printf("Complete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC);

return 0;
}
1 change: 1 addition & 0 deletions src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# ]]

add_subdirectory(GENROUwS)
add_subdirectory(GenClassical)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gridkit_add_library(phasor_dynamics_classical_gen
SOURCES
GenClassical.cpp
OUTPUT_NAME
gridkit_phasor_dynamics_classical_gen)
Loading
Loading