From 6a2dbfed9bdaf6356d3a493b70f479bc1ccf8cf8 Mon Sep 17 00:00:00 2001 From: abirchfield Date: Tue, 11 Mar 2025 11:38:57 -0500 Subject: [PATCH 01/21] Initial working version of example1 --- examples/CMakeLists.txt | 2 + examples/PhasorDynamics/CMakeLists.txt | 1 + .../PhasorDynamics/Example1/CMakeLists.txt | 9 + examples/PhasorDynamics/Example1/example1.cpp | 60 ++++ examples/PhasorDynamics/Example1/example1.hpp | 30 ++ .../PhasorDynamics/BusFault/BusFault.cpp | 1 + .../PhasorDynamics/BusFault/BusFault.hpp | 113 +++++++ .../PhasorDynamics/BusFault/CMakeLists.txt | 5 + .../SynchronousMachine/CMakeLists.txt | 2 + .../GENROUwS/CMakeLists.txt | 5 + .../SynchronousMachine/GENROUwS/GENROU.cpp | 1 + .../SynchronousMachine/GENROUwS/GENROU.hpp | 317 ++++++++++++++++++ src/Solver/Dynamic/Ida.cpp | 49 ++- src/Solver/Dynamic/Ida.hpp | 15 +- 14 files changed, 608 insertions(+), 2 deletions(-) create mode 100644 examples/PhasorDynamics/CMakeLists.txt create mode 100644 examples/PhasorDynamics/Example1/CMakeLists.txt create mode 100644 examples/PhasorDynamics/Example1/example1.cpp create mode 100644 examples/PhasorDynamics/Example1/example1.hpp create mode 100644 src/Model/PhasorDynamics/BusFault/BusFault.cpp create mode 100644 src/Model/PhasorDynamics/BusFault/BusFault.hpp create mode 100644 src/Model/PhasorDynamics/BusFault/CMakeLists.txt create mode 100644 src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt create mode 100644 src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp create mode 100644 src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 85096b798..6c867ea0d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,3 +24,5 @@ endif() if(GRIDKIT_ENABLE_ENZYME) add_subdirectory(Enzyme) endif() + +add_subdirectory(PhasorDynamics) \ No newline at end of file diff --git a/examples/PhasorDynamics/CMakeLists.txt b/examples/PhasorDynamics/CMakeLists.txt new file mode 100644 index 000000000..5d4417987 --- /dev/null +++ b/examples/PhasorDynamics/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Example1) \ No newline at end of file diff --git a/examples/PhasorDynamics/Example1/CMakeLists.txt b/examples/PhasorDynamics/Example1/CMakeLists.txt new file mode 100644 index 000000000..78d3b018e --- /dev/null +++ b/examples/PhasorDynamics/Example1/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(phasordynamics_example1 example1.cpp) +target_link_libraries(phasordynamics_example1 + GRIDKIT::bus + SUNDIALS::sunlinsolklu + SUNDIALS::core + SUNDIALS::ida + SUNDIALS::idas + SUNDIALS::sunmatrixdense) +install(TARGETS phasordynamics_example1 RUNTIME DESTINATION bin) diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp new file mode 100644 index 000000000..976f03f33 --- /dev/null +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -0,0 +1,60 @@ +#include "example1.hpp" + +#define _CRT_SECURE_NO_WARNINGS + +using namespace GridKit::PhasorDynamics; +using namespace AnalysisManager::Sundials; + +int main() +{ + printf("Example 1 version 2\n"); + + /* Create model parts */ + SystemModel sys; + Bus bus1(0.9949877346411762, 0.09999703952427966); + BusInfinite bus2(1.0, 0.0); + Branch branch(&bus1, &bus2, 0, 0.1, 0, 0); + BusFault fault(&bus1, 0, 1e-3, 0); + GENROU gen(&bus1, 1, 1, 0.05013, 3, 0, 0, 7, .04, .05, .75, 2.1, 0.2, 0.18, + 0.5, 0.5, 0.18, 0.15, 0, 0); + + /* Connect everything together */ + sys.addBus(&bus1); + sys.addBus(&bus2); + sys.addComponent(&branch); + sys.addComponent(&fault); + sys.addComponent(&gen); + sys.allocate(); + + double dt = 1.0/4.0/60.0; + + /* Output file header */ + FILE *f = fopen("example1_v2_results.csv", "w"); + if (!f) printf("ERROR writing to output file!\n"); + fprintf(f, "%s,%s", "t", "IDA Return Value"); + for (int i = 0; i < sys.size(); ++i) fprintf(f, ",Y[%d]", i); + for (int i = 0; i < sys.size(); ++i) fprintf(f, ",Yp[%d]", i); + fprintf(f, "\n"); + + /* Set up simulation */ + Ida ida(&sys); + ida.configureSimulation(); + + /* Run simulation */ + double start = (double) clock(); + ida.printOutputF(0, 0, f); + ida.initializeSimulation(0, false); + ida.runSimulationFixed(0, dt, 1, f); + fault.setStatus(1); + ida.initializeSimulation(1, false); + ida.runSimulationFixed(1, dt, 1.1, f); + fault.setStatus(0); + ida.initializeSimulation(1.1, false); + ida.runSimulationFixed(1.1, dt, 30, f); + + printf("Complete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC); + fclose(f); + + return 0; + +} \ No newline at end of file diff --git a/examples/PhasorDynamics/Example1/example1.hpp b/examples/PhasorDynamics/Example1/example1.hpp new file mode 100644 index 000000000..836c729fe --- /dev/null +++ b/examples/PhasorDynamics/Example1/example1.hpp @@ -0,0 +1,30 @@ +#include +#define _USE_MATH_DEFINES +#include +#include + +//#include +#include +#include +#include +#include +#include + +#include "Model/PhasorDynamics/SystemModel.hpp" +#include "Model/PhasorDynamics/Bus/Bus.hpp" +#include "Model/PhasorDynamics/Bus/BusInfinite.hpp" +#include "Model/PhasorDynamics/Branch/Branch.hpp" +#include "Model/PhasorDynamics/BusFault/BusFault.hpp" +#include "Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp" + + +#include "Solver/Dynamic/Ida.hpp" + +#include "Model/PhasorDynamics/Bus/Bus.cpp" +#include "Model/PhasorDynamics/Bus/BusInfinite.cpp" +#include "Model/PhasorDynamics/Branch/Branch.cpp" +#include "Solver/Dynamic/Ida.cpp" + + + +int main(); diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.cpp b/src/Model/PhasorDynamics/BusFault/BusFault.cpp new file mode 100644 index 000000000..42b70b455 --- /dev/null +++ b/src/Model/PhasorDynamics/BusFault/BusFault.cpp @@ -0,0 +1 @@ +#include "BusFault.hpp" \ No newline at end of file diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.hpp b/src/Model/PhasorDynamics/BusFault/BusFault.hpp new file mode 100644 index 000000000..9ee2cc98b --- /dev/null +++ b/src/Model/PhasorDynamics/BusFault/BusFault.hpp @@ -0,0 +1,113 @@ +/* Bus Fault Component - Adam Birchfield */ +#pragma once + +#include +#include + +namespace GridKit +{ +namespace PhasorDynamics +{ + using ComponentT = Component; + using BaseBusT = BusBase; + + class BusFault : public ComponentT + { + using ComponentT::size_; + using ComponentT::nnz_; + using ComponentT::time_; + using ComponentT::alpha_; + using ComponentT::y_; + using ComponentT::yp_; + using ComponentT::tag_; + using ComponentT::f_; + using ComponentT::g_; + using ComponentT::yB_; + using ComponentT::ypB_; + using ComponentT::fB_; + using ComponentT::gB_; + using ComponentT::param_; + + + public: + BusFault(BaseBusT* bus) : bus_(bus), R_(0), X_(0.01), + status_(0), busID_(0) + { + size_ = 0; + } + + BusFault(BaseBusT* bus, double R, double X, int status) : + bus_(bus), R_(R), X_(X), status_(status), busID_(0) + { + size_ = 0; + } + + ~BusFault() { } + + int allocate() override { return 0; } + + int initialize() override { return 0; } + + int tagDifferentiable() override { return 0; } + + int evaluateResidual() override + { + if (status_) + { + double B = -X_ / (X_*X_ + R_*R_); + double G = R_ / (X_*X_ + R_*R_); + Ir() += -Vr()*G + Vi()*B; + Ii() += -Vr()*B - Vi()*G; + } + return 0; + } + + int evaluateJacobian() override { return 0; } + + + int evaluateIntegrand() override { return 0; } + int initializeAdjoint() override { return 0; } + int evaluateAdjointResidual() override { return 0; } + int evaluateAdjointIntegrand() override { return 0; } + + void updateTime(double t, double a) override { } + + public: + void setR(double R) { R_ = R; } + + void setX(double X) { X_ = X; } + + void setStatus(int status) { status_ = status; } + + + private: + double& Vr() + { + return bus_->Vr(); + } + + double& Vi() + { + return bus_->Vi(); + } + + double& Ir() + { + return bus_->Ir(); + } + + double& Ii() + { + return bus_->Ii(); + } + + private: + BaseBusT* bus_; + double R_; + double X_; + int status_; + const int busID_; + }; + +} +} diff --git a/src/Model/PhasorDynamics/BusFault/CMakeLists.txt b/src/Model/PhasorDynamics/BusFault/CMakeLists.txt new file mode 100644 index 000000000..c78284ee8 --- /dev/null +++ b/src/Model/PhasorDynamics/BusFault/CMakeLists.txt @@ -0,0 +1,5 @@ +gridkit_add_library(phasor_dynamics_BusFault + SOURCES + BusFault.cpp + OUTPUT_NAME + gridkit_phasor_dynamics_BusFault) \ No newline at end of file diff --git a/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt b/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt index f8239be47..07667d325 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt +++ b/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt @@ -10,3 +10,5 @@ gridkit_add_library(phasor_dynamics_synchronous_machine SynchronousMachine.cpp OUTPUT_NAME gridkit_phasor_dynamics_synchronous_machine) + +add_subdirectory(GENROUwS) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt new file mode 100644 index 000000000..fbe3da175 --- /dev/null +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt @@ -0,0 +1,5 @@ +gridkit_add_library(phasor_dynamics_GENROU + SOURCES + GENROU.cpp + OUTPUT_NAME + gridkit_phasor_dynamics_GENROU) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp new file mode 100644 index 000000000..f4e56babf --- /dev/null +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp @@ -0,0 +1 @@ +#include "GENROU.hpp" \ No newline at end of file diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp new file mode 100644 index 000000000..4dcdc942f --- /dev/null +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp @@ -0,0 +1,317 @@ +/* GENROU Component - Adam Birchfield */ +#pragma once + +#define _USE_MATH_DEFINES +#include +#include + +namespace GridKit +{ +namespace PhasorDynamics +{ + using ComponentT = Component; + using BaseBusT = BusBase; + + class GENROU : public ComponentT + { + using ComponentT::size_; + using ComponentT::nnz_; + using ComponentT::time_; + using ComponentT::alpha_; + using ComponentT::y_; + using ComponentT::yp_; + using ComponentT::tag_; + using ComponentT::f_; + using ComponentT::g_; + using ComponentT::yB_; + using ComponentT::ypB_; + using ComponentT::fB_; + using ComponentT::gB_; + using ComponentT::param_; + + + public: + + GENROU(BaseBusT* bus, int unit_id) : bus_(bus), unit_id_(unit_id), + p0_(0), q0_(0), busID_(0), H_(3), D_(0), Ra_(0), Tdop_(7), + Tdopp_(.04), Tqopp_(.05), Tqop_(.75), Xd_(2.1), Xdp_(0.2), + Xdpp_(0.18), Xq_(.5), Xqp_(.5), Xqpp_(.18), Xl_(.15), + S10_(0), S12_(0) + { + size_ = 21; + set_derived_params(); + } + + GENROU(BaseBusT* bus, int unit_id, double p0, double q0, double H, + double D, double Ra, double Tdop, double Tdopp, double Tqopp, + double Tqop, double Xd, double Xdp, double Xdpp, double Xq, + double Xqp, double Xqpp, double Xl, double S10, double S12) : + bus_(bus), unit_id_(unit_id), p0_(p0), q0_(q0), busID_(0), H_(H), + D_(D), Ra_(Ra), Tdop_(Tdop), Tdopp_(Tdopp), Tqopp_(Tqopp), + Tqop_(Tqop), Xd_(Xd), Xdp_(Xdp), Xdpp_(Xdpp), Xq_(Xq), Xqp_(Xqp), + Xqpp_(Xqpp), Xl_(Xl), S10_(S10), S12_(S12) + { + size_ = 21; + set_derived_params(); + } + + void set_derived_params() + { + SA_ = 0; + SB_ = 0; + if (S12_ != 0) + { + double s112 = sqrt(S10_ / S12_); + SA_ = (1.2*s112 + 1) / (s112 + 1); + SB_ = (1.2*s112 - 1) / (s112 - 1); + if (SB_ < SA_) SA_ = SB_; + SB_ = S12_ / pow(SA_ - 1.2, 2); + } + Xd1_ = Xd_ - Xdp_; + Xd2_ = Xdp_ - Xl_; + Xd3_ = (Xdp_ - Xdpp_) / (Xd2_ * Xd2_); + Xd4_ = (Xdp_ - Xdpp_) / Xd2_; + Xd5_ = (Xdpp_ - Xl_) / Xd2_; + Xq1_ = Xq_ - Xqp_; + Xq2_ = Xqp_ - Xl_; + Xq3_ = (Xqp_ - Xqpp_) / (Xq2_ * Xq2_); + Xq4_ = (Xqp_ - Xqpp_) / Xq2_; + Xq5_ = (Xqpp_ - Xl_) / Xq2_; + Xqd_ = (Xq_ - Xl_) / (Xd_ - Xl_); + G_ = Ra_ / (Ra_*Ra_ + Xqpp_*Xqpp_); + B_ = -Xqpp_ / (Ra_*Ra_ + Xqpp_*Xqpp_); + + } + + ~GENROU() { } + + int allocate() override + { + f_.resize(size_); + y_.resize(size_); + yp_.resize(size_); + tag_.resize(size_); + fB_.resize(size_); + yB_.resize(size_); + ypB_.resize(size_); + return 0; + } + + int initialize() override + { + double delta, omega, Eqp, psidp, psiqp, Edp, psiqpp, psidpp, psipp, + vd, vq, id, iq, ir, ii, Te, g, b, ksat; + + /* Initialization tricks -- assuming NO saturation */ + double vr, vi, p, q, vm2, Er, Ei; + vr = Vr(); + vi = Vi(); + p = p0_; + q = q0_; + vm2 = vr*vr + vi*vi; + Er = vr + (Ra_*p*vr + Ra_*q*vi - Xq_*p*vi + Xq_*q*vr) / vm2; + Ei = vi + (Ra_*p*vi - Ra_*q*vr + Xq_*p*vr + Xq_*q*vi) / vm2; + delta = atan2(Ei, Er); + omega = 0; + ir = (p*vr + q*vi) / vm2; + ii = (p*vi - q*vr) / vm2; + id = ir*sin(delta) -ii*cos(delta); + iq = ir*cos(delta) +ii*sin(delta); + vd = vr*sin(delta) - vi*cos(delta) + id*Ra_ - iq*Xqpp_; + vq = vr*cos(delta) + vi*sin(delta) + id*Xqpp_ - iq*Ra_; + psiqpp = -vd / (1 + omega); + psidpp = vq / (1 + omega); + Te = (psidpp - id*Xdpp_)*iq - (psiqpp - iq*Xdpp_)*id; + psiqp = -(-(Xqp_-Xl_)*iq+psiqpp*(Xqp_-Xl_)/(Xqpp_-Xl_)) + /(1+(Xqp_-Xqpp_)/(Xqpp_-Xl_)); + Edp = psiqp - (Xqp_ - Xl_) * iq; + psidp = -((Xdp_-Xl_)*id-psidpp*(Xdp_-Xl_)/(Xdpp_-Xl_)) + /(1+(Xdp_-Xdpp_)/(Xdpp_-Xl_)); + Eqp = psidp + (Xdp_ - Xl_) * id; + + /* Now we have the state variables, solve for alg. variables */ + + y_[0] = delta; //= 0.55399038; + y_[1] = omega; // = 0; + y_[2] = Eqp; // = 0.995472581; + y_[3] = psidp; // = 0.971299567; + y_[4] = psiqp; // = 0.306880069; + y_[5] = Edp; // = 0; + + y_[6] = psiqpp = -psiqp*Xq4_ - Edp*Xq5_; + y_[7] = psidpp = psidp*Xd4_ + Eqp*Xd5_; + y_[8] = psipp = sqrt(psiqpp*psiqpp + psidpp*psidpp); + y_[9] = ksat = SB_*pow(psipp - SA_, 2); + y_[10] = vd = -psiqpp*(1 + omega); + y_[11] = vq = psidpp*(1 + omega); + y_[12] = Te = (psidpp - id*Xdpp_)*iq - (psiqpp - iq*Xdpp_)*id; + y_[13] = id; + y_[14] = iq; + y_[15] = ir; + y_[16] = ii; + y_[17] = pmech_set_ = Te; + y_[18] = efd_set_ = Eqp + Xd1_*(id + + Xd3_*(Eqp - psidp - Xd2_*id)) + psidpp*ksat; + y_[19] = G_*(vd*sin(delta)+vq*cos(delta)) + - B_*(vd*-cos(delta) + vq*sin(delta)); /* inort, real */; + y_[20] = B_*(vd*sin(delta)+vq*cos(delta)) + + G_*(vd*-cos(delta) + vq*sin(delta)); /* inort, imag */ + + for (int i = 0; i < size_; ++i) yp_[i] = 0.0; + return 0; + } + + int tagDifferentiable() override + { + for (int i = 0; i < size_; ++i) + { + tag_[i] = i < 6; + } + return 0; + } + + int evaluateResidual() override + { + double delta, omega, Eqp, psidp, psiqp, Edp, psiqpp, psidpp, psipp, + ksat, vd, vq, telec, id, iq, ir, ii, pmech, efd, inr, ini, vr, + vi, vr_inf, vi_inf, delta_dot, omega_dot, Eqp_dot, psidp_dot, + psiqp_dot, Edp_dot; + + /* Read variables */ + delta = y_[0]; + omega = y_[1]; + Eqp = y_[2]; + psidp = y_[3]; + psiqp = y_[4]; + Edp = y_[5]; + psiqpp = y_[6]; + psidpp = y_[7]; + psipp = y_[8]; + ksat = y_[9]; + vd = y_[10]; + vq = y_[11]; + telec = y_[12]; + id = y_[13]; + iq = y_[14]; + ir = y_[15]; + ii = y_[16]; + pmech = y_[17]; + efd = y_[18]; + inr = y_[19]; + ini = y_[20]; + vr = Vr(); + vi = Vi(); + + /* Read derivatives */ + delta_dot = yp_[0]; + omega_dot = yp_[1]; + Eqp_dot = yp_[2]; + psidp_dot = yp_[3]; + psiqp_dot = yp_[4]; + Edp_dot = yp_[5]; + + /* 6 GENROU differential equations */ + f_[0] = delta_dot - omega*(2*M_PI*60); + f_[1] = omega_dot - (1/(2*H_)) * ((pmech - D_*omega) / (1 + omega) + - telec); + f_[2] = Eqp_dot - (1/Tdop_) * (efd - (Eqp + Xd1_*(id + Xd3_*(Eqp + - psidp - Xd2_*id)) + psidpp*ksat )); + f_[3] = psidp_dot - (1/Tdopp_) * (Eqp - psidp - Xd2_*id); + f_[4] = psiqp_dot - (1/Tqopp_) * (Edp - psiqp + Xq2_*iq); + f_[5] = Edp_dot - (1/Tqop_) * (-Edp + Xqd_*psiqpp*ksat + + Xq1_*(iq - Xq3_*(Edp + iq*Xq2_ - psiqp))); + + /* 11 GENROU algebraic equations */ + f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); + f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); + f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); + f_[9] = ksat - SB_*pow(psipp - SA_, 2.0); + f_[10] = vd + psiqpp * (1 + omega); + f_[11] = vq - psidpp * (1 + omega); + f_[12] = telec - ((psidpp - id*Xdpp_)*iq - (psiqpp - iq*Xdpp_)*id); + f_[13] = id - (ir*sin(delta) - ii*cos(delta)); + f_[14] = iq - (ir*cos(delta) + ii*sin(delta)); + f_[15] = ir + G_*vr - B_*vi - inr; + f_[16] = ii + B_*vr + G_*vi - ini; + + /* 2 GENROU control inputs are set to constant for this example */ + f_[17] = pmech - pmech_set_; + f_[18] = efd - efd_set_; + + /* 2 GENROU current source definitions */ + f_[19] = inr - (G_*(sin(delta)*vd + cos(delta)*vq) + - B_*(-cos(delta)*vd + sin(delta)*vq)); + f_[20] = ini - (B_*(sin(delta)*vd + cos(delta)*vq) + + G_*(-cos(delta)*vd + sin(delta)*vq)); + + /* Current balance */ + Ir() += inr - Vr()*G_ + Vi()*B_; + Ii() += ini - Vr()*B_ - Vi()*G_; + + //printf("GENROU residual\n"); + //for (int i = 0 ; i < 21; ++i) printf("%d: %g\n", i, f_[i]); + + //printf("GENROU inr %g Vr %g B %g Vi %g G %g\n", inr, Vr(), B_, Vi(), G_); + //printf("GENROU Ii = %g\n", inr - Vr()*B_ - Vi()*G_); + + return 0; + } + + int evaluateJacobian() override + { + /* TODO */ + return 0; + } + + /* Don't know what to do with any of these */ + int evaluateIntegrand() override { return 0; } + int initializeAdjoint() override { return 0; } + int evaluateAdjointResidual() override { return 0; } + int evaluateAdjointIntegrand() override { return 0; } + void updateTime(double t, double a) override { } + + private: + double& Vr() + { + return bus_->Vr(); + } + + double& Vi() + { + return bus_->Vi(); + } + + double& Ir() + { + return bus_->Ir(); + } + + double& Ii() + { + return bus_->Ii(); + } + + private: + + /* Identification */ + BaseBusT* bus_; + const int busID_; + int unit_id_; + + /* Initial terminal conditions */ + double p0_, q0_; + + /* Input parameters */ + double H_, D_, Ra_, Tdop_, Tdopp_, Tqopp_, Tqop_, Xd_, Xdp_, Xdpp_, + Xq_, Xqp_, Xqpp_, Xl_, S10_, S12_; + + /* Derivied parameters */ + double SA_, SB_, Xd1_, Xd2_, Xd3_, Xd4_, Xd5_, Xq1_, Xq2_, Xq3_, Xq4_, + Xq5_, Xqd_, G_, B_; + + /* Setpoints for control variables (determined at initialization) */ + double pmech_set_, efd_set_; + }; + +} +} diff --git a/src/Solver/Dynamic/Ida.cpp b/src/Solver/Dynamic/Ida.cpp index 456c4dcb1..7d68b9457 100644 --- a/src/Solver/Dynamic/Ida.cpp +++ b/src/Solver/Dynamic/Ida.cpp @@ -75,7 +75,7 @@ namespace AnalysisManager // Create vectors to store restart initial condition yy0_ = N_VClone(yy_); checkAllocation((void*) yy0_, "N_VClone"); - yp0_ = N_VClone(yy_); + yp0_ = N_VClone(yp_); checkAllocation((void*) yp0_, "N_VClone"); // Dummy initial time; will be overridden. @@ -205,6 +205,36 @@ namespace AnalysisManager return retval; } + template + int Ida::runSimulationFixed(real_type t0, real_type dt, + real_type tmax, FILE *f) + { + int retval = 0; + int iout = 0; + real_type t, tret; + + //printOutputF(t0, 0, f); + for (t = t0+dt; t < tmax; t += dt) + { + retval = IDASolve(solver_, t, &tret, yy_, yp_, IDA_NORMAL); + checkOutput(retval, "IDASolve"); + printOutputF(t, retval, f); + + if (retval != IDA_SUCCESS) + { + printf("IDA Failure! %dn", retval); + break; + } + } + + model_->updateTime(t, 0.0); + copyVec(yy_, model_->y()); + copyVec(yp_, model_->yp()); + + return retval; + } + + template int Ida::runSimulation(real_type tf, int nout) { @@ -651,6 +681,23 @@ namespace AnalysisManager } } + void Ida::printOutputF(sunrealtype t, int res, FILE *f) + { + sunrealtype *yval = N_VGetArrayPointer_Serial(yy_); + sunrealtype *ypval = N_VGetArrayPointer_Serial(yp_); + + fprintf(f, "%g,%d", t, res); + for (IdxT i = 0; i < model_->size(); ++i) + { + fprintf(f, ",%g", yval[i]); + } + for (IdxT i = 0; i < model_->size(); ++i) + { + fprintf(f, ",%g", ypval[i]); + } + fprintf(f, "\n"); + } + template void Ida::printOutput(sunrealtype t) { diff --git a/src/Solver/Dynamic/Ida.hpp b/src/Solver/Dynamic/Ida.hpp index 71cc6a40a..8ad99b512 100644 --- a/src/Solver/Dynamic/Ida.hpp +++ b/src/Solver/Dynamic/Ida.hpp @@ -36,6 +36,9 @@ namespace AnalysisManager int runSimulation(real_type tf, int nout = 1); int deleteSimulation(); + // TODO: Temporary + int runSimulationFixed(real_type t0, real_type dt, real_type tmax, FILE* f); + int configureQuadrature(); int initializeQuadrature(); int runSimulationQuadrature(real_type tf, int nout = 1); @@ -101,6 +104,7 @@ namespace AnalysisManager void printOutput(sunrealtype t); void printSpecial(sunrealtype t, N_Vector x); void printFinalStats(); + void printOutputF(sunrealtype t, int res, FILE* f); private: static int Residual(sunrealtype t, @@ -109,7 +113,16 @@ namespace AnalysisManager N_Vector rr, void* user_data); - static int Jac(sunrealtype t, sunrealtype cj, N_Vector yy, N_Vector yp, N_Vector resvec, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + static int Jac(sunrealtype t, + sunrealtype cj, + N_Vector yy, + N_Vector yp, + N_Vector resvec, + SUNMatrix J, + void* user_data, + N_Vector tmp1, + N_Vector tmp2, + N_Vector tmp3); static int Integrand(sunrealtype t, N_Vector yy, From 313e4c56f4f5e40eb90593194f37c4a6f0c58627 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 11 Mar 2025 19:02:03 -0400 Subject: [PATCH 02/21] Fix minor cherry pick issue. --- src/Solver/Dynamic/Ida.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Solver/Dynamic/Ida.cpp b/src/Solver/Dynamic/Ida.cpp index 7d68b9457..41bb5b816 100644 --- a/src/Solver/Dynamic/Ida.cpp +++ b/src/Solver/Dynamic/Ida.cpp @@ -681,6 +681,7 @@ namespace AnalysisManager } } + template void Ida::printOutputF(sunrealtype t, int res, FILE *f) { sunrealtype *yval = N_VGetArrayPointer_Serial(yy_); From b73554624d87ec15305c1668e8529df20805abc2 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 11 Mar 2025 20:01:55 -0400 Subject: [PATCH 03/21] Update code style for GENROU model and example. --- examples/PhasorDynamics/Example1/example1.cpp | 129 ++-- examples/PhasorDynamics/Example1/example1.hpp | 30 - .../SynchronousMachine/GENROUwS/GENROU.hpp | 669 ++++++++++-------- 3 files changed, 454 insertions(+), 374 deletions(-) delete mode 100644 examples/PhasorDynamics/Example1/example1.hpp diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 976f03f33..702ddc59c 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -1,60 +1,85 @@ -#include "example1.hpp" +#include +#define _USE_MATH_DEFINES +#include +#include + +// #include +#include +#include +#include +#include +#include + +#include "Model/PhasorDynamics/Branch/Branch.cpp" +#include "Model/PhasorDynamics/Branch/Branch.hpp" +#include "Model/PhasorDynamics/Bus/Bus.cpp" +#include "Model/PhasorDynamics/Bus/Bus.hpp" +#include "Model/PhasorDynamics/Bus/BusInfinite.cpp" +#include "Model/PhasorDynamics/Bus/BusInfinite.hpp" +#include "Model/PhasorDynamics/BusFault/BusFault.hpp" +#include "Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp" +#include "Model/PhasorDynamics/SystemModel.hpp" +#include "Solver/Dynamic/Ida.cpp" +#include "Solver/Dynamic/Ida.hpp" #define _CRT_SECURE_NO_WARNINGS -using namespace GridKit::PhasorDynamics; -using namespace AnalysisManager::Sundials; int main() { - printf("Example 1 version 2\n"); - - /* Create model parts */ - SystemModel sys; - Bus bus1(0.9949877346411762, 0.09999703952427966); - BusInfinite bus2(1.0, 0.0); - Branch branch(&bus1, &bus2, 0, 0.1, 0, 0); - BusFault fault(&bus1, 0, 1e-3, 0); - GENROU gen(&bus1, 1, 1, 0.05013, 3, 0, 0, 7, .04, .05, .75, 2.1, 0.2, 0.18, - 0.5, 0.5, 0.18, 0.15, 0, 0); - - /* Connect everything together */ - sys.addBus(&bus1); - sys.addBus(&bus2); - sys.addComponent(&branch); - sys.addComponent(&fault); - sys.addComponent(&gen); - sys.allocate(); - - double dt = 1.0/4.0/60.0; - - /* Output file header */ - FILE *f = fopen("example1_v2_results.csv", "w"); - if (!f) printf("ERROR writing to output file!\n"); - fprintf(f, "%s,%s", "t", "IDA Return Value"); - for (int i = 0; i < sys.size(); ++i) fprintf(f, ",Y[%d]", i); - for (int i = 0; i < sys.size(); ++i) fprintf(f, ",Yp[%d]", i); - fprintf(f, "\n"); - - /* Set up simulation */ - Ida ida(&sys); - ida.configureSimulation(); - - /* Run simulation */ - double start = (double) clock(); - ida.printOutputF(0, 0, f); - ida.initializeSimulation(0, false); - ida.runSimulationFixed(0, dt, 1, f); - fault.setStatus(1); - ida.initializeSimulation(1, false); - ida.runSimulationFixed(1, dt, 1.1, f); - fault.setStatus(0); - ida.initializeSimulation(1.1, false); - ida.runSimulationFixed(1.1, dt, 30, f); - - printf("Complete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC); - fclose(f); - - return 0; + using namespace GridKit::PhasorDynamics; + using namespace AnalysisManager::Sundials; + + printf("Example 1 version 2\n"); + + /* Create model parts */ + SystemModel sys; + Bus bus1(0.9949877346411762, 0.09999703952427966); + BusInfinite bus2(1.0, 0.0); + Branch branch(&bus1, &bus2, 0, 0.1, 0, 0); + BusFault fault(&bus1, 0, 1e-3, 0); + + GENROU gen(&bus1, 1, 1, 0.05013, 3, 0, 0, 7, .04, .05, .75, 2.1, 0.2, 0.18, 0.5, 0.5, 0.18, 0.15, 0, 0); + + /* Connect everything together */ + sys.addBus(&bus1); + sys.addBus(&bus2); + sys.addComponent(&branch); + sys.addComponent(&fault); + sys.addComponent(&gen); + sys.allocate(); + + double dt = 1.0 / 4.0 / 60.0; + + /* Output file header */ + FILE* f = fopen("example1_v2_results.csv", "w"); + if (!f) + printf("ERROR writing to output file!\n"); + fprintf(f, "%s,%s", "t", "IDA Return Value"); + for (int i = 0; i < sys.size(); ++i) + fprintf(f, ",Y[%d]", i); + for (int i = 0; i < sys.size(); ++i) + fprintf(f, ",Yp[%d]", i); + fprintf(f, "\n"); + + /* Set up simulation */ + Ida ida(&sys); + ida.configureSimulation(); + + /* Run simulation */ + double start = (double) clock(); + ida.printOutputF(0, 0, f); + ida.initializeSimulation(0.0, false); + ida.runSimulationFixed(0.0, dt, 1.0, f); + fault.setStatus(1); + ida.initializeSimulation(1.0, false); + ida.runSimulationFixed(1.0, dt, 1.1, f); + fault.setStatus(0); + ida.initializeSimulation(1.1, false); + ida.runSimulationFixed(1.1, dt, 10.0, f); + + printf("Complete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC); + fclose(f); + return 0; } \ No newline at end of file diff --git a/examples/PhasorDynamics/Example1/example1.hpp b/examples/PhasorDynamics/Example1/example1.hpp deleted file mode 100644 index 836c729fe..000000000 --- a/examples/PhasorDynamics/Example1/example1.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#define _USE_MATH_DEFINES -#include -#include - -//#include -#include -#include -#include -#include -#include - -#include "Model/PhasorDynamics/SystemModel.hpp" -#include "Model/PhasorDynamics/Bus/Bus.hpp" -#include "Model/PhasorDynamics/Bus/BusInfinite.hpp" -#include "Model/PhasorDynamics/Branch/Branch.hpp" -#include "Model/PhasorDynamics/BusFault/BusFault.hpp" -#include "Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp" - - -#include "Solver/Dynamic/Ida.hpp" - -#include "Model/PhasorDynamics/Bus/Bus.cpp" -#include "Model/PhasorDynamics/Bus/BusInfinite.cpp" -#include "Model/PhasorDynamics/Branch/Branch.cpp" -#include "Solver/Dynamic/Ida.cpp" - - - -int main(); diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp index 4dcdc942f..5a4550c79 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp @@ -2,316 +2,401 @@ #pragma once #define _USE_MATH_DEFINES -#include #include +#include namespace GridKit { -namespace PhasorDynamics -{ + namespace PhasorDynamics + { using ComponentT = Component; - using BaseBusT = BusBase; + using BaseBusT = BusBase; class GENROU : public ComponentT { - using ComponentT::size_; - using ComponentT::nnz_; - using ComponentT::time_; - using ComponentT::alpha_; - using ComponentT::y_; - using ComponentT::yp_; - using ComponentT::tag_; - using ComponentT::f_; - using ComponentT::g_; - using ComponentT::yB_; - using ComponentT::ypB_; - using ComponentT::fB_; - using ComponentT::gB_; - using ComponentT::param_; - + using ComponentT::alpha_; + using ComponentT::f_; + using ComponentT::fB_; + using ComponentT::g_; + using ComponentT::gB_; + using ComponentT::nnz_; + using ComponentT::param_; + using ComponentT::size_; + using ComponentT::tag_; + using ComponentT::time_; + using ComponentT::y_; + using ComponentT::yB_; + using ComponentT::yp_; + using ComponentT::ypB_; public: - - GENROU(BaseBusT* bus, int unit_id) : bus_(bus), unit_id_(unit_id), - p0_(0), q0_(0), busID_(0), H_(3), D_(0), Ra_(0), Tdop_(7), - Tdopp_(.04), Tqopp_(.05), Tqop_(.75), Xd_(2.1), Xdp_(0.2), - Xdpp_(0.18), Xq_(.5), Xqp_(.5), Xqpp_(.18), Xl_(.15), - S10_(0), S12_(0) + GENROU(BaseBusT* bus, int unit_id) + : bus_(bus), + unit_id_(unit_id), + p0_(0), + q0_(0), + busID_(0), + H_(3), + D_(0), + Ra_(0), + Tdop_(7), + Tdopp_(.04), + Tqopp_(.05), + Tqop_(.75), + Xd_(2.1), + Xdp_(0.2), + Xdpp_(0.18), + Xq_(.5), + Xqp_(.5), + Xqpp_(.18), + Xl_(.15), + S10_(0), + S12_(0) + { + size_ = 21; + set_derived_params(); + } + + GENROU(BaseBusT* bus, + int unit_id, + double p0, + double q0, + double H, + double D, + double Ra, + double Tdop, + double Tdopp, + double Tqopp, + double Tqop, + double Xd, + double Xdp, + double Xdpp, + double Xq, + double Xqp, + double Xqpp, + double Xl, + double S10, + double S12) + : bus_(bus), + unit_id_(unit_id), + p0_(p0), + q0_(q0), + busID_(0), + H_(H), + D_(D), + Ra_(Ra), + Tdop_(Tdop), + Tdopp_(Tdopp), + Tqopp_(Tqopp), + Tqop_(Tqop), + Xd_(Xd), + Xdp_(Xdp), + Xdpp_(Xdpp), + Xq_(Xq), + Xqp_(Xqp), + Xqpp_(Xqpp), + Xl_(Xl), + S10_(S10), + S12_(S12) + { + size_ = 21; + set_derived_params(); + } + + void set_derived_params() + { + SA_ = 0; + SB_ = 0; + if (S12_ != 0) { - size_ = 21; - set_derived_params(); - } + double s112 = sqrt(S10_ / S12_); - GENROU(BaseBusT* bus, int unit_id, double p0, double q0, double H, - double D, double Ra, double Tdop, double Tdopp, double Tqopp, - double Tqop, double Xd, double Xdp, double Xdpp, double Xq, - double Xqp, double Xqpp, double Xl, double S10, double S12) : - bus_(bus), unit_id_(unit_id), p0_(p0), q0_(q0), busID_(0), H_(H), - D_(D), Ra_(Ra), Tdop_(Tdop), Tdopp_(Tdopp), Tqopp_(Tqopp), - Tqop_(Tqop), Xd_(Xd), Xdp_(Xdp), Xdpp_(Xdpp), Xq_(Xq), Xqp_(Xqp), - Xqpp_(Xqpp), Xl_(Xl), S10_(S10), S12_(S12) - { - size_ = 21; - set_derived_params(); + SA_ = (1.2 * s112 + 1) / (s112 + 1); + SB_ = (1.2 * s112 - 1) / (s112 - 1); + if (SB_ < SA_) + SA_ = SB_; + SB_ = S12_ / pow(SA_ - 1.2, 2); } - - void set_derived_params() + Xd1_ = Xd_ - Xdp_; + Xd2_ = Xdp_ - Xl_; + Xd3_ = (Xdp_ - Xdpp_) / (Xd2_ * Xd2_); + Xd4_ = (Xdp_ - Xdpp_) / Xd2_; + Xd5_ = (Xdpp_ - Xl_) / Xd2_; + Xq1_ = Xq_ - Xqp_; + Xq2_ = Xqp_ - Xl_; + Xq3_ = (Xqp_ - Xqpp_) / (Xq2_ * Xq2_); + Xq4_ = (Xqp_ - Xqpp_) / Xq2_; + Xq5_ = (Xqpp_ - Xl_) / Xq2_; + Xqd_ = (Xq_ - Xl_) / (Xd_ - Xl_); + G_ = Ra_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); + B_ = -Xqpp_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); + } + + ~GENROU() + { + } + + int allocate() override + { + f_.resize(size_); + y_.resize(size_); + yp_.resize(size_); + tag_.resize(size_); + fB_.resize(size_); + yB_.resize(size_); + ypB_.resize(size_); + return 0; + } + + int initialize() override + { + /* Initialization tricks -- assuming NO saturation */ + double vr = Vr(); + double vi = Vi(); + double p = p0_; + double q = q0_; + double vm2 = vr * vr + vi * vi; + double Er = vr + (Ra_ * p * vr + Ra_ * q * vi - Xq_ * p * vi + Xq_ * q * vr) / vm2; + double Ei = vi + (Ra_ * p * vi - Ra_ * q * vr + Xq_ * p * vr + Xq_ * q * vi) / vm2; + double delta = atan2(Ei, Er); + double omega = 0; + double ir = (p * vr + q * vi) / vm2; + double ii = (p * vi - q * vr) / vm2; + double id = ir * sin(delta) - ii * cos(delta); + double iq = ir * cos(delta) + ii * sin(delta); + double vd = vr * sin(delta) - vi * cos(delta) + id * Ra_ - iq * Xqpp_; + double vq = vr * cos(delta) + vi * sin(delta) + id * Xqpp_ - iq * Ra_; + double psiqpp = -vd / (1 + omega); + double psidpp = vq / (1 + omega); + double Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; + double psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) + / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); + double Edp = psiqp - (Xqp_ - Xl_) * iq; + double psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) + / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); + double Eqp = psidp + (Xdp_ - Xl_) * id; + + /* Now we have the state variables, solve for alg. variables */ + double ksat; + double psipp; + + y_[0] = delta; //= 0.55399038; + y_[1] = omega; // = 0; + y_[2] = Eqp; // = 0.995472581; + y_[3] = psidp; // = 0.971299567; + y_[4] = psiqp; // = 0.306880069; + y_[5] = Edp; // = 0; + + y_[6] = psiqpp = -psiqp * Xq4_ - Edp * Xq5_; + y_[7] = psidpp = psidp * Xd4_ + Eqp * Xd5_; + y_[8] = psipp = sqrt(psiqpp * psiqpp + psidpp * psidpp); + y_[9] = ksat = SB_ * pow(psipp - SA_, 2); + y_[10] = vd = -psiqpp * (1 + omega); + y_[11] = vq = psidpp * (1 + omega); + y_[12] = Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; + y_[13] = id; + y_[14] = iq; + y_[15] = ir; + y_[16] = ii; + y_[17] = pmech_set_ = Te; + y_[18] = efd_set_ = Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat; + y_[19] = G_ * (vd * sin(delta) + vq * cos(delta)) + - B_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, real */ + y_[20] = B_ * (vd * sin(delta) + vq * cos(delta)) + + G_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, imag */ + + for (int i = 0; i < size_; ++i) + yp_[i] = 0.0; + return 0; + } + + int tagDifferentiable() override + { + for (int i = 0; i < size_; ++i) { - SA_ = 0; - SB_ = 0; - if (S12_ != 0) - { - double s112 = sqrt(S10_ / S12_); - SA_ = (1.2*s112 + 1) / (s112 + 1); - SB_ = (1.2*s112 - 1) / (s112 - 1); - if (SB_ < SA_) SA_ = SB_; - SB_ = S12_ / pow(SA_ - 1.2, 2); - } - Xd1_ = Xd_ - Xdp_; - Xd2_ = Xdp_ - Xl_; - Xd3_ = (Xdp_ - Xdpp_) / (Xd2_ * Xd2_); - Xd4_ = (Xdp_ - Xdpp_) / Xd2_; - Xd5_ = (Xdpp_ - Xl_) / Xd2_; - Xq1_ = Xq_ - Xqp_; - Xq2_ = Xqp_ - Xl_; - Xq3_ = (Xqp_ - Xqpp_) / (Xq2_ * Xq2_); - Xq4_ = (Xqp_ - Xqpp_) / Xq2_; - Xq5_ = (Xqpp_ - Xl_) / Xq2_; - Xqd_ = (Xq_ - Xl_) / (Xd_ - Xl_); - G_ = Ra_ / (Ra_*Ra_ + Xqpp_*Xqpp_); - B_ = -Xqpp_ / (Ra_*Ra_ + Xqpp_*Xqpp_); - + tag_[i] = i < 6; } - - ~GENROU() { } - - int allocate() override - { - f_.resize(size_); - y_.resize(size_); - yp_.resize(size_); - tag_.resize(size_); - fB_.resize(size_); - yB_.resize(size_); - ypB_.resize(size_); - return 0; - } - - int initialize() override - { - double delta, omega, Eqp, psidp, psiqp, Edp, psiqpp, psidpp, psipp, - vd, vq, id, iq, ir, ii, Te, g, b, ksat; - - /* Initialization tricks -- assuming NO saturation */ - double vr, vi, p, q, vm2, Er, Ei; - vr = Vr(); - vi = Vi(); - p = p0_; - q = q0_; - vm2 = vr*vr + vi*vi; - Er = vr + (Ra_*p*vr + Ra_*q*vi - Xq_*p*vi + Xq_*q*vr) / vm2; - Ei = vi + (Ra_*p*vi - Ra_*q*vr + Xq_*p*vr + Xq_*q*vi) / vm2; - delta = atan2(Ei, Er); - omega = 0; - ir = (p*vr + q*vi) / vm2; - ii = (p*vi - q*vr) / vm2; - id = ir*sin(delta) -ii*cos(delta); - iq = ir*cos(delta) +ii*sin(delta); - vd = vr*sin(delta) - vi*cos(delta) + id*Ra_ - iq*Xqpp_; - vq = vr*cos(delta) + vi*sin(delta) + id*Xqpp_ - iq*Ra_; - psiqpp = -vd / (1 + omega); - psidpp = vq / (1 + omega); - Te = (psidpp - id*Xdpp_)*iq - (psiqpp - iq*Xdpp_)*id; - psiqp = -(-(Xqp_-Xl_)*iq+psiqpp*(Xqp_-Xl_)/(Xqpp_-Xl_)) - /(1+(Xqp_-Xqpp_)/(Xqpp_-Xl_)); - Edp = psiqp - (Xqp_ - Xl_) * iq; - psidp = -((Xdp_-Xl_)*id-psidpp*(Xdp_-Xl_)/(Xdpp_-Xl_)) - /(1+(Xdp_-Xdpp_)/(Xdpp_-Xl_)); - Eqp = psidp + (Xdp_ - Xl_) * id; - - /* Now we have the state variables, solve for alg. variables */ - - y_[0] = delta; //= 0.55399038; - y_[1] = omega; // = 0; - y_[2] = Eqp; // = 0.995472581; - y_[3] = psidp; // = 0.971299567; - y_[4] = psiqp; // = 0.306880069; - y_[5] = Edp; // = 0; - - y_[6] = psiqpp = -psiqp*Xq4_ - Edp*Xq5_; - y_[7] = psidpp = psidp*Xd4_ + Eqp*Xd5_; - y_[8] = psipp = sqrt(psiqpp*psiqpp + psidpp*psidpp); - y_[9] = ksat = SB_*pow(psipp - SA_, 2); - y_[10] = vd = -psiqpp*(1 + omega); - y_[11] = vq = psidpp*(1 + omega); - y_[12] = Te = (psidpp - id*Xdpp_)*iq - (psiqpp - iq*Xdpp_)*id; - y_[13] = id; - y_[14] = iq; - y_[15] = ir; - y_[16] = ii; - y_[17] = pmech_set_ = Te; - y_[18] = efd_set_ = Eqp + Xd1_*(id - + Xd3_*(Eqp - psidp - Xd2_*id)) + psidpp*ksat; - y_[19] = G_*(vd*sin(delta)+vq*cos(delta)) - - B_*(vd*-cos(delta) + vq*sin(delta)); /* inort, real */; - y_[20] = B_*(vd*sin(delta)+vq*cos(delta)) - + G_*(vd*-cos(delta) + vq*sin(delta)); /* inort, imag */ - - for (int i = 0; i < size_; ++i) yp_[i] = 0.0; - return 0; - } - - int tagDifferentiable() override - { - for (int i = 0; i < size_; ++i) - { - tag_[i] = i < 6; - } - return 0; - } - - int evaluateResidual() override - { - double delta, omega, Eqp, psidp, psiqp, Edp, psiqpp, psidpp, psipp, - ksat, vd, vq, telec, id, iq, ir, ii, pmech, efd, inr, ini, vr, - vi, vr_inf, vi_inf, delta_dot, omega_dot, Eqp_dot, psidp_dot, - psiqp_dot, Edp_dot; - - /* Read variables */ - delta = y_[0]; - omega = y_[1]; - Eqp = y_[2]; - psidp = y_[3]; - psiqp = y_[4]; - Edp = y_[5]; - psiqpp = y_[6]; - psidpp = y_[7]; - psipp = y_[8]; - ksat = y_[9]; - vd = y_[10]; - vq = y_[11]; - telec = y_[12]; - id = y_[13]; - iq = y_[14]; - ir = y_[15]; - ii = y_[16]; - pmech = y_[17]; - efd = y_[18]; - inr = y_[19]; - ini = y_[20]; - vr = Vr(); - vi = Vi(); - - /* Read derivatives */ - delta_dot = yp_[0]; - omega_dot = yp_[1]; - Eqp_dot = yp_[2]; - psidp_dot = yp_[3]; - psiqp_dot = yp_[4]; - Edp_dot = yp_[5]; - - /* 6 GENROU differential equations */ - f_[0] = delta_dot - omega*(2*M_PI*60); - f_[1] = omega_dot - (1/(2*H_)) * ((pmech - D_*omega) / (1 + omega) - - telec); - f_[2] = Eqp_dot - (1/Tdop_) * (efd - (Eqp + Xd1_*(id + Xd3_*(Eqp - - psidp - Xd2_*id)) + psidpp*ksat )); - f_[3] = psidp_dot - (1/Tdopp_) * (Eqp - psidp - Xd2_*id); - f_[4] = psiqp_dot - (1/Tqopp_) * (Edp - psiqp + Xq2_*iq); - f_[5] = Edp_dot - (1/Tqop_) * (-Edp + Xqd_*psiqpp*ksat - + Xq1_*(iq - Xq3_*(Edp + iq*Xq2_ - psiqp))); - - /* 11 GENROU algebraic equations */ - f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); - f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); - f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); - f_[9] = ksat - SB_*pow(psipp - SA_, 2.0); - f_[10] = vd + psiqpp * (1 + omega); - f_[11] = vq - psidpp * (1 + omega); - f_[12] = telec - ((psidpp - id*Xdpp_)*iq - (psiqpp - iq*Xdpp_)*id); - f_[13] = id - (ir*sin(delta) - ii*cos(delta)); - f_[14] = iq - (ir*cos(delta) + ii*sin(delta)); - f_[15] = ir + G_*vr - B_*vi - inr; - f_[16] = ii + B_*vr + G_*vi - ini; - - /* 2 GENROU control inputs are set to constant for this example */ - f_[17] = pmech - pmech_set_; - f_[18] = efd - efd_set_; - - /* 2 GENROU current source definitions */ - f_[19] = inr - (G_*(sin(delta)*vd + cos(delta)*vq) - - B_*(-cos(delta)*vd + sin(delta)*vq)); - f_[20] = ini - (B_*(sin(delta)*vd + cos(delta)*vq) - + G_*(-cos(delta)*vd + sin(delta)*vq)); - - /* Current balance */ - Ir() += inr - Vr()*G_ + Vi()*B_; - Ii() += ini - Vr()*B_ - Vi()*G_; - - //printf("GENROU residual\n"); - //for (int i = 0 ; i < 21; ++i) printf("%d: %g\n", i, f_[i]); - - //printf("GENROU inr %g Vr %g B %g Vi %g G %g\n", inr, Vr(), B_, Vi(), G_); - //printf("GENROU Ii = %g\n", inr - Vr()*B_ - Vi()*G_); - - return 0; - } - - int evaluateJacobian() override - { - /* TODO */ - return 0; - } - - /* Don't know what to do with any of these */ - int evaluateIntegrand() override { return 0; } - int initializeAdjoint() override { return 0; } - int evaluateAdjointResidual() override { return 0; } - int evaluateAdjointIntegrand() override { return 0; } - void updateTime(double t, double a) override { } + return 0; + } + + int evaluateResidual() override + { + /* Read variables */ + double delta = y_[0]; + double omega = y_[1]; + double Eqp = y_[2]; + double psidp = y_[3]; + double psiqp = y_[4]; + double Edp = y_[5]; + double psiqpp = y_[6]; + double psidpp = y_[7]; + double psipp = y_[8]; + double ksat = y_[9]; + double vd = y_[10]; + double vq = y_[11]; + double telec = y_[12]; + double id = y_[13]; + double iq = y_[14]; + double ir = y_[15]; + double ii = y_[16]; + double pmech = y_[17]; + double efd = y_[18]; + double inr = y_[19]; + double ini = y_[20]; + double vr = Vr(); + double vi = Vi(); + + /* Read derivatives */ + double delta_dot = yp_[0]; + double omega_dot = yp_[1]; + double Eqp_dot = yp_[2]; + double psidp_dot = yp_[3]; + double psiqp_dot = yp_[4]; + double Edp_dot = yp_[5]; + + /* 6 GENROU differential equations */ + f_[0] = delta_dot - omega * (2 * M_PI * 60); + f_[1] = omega_dot - (1 / (2 * H_)) * ((pmech - D_ * omega) / (1 + omega) - telec); + f_[2] = Eqp_dot - (1 / Tdop_) * (efd - (Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat)); + f_[3] = psidp_dot - (1 / Tdopp_) * (Eqp - psidp - Xd2_ * id); + f_[4] = psiqp_dot - (1 / Tqopp_) * (Edp - psiqp + Xq2_ * iq); + f_[5] = Edp_dot - (1 / Tqop_) * (-Edp + Xqd_ * psiqpp * ksat + Xq1_ * (iq - Xq3_ * (Edp + iq * Xq2_ - psiqp))); + + /* 11 GENROU algebraic equations */ + f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); + f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); + f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); + f_[9] = ksat - SB_ * pow(psipp - SA_, 2.0); + f_[10] = vd + psiqpp * (1 + omega); + f_[11] = vq - psidpp * (1 + omega); + f_[12] = telec - ((psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id); + f_[13] = id - (ir * sin(delta) - ii * cos(delta)); + f_[14] = iq - (ir * cos(delta) + ii * sin(delta)); + f_[15] = ir + G_ * vr - B_ * vi - inr; + f_[16] = ii + B_ * vr + G_ * vi - ini; + + /* 2 GENROU control inputs are set to constant for this example */ + f_[17] = pmech - pmech_set_; + f_[18] = efd - efd_set_; + + /* 2 GENROU current source definitions */ + f_[19] = inr - (G_ * (sin(delta) * vd + cos(delta) * vq) - B_ * (-cos(delta) * vd + sin(delta) * vq)); + f_[20] = ini - (B_ * (sin(delta) * vd + cos(delta) * vq) + G_ * (-cos(delta) * vd + sin(delta) * vq)); + + /* Current balance */ + Ir() += inr - Vr() * G_ + Vi() * B_; + Ii() += ini - Vr() * B_ - Vi() * G_; + + // printf("GENROU residual\n"); + // for (int i = 0 ; i < 21; ++i) printf("%d: %g\n", i, f_[i]); + + // printf("GENROU inr %g Vr %g B %g Vi %g G %g\n", inr, Vr(), B_, Vi(), G_); + // printf("GENROU Ii = %g\n", inr - Vr()*B_ - Vi()*G_); + + return 0; + } + + int evaluateJacobian() override + { + /* TODO */ + return 0; + } + + /* Don't know what to do with any of these */ + int evaluateIntegrand() override + { + return 0; + } + + int initializeAdjoint() override + { + return 0; + } + + int evaluateAdjointResidual() override + { + return 0; + } + + int evaluateAdjointIntegrand() override + { + return 0; + } + + void updateTime(double t, double a) override + { + } private: - double& Vr() - { - return bus_->Vr(); - } - - double& Vi() - { - return bus_->Vi(); - } - - double& Ir() - { - return bus_->Ir(); - } - - double& Ii() - { - return bus_->Ii(); - } + double& Vr() + { + return bus_->Vr(); + } + + double& Vi() + { + return bus_->Vi(); + } + + double& Ir() + { + return bus_->Ir(); + } + + double& Ii() + { + return bus_->Ii(); + } private: - - /* Identification */ - BaseBusT* bus_; - const int busID_; - int unit_id_; - - /* Initial terminal conditions */ - double p0_, q0_; - - /* Input parameters */ - double H_, D_, Ra_, Tdop_, Tdopp_, Tqopp_, Tqop_, Xd_, Xdp_, Xdpp_, - Xq_, Xqp_, Xqpp_, Xl_, S10_, S12_; - - /* Derivied parameters */ - double SA_, SB_, Xd1_, Xd2_, Xd3_, Xd4_, Xd5_, Xq1_, Xq2_, Xq3_, Xq4_, - Xq5_, Xqd_, G_, B_; - - /* Setpoints for control variables (determined at initialization) */ - double pmech_set_, efd_set_; + /* Identification */ + BaseBusT* bus_; + const int busID_; + int unit_id_; + + /* Initial terminal conditions */ + double p0_; + double q0_; + + /* Input parameters */ + double H_; + double D_; + double Ra_; + double Tdop_; + double Tdopp_; + double Tqopp_; + double Tqop_; + double Xd_; + double Xdp_; + double Xdpp_; + double Xq_; + double Xqp_; + double Xqpp_; + double Xl_; + double S10_; + double S12_; + + /* Derivied parameters */ + double SA_; + double SB_; + double Xd1_; + double Xd2_; + double Xd3_; + double Xd4_; + double Xd5_; + double Xq1_; + double Xq2_; + double Xq3_; + double Xq4_; + double Xq5_; + double Xqd_; + double G_; + double B_; + + /* Setpoints for control variables (determined at initialization) */ + double pmech_set_; + double efd_set_; }; -} -} + } // namespace PhasorDynamics +} // namespace GridKit From 1205fe5206009997577b89120305b04c1716486c Mon Sep 17 00:00:00 2001 From: pelesh Date: Wed, 12 Mar 2025 00:10:06 +0000 Subject: [PATCH 04/21] Apply pre-commmit fixes --- examples/CMakeLists.txt | 2 +- examples/PhasorDynamics/CMakeLists.txt | 2 +- examples/PhasorDynamics/Example1/example1.cpp | 3 +- .../PhasorDynamics/BusFault/BusFault.cpp | 2 +- .../PhasorDynamics/BusFault/BusFault.hpp | 213 ++++++++++-------- .../PhasorDynamics/BusFault/CMakeLists.txt | 2 +- .../SynchronousMachine/GENROUwS/GENROU.cpp | 2 +- .../SynchronousMachine/GENROUwS/GENROU.hpp | 4 +- src/Solver/Dynamic/Ida.cpp | 50 ++-- 9 files changed, 157 insertions(+), 123 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6c867ea0d..53e484816 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,4 +25,4 @@ if(GRIDKIT_ENABLE_ENZYME) add_subdirectory(Enzyme) endif() -add_subdirectory(PhasorDynamics) \ No newline at end of file +add_subdirectory(PhasorDynamics) diff --git a/examples/PhasorDynamics/CMakeLists.txt b/examples/PhasorDynamics/CMakeLists.txt index 5d4417987..c758e4e56 100644 --- a/examples/PhasorDynamics/CMakeLists.txt +++ b/examples/PhasorDynamics/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(Example1) \ No newline at end of file +add_subdirectory(Example1) diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 702ddc59c..8e498c833 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -24,7 +24,6 @@ #define _CRT_SECURE_NO_WARNINGS - int main() { using namespace GridKit::PhasorDynamics; @@ -82,4 +81,4 @@ int main() fclose(f); return 0; -} \ No newline at end of file +} diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.cpp b/src/Model/PhasorDynamics/BusFault/BusFault.cpp index 42b70b455..277e80e1e 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.cpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.cpp @@ -1 +1 @@ -#include "BusFault.hpp" \ No newline at end of file +#include "BusFault.hpp" diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.hpp b/src/Model/PhasorDynamics/BusFault/BusFault.hpp index 9ee2cc98b..800a7dfc9 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.hpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.hpp @@ -1,113 +1,150 @@ /* Bus Fault Component - Adam Birchfield */ #pragma once -#include #include +#include namespace GridKit { -namespace PhasorDynamics -{ + namespace PhasorDynamics + { using ComponentT = Component; - using BaseBusT = BusBase; + using BaseBusT = BusBase; class BusFault : public ComponentT { - using ComponentT::size_; - using ComponentT::nnz_; - using ComponentT::time_; - using ComponentT::alpha_; - using ComponentT::y_; - using ComponentT::yp_; - using ComponentT::tag_; - using ComponentT::f_; - using ComponentT::g_; - using ComponentT::yB_; - using ComponentT::ypB_; - using ComponentT::fB_; - using ComponentT::gB_; - using ComponentT::param_; - + using ComponentT::alpha_; + using ComponentT::f_; + using ComponentT::fB_; + using ComponentT::g_; + using ComponentT::gB_; + using ComponentT::nnz_; + using ComponentT::param_; + using ComponentT::size_; + using ComponentT::tag_; + using ComponentT::time_; + using ComponentT::y_; + using ComponentT::yB_; + using ComponentT::yp_; + using ComponentT::ypB_; public: - BusFault(BaseBusT* bus) : bus_(bus), R_(0), X_(0.01), - status_(0), busID_(0) + BusFault(BaseBusT* bus) + : bus_(bus), R_(0), X_(0.01), status_(0), busID_(0) + { + size_ = 0; + } + + BusFault(BaseBusT* bus, double R, double X, int status) + : bus_(bus), R_(R), X_(X), status_(status), busID_(0) + { + size_ = 0; + } + + ~BusFault() + { + } + + int allocate() override + { + return 0; + } + + int initialize() override + { + return 0; + } + + int tagDifferentiable() override + { + return 0; + } + + int evaluateResidual() override + { + if (status_) { - size_ = 0; + double B = -X_ / (X_ * X_ + R_ * R_); + double G = R_ / (X_ * X_ + R_ * R_); + Ir() += -Vr() * G + Vi() * B; + Ii() += -Vr() * B - Vi() * G; } - - BusFault(BaseBusT* bus, double R, double X, int status) : - bus_(bus), R_(R), X_(X), status_(status), busID_(0) - { - size_ = 0; - } - - ~BusFault() { } - - int allocate() override { return 0; } - - int initialize() override { return 0; } - - int tagDifferentiable() override { return 0; } - - int evaluateResidual() override - { - if (status_) - { - double B = -X_ / (X_*X_ + R_*R_); - double G = R_ / (X_*X_ + R_*R_); - Ir() += -Vr()*G + Vi()*B; - Ii() += -Vr()*B - Vi()*G; - } - return 0; - } - - int evaluateJacobian() override { return 0; } - - - int evaluateIntegrand() override { return 0; } - int initializeAdjoint() override { return 0; } - int evaluateAdjointResidual() override { return 0; } - int evaluateAdjointIntegrand() override { return 0; } - - void updateTime(double t, double a) override { } + return 0; + } + + int evaluateJacobian() override + { + return 0; + } + + int evaluateIntegrand() override + { + return 0; + } + + int initializeAdjoint() override + { + return 0; + } + + int evaluateAdjointResidual() override + { + return 0; + } + + int evaluateAdjointIntegrand() override + { + return 0; + } + + void updateTime(double t, double a) override + { + } public: - void setR(double R) { R_ = R; } + void setR(double R) + { + R_ = R; + } - void setX(double X) { X_ = X; } - - void setStatus(int status) { status_ = status; } + void setX(double X) + { + X_ = X; + } + void setStatus(int status) + { + status_ = status; + } private: - double& Vr() - { - return bus_->Vr(); - } - - double& Vi() - { - return bus_->Vi(); - } - - double& Ir() - { - return bus_->Ir(); - } - - double& Ii() - { - return bus_->Ii(); - } + double& Vr() + { + return bus_->Vr(); + } + + double& Vi() + { + return bus_->Vi(); + } + + double& Ir() + { + return bus_->Ir(); + } + + double& Ii() + { + return bus_->Ii(); + } private: - BaseBusT* bus_; - double R_; - double X_; - int status_; - const int busID_; + BaseBusT* bus_; + double R_; + double X_; + int status_; + const int busID_; }; -} -} + } // namespace PhasorDynamics +} // namespace GridKit diff --git a/src/Model/PhasorDynamics/BusFault/CMakeLists.txt b/src/Model/PhasorDynamics/BusFault/CMakeLists.txt index c78284ee8..57279fe45 100644 --- a/src/Model/PhasorDynamics/BusFault/CMakeLists.txt +++ b/src/Model/PhasorDynamics/BusFault/CMakeLists.txt @@ -2,4 +2,4 @@ gridkit_add_library(phasor_dynamics_BusFault SOURCES BusFault.cpp OUTPUT_NAME - gridkit_phasor_dynamics_BusFault) \ No newline at end of file + gridkit_phasor_dynamics_BusFault) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp index f4e56babf..3540acfd7 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp @@ -1 +1 @@ -#include "GENROU.hpp" \ No newline at end of file +#include "GENROU.hpp" diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp index 5a4550c79..2b1a6692e 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp @@ -170,10 +170,10 @@ namespace GridKit double psidpp = vq / (1 + omega); double Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; double psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) - / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); + / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); double Edp = psiqp - (Xqp_ - Xl_) * iq; double psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) - / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); + / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); double Eqp = psidp + (Xdp_ - Xl_) * id; /* Now we have the state variables, solve for alg. variables */ diff --git a/src/Solver/Dynamic/Ida.cpp b/src/Solver/Dynamic/Ida.cpp index 41bb5b816..acb9dd2fb 100644 --- a/src/Solver/Dynamic/Ida.cpp +++ b/src/Solver/Dynamic/Ida.cpp @@ -206,35 +206,33 @@ namespace AnalysisManager } template - int Ida::runSimulationFixed(real_type t0, real_type dt, - real_type tmax, FILE *f) - { - int retval = 0; - int iout = 0; - real_type t, tret; - - //printOutputF(t0, 0, f); - for (t = t0+dt; t < tmax; t += dt) + int Ida::runSimulationFixed(real_type t0, real_type dt, real_type tmax, FILE* f) + { + int retval = 0; + int iout = 0; + real_type t, tret; + + // printOutputF(t0, 0, f); + for (t = t0 + dt; t < tmax; t += dt) + { + retval = IDASolve(solver_, t, &tret, yy_, yp_, IDA_NORMAL); + checkOutput(retval, "IDASolve"); + printOutputF(t, retval, f); + + if (retval != IDA_SUCCESS) { - retval = IDASolve(solver_, t, &tret, yy_, yp_, IDA_NORMAL); - checkOutput(retval, "IDASolve"); - printOutputF(t, retval, f); - - if (retval != IDA_SUCCESS) - { - printf("IDA Failure! %dn", retval); - break; - } + printf("IDA Failure! %dn", retval); + break; } + } - model_->updateTime(t, 0.0); - copyVec(yy_, model_->y()); - copyVec(yp_, model_->yp()); + model_->updateTime(t, 0.0); + copyVec(yy_, model_->y()); + copyVec(yp_, model_->yp()); - return retval; + return retval; } - template int Ida::runSimulation(real_type tf, int nout) { @@ -682,10 +680,10 @@ namespace AnalysisManager } template - void Ida::printOutputF(sunrealtype t, int res, FILE *f) + void Ida::printOutputF(sunrealtype t, int res, FILE* f) { - sunrealtype *yval = N_VGetArrayPointer_Serial(yy_); - sunrealtype *ypval = N_VGetArrayPointer_Serial(yp_); + sunrealtype* yval = N_VGetArrayPointer_Serial(yy_); + sunrealtype* ypval = N_VGetArrayPointer_Serial(yp_); fprintf(f, "%g,%d", t, res); for (IdxT i = 0; i < model_->size(); ++i) From 419be8dda8d1b03f1b79575fd2a0aab68bfb9f56 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 11 Mar 2025 20:21:43 -0400 Subject: [PATCH 05/21] Updates to CMake and code style. --- examples/CMakeLists.txt | 3 +-- src/Model/PhasorDynamics/BusFault/BusFault.hpp | 9 +++++---- .../PhasorDynamics/SynchronousMachine/GENROUwS/README.md | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 53e484816..6e0382b71 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,6 +13,7 @@ if(TARGET SUNDIALS::idas) add_subdirectory(RLCircuit) add_subdirectory(Microgrid) add_subdirectory(ScaleMicrogrid) + add_subdirectory(PhasorDynamics) if(GRIDKIT_ENABLE_IPOPT) add_subdirectory(DynamicConstrainedOpt) add_subdirectory(GenConstLoad) @@ -24,5 +25,3 @@ endif() if(GRIDKIT_ENABLE_ENZYME) add_subdirectory(Enzyme) endif() - -add_subdirectory(PhasorDynamics) diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.hpp b/src/Model/PhasorDynamics/BusFault/BusFault.hpp index 800a7dfc9..4de69fbd7 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.hpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.hpp @@ -64,10 +64,11 @@ namespace GridKit { if (status_) { - double B = -X_ / (X_ * X_ + R_ * R_); - double G = R_ / (X_ * X_ + R_ * R_); - Ir() += -Vr() * G + Vi() * B; - Ii() += -Vr() * B - Vi() * G; + double B = -X_ / (X_ * X_ + R_ * R_); + double G = R_ / (X_ * X_ + R_ * R_); + + Ir() += -Vr() * G + Vi() * B; + Ii() += -Vr() * B - Vi() * G; } return 0; } diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/README.md b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/README.md index 029c89b60..fec362fec 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/README.md +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/README.md @@ -93,9 +93,14 @@ then Sat(\psi'')=Sat(\vert V_{r}+jV_{i} \vert) ``` -It is important to point out that finding the initial value of $`\delta`$ for the model without saturation direct method can be used. In case when saturation is considered some "claver" math is needed. Key insight for determining initial $`\delta`$ is that the magnitude of the saturation depends upon the magnitude of $`\psi''`$, which is independent of $`\delta`$. +It is important to point out that finding the initial value of $`\delta`$ for +the model without saturation direct method can be used. In case when saturation +is considered some "claver" math is needed. Key insight for determining initial +$`\delta`$ is that the magnitude of the saturation depends upon the magnitude +of $`\psi''`$, which is independent of $`\delta`$. ```math -\delta=tan^{-1}(\dfrac{K_{sat}V_{iterm}+K_{sat}R_{a}I_{i}+(K_{sat}X''_{d}+X_{q}-X''_{q})I_{r}}{K_{sat}V_{rterm}+K_{sat}R_{a}I_{r}-(K_{sat}X''_{d}+X_{q}-X''_{q})I_{i}}) +\delta=\tan^{-1}\left(\dfrac{K_{sat}V_{iterm}+K_{sat}R_{a}I_{i}+(K_{sat}X''_{d}+X_{q}-X''_{q})I_{r}} + {K_{sat}V_{rterm}+K_{sat}R_{a}I_{r}-(K_{sat}X''_{d}+X_{q}-X''_{q})I_{i}} \right) ``` where ```math From a028a6e49f1c1bc5c26b3d4656cc2fbb485213db Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 11 Mar 2025 20:45:06 -0400 Subject: [PATCH 06/21] Export all symbols when using MSVSC to build GridKit. --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 770855b93..a8de08e39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,11 @@ set(PACKAGE_VERSION_PATCH "7") 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_STANDARD 17) + # Ipopt support is disabled by default option(GRIDKIT_ENABLE_IPOPT "Enable Ipopt support" OFF) @@ -33,6 +38,7 @@ option(GRIDKIT_ENABLE_SUNDIALS_SPARSE "Enable SUNDIALS sparse linear solvers" ON option(GRIDKIT_ENABLE_ENZYME "Enable automatic differentiation with Enzyme" OFF) set(CMAKE_MACOSX_RPATH 1) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -57,11 +63,6 @@ if("${isSystemDir}" STREQUAL "-1") endif("${isSystemDir}" STREQUAL "-1") -# TODO: Probably beter to set a debug interface target -set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG") - -set(CMAKE_CXX_STANDARD 17) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) option(GRIDKIT_BUILD_SHARED "Build shared libraries" ON) From df497ac2d71340a0b625b8501e406e6e1f1835d3 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 1 Apr 2025 08:24:36 -0400 Subject: [PATCH 07/21] Stream output and comparison to reference solution. --- .../Example1_Powerworld_Reference.hpp | 2406 +++++++++++++++++ examples/PhasorDynamics/Example1/example1.cpp | 86 +- src/Solver/Dynamic/Ida.cpp | 29 +- src/Solver/Dynamic/Ida.hpp | 4 +- 4 files changed, 2499 insertions(+), 26 deletions(-) create mode 100644 examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp diff --git a/examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp b/examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp new file mode 100644 index 000000000..8cf450581 --- /dev/null +++ b/examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp @@ -0,0 +1,2406 @@ +#include + +// Columns: +// Time, Machine Speed (PowerWorld), Bus 1 Voltage Magnitude (PowerWorld)}, +std::vector> reference_solution = + {{0, 1, 1.000000477}, + {0.004167, 1, 1.000000477}, + {0.008333, 1, 1.000000477}, + {0.0125, 0.99999994, 1.000000477}, + {0.016667, 0.99999994, 1.000000477}, + {0.020833, 0.99999994, 1.000000477}, + {0.025, 0.99999994, 1.000000477}, + {0.029167, 0.99999994, 1.000000477}, + {0.033333, 0.99999994, 1.000000477}, + {0.0375, 0.99999994, 1.000000477}, + {0.041667, 0.99999994, 1.000000477}, + {0.045833, 0.99999994, 1.000000477}, + {0.05, 0.999999881, 1.000000477}, + {0.054167, 0.999999881, 1.000000477}, + {0.058333, 0.999999881, 1.000000477}, + {0.0625, 0.999999881, 1.000000477}, + {0.066667, 0.999999881, 1.000000477}, + {0.070833, 0.999999881, 1.000000477}, + {0.075, 0.999999881, 1.000000477}, + {0.079167, 0.999999881, 1.000000477}, + {0.083333, 0.999999881, 1.000000477}, + {0.0875, 0.999999881, 1.000000477}, + {0.091667, 0.999999881, 1.000000477}, + {0.095833, 0.999999881, 1.000000477}, + {0.1, 0.999999881, 1.000000477}, + {0.104167, 0.999999881, 1.000000477}, + {0.108333, 0.999999881, 1.000000477}, + {0.1125, 0.999999881, 1.000000477}, + {0.116667, 0.999999881, 1.000000477}, + {0.120833, 0.999999881, 1.000000477}, + {0.125, 0.999999881, 1.000000477}, + {0.129167, 0.999999881, 1.000000477}, + {0.133333, 0.999999881, 1.000000477}, + {0.1375, 0.99999994, 1.000000477}, + {0.141667, 0.99999994, 1.000000477}, + {0.145833, 0.99999994, 1.000000477}, + {0.15, 0.99999994, 1.000000477}, + {0.154167, 0.99999994, 1.000000477}, + {0.158333, 0.99999994, 1.000000477}, + {0.1625, 0.99999994, 1.000000477}, + {0.166667, 0.99999994, 1.000000477}, + {0.170833, 0.99999994, 1.000000477}, + {0.175, 0.99999994, 1.000000477}, + {0.179167, 0.99999994, 1.000000477}, + {0.183333, 0.99999994, 1.000000477}, + {0.1875, 0.99999994, 1.000000477}, + {0.191667, 0.99999994, 1.000000477}, + {0.195833, 1, 1.000000477}, + {0.2, 1, 1.000000477}, + {0.204167, 1, 1.000000477}, + {0.208333, 1, 1.000000477}, + {0.2125, 1, 1.000000477}, + {0.216667, 1, 1.000000477}, + {0.220833, 1, 1.000000477}, + {0.225, 1, 1.000000477}, + {0.229167, 1, 1.000000477}, + {0.233333, 1, 1.000000477}, + {0.2375, 1, 1.000000477}, + {0.241667, 1, 1.000000477}, + {0.245833, 1, 1.000000477}, + {0.25, 1, 1.000000477}, + {0.254167, 1, 1.000000477}, + {0.258333, 1, 1.000000477}, + {0.2625, 1, 1.000000477}, + {0.266667, 1, 1.000000477}, + {0.270833, 1, 1.000000477}, + {0.275, 1, 1.000000477}, + {0.279167, 1, 1.000000477}, + {0.283333, 1, 1.000000477}, + {0.2875, 1, 1.000000477}, + {0.291667, 1, 1.000000477}, + {0.295833, 1.000000119, 1.000000477}, + {0.3, 1.000000119, 1.000000477}, + {0.304167, 1.000000119, 1.000000477}, + {0.308333, 1.000000119, 1.000000477}, + {0.3125, 1.000000119, 1.000000477}, + {0.316667, 1.000000119, 1.000000477}, + {0.320833, 1.000000119, 1.000000477}, + {0.325, 1.000000119, 1.000000477}, + {0.329167, 1.000000119, 1.000000477}, + {0.333333, 1.000000119, 1.000000477}, + {0.3375, 1.000000119, 1.000000477}, + {0.341667, 1.000000119, 1.000000477}, + {0.345833, 1.000000119, 1.000000477}, + {0.35, 1.000000119, 1.000000477}, + {0.354167, 1.000000119, 1.000000477}, + {0.358333, 1.000000119, 1.000000477}, + {0.3625, 1, 1.000000477}, + {0.366667, 1, 1.000000477}, + {0.370833, 1, 1.000000477}, + {0.375, 1, 1.000000477}, + {0.379167, 1, 1.000000477}, + {0.383333, 1, 1.000000477}, + {0.3875, 1, 1.000000477}, + {0.391667, 1, 1.000000477}, + {0.395833, 1, 1.000000477}, + {0.4, 1, 1.000000477}, + {0.404167, 1, 1.000000477}, + {0.408333, 1, 1.000000477}, + {0.4125, 1, 1.000000477}, + {0.416667, 1, 1.000000477}, + {0.420833, 1, 1.000000477}, + {0.425, 1, 1.000000477}, + {0.429167, 1, 1.000000477}, + {0.433333, 1, 1.000000477}, + {0.4375, 1, 1.000000477}, + {0.441667, 1, 1.000000477}, + {0.445833, 1, 1.000000477}, + {0.45, 1, 1.000000477}, + {0.454167, 1, 1.000000477}, + {0.458333, 1, 1.000000477}, + {0.4625, 1, 1.000000477}, + {0.466667, 1, 1.000000477}, + {0.470833, 1, 1.000000477}, + {0.475, 1, 1.000000477}, + {0.479167, 1, 1.000000477}, + {0.483333, 1, 1.000000477}, + {0.4875, 1, 1.000000477}, + {0.491667, 1, 1.000000477}, + {0.495833, 1, 1.000000477}, + {0.5, 1, 1.000000477}, + {0.504167, 1, 1.000000477}, + {0.508333, 1, 1.000000477}, + {0.5125, 0.99999994, 1.000000477}, + {0.516667, 0.99999994, 1.000000477}, + {0.520833, 0.99999994, 1.000000477}, + {0.525, 0.99999994, 1.000000477}, + {0.529167, 0.99999994, 1.000000477}, + {0.533333, 0.99999994, 1.000000477}, + {0.5375, 0.99999994, 1.000000477}, + {0.541667, 0.99999994, 1.000000477}, + {0.545833, 0.99999994, 1.000000477}, + {0.55, 0.99999994, 1.000000477}, + {0.554167, 0.99999994, 1.000000477}, + {0.558333, 0.99999994, 1.000000477}, + {0.5625, 0.99999994, 1.000000477}, + {0.566667, 0.99999994, 1.000000477}, + {0.570833, 0.99999994, 1.000000477}, + {0.575, 0.99999994, 1.000000477}, + {0.579167, 0.99999994, 1.000000477}, + {0.583333, 0.99999994, 1.000000477}, + {0.5875, 0.99999994, 1.000000477}, + {0.591667, 0.99999994, 1.000000477}, + {0.595833, 0.99999994, 1.000000477}, + {0.6, 0.99999994, 1.000000477}, + {0.604167, 0.99999994, 1.000000477}, + {0.608333, 0.99999994, 1.000000477}, + {0.6125, 0.99999994, 1.000000477}, + {0.616667, 0.99999994, 1.000000477}, + {0.620833, 1, 1.000000477}, + {0.625, 1, 1.000000477}, + {0.629167, 1, 1.000000477}, + {0.633333, 1, 1.000000477}, + {0.6375, 1, 1.000000477}, + {0.641667, 1, 1.000000477}, + {0.645833, 1, 1.000000477}, + {0.65, 1, 1.000000477}, + {0.654167, 1, 1.000000477}, + {0.658333, 1, 1.000000477}, + {0.6625, 1, 1.000000477}, + {0.666667, 1, 1.000000477}, + {0.670833, 1, 1.000000477}, + {0.675, 1, 1.000000477}, + {0.679167, 1, 1.000000477}, + {0.683333, 1, 1.000000477}, + {0.6875, 1, 1.000000477}, + {0.691667, 1, 1.000000477}, + {0.695833, 1, 1.000000477}, + {0.7, 1, 1.000000477}, + {0.704167, 1, 1.000000477}, + {0.708333, 1, 1.000000477}, + {0.7125, 1, 1.000000477}, + {0.716667, 1, 1.000000477}, + {0.720833, 1, 1.000000477}, + {0.725, 1, 1.000000477}, + {0.729167, 1, 1.000000477}, + {0.733333, 1, 1.000000477}, + {0.7375, 1, 1.000000477}, + {0.741667, 1, 1.000000477}, + {0.745833, 1, 1.000000477}, + {0.75, 1, 1.000000477}, + {0.754167, 1, 1.000000477}, + {0.758333, 1, 1.000000477}, + {0.7625, 1, 1.000000477}, + {0.766667, 1, 1.000000477}, + {0.770833, 1, 1.000000477}, + {0.775, 1, 1.000000477}, + {0.779167, 1, 1.000000477}, + {0.783333, 1, 1.000000477}, + {0.7875, 1, 1.000000477}, + {0.791667, 1, 1.000000477}, + {0.795833, 1, 1.000000477}, + {0.8, 1, 1.000000477}, + {0.804167, 1, 1.000000477}, + {0.808333, 1, 1.000000477}, + {0.8125, 1, 1.000000477}, + {0.816667, 1, 1.000000477}, + {0.820833, 1, 1.000000477}, + {0.825, 1, 1.000000477}, + {0.829167, 1, 1.000000477}, + {0.833333, 1, 1.000000477}, + {0.8375, 1, 1.000000477}, + {0.841667, 1, 1.000000477}, + {0.845833, 1, 1.000000477}, + {0.85, 1, 1.000000477}, + {0.854167, 1, 1.000000477}, + {0.858333, 1, 1.000000477}, + {0.8625, 1, 1.000000477}, + {0.866667, 1, 1.000000477}, + {0.870833, 1, 1.000000477}, + {0.875, 1, 1.000000477}, + {0.879167, 1, 1.000000477}, + {0.883333, 1, 1.000000477}, + {0.8875, 1, 1.000000477}, + {0.891667, 1, 1.000000477}, + {0.895833, 1, 1.000000477}, + {0.9, 1, 1.000000477}, + {0.904167, 1, 1.000000477}, + {0.908333, 1, 1.000000477}, + {0.9125, 1, 1.000000477}, + {0.916667, 1, 1.000000477}, + {0.920833, 1, 1.000000477}, + {0.925, 1, 1.000000477}, + {0.929167, 1, 1.000000477}, + {0.933333, 1, 1.000000477}, + {0.9375, 1, 1.000000477}, + {0.941667, 1, 1.000000477}, + {0.945833, 1, 1.000000477}, + {0.95, 1, 1.000000477}, + {0.954167, 1, 1.000000477}, + {0.958333, 1, 1.000000477}, + {0.9625, 1, 1.000000477}, + {0.966667, 1, 1.000000477}, + {0.970833, 1, 1.000000477}, + {0.975, 1, 1.000000477}, + {0.979167, 1, 1.000000477}, + {0.983333, 1, 1.000000477}, + {0.9875, 1, 1.000000477}, + {0.991667, 1, 1.000000477}, + {0.995833, 1, 1.000000477}, + {1, 1, 1.000000477}, + {1.004167, 1.000682712, 0.015128844}, + {1.008333, 1.001363397, 0.014973078}, + {1.0125, 1.002042532, 0.014841928}, + {1.016667, 1.002720356, 0.014729479}, + {1.020833, 1.00339675, 0.014631276}, + {1.025, 1.004072189, 0.014543867}, + {1.029167, 1.004746675, 0.01446466}, + {1.033333, 1.00541997, 0.014391631}, + {1.0375, 1.006092548, 0.01432314}, + {1.041667, 1.006764412, 0.014257919}, + {1.045833, 1.007435203, 0.014194945}, + {1.05, 1.008105278, 0.014133334}, + {1.054167, 1.008774638, 0.014072391}, + {1.058333, 1.009443045, 0.014011139}, + {1.0625, 1.010110855, 0.01395021}, + {1.066667, 1.010777831, 0.013887996}, + {1.070833, 1.011443853, 0.013824509}, + {1.075, 1.01210916, 0.013759368}, + {1.079167, 1.012773633, 0.013692267}, + {1.083333, 1.013437271, 0.013622929}, + {1.0875, 1.014100075, 0.013551049}, + {1.091667, 1.014762163, 0.013476389}, + {1.095833, 1.015423179, 0.013398723}, + {1.1, 1.016083598, 0.013398723}, + {1.104167, 1.015262365, 0.88047874}, + {1.108333, 1.014493585, 0.89023459}, + {1.1125, 1.013762116, 0.898759723}, + {1.116667, 1.013056278, 0.906125188}, + {1.120833, 1.012367129, 0.912427425}, + {1.125, 1.01168704, 0.917777061}, + {1.129167, 1.011010766, 0.922281682}, + {1.133333, 1.010334253, 0.926045954}, + {1.1375, 1.009654403, 0.929170609}, + {1.141667, 1.008969307, 0.931745946}, + {1.145833, 1.008277893, 0.93385452}, + {1.15, 1.007579207, 0.935571969}, + {1.154167, 1.006873131, 0.936964393}, + {1.158333, 1.006160259, 0.938090801}, + {1.1625, 1.005440712, 0.939003944}, + {1.166667, 1.0047158, 0.9397493}, + {1.170833, 1.003986597, 0.940366805}, + {1.175, 1.003253937, 0.940891325}, + {1.179167, 1.002519608, 0.941352487}, + {1.183333, 1.001785278, 0.94177556}, + {1.1875, 1.001052022, 0.942182004}, + {1.191667, 1.000321627, 0.942589283}, + {1.195833, 0.999596179, 0.943011642}, + {1.2, 0.998876929, 0.943460345}, + {1.204167, 0.998165727, 0.943943799}, + {1.208333, 0.997464538, 0.944467604}, + {1.2125, 0.996774673, 0.945035696}, + {1.216667, 0.996098042, 0.945649385}, + {1.220833, 0.995436549, 0.946308196}, + {1.225, 0.994791448, 0.947010458}, + {1.229167, 0.994164526, 0.947752595}, + {1.233333, 0.993557453, 0.948529899}, + {1.2375, 0.99297154, 0.949337125}, + {1.241667, 0.992408335, 0.950167537}, + {1.245833, 0.99186933, 0.951014042}, + {1.25, 0.991355598, 0.951869369}, + {1.254167, 0.990868449, 0.952725708}, + {1.258333, 0.990409136, 0.953574955}, + {1.2625, 0.989978492, 0.954409778}, + {1.266667, 0.989577591, 0.955215633}, + {1.270833, 0.989207327, 0.956005096}, + {1.275, 0.988868177, 0.956751525}, + {1.279167, 0.988560915, 0.957458079}, + {1.283333, 0.988285899, 0.958120406}, + {1.2875, 0.988043547, 0.958723307}, + {1.291667, 0.987834036, 0.959283113}, + {1.295833, 0.987657607, 0.959768534}, + {1.3, 0.987514019, 0.960213661}, + {1.304167, 0.987403274, 0.96057564}, + {1.308333, 0.987325132, 0.96090132}, + {1.3125, 0.987279058, 0.961140752}, + {1.316667, 0.987264812, 0.961349428}, + {1.320833, 0.987281561, 0.961474001}, + {1.325, 0.987328827, 0.961574197}, + {1.329167, 0.987405658, 0.961597323}, + {1.333333, 0.987511337, 0.961602867}, + {1.3375, 0.987644792, 0.96154201}, + {1.341667, 0.987805247, 0.961470485}, + {1.345833, 0.987991393, 0.961345851}, + {1.35, 0.988202393, 0.961207449}, + {1.354167, 0.988437057, 0.961049318}, + {1.358333, 0.988694072, 0.960876703}, + {1.3625, 0.988972366, 0.960694611}, + {1.366667, 0.989270747, 0.960507751}, + {1.370833, 0.989587843, 0.96032083}, + {1.375, 0.989922643, 0.960137904}, + {1.379167, 0.990273893, 0.959962845}, + {1.383333, 0.990640223, 0.95979917}, + {1.3875, 0.991020679, 0.959649861}, + {1.391667, 0.991413951, 0.959517598}, + {1.395833, 0.991818845, 0.959404588}, + {1.4, 0.992234349, 0.959312677}, + {1.404167, 0.99265933, 0.959243178}, + {1.408333, 0.993092477, 0.959197223}, + {1.4125, 0.993533015, 0.959175408}, + {1.416667, 0.993979812, 0.95917803}, + {1.420833, 0.994431734, 0.959205091}, + {1.425, 0.994888008, 0.959256351}, + {1.429167, 0.995347559, 0.959331334}, + {1.433333, 0.995809376, 0.959429204}, + {1.4375, 0.996272743, 0.959549129}, + {1.441667, 0.996736646, 0.95968461}, + {1.445833, 0.997200072, 0.959850907}, + {1.45, 0.997662604, 0.960024655}, + {1.454167, 0.998123169, 0.960226417}, + {1.458333, 0.998580933, 0.960433066}, + {1.4625, 0.999035299, 0.960664332}, + {1.466667, 0.999485552, 0.96089834}, + {1.470833, 0.99993068, 0.961153209}, + {1.475, 1.000370383, 0.961408794}, + {1.479167, 1.000803709, 0.961681604}, + {1.483333, 1.001230001, 0.961953163}, + {1.4875, 1.001648784, 0.962238312}, + {1.491667, 1.00205946, 0.962520778}, + {1.495833, 1.002461076, 0.962813199}, + {1.5, 1.002853513, 0.963101745}, + {1.504167, 1.003236055, 0.963396966}, + {1.508333, 1.003607988, 0.96368736}, + {1.5125, 1.003968954, 0.963981271}, + {1.516667, 1.004318357, 0.964269757}, + {1.520833, 1.004655838, 0.964558721}, + {1.525, 1.004980803, 0.964841962}, + {1.529167, 1.005292892, 0.965122938}, + {1.533333, 1.005591631, 0.965397894}, + {1.5375, 1.00587666, 0.965667963}, + {1.541667, 1.006147623, 0.96593219}, + {1.545833, 1.006403923, 0.966188729}, + {1.55, 1.006645441, 0.966439664}, + {1.554167, 1.00687182, 0.966680348}, + {1.558333, 1.007082582, 0.966915607}, + {1.5625, 1.007277608, 0.967138052}, + {1.566667, 1.00745666, 0.967355549}, + {1.570833, 1.007619381, 0.96755743}, + {1.575, 1.007765532, 0.967754841}, + {1.579167, 1.007894993, 0.967934012}, + {1.583333, 1.008007526, 0.968109071}, + {1.5875, 1.008103132, 0.968263447}, + {1.591667, 1.008181453, 0.968414128}, + {1.595833, 1.008242607, 0.968541622}, + {1.6, 1.008286357, 0.968665838}, + {1.604167, 1.008312702, 0.968764782}, + {1.608333, 1.008321762, 0.968860805}, + {1.6125, 1.008313417, 0.968929827}, + {1.616667, 1.008287787, 0.968996286}, + {1.620833, 1.008244872, 0.969034612}, + {1.625, 1.00818491, 0.969070733}, + {1.629167, 1.00810802, 0.969078183}, + {1.633333, 1.008014202, 0.969083905}, + {1.6375, 1.007904053, 0.969061136}, + {1.641667, 1.007777452, 0.969037175}, + {1.645833, 1.007634878, 0.968985915}, + {1.65, 1.007476687, 0.96893394}, + {1.654167, 1.007303119, 0.968856812}, + {1.658333, 1.007114768, 0.968779624}, + {1.6625, 1.006911874, 0.968680382}, + {1.666667, 1.006694913, 0.968581617}, + {1.670833, 1.00646472, 0.968464911}, + {1.675, 1.006221414, 0.968349338}, + {1.679167, 1.005965829, 0.968220592}, + {1.683333, 1.005698442, 0.968093693}, + {1.6875, 1.005420089, 0.967959166}, + {1.691667, 1.005131125, 0.967827022}, + {1.695833, 1.004832625, 0.967693269}, + {1.7, 1.004525065, 0.967562377}, + {1.704167, 1.00420928, 0.967436075}, + {1.708333, 1.003885984, 0.967313051}, + {1.7125, 1.003556132, 0.967200637}, + {1.716667, 1.003220201, 0.967091799}, + {1.720833, 1.0028795, 0.966999233}, + {1.725, 1.00253439, 0.966910303}, + {1.729167, 1.00218606, 0.966842711}, + {1.733333, 1.001835227, 0.966778576}, + {1.7375, 1.001482844, 0.966739953}, + {1.741667, 1.001129627, 0.966711283}, + {1.745833, 1.000776529, 0.966690898}, + {1.75, 1.000424623, 0.966700375}, + {1.754167, 1.000074387, 0.96671176}, + {1.758333, 0.999727011, 0.966754198}, + {1.7625, 0.999383092, 0.966797709}, + {1.766667, 0.999043643, 0.966872096}, + {1.770833, 0.998709381, 0.966946483}, + {1.775, 0.998381138, 0.967050433}, + {1.779167, 0.99805963, 0.967153192}, + {1.783333, 0.997745872, 0.96728301}, + {1.7875, 0.997440159, 0.967410386}, + {1.791667, 0.997143567, 0.967561364}, + {1.795833, 0.99685663, 0.967714787}, + {1.8, 0.996579885, 0.967869997}, + {1.804167, 0.996314168, 0.968042195}, + {1.808333, 0.996059835, 0.968208969}, + {1.8125, 0.995817542, 0.968387842}, + {1.816667, 0.995587707, 0.968560398}, + {1.820833, 0.995370924, 0.968739927}, + {1.825, 0.995167375, 0.968912601}, + {1.829167, 0.994977593, 0.969087243}, + {1.833333, 0.994801879, 0.969254494}, + {1.8375, 0.99464041, 0.96941936}, + {1.841667, 0.994493544, 0.969576657}, + {1.845833, 0.994361401, 0.969727576}, + {1.85, 0.994244099, 0.969871104}, + {1.854167, 0.994141817, 0.970005214}, + {1.858333, 0.994054556, 0.970132172}, + {1.8625, 0.993982315, 0.970247447}, + {1.866667, 0.993925095, 0.970356286}, + {1.870833, 0.993882775, 0.97045207}, + {1.875, 0.993855238, 0.970542192}, + {1.879167, 0.993842363, 0.970618844}, + {1.883333, 0.993843973, 0.970690787}, + {1.8875, 0.993859708, 0.970749676}, + {1.891667, 0.993889451, 0.97080493}, + {1.895833, 0.993932843, 0.970848203}, + {1.9, 0.993989527, 0.970888972}, + {1.904167, 0.994059205, 0.97091943}, + {1.908333, 0.994141459, 0.970948577}, + {1.9125, 0.994235873, 0.970969498}, + {1.916667, 0.994342029, 0.970990121}, + {1.920833, 0.99445945, 0.971004903}, + {1.925, 0.994587719, 0.971020401}, + {1.929167, 0.9947263, 0.971032619}, + {1.933333, 0.994874775, 0.971046269}, + {1.9375, 0.995032549, 0.971059203}, + {1.941667, 0.995199144, 0.971074224}, + {1.945833, 0.995373964, 0.971090853}, + {1.95, 0.995556593, 0.971110106}, + {1.954167, 0.995746374, 0.971133053}, + {1.958333, 0.995942831, 0.971158922}, + {1.9625, 0.996145368, 0.971190274}, + {1.966667, 0.996353567, 0.971224725}, + {1.970833, 0.996566653, 0.97126615}, + {1.975, 0.996784389, 0.971310556}, + {1.979167, 0.997005939, 0.971363068}, + {1.983333, 0.997230887, 0.971418381}, + {1.9875, 0.997458696, 0.971482456}, + {1.991667, 0.997688949, 0.971549094}, + {1.995833, 0.997920871, 0.971624851}, + {2, 0.998154223, 0.971702695}, + {2.004167, 0.99838829, 0.971789718}, + {2.008333, 0.998622656, 0.971878409}, + {2.0125, 0.998856843, 0.971975863}, + {2.016667, 0.999090433, 0.972074568}, + {2.020833, 0.999322772, 0.972181499}, + {2.025, 0.999553561, 0.972289145}, + {2.029167, 0.999782324, 0.972404182}, + {2.033333, 1.000008583, 0.972519457}, + {2.0375, 1.000231862, 0.97264123}, + {2.041667, 1.000451922, 0.972762704}, + {2.045833, 1.000668168, 0.972889543}, + {2.05, 1.000880361, 0.973015666}, + {2.054167, 1.001088023, 0.973146021}, + {2.058333, 1.001290798, 0.973275185}, + {2.0625, 1.001488328, 0.973407388}, + {2.066667, 1.001680374, 0.973538041}, + {2.070833, 1.00186646, 0.973670363}, + {2.075, 1.002046466, 0.973800957}, + {2.079167, 1.002219915, 0.973931909}, + {2.083333, 1.002386689, 0.974060893}, + {2.0875, 1.00254631, 0.974188983}, + {2.091667, 1.002698779, 0.974314928}, + {2.095833, 1.002843618, 0.974438667}, + {2.1, 1.002980828, 0.974560261}, + {2.104167, 1.003109932, 0.974678457}, + {2.108333, 1.003231049, 0.974794388}, + {2.1125, 1.003343701, 0.974905789}, + {2.116667, 1.003448009, 0.975015044}, + {2.120833, 1.003543615, 0.975118697}, + {2.125, 1.003630638, 0.975220263}, + {2.129167, 1.00370872, 0.975315332}, + {2.133333, 1.003777862, 0.975408375}, + {2.1375, 1.003837943, 0.975494087}, + {2.141667, 1.003889084, 0.97557801}, + {2.145833, 1.003931046, 0.975653946}, + {2.15, 1.003963828, 0.975728214}, + {2.154167, 1.003987551, 0.975794077}, + {2.158333, 1.004002213, 0.97585845}, + {2.1625, 1.004007816, 0.975914061}, + {2.166667, 1.00400424, 0.97596848}, + {2.170833, 1.003991842, 0.976014078}, + {2.175, 1.003970623, 0.976058662}, + {2.179167, 1.003940463, 0.976094544}, + {2.183333, 1.003901839, 0.976129651}, + {2.1875, 1.003854632, 0.976156354}, + {2.191667, 1.003799081, 0.97618264}, + {2.195833, 1.003735423, 0.976201057}, + {2.2, 1.003663778, 0.976219237}, + {2.204167, 1.003584385, 0.976230323}, + {2.208333, 1.003497481, 0.97624141}, + {2.2125, 1.003403306, 0.976246357}, + {2.216667, 1.003302097, 0.976251602}, + {2.220833, 1.003194094, 0.976251721}, + {2.225, 1.003079653, 0.976252377}, + {2.229167, 1.002959013, 0.976249218}, + {2.233333, 1.002832532, 0.976246715}, + {2.2375, 1.002700567, 0.976241708}, + {2.241667, 1.002563357, 0.976237595}, + {2.245833, 1.002421498, 0.97623235}, + {2.25, 1.00227499, 0.976228058}, + {2.254167, 1.002124429, 0.976224005}, + {2.258333, 1.001970172, 0.976221025}, + {2.2625, 1.001812577, 0.976219654}, + {2.266667, 1.001652002, 0.976219356}, + {2.270833, 1.001489043, 0.976221859}, + {2.275, 1.001323819, 0.976225436}, + {2.279167, 1.001156807, 0.976232946}, + {2.283333, 1.000988603, 0.976241529}, + {2.2875, 1.000819445, 0.97625488}, + {2.291667, 1.000649691, 0.976269126}, + {2.295833, 1.000480056, 0.976288915}, + {2.3, 1.00031054, 0.976309478}, + {2.304167, 1.00014174, 0.976336062}, + {2.308333, 0.999974132, 0.976363182}, + {2.3125, 0.999808013, 0.97639662}, + {2.316667, 0.999643743, 0.976430357}, + {2.320833, 0.999481857, 0.976470292}, + {2.325, 0.999322474, 0.976510406}, + {2.329167, 0.999166131, 0.97655654}, + {2.333333, 0.999013186, 0.976602495}, + {2.3375, 0.998863876, 0.976654112}, + {2.341667, 0.998718619, 0.976705313}, + {2.345833, 0.998577714, 0.97676152}, + {2.35, 0.998441339, 0.976817131}, + {2.354167, 0.99830997, 0.976876974}, + {2.358333, 0.998183727, 0.976935983}, + {2.3625, 0.998062968, 0.976998508}, + {2.366667, 0.997947812, 0.97706002}, + {2.370833, 0.997838557, 0.977124095}, + {2.375, 0.997735381, 0.977187037}, + {2.379167, 0.997638524, 0.977251768}, + {2.383333, 0.997548044, 0.977315128}, + {2.3875, 0.99746418, 0.97737956}, + {2.391667, 0.997386992, 0.977442563}, + {2.395833, 0.997316659, 0.977505863}, + {2.4, 0.99725318, 0.977567792}, + {2.404167, 0.997196674, 0.977629304}, + {2.408333, 0.997147202, 0.977689505}, + {2.4125, 0.997104764, 0.977748811}, + {2.416667, 0.997069418, 0.977806926}, + {2.420833, 0.997041106, 0.977863729}, + {2.425, 0.997019887, 0.977919519}, + {2.429167, 0.997005641, 0.977973759}, + {2.433333, 0.99699831, 0.978027105}, + {2.4375, 0.996997893, 0.978078902}, + {2.441667, 0.997004211, 0.978129923}, + {2.445833, 0.997017264, 0.978179455}, + {2.45, 0.997036815, 0.97822845}, + {2.454167, 0.997062802, 0.978276134}, + {2.458333, 0.997095108, 0.97832346}, + {2.4625, 0.997133493, 0.978369713}, + {2.466667, 0.997177839, 0.978415847}, + {2.470833, 0.997227907, 0.978461266}, + {2.475, 0.997283578, 0.978506744}, + {2.479167, 0.997344553, 0.978551865}, + {2.483333, 0.997410715, 0.978597224}, + {2.4875, 0.997481763, 0.978642642}, + {2.491667, 0.99755758, 0.978688478}, + {2.495833, 0.997637749, 0.978734732}, + {2.5, 0.997722149, 0.978781521}, + {2.504167, 0.997810483, 0.978829205}, + {2.508333, 0.997902572, 0.978877366}, + {2.5125, 0.997998059, 0.978926837}, + {2.516667, 0.998096764, 0.978976846}, + {2.520833, 0.99819833, 0.979028463}, + {2.525, 0.998302639, 0.979080617}, + {2.529167, 0.998409212, 0.97913456}, + {2.533333, 0.998517931, 0.979189098}, + {2.5375, 0.998628497, 0.979245543}, + {2.541667, 0.998740673, 0.979302526}, + {2.545833, 0.998854041, 0.979361534}, + {2.55, 0.998968482, 0.97942096}, + {2.554167, 0.999083698, 0.979482412}, + {2.558333, 0.99919939, 0.979544222}, + {2.5625, 0.999315321, 0.97960794}, + {2.566667, 0.999431312, 0.979671896}, + {2.570833, 0.999546885, 0.979737639}, + {2.575, 0.999662042, 0.979803562}, + {2.579167, 0.999776363, 0.979871035}, + {2.583333, 0.999889672, 0.979938447}, + {2.5875, 1.000001788, 0.980007231}, + {2.591667, 1.000112414, 0.980075896}, + {2.595833, 1.000221252, 0.980145454}, + {2.6, 1.000328302, 0.980214894}, + {2.604167, 1.000433087, 0.98028487}, + {2.608333, 1.000535607, 0.980354488}, + {2.6125, 1.000635624, 0.980424404}, + {2.616667, 1.000732899, 0.980493844}, + {2.620833, 1.000827312, 0.980563104}, + {2.625, 1.000918627, 0.980631888}, + {2.629167, 1.001006722, 0.980700076}, + {2.633333, 1.001091361, 0.980767667}, + {2.6375, 1.001172543, 0.980834305}, + {2.641667, 1.001250029, 0.980900288}, + {2.645833, 1.001323581, 0.980964839}, + {2.65, 1.001393318, 0.981028795}, + {2.654167, 1.001459002, 0.981091022}, + {2.658333, 1.001520634, 0.981152534}, + {2.6625, 1.001577854, 0.98121196}, + {2.666667, 1.001630902, 0.98127073}, + {2.670833, 1.00167942, 0.981327116}, + {2.675, 1.001723647, 0.981382847}, + {2.679167, 1.001763225, 0.981435895}, + {2.683333, 1.001798391, 0.981488407}, + {2.6875, 1.001828909, 0.981538057}, + {2.691667, 1.001854777, 0.981587112}, + {2.695833, 1.001875997, 0.981633246}, + {2.7, 1.001892686, 0.981678843}, + {2.704167, 1.001904726, 0.981721342}, + {2.708333, 1.001912117, 0.981763482}, + {2.7125, 1.001914978, 0.981802464}, + {2.716667, 1.001913309, 0.981841147}, + {2.720833, 1.00190711, 0.981876731}, + {2.725, 1.001896501, 0.981912136}, + {2.729167, 1.00188148, 0.981944501}, + {2.733333, 1.001862168, 0.981976748}, + {2.7375, 1.001838684, 0.982006192}, + {2.741667, 1.001811028, 0.982035518}, + {2.745833, 1.001779318, 0.98206234}, + {2.75, 1.001743793, 0.982089102}, + {2.754167, 1.001704335, 0.98211354}, + {2.758333, 1.001661181, 0.982138097}, + {2.7625, 1.001614571, 0.982160687}, + {2.766667, 1.001564503, 0.982183337}, + {2.770833, 1.001511216, 0.982204437}, + {2.775, 1.001454711, 0.982225657}, + {2.779167, 1.001395345, 0.982245624}, + {2.783333, 1.001333117, 0.98226589}, + {2.7875, 1.001268268, 0.982285261}, + {2.791667, 1.001200914, 0.982304871}, + {2.795833, 1.001131415, 0.982324004}, + {2.8, 1.001059771, 0.982343495}, + {2.804167, 1.000986099, 0.982362807}, + {2.808333, 1.000910878, 0.982382476}, + {2.8125, 1.000833988, 0.982402384}, + {2.816667, 1.000755906, 0.98242265}, + {2.820833, 1.000676632, 0.982443452}, + {2.825, 1.000596285, 0.982464552}, + {2.829167, 1.000515342, 0.982486546}, + {2.833333, 1.000433803, 0.982508838}, + {2.8375, 1.000351906, 0.982532263}, + {2.841667, 1.000269771, 0.982555926}, + {2.845833, 1.000187874, 0.9825809}, + {2.85, 1.000106096, 0.982606173}, + {2.854167, 1.000024676, 0.982632816}, + {2.858333, 0.999943972, 0.982659698}, + {2.8625, 0.999864042, 0.982688129}, + {2.866667, 0.999785066, 0.98271668}, + {2.870833, 0.999707282, 0.98274678}, + {2.875, 0.999630749, 0.982777059}, + {2.879167, 0.999555767, 0.982808828}, + {2.883333, 0.999482453, 0.982840717}, + {2.8875, 0.999410987, 0.982874095}, + {2.891667, 0.999341428, 0.982907474}, + {2.895833, 0.999274015, 0.982942283}, + {2.9, 0.999208868, 0.982977033}, + {2.904167, 0.999146104, 0.983013093}, + {2.908333, 0.999085844, 0.983049035}, + {2.9125, 0.999028206, 0.983086228}, + {2.916667, 0.99897325, 0.983123243}, + {2.920833, 0.998921216, 0.98316133}, + {2.925, 0.998872042, 0.983199179}, + {2.929167, 0.998825967, 0.983237982}, + {2.933333, 0.998782873, 0.983276546}, + {2.9375, 0.998742998, 0.983315885}, + {2.941667, 0.998706341, 0.983354986}, + {2.945833, 0.998672962, 0.983394682}, + {2.95, 0.998642862, 0.9834342}, + {2.954167, 0.998616099, 0.983474135}, + {2.958333, 0.998592734, 0.983513892}, + {2.9625, 0.998572767, 0.983554006}, + {2.966667, 0.998556137, 0.983593881}, + {2.970833, 0.998542905, 0.983634114}, + {2.975, 0.99853307, 0.983674109}, + {2.979167, 0.998526633, 0.983714342}, + {2.983333, 0.998523533, 0.983754396}, + {2.9875, 0.998523712, 0.98379463}, + {2.991667, 0.998527169, 0.983834684}, + {2.995833, 0.998533845, 0.983874977}, + {3, 0.998543739, 0.983915091}, + {3.004167, 0.998556674, 0.983955443}, + {3.008333, 0.998572707, 0.983995676}, + {3.0125, 0.998591661, 0.984036088}, + {3.016667, 0.998613536, 0.98407644}, + {3.020833, 0.998638153, 0.984117031}, + {3.025, 0.998665512, 0.984157622}, + {3.029167, 0.998695493, 0.984198391}, + {3.033333, 0.998727977, 0.984239221}, + {3.0375, 0.998762906, 0.984280348}, + {3.041667, 0.998800099, 0.984321475}, + {3.045833, 0.998839438, 0.9843629}, + {3.05, 0.998880863, 0.984404445}, + {3.054167, 0.998924255, 0.984446287}, + {3.058333, 0.998969436, 0.984488249}, + {3.0625, 0.999016345, 0.984530509}, + {3.066667, 0.999064803, 0.984572887}, + {3.070833, 0.999114692, 0.984615624}, + {3.075, 0.999165893, 0.98465848}, + {3.079167, 0.999218225, 0.984701633}, + {3.083333, 0.999271631, 0.984744906}, + {3.0875, 0.999325931, 0.984788537}, + {3.091667, 0.999381006, 0.984832227}, + {3.095833, 0.999436736, 0.984876215}, + {3.1, 0.999492943, 0.984920263}, + {3.104167, 0.999549508, 0.984964609}, + {3.108333, 0.999606311, 0.985008955}, + {3.1125, 0.999663234, 0.98505348}, + {3.116667, 0.999720097, 0.985098004}, + {3.120833, 0.99977684, 0.985142648}, + {3.125, 0.999833286, 0.985187292}, + {3.129167, 0.999889314, 0.985231936}, + {3.133333, 0.999944806, 0.98527652}, + {3.1375, 0.999999642, 0.985321045}, + {3.141667, 1.000053763, 0.98536545}, + {3.145833, 1.000106931, 0.985409677}, + {3.15, 1.000159144, 0.985453784}, + {3.154167, 1.000210285, 0.985497534}, + {3.158333, 1.000260115, 0.985541224}, + {3.1625, 1.000308752, 0.985584378}, + {3.166667, 1.000355959, 0.985627472}, + {3.170833, 1.000401735, 0.985669911}, + {3.175, 1.000445843, 0.98571223}, + {3.179167, 1.0004884, 0.985753834}, + {3.183333, 1.00052917, 0.985795259}, + {3.1875, 1.000568032, 0.98583585}, + {3.191667, 1.000605226, 0.985876262}, + {3.195833, 1.000640273, 0.98591572}, + {3.2, 1.000673413, 0.985955}, + {3.204167, 1.000704527, 0.985993266}, + {3.208333, 1.000733614, 0.986031294}, + {3.2125, 1.000760436, 0.986068249}, + {3.216667, 1.000785112, 0.986105025}, + {3.220833, 1.000807524, 0.986140609}, + {3.225, 1.000827789, 0.986176014}, + {3.229167, 1.00084579, 0.986210167}, + {3.233333, 1.000861406, 0.986244142}, + {3.2375, 1.000874758, 0.986276925}, + {3.241667, 1.000885844, 0.986309528}, + {3.245833, 1.000894666, 0.986340821}, + {3.25, 1.000901222, 0.986372054}, + {3.254167, 1.000905395, 0.986401975}, + {3.258333, 1.000907302, 0.986431777}, + {3.2625, 1.000906944, 0.986460388}, + {3.266667, 1.000904441, 0.986488879}, + {3.270833, 1.000899673, 0.986516178}, + {3.275, 1.000892639, 0.986543477}, + {3.279167, 1.000883579, 0.986569583}, + {3.283333, 1.000872493, 0.98659569}, + {3.2875, 1.000859261, 0.986620784}, + {3.291667, 1.000844121, 0.986645818}, + {3.295833, 1.000826955, 0.986669898}, + {3.3, 1.000807881, 0.986694038}, + {3.304167, 1.000787139, 0.986717284}, + {3.308333, 1.000764608, 0.986740589}, + {3.3125, 1.00074029, 0.986763179}, + {3.316667, 1.000714421, 0.986785829}, + {3.320833, 1.000687122, 0.986807883}, + {3.325, 1.000658274, 0.986829996}, + {3.329167, 1.000628114, 0.986851633}, + {3.333333, 1.000596523, 0.986873388}, + {3.3375, 1.00056386, 0.986894786}, + {3.341667, 1.000530124, 0.986916244}, + {3.345833, 1.000495315, 0.986937523}, + {3.35, 1.000459552, 0.986958921}, + {3.354167, 1.000423074, 0.986980259}, + {3.358333, 1.000385761, 0.987001657}, + {3.3625, 1.000347853, 0.987023056}, + {3.366667, 1.000309348, 0.987044632}, + {3.370833, 1.000270367, 0.987066269}, + {3.375, 1.000231028, 0.987088084}, + {3.379167, 1.000191569, 0.987110138}, + {3.383333, 1.000151753, 0.987132251}, + {3.3875, 1.000112057, 0.987154663}, + {3.391667, 1.000072241, 0.987177193}, + {3.395833, 1.000032663, 0.987200141}, + {3.4, 0.999993145, 0.987223148}, + {3.404167, 0.999954045, 0.987246573}, + {3.408333, 0.999915302, 0.987270117}, + {3.4125, 0.999877036, 0.987294137}, + {3.416667, 0.999839365, 0.987318218}, + {3.420833, 0.999802351, 0.987342775}, + {3.425, 0.999765992, 0.987367451}, + {3.429167, 0.999730527, 0.987392604}, + {3.433333, 0.999695897, 0.987417817}, + {3.4375, 0.99966222, 0.987443566}, + {3.441667, 0.999629617, 0.987469375}, + {3.445833, 0.999598086, 0.98749572}, + {3.45, 0.999567688, 0.987522006}, + {3.454167, 0.999538481, 0.987548888}, + {3.458333, 0.999510586, 0.98757571}, + {3.4625, 0.999484062, 0.987603068}, + {3.466667, 0.999458849, 0.987630427}, + {3.470833, 0.999435067, 0.987658262}, + {3.475, 0.999412715, 0.987686098}, + {3.479167, 0.999391854, 0.98771435}, + {3.483333, 0.999372542, 0.987742543}, + {3.4875, 0.999354839, 0.987771213}, + {3.491667, 0.999338627, 0.987799883}, + {3.495833, 0.999324083, 0.987828851}, + {3.5, 0.999311149, 0.987857878}, + {3.504167, 0.999299824, 0.987887204}, + {3.508333, 0.999290168, 0.987916529}, + {3.5125, 0.999282122, 0.987946153}, + {3.516667, 0.999275744, 0.987975776}, + {3.520833, 0.999270976, 0.988005638}, + {3.525, 0.999267876, 0.9880355}, + {3.529167, 0.999266386, 0.98806566}, + {3.533333, 0.999266505, 0.98809576}, + {3.5375, 0.999268234, 0.988126099}, + {3.541667, 0.999271512, 0.988156438}, + {3.545833, 0.99927634, 0.988187015}, + {3.55, 0.999282718, 0.988217533}, + {3.554167, 0.999290526, 0.988248229}, + {3.558333, 0.999299765, 0.988278985}, + {3.5625, 0.999310493, 0.98830986}, + {3.566667, 0.999322534, 0.988340735}, + {3.570833, 0.999335885, 0.988371789}, + {3.575, 0.999350548, 0.988402784}, + {3.579167, 0.999366403, 0.988433957}, + {3.583333, 0.99938345, 0.98846513}, + {3.5875, 0.999401629, 0.988496423}, + {3.591667, 0.999420881, 0.988527715}, + {3.595833, 0.999441147, 0.988559127}, + {3.6, 0.999462366, 0.988590479}, + {3.604167, 0.999484479, 0.98862195}, + {3.608333, 0.999507427, 0.988653421}, + {3.6125, 0.99953115, 0.988684893}, + {3.616667, 0.999555588, 0.988716424}, + {3.620833, 0.999580622, 0.988747954}, + {3.625, 0.999606252, 0.988779485}, + {3.629167, 0.999632418, 0.988810956}, + {3.633333, 0.999659002, 0.988842487}, + {3.6375, 0.999685943, 0.988873959}, + {3.641667, 0.999713242, 0.98890543}, + {3.645833, 0.99974072, 0.988936782}, + {3.65, 0.999768436, 0.988968134}, + {3.654167, 0.999796212, 0.988999367}, + {3.658333, 0.999824107, 0.9890306}, + {3.6625, 0.999851942, 0.989061654}, + {3.666667, 0.999879658, 0.989092648}, + {3.670833, 0.999907255, 0.989123464}, + {3.675, 0.999934673, 0.989154279}, + {3.679167, 0.999961793, 0.989184797}, + {3.683333, 0.999988556, 0.989215255}, + {3.6875, 1.00001502, 0.989245474}, + {3.691667, 1.000041008, 0.989275634}, + {3.695833, 1.0000664, 0.989305437}, + {3.7, 1.000091314, 0.989335179}, + {3.704167, 1.000115633, 0.989364564}, + {3.708333, 1.000139356, 0.98939383}, + {3.7125, 1.000162244, 0.989422739}, + {3.716667, 1.000184536, 0.989451587}, + {3.720833, 1.000205874, 0.989479899}, + {3.725, 1.000226498, 0.989508212}, + {3.729167, 1.000246286, 0.989535987}, + {3.733333, 1.000265121, 0.989563704}, + {3.7375, 1.000283003, 0.989590943}, + {3.741667, 1.000299931, 0.989618063}, + {3.745833, 1.000315905, 0.989644587}, + {3.75, 1.000330806, 0.989671111}, + {3.754167, 1.000344634, 0.989697039}, + {3.758333, 1.000357509, 0.989722848}, + {3.7625, 1.000369191, 0.98974812}, + {3.766667, 1.000379801, 0.989773333}, + {3.770833, 1.000389338, 0.98979789}, + {3.775, 1.000397801, 0.989822447}, + {3.779167, 1.000405073, 0.989846408}, + {3.783333, 1.000411153, 0.98987025}, + {3.7875, 1.00041616, 0.989893556}, + {3.791667, 1.000419974, 0.989916801}, + {3.795833, 1.000422716, 0.989939451}, + {3.8, 1.000424385, 0.989962041}, + {3.804167, 1.000424862, 0.989984095}, + {3.808333, 1.000424266, 0.990006089}, + {3.8125, 1.000422597, 0.990027547}, + {3.816667, 1.000419736, 0.990049005}, + {3.820833, 1.000415921, 0.990069926}, + {3.825, 1.000411034, 0.990090847}, + {3.829167, 1.000405192, 0.990111291}, + {3.833333, 1.000398278, 0.990131736}, + {3.8375, 1.00039053, 0.990151703}, + {3.841667, 1.000381708, 0.990171731}, + {3.845833, 1.000372052, 0.99019134}, + {3.85, 1.000361443, 0.99021095}, + {3.854167, 1.000350118, 0.990230203}, + {3.858333, 1.000337839, 0.990249455}, + {3.8625, 1.000324965, 0.990268469}, + {3.866667, 1.000311255, 0.990287483}, + {3.870833, 1.000296831, 0.990306258}, + {3.875, 1.000281811, 0.990325034}, + {3.879167, 1.000266194, 0.99034363}, + {3.883333, 1.000249982, 0.990362227}, + {3.8875, 1.000233293, 0.990380764}, + {3.891667, 1.000216126, 0.990399241}, + {3.895833, 1.000198603, 0.990417659}, + {3.9, 1.000180602, 0.990436137}, + {3.904167, 1.000162244, 0.990454555}, + {3.908333, 1.000143766, 0.990473032}, + {3.9125, 1.000124931, 0.990491509}, + {3.916667, 1.000105858, 0.990509987}, + {3.920833, 1.000086665, 0.990528524}, + {3.925, 1.000067472, 0.990547061}, + {3.929167, 1.000048161, 0.990565717}, + {3.933333, 1.000028849, 0.990584433}, + {3.9375, 1.000009537, 0.990603209}, + {3.941667, 0.999990344, 0.990622103}, + {3.945833, 0.999971271, 0.990641057}, + {3.95, 0.999952376, 0.990660071}, + {3.954167, 0.99993372, 0.990679264}, + {3.958333, 0.999915302, 0.990698457}, + {3.9625, 0.999897242, 0.990717828}, + {3.966667, 0.999879479, 0.990737259}, + {3.970833, 0.999862075, 0.990756929}, + {3.975, 0.999845088, 0.990776539}, + {3.979167, 0.999828577, 0.990796447}, + {3.983333, 0.999812543, 0.990816295}, + {3.9875, 0.999797046, 0.990836442}, + {3.991667, 0.999782085, 0.990856528}, + {3.995833, 0.999767721, 0.990876913}, + {4, 0.999753952, 0.990897238}, + {4.004167, 0.999740779, 0.990917861}, + {4.008333, 0.999728322, 0.990938425}, + {4.0125, 0.99971652, 0.990959287}, + {4.016667, 0.999705434, 0.990980089}, + {4.020833, 0.999695063, 0.991001189}, + {4.025, 0.999685407, 0.991022229}, + {4.029167, 0.999676526, 0.991043508}, + {4.033333, 0.999668419, 0.991064787}, + {4.0375, 0.999661088, 0.991086245}, + {4.041667, 0.999654531, 0.991107702}, + {4.045833, 0.99964875, 0.991129398}, + {4.05, 0.999643803, 0.991151035}, + {4.054167, 0.99963963, 0.99117291}, + {4.058333, 0.999636233, 0.991194725}, + {4.0625, 0.99963367, 0.991216719}, + {4.066667, 0.999631941, 0.991238713}, + {4.070833, 0.999630928, 0.991260886}, + {4.075, 0.999630749, 0.991283059}, + {4.079167, 0.999631345, 0.991305292}, + {4.083333, 0.999632716, 0.991327584}, + {4.0875, 0.999634802, 0.991349995}, + {4.091667, 0.999637663, 0.991372347}, + {4.095833, 0.999641299, 0.991394877}, + {4.1, 0.999645591, 0.991417348}, + {4.104167, 0.999650598, 0.991439939}, + {4.108333, 0.99965626, 0.991462469}, + {4.1125, 0.999662578, 0.991485119}, + {4.116667, 0.999669552, 0.991507709}, + {4.120833, 0.999677122, 0.991530359}, + {4.125, 0.999685287, 0.991553009}, + {4.129167, 0.99969399, 0.991575718}, + {4.133333, 0.999703228, 0.991598368}, + {4.1375, 0.999713004, 0.991621077}, + {4.141667, 0.999723196, 0.991643786}, + {4.145833, 0.999733865, 0.991666436}, + {4.15, 0.999745011, 0.991689086}, + {4.154167, 0.999756455, 0.991711676}, + {4.158333, 0.999768317, 0.991734326}, + {4.1625, 0.999780476, 0.991756856}, + {4.166667, 0.999792933, 0.991779447}, + {4.170833, 0.999805629, 0.991801858}, + {4.175, 0.999818563, 0.991824329}, + {4.179167, 0.999831676, 0.991846681}, + {4.183333, 0.999844968, 0.991869032}, + {4.1875, 0.999858439, 0.991891265}, + {4.191667, 0.999871969, 0.991913497}, + {4.195833, 0.999885499, 0.991935551}, + {4.2, 0.999899149, 0.991957605}, + {4.204167, 0.999912739, 0.99197948}, + {4.208333, 0.999926329, 0.992001355}, + {4.2125, 0.999939859, 0.992023051}, + {4.216667, 0.99995327, 0.992044747}, + {4.220833, 0.999966562, 0.992066205}, + {4.225, 0.999979734, 0.992087603}, + {4.229167, 0.999992669, 0.992108822}, + {4.233333, 1.000005484, 0.992130041}, + {4.2375, 1.000018001, 0.992150962}, + {4.241667, 1.00003016, 0.992171884}, + {4.245833, 1.0000422, 0.992192566}, + {4.25, 1.000053763, 0.99221319}, + {4.254167, 1.000065088, 0.992233574}, + {4.258333, 1.000076056, 0.9922539}, + {4.2625, 1.000086665, 0.992273927}, + {4.266667, 1.000096798, 0.992293954}, + {4.270833, 1.000106454, 0.992313683}, + {4.275, 1.000115752, 0.992333353}, + {4.279167, 1.000124574, 0.992352784}, + {4.283333, 1.000133038, 0.992372096}, + {4.2875, 1.000140905, 0.992391169}, + {4.291667, 1.000148177, 0.992410183}, + {4.295833, 1.000155091, 0.992428839}, + {4.3, 1.000161409, 0.992447555}, + {4.304167, 1.000167251, 0.992465854}, + {4.308333, 1.000172496, 0.992484212}, + {4.3125, 1.000177264, 0.992502213}, + {4.316667, 1.000181437, 0.992520213}, + {4.320833, 1.000185013, 0.992537856}, + {4.325, 1.000188112, 0.992555499}, + {4.329167, 1.000190616, 0.992572844}, + {4.333333, 1.000192642, 0.992590189}, + {4.3375, 1.000193954, 0.992607176}, + {4.341667, 1.000194788, 0.992624164}, + {4.345833, 1.000195146, 0.992640913}, + {4.35, 1.000194907, 0.992657602}, + {4.354167, 1.000194073, 0.992673993}, + {4.358333, 1.000192881, 0.992690444}, + {4.3625, 1.000190973, 0.992706597}, + {4.366667, 1.000188708, 0.99272275}, + {4.370833, 1.000185847, 0.992738664}, + {4.375, 1.000182509, 0.992754579}, + {4.379167, 1.000178695, 0.992770255}, + {4.383333, 1.000174522, 0.992785931}, + {4.3875, 1.000169754, 0.992801368}, + {4.391667, 1.000164747, 0.992816865}, + {4.395833, 1.000159144, 0.992832184}, + {4.4, 1.000153303, 0.992847502}, + {4.404167, 1.000146985, 0.992862642}, + {4.408333, 1.000140309, 0.992877781}, + {4.4125, 1.000133276, 0.992892802}, + {4.416667, 1.000126004, 0.992907822}, + {4.420833, 1.000118494, 0.992922723}, + {4.425, 1.000110626, 0.992937624}, + {4.429167, 1.00010252, 0.992952466}, + {4.433333, 1.000094175, 0.992967308}, + {4.4375, 1.000085592, 0.99298209}, + {4.441667, 1.00007689, 0.992996871}, + {4.445833, 1.000067949, 0.993011653}, + {4.45, 1.000058889, 0.993026376}, + {4.454167, 1.00004971, 0.993041158}, + {4.458333, 1.000040531, 0.99305588}, + {4.4625, 1.000031233, 0.993070602}, + {4.466667, 1.000021815, 0.993085384}, + {4.470833, 1.000012517, 0.993100107}, + {4.475, 1.000003099, 0.993114889}, + {4.479167, 0.999993742, 0.99312973}, + {4.483333, 0.999984443, 0.993144512}, + {4.4875, 0.999975204, 0.993159413}, + {4.491667, 0.999966025, 0.993174255}, + {4.495833, 0.999956965, 0.993189216}, + {4.5, 0.999948025, 0.993204176}, + {4.504167, 0.999939263, 0.993219137}, + {4.508333, 0.99993062, 0.993234158}, + {4.5125, 0.999922216, 0.993249297}, + {4.516667, 0.999913991, 0.993264377}, + {4.520833, 0.999906003, 0.993279576}, + {4.525, 0.999898255, 0.993294775}, + {4.529167, 0.999890745, 0.993310034}, + {4.533333, 0.999883533, 0.993325353}, + {4.5375, 0.999876559, 0.993340731}, + {4.541667, 0.999869883, 0.993356109}, + {4.545833, 0.999863565, 0.993371606}, + {4.55, 0.999857545, 0.993387103}, + {4.554167, 0.999851882, 0.993402719}, + {4.558333, 0.999846518, 0.993418276}, + {4.5625, 0.999841511, 0.993434012}, + {4.566667, 0.999836922, 0.993449688}, + {4.570833, 0.99983263, 0.993465483}, + {4.575, 0.999828756, 0.993481219}, + {4.579167, 0.999825239, 0.993497133}, + {4.583333, 0.99982208, 0.993512988}, + {4.5875, 0.999819338, 0.993528962}, + {4.591667, 0.999817014, 0.993544877}, + {4.595833, 0.999815047, 0.99356091}, + {4.6, 0.999813497, 0.993576944}, + {4.604167, 0.999812305, 0.993593037}, + {4.608333, 0.99981153, 0.99360913}, + {4.6125, 0.999811113, 0.993625283}, + {4.616667, 0.999811053, 0.993641496}, + {4.620833, 0.999811411, 0.993657649}, + {4.625, 0.999812186, 0.993673861}, + {4.629167, 0.999813259, 0.993690133}, + {4.633333, 0.999814749, 0.993706405}, + {4.6375, 0.999816537, 0.993722677}, + {4.641667, 0.999818742, 0.993738949}, + {4.645833, 0.999821246, 0.993755221}, + {4.65, 0.999824047, 0.993771493}, + {4.654167, 0.999827206, 0.993787825}, + {4.658333, 0.999830663, 0.993804097}, + {4.6625, 0.999834418, 0.993820429}, + {4.666667, 0.999838471, 0.993836701}, + {4.670833, 0.999842763, 0.993852973}, + {4.675, 0.999847353, 0.993869245}, + {4.679167, 0.999852121, 0.993885517}, + {4.683333, 0.999857187, 0.99390173}, + {4.6875, 0.999862432, 0.993917942}, + {4.691667, 0.999867916, 0.993934095}, + {4.695833, 0.999873579, 0.993950248}, + {4.7, 0.99987936, 0.993966401}, + {4.704167, 0.99988538, 0.993982494}, + {4.708333, 0.99989146, 0.993998528}, + {4.7125, 0.999897718, 0.994014502}, + {4.716667, 0.999904037, 0.994030535}, + {4.720833, 0.999910533, 0.99404639}, + {4.725, 0.99991703, 0.994062304}, + {4.729167, 0.999923587, 0.9940781}, + {4.733333, 0.999930203, 0.994093835}, + {4.7375, 0.999936879, 0.994109511}, + {4.741667, 0.999943554, 0.994125187}, + {4.745833, 0.999950171, 0.994140744}, + {4.75, 0.999956846, 0.994156241}, + {4.754167, 0.999963462, 0.994171679}, + {4.758333, 0.999970019, 0.994187057}, + {4.7625, 0.999976516, 0.994202256}, + {4.766667, 0.999982893, 0.994217515}, + {4.770833, 0.999989212, 0.994232595}, + {4.775, 0.99999547, 0.994247675}, + {4.779167, 1.00000155, 0.994262576}, + {4.783333, 1.00000751, 0.994277477}, + {4.7875, 1.000013351, 0.994292259}, + {4.791667, 1.000018954, 0.994306982}, + {4.795833, 1.000024438, 0.994321525}, + {4.8, 1.000029802, 0.994336069}, + {4.804167, 1.000034928, 0.994350433}, + {4.808333, 1.000039816, 0.994364798}, + {4.8125, 1.000044584, 0.994378984}, + {4.816667, 1.000048995, 0.99439317}, + {4.820833, 1.000053287, 0.994407177}, + {4.825, 1.00005734, 0.994421124}, + {4.829167, 1.000061154, 0.994434953}, + {4.833333, 1.000064611, 0.994448721}, + {4.8375, 1.000067949, 0.994462311}, + {4.841667, 1.000071049, 0.994475901}, + {4.845833, 1.000073791, 0.994489312}, + {4.85, 1.000076294, 0.994502723}, + {4.854167, 1.000078559, 0.994515955}, + {4.858333, 1.000080466, 0.994529188}, + {4.8625, 1.000082254, 0.994542241}, + {4.866667, 1.000083685, 0.994555235}, + {4.870833, 1.000084758, 0.99456811}, + {4.875, 1.000085711, 0.994580984}, + {4.879167, 1.000086308, 0.99459368}, + {4.883333, 1.000086665, 0.994606376}, + {4.8875, 1.000086784, 0.994618893}, + {4.891667, 1.000086546, 0.99463141}, + {4.895833, 1.000086069, 0.994643748}, + {4.9, 1.000085354, 0.994656146}, + {4.904167, 1.0000844, 0.994668365}, + {4.908333, 1.000083208, 0.994680583}, + {4.9125, 1.000081778, 0.994692683}, + {4.916667, 1.000080109, 0.994704783}, + {4.920833, 1.000078201, 0.994716704}, + {4.925, 1.000076056, 0.994728684}, + {4.929167, 1.000073791, 0.994740546}, + {4.933333, 1.000071168, 0.994752407}, + {4.9375, 1.000068426, 0.994764149}, + {4.941667, 1.000065565, 0.994775891}, + {4.945833, 1.000062346, 0.994787514}, + {4.95, 1.000059128, 0.994799197}, + {4.954167, 1.000055671, 0.99481076}, + {4.958333, 1.000052094, 0.994822323}, + {4.9625, 1.000048399, 0.994833887}, + {4.966667, 1.000044465, 0.99484539}, + {4.970833, 1.000040531, 0.994856834}, + {4.975, 1.000036478, 0.994868279}, + {4.979167, 1.000032187, 0.994879723}, + {4.983333, 1.000028014, 0.994891107}, + {4.9875, 1.000023603, 0.994902492}, + {4.991667, 1.000019193, 0.994913876}, + {4.995833, 1.000014782, 0.994925261}, + {5, 1.000010252, 0.994936585}, + {5.004167, 1.000005722, 0.99494797}, + {5.008333, 1.000001192, 0.994959295}, + {5.0125, 0.999996662, 0.99497062}, + {5.016667, 0.999992073, 0.994981945}, + {5.020833, 0.999987543, 0.994993329}, + {5.025, 0.999983072, 0.995004654}, + {5.029167, 0.999978602, 0.995015979}, + {5.033333, 0.999974132, 0.995027363}, + {5.0375, 0.99996978, 0.995038688}, + {5.041667, 0.999965489, 0.995050073}, + {5.045833, 0.999961257, 0.995061457}, + {5.05, 0.999957144, 0.995072842}, + {5.054167, 0.999953091, 0.995084286}, + {5.058333, 0.999949157, 0.99509567}, + {5.0625, 0.999945343, 0.995107114}, + {5.066667, 0.999941587, 0.995118558}, + {5.070833, 0.999938011, 0.995130002}, + {5.075, 0.999934614, 0.995141506}, + {5.079167, 0.999931276, 0.99515301}, + {5.083333, 0.999928117, 0.995164514}, + {5.0875, 0.999925137, 0.995176017}, + {5.091667, 0.999922276, 0.995187581}, + {5.095833, 0.999919593, 0.995199144}, + {5.1, 0.99991709, 0.995210707}, + {5.104167, 0.999914765, 0.99522233}, + {5.108333, 0.99991262, 0.995233953}, + {5.1125, 0.999910653, 0.995245576}, + {5.116667, 0.999908865, 0.995257199}, + {5.120833, 0.999907255, 0.995268881}, + {5.125, 0.999905825, 0.995280504}, + {5.129167, 0.999904573, 0.995292187}, + {5.133333, 0.99990356, 0.995303869}, + {5.1375, 0.999902725, 0.995315611}, + {5.141667, 0.99990201, 0.995327294}, + {5.145833, 0.999901593, 0.995339036}, + {5.15, 0.999901295, 0.995350778}, + {5.154167, 0.999901176, 0.99536252}, + {5.158333, 0.999901295, 0.995374262}, + {5.1625, 0.999901593, 0.995386004}, + {5.166667, 0.99990201, 0.995397747}, + {5.170833, 0.999902666, 0.995409489}, + {5.175, 0.9999035, 0.995421231}, + {5.179167, 0.999904454, 0.995432973}, + {5.183333, 0.999905646, 0.995444715}, + {5.1875, 0.999906957, 0.995456457}, + {5.191667, 0.999908388, 0.995468199}, + {5.195833, 0.999910057, 0.995479882}, + {5.2, 0.999911845, 0.995491624}, + {5.204167, 0.999913752, 0.995503306}, + {5.208333, 0.999915779, 0.995514989}, + {5.2125, 0.999917984, 0.995526671}, + {5.216667, 0.999920249, 0.995538294}, + {5.220833, 0.999922693, 0.995549917}, + {5.225, 0.999925196, 0.99556154}, + {5.229167, 0.999927878, 0.995573103}, + {5.233333, 0.999930561, 0.995584726}, + {5.2375, 0.999933362, 0.99559623}, + {5.241667, 0.999936283, 0.995607734}, + {5.245833, 0.999939263, 0.995619237}, + {5.25, 0.999942303, 0.995630682}, + {5.254167, 0.999945343, 0.995642126}, + {5.258333, 0.999948502, 0.99565351}, + {5.2625, 0.999951661, 0.995664835}, + {5.266667, 0.999954879, 0.99567616}, + {5.270833, 0.999958098, 0.995687425}, + {5.275, 0.999961376, 0.99569869}, + {5.279167, 0.999964654, 0.995709896}, + {5.283333, 0.999967933, 0.995721042}, + {5.2875, 0.999971151, 0.995732129}, + {5.291667, 0.99997443, 0.995743215}, + {5.295833, 0.999977648, 0.995754182}, + {5.3, 0.999980807, 0.995765209}, + {5.304167, 0.999983966, 0.995776117}, + {5.308333, 0.999987125, 0.995787024}, + {5.3125, 0.999990165, 0.995797813}, + {5.316667, 0.999993205, 0.995808601}, + {5.320833, 0.999996126, 0.995819271}, + {5.325, 0.999999046, 0.995829999}, + {5.329167, 1.000001788, 0.995840549}, + {5.333333, 1.00000453, 0.995851159}, + {5.3375, 1.000007153, 0.99586159}, + {5.341667, 1.000009775, 0.99587208}, + {5.345833, 1.000012159, 0.995882452}, + {5.35, 1.000014544, 0.995892823}, + {5.354167, 1.000016809, 0.995903075}, + {5.358333, 1.000018954, 0.995913327}, + {5.3625, 1.000020981, 0.99592346}, + {5.366667, 1.000022888, 0.995933592}, + {5.370833, 1.000024676, 0.995943606}, + {5.375, 1.000026345, 0.995953619}, + {5.379167, 1.000027895, 0.995963573}, + {5.383333, 1.000029325, 0.995973468}, + {5.3875, 1.000030637, 0.995983303}, + {5.391667, 1.000031829, 0.995993078}, + {5.395833, 1.000032783, 0.996002793}, + {5.4, 1.000033736, 0.996012509}, + {5.404167, 1.000034451, 0.996022105}, + {5.408333, 1.000035167, 0.996031642}, + {5.4125, 1.000035644, 0.996041179}, + {5.416667, 1.000036001, 0.996050656}, + {5.420833, 1.00003624, 0.996060073}, + {5.425, 1.000036359, 0.996069431}, + {5.429167, 1.00003624, 0.99607873}, + {5.433333, 1.00003612, 0.996088028}, + {5.4375, 1.000035882, 0.996097267}, + {5.441667, 1.000035405, 0.996106446}, + {5.445833, 1.000034928, 0.996115625}, + {5.45, 1.000034213, 0.996124744}, + {5.454167, 1.000033498, 0.996133745}, + {5.458333, 1.000032663, 0.996142805}, + {5.4625, 1.00003159, 0.996151805}, + {5.466667, 1.000030518, 0.996160746}, + {5.470833, 1.000029325, 0.996169686}, + {5.475, 1.000028014, 0.996178567}, + {5.479167, 1.000026703, 0.996187449}, + {5.483333, 1.000025153, 0.99619627}, + {5.4875, 1.000023603, 0.996205091}, + {5.491667, 1.000022054, 0.996213853}, + {5.495833, 1.000020266, 0.996222615}, + {5.5, 1.000018477, 0.996231318}, + {5.504167, 1.000016689, 0.99624002}, + {5.508333, 1.000014782, 0.996248722}, + {5.5125, 1.000012755, 0.996257365}, + {5.516667, 1.000010729, 0.996266007}, + {5.520833, 1.000008702, 0.99627465}, + {5.525, 1.000006676, 0.996283293}, + {5.529167, 1.00000453, 0.996291876}, + {5.533333, 1.000002384, 0.996300459}, + {5.5375, 1.000000238, 0.996309042}, + {5.541667, 0.999998033, 0.996317625}, + {5.545833, 0.999995828, 0.996326149}, + {5.55, 0.999993622, 0.996334672}, + {5.554167, 0.999991417, 0.996343195}, + {5.558333, 0.999989212, 0.996351779}, + {5.5625, 0.999987006, 0.996360302}, + {5.566667, 0.99998486, 0.996368825}, + {5.570833, 0.999982715, 0.996377289}, + {5.575, 0.999980569, 0.996385813}, + {5.579167, 0.999978483, 0.996394336}, + {5.583333, 0.999976397, 0.99640286}, + {5.5875, 0.99997443, 0.996411324}, + {5.591667, 0.999972463, 0.996419847}, + {5.595833, 0.999970496, 0.99642837}, + {5.6, 0.999968648, 0.996436894}, + {5.604167, 0.99996686, 0.996445358}, + {5.608333, 0.999965072, 0.996453881}, + {5.6125, 0.999963403, 0.996462405}, + {5.616667, 0.999961793, 0.996470869}, + {5.620833, 0.999960244, 0.996479392}, + {5.625, 0.999958754, 0.996487916}, + {5.629167, 0.999957383, 0.996496439}, + {5.633333, 0.999956071, 0.996504962}, + {5.6375, 0.99995482, 0.996513486}, + {5.641667, 0.999953687, 0.996522009}, + {5.645833, 0.999952614, 0.996530533}, + {5.65, 0.999951661, 0.996539056}, + {5.654167, 0.999950767, 0.99654758}, + {5.658333, 0.999949932, 0.996556044}, + {5.6625, 0.999949276, 0.996564627}, + {5.666667, 0.999948621, 0.99657315}, + {5.670833, 0.999948144, 0.996581614}, + {5.675, 0.999947667, 0.996590137}, + {5.679167, 0.999947369, 0.996598661}, + {5.683333, 0.999947131, 0.996607184}, + {5.6875, 0.999946952, 0.996615708}, + {5.691667, 0.999946892, 0.996624231}, + {5.695833, 0.999946952, 0.996632755}, + {5.7, 0.999947071, 0.996641219}, + {5.704167, 0.999947309, 0.996649742}, + {5.708333, 0.999947608, 0.996658266}, + {5.7125, 0.999947965, 0.996666729}, + {5.716667, 0.999948442, 0.996675193}, + {5.720833, 0.999948978, 0.996683657}, + {5.725, 0.999949634, 0.996692121}, + {5.729167, 0.999950349, 0.996700585}, + {5.733333, 0.999951124, 0.996709049}, + {5.7375, 0.999952018, 0.996717453}, + {5.741667, 0.999952912, 0.996725857}, + {5.745833, 0.999953926, 0.996734262}, + {5.75, 0.999954998, 0.996742666}, + {5.754167, 0.999956131, 0.99675101}, + {5.758333, 0.999957263, 0.996759415}, + {5.7625, 0.999958515, 0.9967677}, + {5.766667, 0.999959826, 0.996776044}, + {5.770833, 0.999961138, 0.996784329}, + {5.775, 0.999962509, 0.996792674}, + {5.779167, 0.999963939, 0.9968009}, + {5.783333, 0.99996537, 0.996809185}, + {5.7875, 0.99996686, 0.99681735}, + {5.791667, 0.99996835, 0.996825576}, + {5.795833, 0.9999699, 0.996833742}, + {5.8, 0.999971449, 0.996841908}, + {5.804167, 0.999972999, 0.996850014}, + {5.808333, 0.999974608, 0.99685812}, + {5.8125, 0.999976218, 0.996866167}, + {5.816667, 0.999977827, 0.996874273}, + {5.820833, 0.999979436, 0.99688226}, + {5.825, 0.999980986, 0.996890247}, + {5.829167, 0.999982595, 0.996898234}, + {5.833333, 0.999984205, 0.996906161}, + {5.8375, 0.999985754, 0.996914029}, + {5.841667, 0.999987304, 0.996921897}, + {5.845833, 0.999988854, 0.996929765}, + {5.85, 0.999990344, 0.996937573}, + {5.854167, 0.999991834, 0.996945322}, + {5.858333, 0.999993324, 0.99695307}, + {5.8625, 0.999994755, 0.996960759}, + {5.866667, 0.999996126, 0.996968508}, + {5.870833, 0.999997497, 0.996976137}, + {5.875, 0.999998748, 0.996983767}, + {5.879167, 1, 0.996991277}, + {5.883333, 1.000001311, 0.996998847}, + {5.8875, 1.000002384, 0.997006357}, + {5.891667, 1.000003576, 0.997013867}, + {5.895833, 1.000004649, 0.997021258}, + {5.9, 1.000005603, 0.997028708}, + {5.904167, 1.000006557, 0.99703604}, + {5.908333, 1.00000751, 0.997043431}, + {5.9125, 1.000008345, 0.997050703}, + {5.916667, 1.00000906, 0.997057974}, + {5.920833, 1.000009775, 0.997065246}, + {5.925, 1.00001049, 0.997072458}, + {5.929167, 1.000011086, 0.997079611}, + {5.933333, 1.000011563, 0.997086763}, + {5.9375, 1.00001204, 0.997093856}, + {5.941667, 1.000012398, 0.997100949}, + {5.945833, 1.000012755, 0.997107983}, + {5.95, 1.000012994, 0.997115016}, + {5.954167, 1.000013232, 0.99712199}, + {5.958333, 1.000013351, 0.997128963}, + {5.9625, 1.000013351, 0.997135878}, + {5.966667, 1.000013471, 0.997142792}, + {5.970833, 1.000013351, 0.997149646}, + {5.975, 1.000013232, 0.997156501}, + {5.979167, 1.000013113, 0.997163296}, + {5.983333, 1.000012875, 0.99717015}, + {5.9875, 1.000012517, 0.997176886}, + {5.991667, 1.000012159, 0.997183621}, + {5.995833, 1.000011802, 0.997190356}, + {6, 1.000011325, 0.997197032}, + {6.004167, 1.000010729, 0.997203708}, + {6.008333, 1.000010252, 0.997210383}, + {6.0125, 1.000009656, 0.997217}, + {6.016667, 1.000008941, 0.997223616}, + {6.020833, 1.000008225, 0.997230172}, + {6.025, 1.00000751, 0.997236729}, + {6.029167, 1.000006676, 0.997243285}, + {6.033333, 1.00000596, 0.997249842}, + {6.0375, 1.000005007, 0.997256339}, + {6.041667, 1.000004172, 0.997262836}, + {6.045833, 1.000003219, 0.997269332}, + {6.05, 1.000002265, 0.99727577}, + {6.054167, 1.000001311, 0.997282207}, + {6.058333, 1.000000358, 0.997288644}, + {6.0625, 0.999999344, 0.997295082}, + {6.066667, 0.999998331, 0.997301519}, + {6.070833, 0.999997258, 0.997307897}, + {6.075, 0.999996245, 0.997314274}, + {6.079167, 0.999995172, 0.997320652}, + {6.083333, 0.999994099, 0.99732703}, + {6.0875, 0.999993026, 0.997333407}, + {6.091667, 0.999992013, 0.997339785}, + {6.095833, 0.99999094, 0.997346103}, + {6.1, 0.999989867, 0.997352421}, + {6.104167, 0.999988794, 0.997358739}, + {6.108333, 0.999987781, 0.997365057}, + {6.1125, 0.999986768, 0.997371376}, + {6.116667, 0.999985754, 0.997377694}, + {6.120833, 0.999984741, 0.997384012}, + {6.125, 0.999983788, 0.99739027}, + {6.129167, 0.999982834, 0.997396588}, + {6.133333, 0.99998188, 0.997402847}, + {6.1375, 0.999980986, 0.997409165}, + {6.141667, 0.999980092, 0.997415423}, + {6.145833, 0.999979258, 0.997421682}, + {6.15, 0.999978423, 0.99742794}, + {6.154167, 0.999977648, 0.997434199}, + {6.158333, 0.999976933, 0.997440457}, + {6.1625, 0.999976218, 0.997446716}, + {6.166667, 0.999975562, 0.997452974}, + {6.170833, 0.999974906, 0.997459233}, + {6.175, 0.99997431, 0.997465432}, + {6.179167, 0.999973774, 0.99747169}, + {6.183333, 0.999973238, 0.997477889}, + {6.1875, 0.999972761, 0.997484148}, + {6.191667, 0.999972343, 0.997490346}, + {6.195833, 0.999971986, 0.997496605}, + {6.2, 0.999971628, 0.997502804}, + {6.204167, 0.99997133, 0.997509003}, + {6.208333, 0.999971092, 0.997515202}, + {6.2125, 0.999970913, 0.9975214}, + {6.216667, 0.999970734, 0.997527599}, + {6.220833, 0.999970615, 0.997533798}, + {6.225, 0.999970555, 0.997539937}, + {6.229167, 0.999970555, 0.997546136}, + {6.233333, 0.999970555, 0.997552276}, + {6.2375, 0.999970615, 0.997558475}, + {6.241667, 0.999970734, 0.997564614}, + {6.245833, 0.999970853, 0.997570753}, + {6.25, 0.999971092, 0.997576892}, + {6.254167, 0.99997133, 0.997583032}, + {6.258333, 0.999971569, 0.997589111}, + {6.2625, 0.999971926, 0.997595251}, + {6.266667, 0.999972284, 0.99760133}, + {6.270833, 0.999972641, 0.99760741}, + {6.275, 0.999973059, 0.99761349}, + {6.279167, 0.999973536, 0.997619569}, + {6.283333, 0.999974012, 0.997625649}, + {6.2875, 0.999974549, 0.997631669}, + {6.291667, 0.999975085, 0.997637689}, + {6.295833, 0.999975681, 0.997643709}, + {6.3, 0.999976277, 0.997649729}, + {6.304167, 0.999976933, 0.997655749}, + {6.308333, 0.999977589, 0.99766171}, + {6.3125, 0.999978244, 0.99766767}, + {6.316667, 0.99997896, 0.997673631}, + {6.320833, 0.999979675, 0.997679532}, + {6.325, 0.99998039, 0.997685492}, + {6.329167, 0.999981165, 0.997691393}, + {6.333333, 0.99998188, 0.997697234}, + {6.3375, 0.999982655, 0.997703135}, + {6.341667, 0.99998343, 0.997708976}, + {6.345833, 0.999984205, 0.997714818}, + {6.35, 0.999985039, 0.997720659}, + {6.354167, 0.999985814, 0.99772644}, + {6.358333, 0.999986589, 0.997732222}, + {6.3625, 0.999987364, 0.997737944}, + {6.366667, 0.999988139, 0.997743726}, + {6.370833, 0.999988973, 0.997749448}, + {6.375, 0.999989748, 0.99775517}, + {6.379167, 0.999990463, 0.997760832}, + {6.383333, 0.999991238, 0.997766495}, + {6.3875, 0.999992013, 0.997772098}, + {6.391667, 0.999992728, 0.99777776}, + {6.395833, 0.999993443, 0.997783363}, + {6.4, 0.999994159, 0.997788966}, + {6.404167, 0.999994814, 0.997794509}, + {6.408333, 0.99999547, 0.997800052}, + {6.4125, 0.999996126, 0.997805536}, + {6.416667, 0.999996781, 0.997811079}, + {6.420833, 0.999997377, 0.997816503}, + {6.425, 0.999997973, 0.997821987}, + {6.429167, 0.99999851, 0.997827411}, + {6.433333, 0.999999046, 0.997832835}, + {6.4375, 0.999999523, 0.997838199}, + {6.441667, 1, 0.997843623}, + {6.445833, 1.000000477, 0.997848928}, + {6.45, 1.000000834, 0.997854292}, + {6.454167, 1.000001192, 0.997859597}, + {6.458333, 1.00000155, 0.997864902}, + {6.4625, 1.000001907, 0.997870147}, + {6.466667, 1.000002265, 0.997875392}, + {6.470833, 1.000002503, 0.997880638}, + {6.475, 1.000002742, 0.997885823}, + {6.479167, 1.000002861, 0.997891009}, + {6.483333, 1.000003099, 0.997896194}, + {6.4875, 1.000003219, 0.99790132}, + {6.491667, 1.000003338, 0.997906446}, + {6.495833, 1.000003457, 0.997911572}, + {6.5, 1.000003457, 0.997916639}, + {6.504167, 1.000003457, 0.997921705}, + {6.508333, 1.000003457, 0.997926772}, + {6.5125, 1.000003338, 0.997931838}, + {6.516667, 1.000003338, 0.997936845}, + {6.520833, 1.000003219, 0.997941852}, + {6.525, 1.000003099, 0.997946858}, + {6.529167, 1.000002861, 0.997951806}, + {6.533333, 1.000002742, 0.997956753}, + {6.5375, 1.000002503, 0.9979617}, + {6.541667, 1.000002265, 0.997966647}, + {6.545833, 1.000002027, 0.997971535}, + {6.55, 1.000001669, 0.997976422}, + {6.554167, 1.000001311, 0.99798131}, + {6.558333, 1.000001073, 0.997986197}, + {6.5625, 1.000000715, 0.997991025}, + {6.566667, 1.000000238, 0.997995913}, + {6.570833, 0.999999881, 0.998000741}, + {6.575, 0.999999523, 0.998005509}, + {6.579167, 0.999999046, 0.998010337}, + {6.583333, 0.999998629, 0.998015106}, + {6.5875, 0.999998152, 0.998019934}, + {6.591667, 0.999997735, 0.998024702}, + {6.595833, 0.999997258, 0.998029411}, + {6.6, 0.999996781, 0.998034179}, + {6.604167, 0.999996245, 0.998038948}, + {6.608333, 0.999995768, 0.998043656}, + {6.6125, 0.999995232, 0.998048365}, + {6.616667, 0.999994755, 0.998053074}, + {6.620833, 0.999994218, 0.998057783}, + {6.625, 0.999993742, 0.998062491}, + {6.629167, 0.999993205, 0.998067141}, + {6.633333, 0.999992728, 0.998071849}, + {6.6375, 0.999992192, 0.998076499}, + {6.641667, 0.999991715, 0.998081207}, + {6.645833, 0.999991179, 0.998085856}, + {6.65, 0.999990702, 0.998090506}, + {6.654167, 0.999990225, 0.998095095}, + {6.658333, 0.999989748, 0.998099744}, + {6.6625, 0.999989271, 0.998104393}, + {6.666667, 0.999988794, 0.998108983}, + {6.670833, 0.999988377, 0.998113632}, + {6.675, 0.99998796, 0.998118222}, + {6.679167, 0.999987543, 0.998122811}, + {6.683333, 0.999987125, 0.998127401}, + {6.6875, 0.999986708, 0.99813199}, + {6.691667, 0.999986351, 0.99813658}, + {6.695833, 0.999985993, 0.99814117}, + {6.7, 0.999985635, 0.998145759}, + {6.704167, 0.999985337, 0.998150289}, + {6.708333, 0.999985039, 0.998154879}, + {6.7125, 0.999984741, 0.998159409}, + {6.716667, 0.999984503, 0.998163998}, + {6.720833, 0.999984264, 0.998168528}, + {6.725, 0.999984026, 0.998173058}, + {6.729167, 0.999983847, 0.998177588}, + {6.733333, 0.999983668, 0.998182118}, + {6.7375, 0.99998349, 0.998186648}, + {6.741667, 0.99998337, 0.998191178}, + {6.745833, 0.999983251, 0.998195648}, + {6.75, 0.999983132, 0.998200178}, + {6.754167, 0.999983072, 0.998204648}, + {6.758333, 0.999983072, 0.998209178}, + {6.7625, 0.999983013, 0.998213649}, + {6.766667, 0.999983013, 0.998218119}, + {6.770833, 0.999983013, 0.998222589}, + {6.775, 0.999983072, 0.99822706}, + {6.779167, 0.999983132, 0.99823153}, + {6.783333, 0.999983251, 0.998235941}, + {6.7875, 0.999983311, 0.998240411}, + {6.791667, 0.99998343, 0.998244822}, + {6.795833, 0.999983609, 0.998249233}, + {6.8, 0.999983728, 0.998253644}, + {6.804167, 0.999983907, 0.998258054}, + {6.808333, 0.999984145, 0.998262465}, + {6.8125, 0.999984324, 0.998266876}, + {6.816667, 0.999984562, 0.998271227}, + {6.820833, 0.999984801, 0.998275638}, + {6.825, 0.999985099, 0.998279989}, + {6.829167, 0.999985337, 0.99828434}, + {6.833333, 0.999985635, 0.998288691}, + {6.8375, 0.999985933, 0.998292983}, + {6.841667, 0.999986291, 0.998297334}, + {6.845833, 0.999986589, 0.998301625}, + {6.85, 0.999986947, 0.998305976}, + {6.854167, 0.999987304, 0.998310208}, + {6.858333, 0.999987662, 0.9983145}, + {6.8625, 0.999988019, 0.998318791}, + {6.866667, 0.999988377, 0.998323023}, + {6.870833, 0.999988735, 0.998327315}, + {6.875, 0.999989152, 0.998331547}, + {6.879167, 0.99998951, 0.998335719}, + {6.883333, 0.999989927, 0.998339951}, + {6.8875, 0.999990284, 0.998344183}, + {6.891667, 0.999990702, 0.998348355}, + {6.895833, 0.999991059, 0.998352528}, + {6.9, 0.999991477, 0.9983567}, + {6.904167, 0.999991834, 0.998360813}, + {6.908333, 0.999992251, 0.998364985}, + {6.9125, 0.999992609, 0.998369098}, + {6.916667, 0.999993026, 0.99837321}, + {6.920833, 0.999993384, 0.998377264}, + {6.925, 0.999993742, 0.998381376}, + {6.929167, 0.999994099, 0.998385429}, + {6.933333, 0.999994457, 0.998389482}, + {6.9375, 0.999994814, 0.998393536}, + {6.941667, 0.999995172, 0.998397589}, + {6.945833, 0.99999547, 0.998401582}, + {6.95, 0.999995768, 0.998405576}, + {6.954167, 0.999996126, 0.998409569}, + {6.958333, 0.999996424, 0.998413563}, + {6.9625, 0.999996662, 0.998417497}, + {6.966667, 0.99999696, 0.99842149}, + {6.970833, 0.999997199, 0.998425424}, + {6.975, 0.999997497, 0.998429298}, + {6.979167, 0.999997735, 0.998433232}, + {6.983333, 0.999997914, 0.998437107}, + {6.9875, 0.999998152, 0.998440981}, + {6.991667, 0.999998331, 0.998444855}, + {6.995833, 0.99999851, 0.99844873}, + {7, 0.999998689, 0.998452544}, + {7.004167, 0.999998808, 0.998456359}, + {7.008333, 0.999998927, 0.998460233}, + {7.0125, 0.999999046, 0.998463988}, + {7.016667, 0.999999166, 0.998467803}, + {7.020833, 0.999999225, 0.998471558}, + {7.025, 0.999999344, 0.998475313}, + {7.029167, 0.999999404, 0.998479068}, + {7.033333, 0.999999404, 0.998482823}, + {7.0375, 0.999999464, 0.998486519}, + {7.041667, 0.999999464, 0.998490274}, + {7.045833, 0.999999464, 0.998493969}, + {7.05, 0.999999404, 0.998497665}, + {7.054167, 0.999999404, 0.99850136}, + {7.058333, 0.999999344, 0.998504996}, + {7.0625, 0.999999285, 0.998508692}, + {7.066667, 0.999999225, 0.998512328}, + {7.070833, 0.999999106, 0.998515964}, + {7.075, 0.999998987, 0.998519599}, + {7.079167, 0.999998868, 0.998523176}, + {7.083333, 0.999998748, 0.998526812}, + {7.0875, 0.999998629, 0.998530388}, + {7.091667, 0.99999845, 0.998533964}, + {7.095833, 0.999998331, 0.99853754}, + {7.1, 0.999998152, 0.998541117}, + {7.104167, 0.999997973, 0.998544693}, + {7.108333, 0.999997795, 0.99854821}, + {7.1125, 0.999997616, 0.998551726}, + {7.116667, 0.999997377, 0.998555303}, + {7.120833, 0.999997199, 0.998558819}, + {7.125, 0.99999696, 0.998562336}, + {7.129167, 0.999996722, 0.998565793}, + {7.133333, 0.999996483, 0.99856931}, + {7.1375, 0.999996305, 0.998572826}, + {7.141667, 0.999996066, 0.998576283}, + {7.145833, 0.999995828, 0.998579741}, + {7.15, 0.999995589, 0.998583198}, + {7.154167, 0.999995351, 0.998586655}, + {7.158333, 0.999995053, 0.998590112}, + {7.1625, 0.999994814, 0.998593569}, + {7.166667, 0.999994576, 0.998597026}, + {7.170833, 0.999994338, 0.998600423}, + {7.175, 0.999994099, 0.99860388}, + {7.179167, 0.999993861, 0.998607278}, + {7.183333, 0.999993622, 0.998610675}, + {7.1875, 0.999993384, 0.998614073}, + {7.191667, 0.999993145, 0.99861753}, + {7.195833, 0.999992907, 0.998620868}, + {7.2, 0.999992728, 0.998624265}, + {7.204167, 0.99999249, 0.998627663}, + {7.208333, 0.999992311, 0.99863106}, + {7.2125, 0.999992073, 0.998634398}, + {7.216667, 0.999991894, 0.998637795}, + {7.220833, 0.999991715, 0.998641133}, + {7.225, 0.999991536, 0.998644471}, + {7.229167, 0.999991357, 0.998647809}, + {7.233333, 0.999991179, 0.998651147}, + {7.2375, 0.999991, 0.998654485}, + {7.241667, 0.99999088, 0.998657823}, + {7.245833, 0.999990702, 0.99866116}, + {7.25, 0.999990582, 0.998664498}, + {7.254167, 0.999990463, 0.998667777}, + {7.258333, 0.999990344, 0.998671114}, + {7.2625, 0.999990225, 0.998674393}, + {7.266667, 0.999990165, 0.998677671}, + {7.270833, 0.999990106, 0.998681009}, + {7.275, 0.999989986, 0.998684287}, + {7.279167, 0.999989927, 0.998687565}, + {7.283333, 0.999989927, 0.998690844}, + {7.2875, 0.999989867, 0.998694062}, + {7.291667, 0.999989867, 0.99869734}, + {7.295833, 0.999989808, 0.998700619}, + {7.3, 0.999989808, 0.998703837}, + {7.304167, 0.999989808, 0.998707116}, + {7.308333, 0.999989867, 0.998710334}, + {7.3125, 0.999989867, 0.998713553}, + {7.316667, 0.999989927, 0.998716831}, + {7.320833, 0.999989927, 0.99872005}, + {7.325, 0.999989986, 0.998723269}, + {7.329167, 0.999990046, 0.998726428}, + {7.333333, 0.999990165, 0.998729646}, + {7.3375, 0.999990225, 0.998732865}, + {7.341667, 0.999990344, 0.998736024}, + {7.345833, 0.999990404, 0.998739183}, + {7.35, 0.999990523, 0.998742402}, + {7.354167, 0.999990642, 0.998745561}, + {7.358333, 0.999990761, 0.99874872}, + {7.3625, 0.99999094, 0.998751879}, + {7.366667, 0.999991059, 0.998755038}, + {7.370833, 0.999991238, 0.998758137}, + {7.375, 0.999991357, 0.998761296}, + {7.379167, 0.999991536, 0.998764396}, + {7.383333, 0.999991715, 0.998767495}, + {7.3875, 0.999991834, 0.998770654}, + {7.391667, 0.999992013, 0.998773754}, + {7.395833, 0.999992192, 0.998776793}, + {7.4, 0.999992371, 0.998779893}, + {7.404167, 0.999992549, 0.998782992}, + {7.408333, 0.999992788, 0.998786032}, + {7.4125, 0.999992967, 0.998789132}, + {7.416667, 0.999993145, 0.998792171}, + {7.420833, 0.999993324, 0.998795211}, + {7.425, 0.999993563, 0.998798251}, + {7.429167, 0.999993742, 0.998801291}, + {7.433333, 0.99999392, 0.998804271}, + {7.4375, 0.999994099, 0.998807311}, + {7.441667, 0.999994338, 0.998810291}, + {7.445833, 0.999994516, 0.998813272}, + {7.45, 0.999994695, 0.998816252}, + {7.454167, 0.999994874, 0.998819232}, + {7.458333, 0.999995053, 0.998822212}, + {7.4625, 0.999995232, 0.998825133}, + {7.466667, 0.99999541, 0.998828113}, + {7.470833, 0.999995589, 0.998831034}, + {7.475, 0.999995768, 0.998833954}, + {7.479167, 0.999995947, 0.998836875}, + {7.483333, 0.999996126, 0.998839796}, + {7.4875, 0.999996305, 0.998842716}, + {7.491667, 0.999996424, 0.998845577}, + {7.495833, 0.999996603, 0.998848498}, + {7.5, 0.999996722, 0.998851359}, + {7.504167, 0.999996841, 0.99885422}, + {7.508333, 0.99999696, 0.998857081}, + {7.5125, 0.999997139, 0.998859942}, + {7.516667, 0.999997258, 0.998862803}, + {7.520833, 0.999997318, 0.998865604}, + {7.525, 0.999997437, 0.998868406}, + {7.529167, 0.999997556, 0.998871207}, + {7.533333, 0.999997616, 0.998874068}, + {7.5375, 0.999997735, 0.99887681}, + {7.541667, 0.999997795, 0.998879611}, + {7.545833, 0.999997854, 0.998882413}, + {7.55, 0.999997914, 0.998885155}, + {7.554167, 0.999997973, 0.998887956}, + {7.558333, 0.999998033, 0.998890698}, + {7.5625, 0.999998033, 0.99889344}, + {7.566667, 0.999998093, 0.998896182}, + {7.570833, 0.999998093, 0.998898864}, + {7.575, 0.999998093, 0.998901606}, + {7.579167, 0.999998093, 0.998904347}, + {7.583333, 0.999998093, 0.99890703}, + {7.5875, 0.999998093, 0.998909712}, + {7.591667, 0.999998093, 0.998912394}, + {7.595833, 0.999998093, 0.998915076}, + {7.6, 0.999998033, 0.998917758}, + {7.604167, 0.999998033, 0.998920441}, + {7.608333, 0.999997973, 0.998923063}, + {7.6125, 0.999997914, 0.998925745}, + {7.616667, 0.999997854, 0.998928368}, + {7.620833, 0.999997795, 0.998930991}, + {7.625, 0.999997735, 0.998933613}, + {7.629167, 0.999997675, 0.998936236}, + {7.633333, 0.999997616, 0.998938859}, + {7.6375, 0.999997497, 0.998941481}, + {7.641667, 0.999997437, 0.998944104}, + {7.645833, 0.999997318, 0.998946667}, + {7.65, 0.999997258, 0.998949289}, + {7.654167, 0.999997139, 0.998951852}, + {7.658333, 0.999997079, 0.998954415}, + {7.6625, 0.99999696, 0.998956978}, + {7.666667, 0.999996841, 0.998959541}, + {7.670833, 0.999996722, 0.998962104}, + {7.675, 0.999996662, 0.998964667}, + {7.679167, 0.999996543, 0.99896723}, + {7.683333, 0.999996424, 0.998969734}, + {7.6875, 0.999996305, 0.998972297}, + {7.691667, 0.999996185, 0.9989748}, + {7.695833, 0.999996066, 0.998977304}, + {7.7, 0.999995947, 0.998979867}, + {7.704167, 0.999995828, 0.99898237}, + {7.708333, 0.999995708, 0.998984873}, + {7.7125, 0.999995589, 0.998987377}, + {7.716667, 0.99999547, 0.99898988}, + {7.720833, 0.99999541, 0.998992324}, + {7.725, 0.999995291, 0.998994827}, + {7.729167, 0.999995172, 0.998997331}, + {7.733333, 0.999995053, 0.998999774}, + {7.7375, 0.999994934, 0.999002278}, + {7.741667, 0.999994874, 0.999004722}, + {7.745833, 0.999994755, 0.999007165}, + {7.75, 0.999994636, 0.999009669}, + {7.754167, 0.999994576, 0.999012113}, + {7.758333, 0.999994457, 0.999014556}, + {7.7625, 0.999994397, 0.999017}, + {7.766667, 0.999994338, 0.999019444}, + {7.770833, 0.999994218, 0.999021828}, + {7.775, 0.999994159, 0.999024272}, + {7.779167, 0.999994099, 0.999026716}, + {7.783333, 0.99999404, 0.9990291}, + {7.7875, 0.99999398, 0.999031544}, + {7.791667, 0.99999392, 0.999033928}, + {7.795833, 0.999993861, 0.999036372}, + {7.8, 0.999993801, 0.999038756}, + {7.804167, 0.999993801, 0.99904114}, + {7.808333, 0.999993742, 0.999043524}, + {7.8125, 0.999993742, 0.999045908}, + {7.816667, 0.999993682, 0.999048293}, + {7.820833, 0.999993682, 0.999050677}, + {7.825, 0.999993682, 0.999053061}, + {7.829167, 0.999993682, 0.999055445}, + {7.833333, 0.999993682, 0.99905777}, + {7.8375, 0.999993682, 0.999060154}, + {7.841667, 0.999993682, 0.999062479}, + {7.845833, 0.999993682, 0.999064863}, + {7.85, 0.999993682, 0.999067187}, + {7.854167, 0.999993742, 0.999069512}, + {7.858333, 0.999993742, 0.999071836}, + {7.8625, 0.999993801, 0.999074161}, + {7.866667, 0.999993801, 0.999076486}, + {7.870833, 0.999993861, 0.99907881}, + {7.875, 0.99999392, 0.999081135}, + {7.879167, 0.99999398, 0.999083459}, + {7.883333, 0.99999398, 0.999085724}, + {7.8875, 0.99999404, 0.999088049}, + {7.891667, 0.999994099, 0.999090314}, + {7.895833, 0.999994218, 0.999092638}, + {7.9, 0.999994278, 0.999094903}, + {7.904167, 0.999994338, 0.999097168}, + {7.908333, 0.999994397, 0.999099433}, + {7.9125, 0.999994516, 0.999101698}, + {7.916667, 0.999994576, 0.999103963}, + {7.920833, 0.999994636, 0.999106228}, + {7.925, 0.999994755, 0.999108434}, + {7.929167, 0.999994814, 0.999110699}, + {7.933333, 0.999994934, 0.999112964}, + {7.9375, 0.999994993, 0.999115169}, + {7.941667, 0.999995112, 0.999117374}, + {7.945833, 0.999995232, 0.999119639}, + {7.95, 0.999995291, 0.999121845}, + {7.954167, 0.99999541, 0.99912405}, + {7.958333, 0.99999547, 0.999126256}, + {7.9625, 0.999995589, 0.999128401}, + {7.966667, 0.999995708, 0.999130607}, + {7.970833, 0.999995768, 0.999132812}, + {7.975, 0.999995887, 0.999134958}, + {7.979167, 0.999996006, 0.999137163}, + {7.983333, 0.999996066, 0.999139309}, + {7.9875, 0.999996185, 0.999141455}, + {7.991667, 0.999996245, 0.99914366}, + {7.995833, 0.999996364, 0.999145746}, + {8, 0.999996483, 0.999147892}, + {8.004167, 0.999996543, 0.999150038}, + {8.008333, 0.999996662, 0.999152184}, + {8.0125, 0.999996722, 0.999154329}, + {8.016667, 0.999996781, 0.999156415}, + {8.020833, 0.999996901, 0.999158502}, + {8.025, 0.99999696, 0.999160647}, + {8.029167, 0.99999702, 0.999162734}, + {8.033333, 0.999997139, 0.99916482}, + {8.0375, 0.999997199, 0.999166906}, + {8.041667, 0.999997258, 0.999168992}, + {8.045833, 0.999997318, 0.999171078}, + {8.05, 0.999997377, 0.999173105}, + {8.054167, 0.999997437, 0.999175191}, + {8.058333, 0.999997497, 0.999177277}, + {8.0625, 0.999997556, 0.999179304}, + {8.066667, 0.999997616, 0.99918133}, + {8.070833, 0.999997675, 0.999183357}, + {8.075, 0.999997675, 0.999185443}, + {8.079167, 0.999997735, 0.99918741}, + {8.083333, 0.999997795, 0.999189436}, + {8.0875, 0.999997795, 0.999191463}, + {8.091667, 0.999997854, 0.99919349}, + {8.095833, 0.999997854, 0.999195457}, + {8.1, 0.999997854, 0.999197483}, + {8.104167, 0.999997914, 0.99919945}, + {8.108333, 0.999997914, 0.999201477}, + {8.1125, 0.999997914, 0.999203444}, + {8.116667, 0.999997914, 0.99920541}, + {8.120833, 0.999997914, 0.999207377}, + {8.125, 0.999997914, 0.999209344}, + {8.129167, 0.999997914, 0.999211311}, + {8.133333, 0.999997914, 0.999213278}, + {8.1375, 0.999997914, 0.999215186}, + {8.141667, 0.999997854, 0.999217153}, + {8.145833, 0.999997854, 0.99921906}, + {8.15, 0.999997854, 0.999221027}, + {8.154167, 0.999997795, 0.999222934}, + {8.158333, 0.999997795, 0.999224842}, + {8.1625, 0.999997735, 0.999226749}, + {8.166667, 0.999997735, 0.999228716}, + {8.170833, 0.999997675, 0.999230564}, + {8.175, 0.999997675, 0.999232471}, + {8.179167, 0.999997616, 0.999234378}, + {8.183333, 0.999997556, 0.999236286}, + {8.1875, 0.999997556, 0.999238193}, + {8.191667, 0.999997497, 0.999240041}, + {8.195833, 0.999997437, 0.999241948}, + {8.2, 0.999997377, 0.999243796}, + {8.204167, 0.999997318, 0.999245644}, + {8.208333, 0.999997318, 0.999247551}, + {8.2125, 0.999997258, 0.999249399}, + {8.216667, 0.999997199, 0.999251246}, + {8.220833, 0.999997139, 0.999253094}, + {8.225, 0.999997079, 0.999254942}, + {8.229167, 0.99999702, 0.99925679}, + {8.233333, 0.99999696, 0.999258637}, + {8.2375, 0.999996901, 0.999260485}, + {8.241667, 0.999996901, 0.999262273}, + {8.245833, 0.999996841, 0.999264121}, + {8.25, 0.999996781, 0.999265969}, + {8.254167, 0.999996722, 0.999267757}, + {8.258333, 0.999996662, 0.999269605}, + {8.2625, 0.999996603, 0.999271393}, + {8.266667, 0.999996543, 0.999273181}, + {8.270833, 0.999996483, 0.999274969}, + {8.275, 0.999996483, 0.999276817}, + {8.279167, 0.999996424, 0.999278605}, + {8.283333, 0.999996364, 0.999280393}, + {8.2875, 0.999996305, 0.999282181}, + {8.291667, 0.999996305, 0.999283969}, + {8.295833, 0.999996245, 0.999285758}, + {8.3, 0.999996185, 0.999287486}, + {8.304167, 0.999996185, 0.999289274}, + {8.308333, 0.999996126, 0.999291062}, + {8.3125, 0.999996126, 0.999292791}, + {8.316667, 0.999996066, 0.999294579}, + {8.320833, 0.999996066, 0.999296308}, + {8.325, 0.999996006, 0.999298096}, + {8.329167, 0.999996006, 0.999299824}, + {8.333333, 0.999996006, 0.999301553}, + {8.3375, 0.999995947, 0.999303341}, + {8.341667, 0.999995947, 0.999305069}, + {8.345833, 0.999995947, 0.999306798}, + {8.35, 0.999995947, 0.999308527}, + {8.354167, 0.999995887, 0.999310255}, + {8.358333, 0.999995887, 0.999311984}, + {8.3625, 0.999995887, 0.999313712}, + {8.366667, 0.999995887, 0.999315381}, + {8.370833, 0.999995887, 0.99931711}, + {8.375, 0.999995887, 0.999318838}, + {8.379167, 0.999995887, 0.999320507}, + {8.383333, 0.999995947, 0.999322236}, + {8.3875, 0.999995947, 0.999323905}, + {8.391667, 0.999995947, 0.999325633}, + {8.395833, 0.999995947, 0.999327302}, + {8.4, 0.999996006, 0.999329031}, + {8.404167, 0.999996006, 0.999330699}, + {8.408333, 0.999996006, 0.999332368}, + {8.4125, 0.999996066, 0.999334037}, + {8.416667, 0.999996066, 0.999335706}, + {8.420833, 0.999996126, 0.999337375}, + {8.425, 0.999996126, 0.999339044}, + {8.429167, 0.999996185, 0.999340713}, + {8.433333, 0.999996185, 0.999342322}, + {8.4375, 0.999996245, 0.999343991}, + {8.441667, 0.999996305, 0.99934566}, + {8.445833, 0.999996305, 0.99934727}, + {8.45, 0.999996364, 0.999348938}, + {8.454167, 0.999996424, 0.999350548}, + {8.458333, 0.999996483, 0.999352217}, + {8.4625, 0.999996483, 0.999353826}, + {8.466667, 0.999996543, 0.999355435}, + {8.470833, 0.999996603, 0.999357045}, + {8.475, 0.999996662, 0.999358654}, + {8.479167, 0.999996662, 0.999360263}, + {8.483333, 0.999996722, 0.999361873}, + {8.4875, 0.999996781, 0.999363482}, + {8.491667, 0.999996841, 0.999365091}, + {8.495833, 0.999996901, 0.999366701}, + {8.5, 0.99999696, 0.99936825}, + {8.504167, 0.99999696, 0.99936986}, + {8.508333, 0.99999702, 0.999371409}, + {8.5125, 0.999997079, 0.999373019}, + {8.516667, 0.999997139, 0.999374568}, + {8.520833, 0.999997199, 0.999376178}, + {8.525, 0.999997258, 0.999377728}, + {8.529167, 0.999997258, 0.999379277}, + {8.533333, 0.999997318, 0.999380827}, + {8.5375, 0.999997377, 0.999382377}, + {8.541667, 0.999997437, 0.999383926}, + {8.545833, 0.999997497, 0.999385476}, + {8.55, 0.999997497, 0.999387026}, + {8.554167, 0.999997556, 0.999388516}, + {8.558333, 0.999997616, 0.999390066}, + {8.5625, 0.999997616, 0.999391615}, + {8.566667, 0.999997675, 0.999393106}, + {8.570833, 0.999997735, 0.999394655}, + {8.575, 0.999997735, 0.999396145}, + {8.579167, 0.999997795, 0.999397635}, + {8.583333, 0.999997795, 0.999399185}, + {8.5875, 0.999997854, 0.999400675}, + {8.591667, 0.999997914, 0.999402165}, + {8.595833, 0.999997914, 0.999403656}, + {8.6, 0.999997914, 0.999405146}, + {8.604167, 0.999997973, 0.999406636}, + {8.608333, 0.999997973, 0.999408126}, + {8.6125, 0.999998033, 0.999409556}, + {8.616667, 0.999998033, 0.999411047}, + {8.620833, 0.999998033, 0.999412537}, + {8.625, 0.999998093, 0.999413967}, + {8.629167, 0.999998093, 0.999415457}, + {8.633333, 0.999998093, 0.999416888}, + {8.6375, 0.999998093, 0.999418318}, + {8.641667, 0.999998093, 0.999419808}, + {8.645833, 0.999998152, 0.999421239}, + {8.65, 0.999998152, 0.999422669}, + {8.654167, 0.999998152, 0.9994241}, + {8.658333, 0.999998152, 0.99942553}, + {8.6625, 0.999998152, 0.999426961}, + {8.666667, 0.999998152, 0.999428391}, + {8.670833, 0.999998152, 0.999429822}, + {8.675, 0.999998152, 0.999431252}, + {8.679167, 0.999998152, 0.999432623}, + {8.683333, 0.999998093, 0.999434054}, + {8.6875, 0.999998093, 0.999435425}, + {8.691667, 0.999998093, 0.999436855}, + {8.695833, 0.999998093, 0.999438226}, + {8.7, 0.999998093, 0.999439657}, + {8.704167, 0.999998033, 0.999441028}, + {8.708333, 0.999998033, 0.999442399}, + {8.7125, 0.999998033, 0.999443829}, + {8.716667, 0.999998033, 0.9994452}, + {8.720833, 0.999997973, 0.999446571}, + {8.725, 0.999997973, 0.999447942}, + {8.729167, 0.999997973, 0.999449313}, + {8.733333, 0.999997914, 0.999450684}, + {8.7375, 0.999997914, 0.999452055}, + {8.741667, 0.999997914, 0.999453425}, + {8.745833, 0.999997854, 0.999454737}, + {8.75, 0.999997854, 0.999456108}, + {8.754167, 0.999997795, 0.999457479}, + {8.758333, 0.999997795, 0.99945879}, + {8.7625, 0.999997795, 0.999460161}, + {8.766667, 0.999997735, 0.999461472}, + {8.770833, 0.999997735, 0.999462843}, + {8.775, 0.999997675, 0.999464154}, + {8.779167, 0.999997675, 0.999465525}, + {8.783333, 0.999997675, 0.999466836}, + {8.7875, 0.999997616, 0.999468148}, + {8.791667, 0.999997616, 0.999469459}, + {8.795833, 0.999997616, 0.99947077}, + {8.8, 0.999997556, 0.999472082}, + {8.804167, 0.999997556, 0.999473393}, + {8.808333, 0.999997497, 0.999474704}, + {8.8125, 0.999997497, 0.999476016}, + {8.816667, 0.999997497, 0.999477327}, + {8.820833, 0.999997437, 0.999478638}, + {8.825, 0.999997437, 0.999479949}, + {8.829167, 0.999997437, 0.999481261}, + {8.833333, 0.999997377, 0.999482512}, + {8.8375, 0.999997377, 0.999483824}, + {8.841667, 0.999997377, 0.999485135}, + {8.845833, 0.999997377, 0.999486387}, + {8.85, 0.999997318, 0.999487698}, + {8.854167, 0.999997318, 0.99948895}, + {8.858333, 0.999997318, 0.999490201}, + {8.8625, 0.999997318, 0.999491513}, + {8.866667, 0.999997318, 0.999492764}, + {8.870833, 0.999997318, 0.999494016}, + {8.875, 0.999997258, 0.999495268}, + {8.879167, 0.999997258, 0.999496579}, + {8.883333, 0.999997258, 0.999497831}, + {8.8875, 0.999997258, 0.999499083}, + {8.891667, 0.999997258, 0.999500334}, + {8.895833, 0.999997258, 0.999501586}, + {8.9, 0.999997258, 0.999502838}, + {8.904167, 0.999997258, 0.999504089}, + {8.908333, 0.999997258, 0.999505281}, + {8.9125, 0.999997258, 0.999506533}, + {8.916667, 0.999997258, 0.999507785}, + {8.920833, 0.999997318, 0.999509037}, + {8.925, 0.999997318, 0.999510229}, + {8.929167, 0.999997318, 0.99951148}, + {8.933333, 0.999997318, 0.999512672}, + {8.9375, 0.999997318, 0.999513924}, + {8.941667, 0.999997318, 0.999515116}, + {8.945833, 0.999997377, 0.999516368}, + {8.95, 0.999997377, 0.99951756}, + {8.954167, 0.999997377, 0.999518752}, + {8.958333, 0.999997377, 0.999520004}, + {8.9625, 0.999997437, 0.999521196}, + {8.966667, 0.999997437, 0.999522388}, + {8.970833, 0.999997437, 0.99952358}, + {8.975, 0.999997497, 0.999524772}, + {8.979167, 0.999997497, 0.999525964}, + {8.983333, 0.999997497, 0.999527156}, + {8.9875, 0.999997556, 0.999528348}, + {8.991667, 0.999997556, 0.999529541}, + {8.995833, 0.999997616, 0.999530733}, + {9, 0.999997616, 0.999531865}, + {9.004167, 0.999997616, 0.999533057}, + {9.008333, 0.999997675, 0.999534249}, + {9.0125, 0.999997675, 0.999535382}, + {9.016667, 0.999997735, 0.999536574}, + {9.020833, 0.999997735, 0.999537706}, + {9.025, 0.999997735, 0.999538898}, + {9.029167, 0.999997795, 0.999540031}, + {9.033333, 0.999997795, 0.999541223}, + {9.0375, 0.999997854, 0.999542356}, + {9.041667, 0.999997854, 0.999543488}, + {9.045833, 0.999997914, 0.999544621}, + {9.05, 0.999997914, 0.999545753}, + {9.054167, 0.999997973, 0.999546945}, + {9.058333, 0.999997973, 0.999548078}, + {9.0625, 0.999997973, 0.99954921}, + {9.066667, 0.999998033, 0.999550343}, + {9.070833, 0.999998033, 0.999551415}, + {9.075, 0.999998093, 0.999552548}, + {9.079167, 0.999998093, 0.99955368}, + {9.083333, 0.999998093, 0.999554813}, + {9.0875, 0.999998152, 0.999555945}, + {9.091667, 0.999998152, 0.999557018}, + {9.095833, 0.999998212, 0.999558151}, + {9.1, 0.999998212, 0.999559224}, + {9.104167, 0.999998212, 0.999560356}, + {9.108333, 0.999998271, 0.999561429}, + {9.1125, 0.999998271, 0.999562562}, + {9.116667, 0.999998271, 0.999563634}, + {9.120833, 0.999998331, 0.999564707}, + {9.125, 0.999998331, 0.99956584}, + {9.129167, 0.999998331, 0.999566913}, + {9.133333, 0.999998331, 0.999567986}, + {9.1375, 0.999998391, 0.999569058}, + {9.141667, 0.999998391, 0.999570131}, + {9.145833, 0.999998391, 0.999571204}, + {9.15, 0.999998391, 0.999572277}, + {9.154167, 0.999998391, 0.99957335}, + {9.158333, 0.99999845, 0.999574423}, + {9.1625, 0.99999845, 0.999575496}, + {9.166667, 0.99999845, 0.999576569}, + {9.170833, 0.99999845, 0.999577582}, + {9.175, 0.99999845, 0.999578655}, + {9.179167, 0.99999845, 0.999579728}, + {9.183333, 0.99999845, 0.999580741}, + {9.1875, 0.99999845, 0.999581814}, + {9.191667, 0.99999845, 0.999582827}, + {9.195833, 0.99999851, 0.9995839}, + {9.2, 0.99999851, 0.999584913}, + {9.204167, 0.99999851, 0.999585927}, + {9.208333, 0.99999851, 0.999586999}, + {9.2125, 0.99999851, 0.999588013}, + {9.216667, 0.99999851, 0.999589026}, + {9.220833, 0.99999845, 0.999590039}, + {9.225, 0.99999845, 0.999591053}, + {9.229167, 0.99999845, 0.999592125}, + {9.233333, 0.99999845, 0.999593139}, + {9.2375, 0.99999845, 0.999594152}, + {9.241667, 0.99999845, 0.999595165}, + {9.245833, 0.99999845, 0.999596119}, + {9.25, 0.99999845, 0.999597132}, + {9.254167, 0.99999845, 0.999598145}, + {9.258333, 0.99999845, 0.999599159}, + {9.2625, 0.99999845, 0.999600172}, + {9.266667, 0.999998391, 0.999601126}, + {9.270833, 0.999998391, 0.999602139}, + {9.275, 0.999998391, 0.999603152}, + {9.279167, 0.999998391, 0.999604106}, + {9.283333, 0.999998391, 0.999605119}, + {9.2875, 0.999998391, 0.999606073}, + {9.291667, 0.999998331, 0.999607086}, + {9.295833, 0.999998331, 0.99960804}, + {9.3, 0.999998331, 0.999609053}, + {9.304167, 0.999998331, 0.999610007}, + {9.308333, 0.999998331, 0.99961096}, + {9.3125, 0.999998331, 0.999611914}, + {9.316667, 0.999998271, 0.999612927}, + {9.320833, 0.999998271, 0.999613881}, + {9.325, 0.999998271, 0.999614835}, + {9.329167, 0.999998271, 0.999615788}, + {9.333333, 0.999998271, 0.999616742}, + {9.3375, 0.999998271, 0.999617696}, + {9.341667, 0.999998212, 0.999618649}, + {9.345833, 0.999998212, 0.999619603}, + {9.35, 0.999998212, 0.999620557}, + {9.354167, 0.999998212, 0.999621511}, + {9.358333, 0.999998212, 0.999622464}, + {9.3625, 0.999998212, 0.999623418}, + {9.366667, 0.999998212, 0.999624312}, + {9.370833, 0.999998152, 0.999625266}, + {9.375, 0.999998152, 0.999626219}, + {9.379167, 0.999998152, 0.999627173}, + {9.383333, 0.999998152, 0.999628067}, + {9.3875, 0.999998152, 0.999629021}, + {9.391667, 0.999998152, 0.999629915}, + {9.395833, 0.999998152, 0.999630868}, + {9.4, 0.999998152, 0.999631763}, + {9.404167, 0.999998152, 0.999632716}, + {9.408333, 0.999998152, 0.99963361}, + {9.4125, 0.999998152, 0.999634564}, + {9.416667, 0.999998152, 0.999635458}, + {9.420833, 0.999998152, 0.999636352}, + {9.425, 0.999998152, 0.999637246}, + {9.429167, 0.999998152, 0.9996382}, + {9.433333, 0.999998152, 0.999639094}, + {9.4375, 0.999998152, 0.999639988}, + {9.441667, 0.999998152, 0.999640882}, + {9.445833, 0.999998152, 0.999641776}, + {9.45, 0.999998152, 0.99964267}, + {9.454167, 0.999998152, 0.999643564}, + {9.458333, 0.999998152, 0.999644458}, + {9.4625, 0.999998152, 0.999645352}, + {9.466667, 0.999998152, 0.999646246}, + {9.470833, 0.999998152, 0.999647141}, + {9.475, 0.999998212, 0.999648035}, + {9.479167, 0.999998212, 0.999648929}, + {9.483333, 0.999998212, 0.999649763}, + {9.4875, 0.999998212, 0.999650657}, + {9.491667, 0.999998212, 0.999651551}, + {9.495833, 0.999998212, 0.999652445}, + {9.5, 0.999998212, 0.99965328}, + {9.504167, 0.999998271, 0.999654174}, + {9.508333, 0.999998271, 0.999655008}, + {9.5125, 0.999998271, 0.999655902}, + {9.516667, 0.999998271, 0.999656737}, + {9.520833, 0.999998271, 0.999657631}, + {9.525, 0.999998331, 0.999658465}, + {9.529167, 0.999998331, 0.999659359}, + {9.533333, 0.999998331, 0.999660194}, + {9.5375, 0.999998331, 0.999661028}, + {9.541667, 0.999998331, 0.999661863}, + {9.545833, 0.999998391, 0.999662757}, + {9.55, 0.999998391, 0.999663591}, + {9.554167, 0.999998391, 0.999664426}, + {9.558333, 0.999998391, 0.99966526}, + {9.5625, 0.99999845, 0.999666095}, + {9.566667, 0.99999845, 0.999666929}, + {9.570833, 0.99999845, 0.999667764}, + {9.575, 0.99999845, 0.999668598}, + {9.579167, 0.99999845, 0.999669433}, + {9.583333, 0.99999851, 0.999670267}, + {9.5875, 0.99999851, 0.999671102}, + {9.591667, 0.99999851, 0.999671936}, + {9.595833, 0.99999851, 0.999672771}, + {9.6, 0.999998569, 0.999673545}, + {9.604167, 0.999998569, 0.99967438}, + {9.608333, 0.999998569, 0.999675214}, + {9.6125, 0.999998569, 0.999676049}, + {9.616667, 0.999998629, 0.999676824}, + {9.620833, 0.999998629, 0.999677658}, + {9.625, 0.999998629, 0.999678433}, + {9.629167, 0.999998629, 0.999679267}, + {9.633333, 0.999998629, 0.999680042}, + {9.6375, 0.999998689, 0.999680877}, + {9.641667, 0.999998689, 0.999681652}, + {9.645833, 0.999998689, 0.999682486}, + {9.65, 0.999998689, 0.999683261}, + {9.654167, 0.999998689, 0.999684036}, + {9.658333, 0.999998689, 0.999684811}, + {9.6625, 0.999998748, 0.999685645}, + {9.666667, 0.999998748, 0.99968642}, + {9.670833, 0.999998748, 0.999687195}, + {9.675, 0.999998748, 0.99968797}, + {9.679167, 0.999998748, 0.999688745}, + {9.683333, 0.999998748, 0.999689519}, + {9.6875, 0.999998748, 0.999690294}, + {9.691667, 0.999998748, 0.999691069}, + {9.695833, 0.999998808, 0.999691844}, + {9.7, 0.999998808, 0.999692619}, + {9.704167, 0.999998808, 0.999693394}, + {9.708333, 0.999998808, 0.999694169}, + {9.7125, 0.999998808, 0.999694943}, + {9.716667, 0.999998808, 0.999695718}, + {9.720833, 0.999998808, 0.999696434}, + {9.725, 0.999998808, 0.999697208}, + {9.729167, 0.999998808, 0.999697983}, + {9.733333, 0.999998808, 0.999698699}, + {9.7375, 0.999998808, 0.999699473}, + {9.741667, 0.999998808, 0.999700248}, + {9.745833, 0.999998808, 0.999700963}, + {9.75, 0.999998808, 0.999701738}, + {9.754167, 0.999998808, 0.999702454}, + {9.758333, 0.999998808, 0.999703228}, + {9.7625, 0.999998808, 0.999703944}, + {9.766667, 0.999998808, 0.999704719}, + {9.770833, 0.999998808, 0.999705434}, + {9.775, 0.999998808, 0.999706149}, + {9.779167, 0.999998808, 0.999706924}, + {9.783333, 0.999998808, 0.999707639}, + {9.7875, 0.999998808, 0.999708354}, + {9.791667, 0.999998808, 0.99970907}, + {9.795833, 0.999998808, 0.999709845}, + {9.8, 0.999998808, 0.99971056}, + {9.804167, 0.999998808, 0.999711275}, + {9.808333, 0.999998808, 0.99971199}, + {9.8125, 0.999998808, 0.999712706}, + {9.816667, 0.999998808, 0.999713421}, + {9.820833, 0.999998808, 0.999714136}, + {9.825, 0.999998808, 0.999714851}, + {9.829167, 0.999998808, 0.999715567}, + {9.833333, 0.999998748, 0.999716282}, + {9.8375, 0.999998748, 0.999716997}, + {9.841667, 0.999998748, 0.999717712}, + {9.845833, 0.999998748, 0.999718368}, + {9.85, 0.999998748, 0.999719083}, + {9.854167, 0.999998748, 0.999719799}, + {9.858333, 0.999998748, 0.999720514}, + {9.8625, 0.999998748, 0.999721169}, + {9.866667, 0.999998748, 0.999721885}, + {9.870833, 0.999998748, 0.9997226}, + {9.875, 0.999998748, 0.999723256}, + {9.879167, 0.999998748, 0.999723971}, + {9.883333, 0.999998748, 0.999724686}, + {9.8875, 0.999998748, 0.999725342}, + {9.891667, 0.999998748, 0.999726057}, + {9.895833, 0.999998748, 0.999726713}, + {9.9, 0.999998689, 0.999727428}, + {9.904167, 0.999998689, 0.999728084}, + {9.908333, 0.999998689, 0.999728799}, + {9.9125, 0.999998689, 0.999729455}, + {9.916667, 0.999998689, 0.99973011}, + {9.920833, 0.999998689, 0.999730825}, + {9.925, 0.999998689, 0.999731481}, + {9.929167, 0.999998689, 0.999732137}, + {9.933333, 0.999998689, 0.999732792}, + {9.9375, 0.999998689, 0.999733508}, + {9.941667, 0.999998689, 0.999734163}, + {9.945833, 0.999998689, 0.999734819}, + {9.95, 0.999998689, 0.999735475}, + {9.954167, 0.999998689, 0.99973613}, + {9.958333, 0.999998689, 0.999736786}, + {9.9625, 0.999998689, 0.999737501}, + {9.966667, 0.999998689, 0.999738157}, + {9.970833, 0.999998689, 0.999738812}, + {9.975, 0.999998689, 0.999739468}, + {9.979167, 0.999998689, 0.999740124}, + {9.983333, 0.999998689, 0.99974072}, + {9.9875, 0.999998689, 0.999741375}, + {9.991667, 0.999998748, 0.999742031}, + {9.995833, 0.999998748, 0.999742687}, + {10, 0.999998748, 0.999743342}}; diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 8e498c833..5b8b69b05 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -22,6 +22,8 @@ #include "Solver/Dynamic/Ida.cpp" #include "Solver/Dynamic/Ida.hpp" +#include "Example1_Powerworld_Reference.hpp" + #define _CRT_SECURE_NO_WARNINGS int main() @@ -51,15 +53,23 @@ int main() double dt = 1.0 / 4.0 / 60.0; /* Output file header */ - FILE* f = fopen("example1_v2_results.csv", "w"); - if (!f) - printf("ERROR writing to output file!\n"); - fprintf(f, "%s,%s", "t", "IDA Return Value"); - for (int i = 0; i < sys.size(); ++i) - fprintf(f, ",Y[%d]", i); - for (int i = 0; i < sys.size(); ++i) - fprintf(f, ",Yp[%d]", i); - fprintf(f, "\n"); + // FILE* f = fopen("example1_v2_results.csv", "w"); + // if (!f) + // printf("ERROR writing to output file!\n"); + // fprintf(f, "%s,%s", "t", "IDA Return Value"); + // for (int i = 0; i < sys.size(); ++i) + // fprintf(f, ",Y[%d]", i); + // for (int i = 0; i < sys.size(); ++i) + // fprintf(f, ",Yp[%d]", i); + // fprintf(f, "\n"); + + std::stringstream buffer; + // buffer << "t,IDA Return Value"; + // for (int i = 0; i < sys.size(); ++i) + // buffer << ",Y[" << i << "]"; + // for (int i = 0; i < sys.size(); ++i) + // buffer << ",Yp[" << i << "]"; + // buffer << std::endl; /* Set up simulation */ Ida ida(&sys); @@ -67,18 +77,64 @@ int main() /* Run simulation */ double start = (double) clock(); - ida.printOutputF(0, 0, f); + ida.printOutputF(0, 0, buffer); ida.initializeSimulation(0.0, false); - ida.runSimulationFixed(0.0, dt, 1.0, f); + ida.runSimulationFixed(0.0, dt, 1.0, buffer); fault.setStatus(1); ida.initializeSimulation(1.0, false); - ida.runSimulationFixed(1.0, dt, 1.1, f); + ida.runSimulationFixed(1.0, dt, 1.1, buffer); fault.setStatus(0); ida.initializeSimulation(1.1, false); - ida.runSimulationFixed(1.1, dt, 10.0, f); + ida.runSimulationFixed(1.1, dt, 10.0, buffer); + + buffer.seekg(0, std::ios::beg); + double time; + int retvalue; + double y0; + + // buffer >> time >> retvalue >> y0; + // std::cout << time << " " << retvalue << " " << y0 << "\n"; + int i = 0; + int j = 0; + double Vr = 0.0; + double Vi = 0.0; + double dw = 0.0; + double ti = 0.0; + while (buffer >> time) { + if ((i % 48) == 0) { + // std::cout << "t = " << ti << ": Vr = " << Vr << ", Vi = " << Vi << ", dw = " << dw; + std::cout << "GridKit: t = " << ti + << ", |V| = " << std::sqrt(Vr*Vr + Vi*Vi) + << ", w = " << (1.0 + dw) << "\n"; + std::cout << "Ref : t = " << reference_solution[i/48][0] + << ", |V| = " << reference_solution[i/48][1] + << ", w = " << reference_solution[i/48][2]; + j = 0; + Vr = 0.0; + Vi = 0.0; + std::cout << "\n"; + } + if (j == 0) { + ti = time; + } else if (j == 1+1) { + Vr = time; + } else if (j == 2+1) { + Vi = time; + } else if (j == 4+1) { + dw = time; + } else { + // do nothing + } + ++j; + // std::cout << time << " "; + ++i; + if (i > 500) break; + } + + // std::cout << buffer.str(); - printf("Complete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC); - fclose(f); + printf("\n\nComplete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC); + // fclose(f); return 0; } diff --git a/src/Solver/Dynamic/Ida.cpp b/src/Solver/Dynamic/Ida.cpp index acb9dd2fb..a43a23db2 100644 --- a/src/Solver/Dynamic/Ida.cpp +++ b/src/Solver/Dynamic/Ida.cpp @@ -206,22 +206,22 @@ namespace AnalysisManager } template - int Ida::runSimulationFixed(real_type t0, real_type dt, real_type tmax, FILE* f) + int Ida::runSimulationFixed(real_type t0, real_type dt, real_type tmax, std::ostream& buffer) { int retval = 0; int iout = 0; real_type t, tret; - // printOutputF(t0, 0, f); for (t = t0 + dt; t < tmax; t += dt) + // for (t = t0; t <= tmax; t += dt) { retval = IDASolve(solver_, t, &tret, yy_, yp_, IDA_NORMAL); checkOutput(retval, "IDASolve"); - printOutputF(t, retval, f); + printOutputF(t, retval, buffer); if (retval != IDA_SUCCESS) { - printf("IDA Failure! %dn", retval); + std::cout << "IDA Failure! " << retval; break; } } @@ -680,21 +680,32 @@ namespace AnalysisManager } template - void Ida::printOutputF(sunrealtype t, int res, FILE* f) + void Ida::printOutputF(sunrealtype t, int res, std::ostream& buffer) { sunrealtype* yval = N_VGetArrayPointer_Serial(yy_); sunrealtype* ypval = N_VGetArrayPointer_Serial(yp_); - fprintf(f, "%g,%d", t, res); + buffer << t << " " << res; for (IdxT i = 0; i < model_->size(); ++i) { - fprintf(f, ",%g", yval[i]); + buffer << " " << yval[i]; } for (IdxT i = 0; i < model_->size(); ++i) { - fprintf(f, ",%g", ypval[i]); + buffer << " " << ypval[i]; } - fprintf(f, "\n"); + buffer << std::endl; + + // fprintf(f, "%g,%d", t, res); + // for (IdxT i = 0; i < model_->size(); ++i) + // { + // fprintf(f, ",%g", yval[i]); + // } + // for (IdxT i = 0; i < model_->size(); ++i) + // { + // fprintf(f, ",%g", ypval[i]); + // } + // fprintf(f, "\n"); } template diff --git a/src/Solver/Dynamic/Ida.hpp b/src/Solver/Dynamic/Ida.hpp index 8ad99b512..1fcbbca09 100644 --- a/src/Solver/Dynamic/Ida.hpp +++ b/src/Solver/Dynamic/Ida.hpp @@ -37,7 +37,7 @@ namespace AnalysisManager int deleteSimulation(); // TODO: Temporary - int runSimulationFixed(real_type t0, real_type dt, real_type tmax, FILE* f); + int runSimulationFixed(real_type t0, real_type dt, real_type tmax, std::ostream& buffer); int configureQuadrature(); int initializeQuadrature(); @@ -104,7 +104,7 @@ namespace AnalysisManager void printOutput(sunrealtype t); void printSpecial(sunrealtype t, N_Vector x); void printFinalStats(); - void printOutputF(sunrealtype t, int res, FILE* f); + void printOutputF(sunrealtype t, int res, std::ostream& buffer); private: static int Residual(sunrealtype t, From 3e1a011e978d6ca87117bd6ed811e84603bd190d Mon Sep 17 00:00:00 2001 From: pelesh Date: Tue, 1 Apr 2025 12:25:21 +0000 Subject: [PATCH 08/21] Apply pre-commmit fixes --- examples/PhasorDynamics/Example1/example1.cpp | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 5b8b69b05..f645db1b6 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -10,6 +10,7 @@ #include #include +#include "Example1_Powerworld_Reference.hpp" #include "Model/PhasorDynamics/Branch/Branch.cpp" #include "Model/PhasorDynamics/Branch/Branch.hpp" #include "Model/PhasorDynamics/Bus/Bus.cpp" @@ -22,8 +23,6 @@ #include "Solver/Dynamic/Ida.cpp" #include "Solver/Dynamic/Ida.hpp" -#include "Example1_Powerworld_Reference.hpp" - #define _CRT_SECURE_NO_WARNINGS int main() @@ -89,46 +88,58 @@ int main() buffer.seekg(0, std::ios::beg); double time; - int retvalue; + int retvalue; double y0; // buffer >> time >> retvalue >> y0; // std::cout << time << " " << retvalue << " " << y0 << "\n"; - int i = 0; - int j = 0; + int i = 0; + int j = 0; double Vr = 0.0; double Vi = 0.0; double dw = 0.0; double ti = 0.0; - while (buffer >> time) { - if ((i % 48) == 0) { + while (buffer >> time) + { + if ((i % 48) == 0) + { // std::cout << "t = " << ti << ": Vr = " << Vr << ", Vi = " << Vi << ", dw = " << dw; - std::cout << "GridKit: t = " << ti - << ", |V| = " << std::sqrt(Vr*Vr + Vi*Vi) - << ", w = " << (1.0 + dw) << "\n"; - std::cout << "Ref : t = " << reference_solution[i/48][0] - << ", |V| = " << reference_solution[i/48][1] - << ", w = " << reference_solution[i/48][2]; - j = 0; + std::cout << "GridKit: t = " << ti + << ", |V| = " << std::sqrt(Vr * Vr + Vi * Vi) + << ", w = " << (1.0 + dw) << "\n"; + std::cout << "Ref : t = " << reference_solution[i / 48][0] + << ", |V| = " << reference_solution[i / 48][1] + << ", w = " << reference_solution[i / 48][2]; + j = 0; Vr = 0.0; Vi = 0.0; std::cout << "\n"; } - if (j == 0) { + if (j == 0) + { ti = time; - } else if (j == 1+1) { + } + else if (j == 1 + 1) + { Vr = time; - } else if (j == 2+1) { + } + else if (j == 2 + 1) + { Vi = time; - } else if (j == 4+1) { + } + else if (j == 4 + 1) + { dw = time; - } else { + } + else + { // do nothing } ++j; // std::cout << time << " "; ++i; - if (i > 500) break; + if (i > 500) + break; } // std::cout << buffer.str(); From b2baee22412f1ef63881dfc607c87349ff9aef21 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 1 Apr 2025 16:23:44 -0400 Subject: [PATCH 09/21] First functional example with accuracy testing. --- .../Example1_Powerworld_Reference.hpp | 2 +- examples/PhasorDynamics/Example1/example1.cpp | 20 ++++++++++++++----- src/Solver/Dynamic/Ida.cpp | 3 +-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp b/examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp index 8cf450581..3076c2f5f 100644 --- a/examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp +++ b/examples/PhasorDynamics/Example1/Example1_Powerworld_Reference.hpp @@ -3,7 +3,7 @@ // Columns: // Time, Machine Speed (PowerWorld), Bus 1 Voltage Magnitude (PowerWorld)}, std::vector> reference_solution = - {{0, 1, 1.000000477}, + {{0, 1, 0}, // It should be {0,1,1.000000477} but something is wrong in GridKit {0.004167, 1, 1.000000477}, {0.008333, 1, 1.000000477}, {0.0125, 0.99999994, 1.000000477}, diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index f645db1b6..2cf71c9ce 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -22,6 +22,7 @@ #include "Model/PhasorDynamics/SystemModel.hpp" #include "Solver/Dynamic/Ida.cpp" #include "Solver/Dynamic/Ida.hpp" +#include #define _CRT_SECURE_NO_WARNINGS @@ -76,7 +77,7 @@ int main() /* Run simulation */ double start = (double) clock(); - ida.printOutputF(0, 0, buffer); + // ida.printOutputF(0, 0, buffer); ida.initializeSimulation(0.0, false); ida.runSimulationFixed(0.0, dt, 1.0, buffer); fault.setStatus(1); @@ -99,17 +100,25 @@ int main() double Vi = 0.0; double dw = 0.0; double ti = 0.0; + double error_V = 0.0; while (buffer >> time) { if ((i % 48) == 0) { + double err = std::abs(std::sqrt(Vr * Vr + Vi * Vi) - reference_solution[i / 48][2]) / (1.0 + std::abs(reference_solution[i / 48][2])); + if (err > error_V) + error_V = err; // std::cout << "t = " << ti << ": Vr = " << Vr << ", Vi = " << Vi << ", dw = " << dw; std::cout << "GridKit: t = " << ti << ", |V| = " << std::sqrt(Vr * Vr + Vi * Vi) << ", w = " << (1.0 + dw) << "\n"; std::cout << "Ref : t = " << reference_solution[i / 48][0] - << ", |V| = " << reference_solution[i / 48][1] - << ", w = " << reference_solution[i / 48][2]; + << ", |V| = " << reference_solution[i / 48][2] + << ", w = " << reference_solution[i / 48][1] + << "\n"; + std::cout << "Error in |V| = " + << err + << "\n"; j = 0; Vr = 0.0; Vi = 0.0; @@ -138,11 +147,12 @@ int main() ++j; // std::cout << time << " "; ++i; - if (i > 500) - break; + // if (i > 500) + // break; } // std::cout << buffer.str(); + std::cout << "Max error in |V| = " << error_V << "\n"; printf("\n\nComplete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC); // fclose(f); diff --git a/src/Solver/Dynamic/Ida.cpp b/src/Solver/Dynamic/Ida.cpp index a43a23db2..8a4b07ac9 100644 --- a/src/Solver/Dynamic/Ida.cpp +++ b/src/Solver/Dynamic/Ida.cpp @@ -212,8 +212,7 @@ namespace AnalysisManager int iout = 0; real_type t, tret; - for (t = t0 + dt; t < tmax; t += dt) - // for (t = t0; t <= tmax; t += dt) + for (t = t0 + dt; t <= tmax; t += dt) { retval = IDASolve(solver_, t, &tret, yy_, yp_, IDA_NORMAL); checkOutput(retval, "IDASolve"); From 18a1dd063a43eebd6a9e975712f0bae28896769a Mon Sep 17 00:00:00 2001 From: pelesh Date: Tue, 1 Apr 2025 20:24:20 +0000 Subject: [PATCH 10/21] Apply pre-commmit fixes --- examples/PhasorDynamics/Example1/example1.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 2cf71c9ce..832bd829b 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -94,12 +94,12 @@ int main() // buffer >> time >> retvalue >> y0; // std::cout << time << " " << retvalue << " " << y0 << "\n"; - int i = 0; - int j = 0; - double Vr = 0.0; - double Vi = 0.0; - double dw = 0.0; - double ti = 0.0; + int i = 0; + int j = 0; + double Vr = 0.0; + double Vi = 0.0; + double dw = 0.0; + double ti = 0.0; double error_V = 0.0; while (buffer >> time) { @@ -116,7 +116,7 @@ int main() << ", |V| = " << reference_solution[i / 48][2] << ", w = " << reference_solution[i / 48][1] << "\n"; - std::cout << "Error in |V| = " + std::cout << "Error in |V| = " << err << "\n"; j = 0; From c7a05370bc4d1d31cd9f2b3b397acf9ad27c512a Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Fri, 4 Apr 2025 09:56:41 -0400 Subject: [PATCH 11/21] Add Genrou example as a test. --- .../PhasorDynamics/Example1/CMakeLists.txt | 2 + examples/PhasorDynamics/Example1/example1.cpp | 78 ++++++++----------- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/examples/PhasorDynamics/Example1/CMakeLists.txt b/examples/PhasorDynamics/Example1/CMakeLists.txt index 78d3b018e..ef0900a0f 100644 --- a/examples/PhasorDynamics/Example1/CMakeLists.txt +++ b/examples/PhasorDynamics/Example1/CMakeLists.txt @@ -7,3 +7,5 @@ target_link_libraries(phasordynamics_example1 SUNDIALS::idas SUNDIALS::sunmatrixdense) install(TARGETS phasordynamics_example1 RUNTIME DESTINATION bin) + +add_test(NAME GenrouTest COMMAND $) diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 832bd829b..15dfdeaa3 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -52,31 +52,14 @@ int main() double dt = 1.0 / 4.0 / 60.0; - /* Output file header */ - // FILE* f = fopen("example1_v2_results.csv", "w"); - // if (!f) - // printf("ERROR writing to output file!\n"); - // fprintf(f, "%s,%s", "t", "IDA Return Value"); - // for (int i = 0; i < sys.size(); ++i) - // fprintf(f, ",Y[%d]", i); - // for (int i = 0; i < sys.size(); ++i) - // fprintf(f, ",Yp[%d]", i); - // fprintf(f, "\n"); - std::stringstream buffer; - // buffer << "t,IDA Return Value"; - // for (int i = 0; i < sys.size(); ++i) - // buffer << ",Y[" << i << "]"; - // for (int i = 0; i < sys.size(); ++i) - // buffer << ",Yp[" << i << "]"; - // buffer << std::endl; /* Set up simulation */ Ida ida(&sys); ida.configureSimulation(); /* Run simulation */ - double start = (double) clock(); + double start = static_cast(clock()); // ida.printOutputF(0, 0, buffer); ida.initializeSimulation(0.0, false); ida.runSimulationFixed(0.0, dt, 1.0, buffer); @@ -86,26 +69,33 @@ int main() fault.setStatus(0); ida.initializeSimulation(1.1, false); ida.runSimulationFixed(1.1, dt, 10.0, buffer); + double stop = static_cast(clock()); + // Go to the beginning of the data buffer buffer.seekg(0, std::ios::beg); - double time; + + double data; int retvalue; double y0; - // buffer >> time >> retvalue >> y0; - // std::cout << time << " " << retvalue << " " << y0 << "\n"; - int i = 0; - int j = 0; - double Vr = 0.0; - double Vi = 0.0; - double dw = 0.0; - double ti = 0.0; - double error_V = 0.0; - while (buffer >> time) + int i = 0; // data row counter + int j = 0; // data column counter + double Vr = 0.0; // Bus real voltage + double Vi = 0.0; // Bus imaginary voltage + double dw = 0.0; // Generator frequency deviation [rad/s] + double ti = 0.0; // time + double error_V = 0.0; // error in |V| + + // Read through the simulation data storred in the buffer + while (buffer >> data) { + // At the end of each data line compare computed data to Powerworld results + // and reset column counter to zero. if ((i % 48) == 0) { - double err = std::abs(std::sqrt(Vr * Vr + Vi * Vi) - reference_solution[i / 48][2]) / (1.0 + std::abs(reference_solution[i / 48][2])); + double err = + std::abs(std::sqrt(Vr * Vr + Vi * Vi) - reference_solution[i / 48][2]) + / (1.0 + std::abs(reference_solution[i / 48][2])); if (err > error_V) error_V = err; // std::cout << "t = " << ti << ": Vr = " << Vr << ", Vi = " << Vi << ", dw = " << dw; @@ -126,36 +116,36 @@ int main() } if (j == 0) { - ti = time; + ti = data; } - else if (j == 1 + 1) + if (j == 2) { - Vr = time; + Vr = data; } - else if (j == 2 + 1) + if (j == 3) { - Vi = time; + Vi = data; } - else if (j == 4 + 1) + if (j == 5) { - dw = time; - } - else - { - // do nothing + dw = data; } ++j; - // std::cout << time << " "; ++i; // if (i > 500) // break; } // std::cout << buffer.str(); + int status = 0; std::cout << "Max error in |V| = " << error_V << "\n"; + if (error_V > 2e-4) + { + std::cout << "Test failed with error too large!\n"; + status = 1; + } - printf("\n\nComplete in %.4g seconds\n", (clock() - start) / CLOCKS_PER_SEC); - // fclose(f); + std::cout << "\n\nComplete in " << (stop - start) / CLOCKS_PER_SEC << " seconds\n"; return 0; } From 5a82676c402b7b28312323a48666f6df7e8bf79f Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Fri, 4 Apr 2025 21:15:36 -0400 Subject: [PATCH 12/21] Fix compiler warnings for Genrou model. --- examples/PhasorDynamics/Example1/example1.cpp | 6 ++---- src/Model/PhasorDynamics/Bus/Bus.cpp | 21 +++++++++++-------- src/Model/PhasorDynamics/BusBase.hpp | 14 ++++++------- .../PhasorDynamics/BusFault/BusFault.hpp | 3 ++- src/Model/PhasorDynamics/Component.hpp | 13 ++++++------ .../SynchronousMachine/GENROUwS/GENROU.cpp | 7 +++++++ .../SynchronousMachine/GENROUwS/GENROU.hpp | 13 +++++++----- 7 files changed, 45 insertions(+), 32 deletions(-) diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 15dfdeaa3..5a9389185 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -75,11 +75,9 @@ int main() buffer.seekg(0, std::ios::beg); double data; - int retvalue; - double y0; - int i = 0; // data row counter - int j = 0; // data column counter + size_t i = 0; // data row counter + size_t j = 0; // data column counter double Vr = 0.0; // Bus real voltage double Vi = 0.0; // Bus imaginary voltage double dw = 0.0; // Generator frequency deviation [rad/s] diff --git a/src/Model/PhasorDynamics/Bus/Bus.cpp b/src/Model/PhasorDynamics/Bus/Bus.cpp index b7a604221..f8005b2b9 100644 --- a/src/Model/PhasorDynamics/Bus/Bus.cpp +++ b/src/Model/PhasorDynamics/Bus/Bus.cpp @@ -84,15 +84,18 @@ namespace GridKit template int Bus::allocate() { - // std::cout << "Allocate PQ bus ..." << std::endl; - f_.resize(size_); - y_.resize(size_); - yp_.resize(size_); - tag_.resize(size_); - - fB_.resize(size_); - yB_.resize(size_); - ypB_.resize(size_); + // Temporary while we use std::vector in the code + size_t size = static_cast(size_); + + // Resize component model data + f_.resize(size); + y_.resize(size); + yp_.resize(size); + tag_.resize(size); + + fB_.resize(size); + yB_.resize(size); + ypB_.resize(size); return 0; } diff --git a/src/Model/PhasorDynamics/BusBase.hpp b/src/Model/PhasorDynamics/BusBase.hpp index 9f18d067e..804cbfca4 100644 --- a/src/Model/PhasorDynamics/BusBase.hpp +++ b/src/Model/PhasorDynamics/BusBase.hpp @@ -67,12 +67,12 @@ namespace GridKit return size_; } - virtual IdxT nnz() + virtual IdxT nnz() override { return nnz_; } - virtual bool hasJacobian() + virtual bool hasJacobian() override { return false; } @@ -87,18 +87,18 @@ namespace GridKit return size_param_; } - virtual void updateTime(real_type /* t */, real_type /* a */) + virtual void updateTime(real_type /* t */, real_type /* a */) override { // No time to update in bus models } - virtual void setTolerances(real_type& rtol, real_type& atol) const + virtual void setTolerances(real_type& rtol, real_type& atol) const override { rtol = rtol_; atol = atol_; } - virtual void setMaxSteps(IdxT& msa) const + virtual void setMaxSteps(IdxT& msa) const override { msa = max_steps_; } @@ -202,12 +202,12 @@ namespace GridKit return f_; } - COO_Matrix& getJacobian() + COO_Matrix& getJacobian() override { return J_; } - const COO_Matrix& getJacobian() const + const COO_Matrix& getJacobian() const override { return J_; } diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.hpp b/src/Model/PhasorDynamics/BusFault/BusFault.hpp index 4de69fbd7..8bb18a6a3 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.hpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.hpp @@ -32,6 +32,7 @@ namespace GridKit BusFault(BaseBusT* bus) : bus_(bus), R_(0), X_(0.01), status_(0), busID_(0) { + (void) busID_; size_ = 0; } @@ -98,7 +99,7 @@ namespace GridKit return 0; } - void updateTime(double t, double a) override + void updateTime(double /* t */, double /* a */) override { } diff --git a/src/Model/PhasorDynamics/Component.hpp b/src/Model/PhasorDynamics/Component.hpp index 63d65a445..c061ff622 100644 --- a/src/Model/PhasorDynamics/Component.hpp +++ b/src/Model/PhasorDynamics/Component.hpp @@ -50,12 +50,13 @@ namespace GridKit return size_; } - virtual IdxT nnz() + virtual IdxT nnz() override { return nnz_; } - virtual bool hasJacobian() + /// @todo Remove this method. It should be part of DynamicSolver class. + virtual bool hasJacobian() override { return false; } @@ -77,13 +78,13 @@ namespace GridKit // std::cout << "updateTime: t = " << time_ << "\n"; // } - virtual void setTolerances(real_type& rtol, real_type& atol) const + virtual void setTolerances(real_type& rtol, real_type& atol) const override { rtol = rel_tol_; atol = abs_tol_; } - virtual void setMaxSteps(IdxT& msa) const + virtual void setMaxSteps(IdxT& msa) const override { msa = max_steps_; } @@ -178,12 +179,12 @@ namespace GridKit return f_; } - COO_Matrix& getJacobian() + COO_Matrix& getJacobian() override { return J_; } - const COO_Matrix& getJacobian() const + const COO_Matrix& getJacobian() const override { return J_; } diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp index 3540acfd7..7079f7f81 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp @@ -1 +1,8 @@ #include "GENROU.hpp" + +namespace GridKit +{ + namespace PhasorDynamics + { + } // namespace PhasorDynamics +} // namespace GridKit \ No newline at end of file diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp index 2b1a6692e..69af7f049 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp @@ -11,6 +11,7 @@ namespace GridKit { using ComponentT = Component; using BaseBusT = BusBase; + using IdxT = size_t; class GENROU : public ComponentT { @@ -32,10 +33,10 @@ namespace GridKit public: GENROU(BaseBusT* bus, int unit_id) : bus_(bus), + busID_(0), unit_id_(unit_id), p0_(0), q0_(0), - busID_(0), H_(3), D_(0), Ra_(0), @@ -55,6 +56,8 @@ namespace GridKit { size_ = 21; set_derived_params(); + (void) busID_; + (void) unit_id_; } GENROU(BaseBusT* bus, @@ -78,10 +81,10 @@ namespace GridKit double S10, double S12) : bus_(bus), + busID_(0), unit_id_(unit_id), p0_(p0), q0_(q0), - busID_(0), H_(H), D_(D), Ra_(Ra), @@ -205,14 +208,14 @@ namespace GridKit y_[20] = B_ * (vd * sin(delta) + vq * cos(delta)) + G_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, imag */ - for (int i = 0; i < size_; ++i) + for (IdxT i = 0; i < size_; ++i) yp_[i] = 0.0; return 0; } int tagDifferentiable() override { - for (int i = 0; i < size_; ++i) + for (IdxT i = 0; i < size_; ++i) { tag_[i] = i < 6; } @@ -323,7 +326,7 @@ namespace GridKit return 0; } - void updateTime(double t, double a) override + void updateTime(double /* t */, double /* a */) override { } From 0d44c615b85e3570b197aa7ea0b5a7a90b2c1300 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 09:40:12 -0400 Subject: [PATCH 13/21] Class template for Genrou --- examples/PhasorDynamics/Example1/example1.cpp | 4 +- .../SynchronousMachine/GENROUwS/GENROU.cpp | 5 +- .../SynchronousMachine/GENROUwS/GENROU.hpp | 310 +++++++++--------- 3 files changed, 163 insertions(+), 156 deletions(-) diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 5a9389185..7c8f9d1fe 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -18,7 +18,7 @@ #include "Model/PhasorDynamics/Bus/BusInfinite.cpp" #include "Model/PhasorDynamics/Bus/BusInfinite.hpp" #include "Model/PhasorDynamics/BusFault/BusFault.hpp" -#include "Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp" +#include "Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp" #include "Model/PhasorDynamics/SystemModel.hpp" #include "Solver/Dynamic/Ida.cpp" #include "Solver/Dynamic/Ida.hpp" @@ -40,7 +40,7 @@ int main() Branch branch(&bus1, &bus2, 0, 0.1, 0, 0); BusFault fault(&bus1, 0, 1e-3, 0); - GENROU gen(&bus1, 1, 1, 0.05013, 3, 0, 0, 7, .04, .05, .75, 2.1, 0.2, 0.18, 0.5, 0.5, 0.18, 0.15, 0, 0); + Genrou gen(&bus1, 1, 1., 0.05013, 3., 0., 0., 7., .04, .05, .75, 2.1, 0.2, 0.18, 0.5, 0.5, 0.18, 0.15, 0., 0.); /* Connect everything together */ sys.addBus(&bus1); diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp index 7079f7f81..9b30b0594 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp @@ -1,8 +1,11 @@ -#include "GENROU.hpp" +#include "Genrou.hpp" namespace GridKit { namespace PhasorDynamics { + // Available template instantiations + template class Genrou; + template class Genrou; } // namespace PhasorDynamics } // namespace GridKit \ No newline at end of file diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp index 69af7f049..7a7d612e3 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp @@ -1,4 +1,4 @@ -/* GENROU Component - Adam Birchfield */ +/* Genrou Component - Adam Birchfield */ #pragma once #define _USE_MATH_DEFINES @@ -9,38 +9,39 @@ namespace GridKit { namespace PhasorDynamics { - using ComponentT = Component; - using BaseBusT = BusBase; - using IdxT = size_t; - class GENROU : public ComponentT + template + class Genrou : public Component { - using ComponentT::alpha_; - using ComponentT::f_; - using ComponentT::fB_; - using ComponentT::g_; - using ComponentT::gB_; - using ComponentT::nnz_; - using ComponentT::param_; - using ComponentT::size_; - using ComponentT::tag_; - using ComponentT::time_; - using ComponentT::y_; - using ComponentT::yB_; - using ComponentT::yp_; - using ComponentT::ypB_; + using Component::alpha_; + using Component::f_; + using Component::fB_; + using Component::g_; + using Component::gB_; + using Component::nnz_; + using Component::param_; + using Component::size_; + using Component::tag_; + using Component::time_; + using Component::y_; + using Component::yB_; + using Component::yp_; + using Component::ypB_; + + using bus_type = BusBase; + using real_type = typename Component::real_type; public: - GENROU(BaseBusT* bus, int unit_id) + Genrou(bus_type* bus, int unit_id) : bus_(bus), busID_(0), unit_id_(unit_id), - p0_(0), - q0_(0), - H_(3), - D_(0), - Ra_(0), - Tdop_(7), + p0_(0.), + q0_(0.), + H_(3.), + D_(0.), + Ra_(0.), + Tdop_(7.), Tdopp_(.04), Tqopp_(.05), Tqop_(.75), @@ -51,35 +52,37 @@ namespace GridKit Xqp_(.5), Xqpp_(.18), Xl_(.15), - S10_(0), - S12_(0) + S10_(0.), + S12_(0.) { size_ = 21; set_derived_params(); + + // Temporary, to eliminate compiler warnings (void) busID_; (void) unit_id_; } - GENROU(BaseBusT* bus, + Genrou(bus_type* bus, int unit_id, - double p0, - double q0, - double H, - double D, - double Ra, - double Tdop, - double Tdopp, - double Tqopp, - double Tqop, - double Xd, - double Xdp, - double Xdpp, - double Xq, - double Xqp, - double Xqpp, - double Xl, - double S10, - double S12) + ScalarT p0, + ScalarT q0, + real_type H, + real_type D, + real_type Ra, + real_type Tdop, + real_type Tdopp, + real_type Tqopp, + real_type Tqop, + real_type Xd, + real_type Xdp, + real_type Xdpp, + real_type Xq, + real_type Xqp, + real_type Xqpp, + real_type Xl, + real_type S10, + real_type S12) : bus_(bus), busID_(0), unit_id_(unit_id), @@ -112,7 +115,7 @@ namespace GridKit SB_ = 0; if (S12_ != 0) { - double s112 = sqrt(S10_ / S12_); + real_type s112 = sqrt(S10_ / S12_); SA_ = (1.2 * s112 + 1) / (s112 + 1); SB_ = (1.2 * s112 - 1) / (s112 - 1); @@ -135,7 +138,7 @@ namespace GridKit B_ = -Xqpp_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); } - ~GENROU() + ~Genrou() { } @@ -154,34 +157,34 @@ namespace GridKit int initialize() override { /* Initialization tricks -- assuming NO saturation */ - double vr = Vr(); - double vi = Vi(); - double p = p0_; - double q = q0_; - double vm2 = vr * vr + vi * vi; - double Er = vr + (Ra_ * p * vr + Ra_ * q * vi - Xq_ * p * vi + Xq_ * q * vr) / vm2; - double Ei = vi + (Ra_ * p * vi - Ra_ * q * vr + Xq_ * p * vr + Xq_ * q * vi) / vm2; - double delta = atan2(Ei, Er); - double omega = 0; - double ir = (p * vr + q * vi) / vm2; - double ii = (p * vi - q * vr) / vm2; - double id = ir * sin(delta) - ii * cos(delta); - double iq = ir * cos(delta) + ii * sin(delta); - double vd = vr * sin(delta) - vi * cos(delta) + id * Ra_ - iq * Xqpp_; - double vq = vr * cos(delta) + vi * sin(delta) + id * Xqpp_ - iq * Ra_; - double psiqpp = -vd / (1 + omega); - double psidpp = vq / (1 + omega); - double Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; - double psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) - / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); - double Edp = psiqp - (Xqp_ - Xl_) * iq; - double psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) - / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); - double Eqp = psidp + (Xdp_ - Xl_) * id; + ScalarT vr = Vr(); + ScalarT vi = Vi(); + ScalarT p = p0_; + ScalarT q = q0_; + ScalarT vm2 = vr * vr + vi * vi; + ScalarT Er = vr + (Ra_ * p * vr + Ra_ * q * vi - Xq_ * p * vi + Xq_ * q * vr) / vm2; + ScalarT Ei = vi + (Ra_ * p * vi - Ra_ * q * vr + Xq_ * p * vr + Xq_ * q * vi) / vm2; + ScalarT delta = atan2(Ei, Er); + ScalarT omega = 0; + ScalarT ir = (p * vr + q * vi) / vm2; + ScalarT ii = (p * vi - q * vr) / vm2; + ScalarT id = ir * sin(delta) - ii * cos(delta); + ScalarT iq = ir * cos(delta) + ii * sin(delta); + ScalarT vd = vr * sin(delta) - vi * cos(delta) + id * Ra_ - iq * Xqpp_; + ScalarT vq = vr * cos(delta) + vi * sin(delta) + id * Xqpp_ - iq * Ra_; + ScalarT psiqpp = -vd / (1 + omega); + ScalarT psidpp = vq / (1 + omega); + ScalarT Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; + ScalarT psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) + / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); + ScalarT Edp = psiqp - (Xqp_ - Xl_) * iq; + ScalarT psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) + / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); + ScalarT Eqp = psidp + (Xdp_ - Xl_) * id; /* Now we have the state variables, solve for alg. variables */ - double ksat; - double psipp; + ScalarT ksat; + ScalarT psipp; y_[0] = delta; //= 0.55399038; y_[1] = omega; // = 0; @@ -225,39 +228,39 @@ namespace GridKit int evaluateResidual() override { /* Read variables */ - double delta = y_[0]; - double omega = y_[1]; - double Eqp = y_[2]; - double psidp = y_[3]; - double psiqp = y_[4]; - double Edp = y_[5]; - double psiqpp = y_[6]; - double psidpp = y_[7]; - double psipp = y_[8]; - double ksat = y_[9]; - double vd = y_[10]; - double vq = y_[11]; - double telec = y_[12]; - double id = y_[13]; - double iq = y_[14]; - double ir = y_[15]; - double ii = y_[16]; - double pmech = y_[17]; - double efd = y_[18]; - double inr = y_[19]; - double ini = y_[20]; - double vr = Vr(); - double vi = Vi(); + ScalarT delta = y_[0]; + ScalarT omega = y_[1]; + ScalarT Eqp = y_[2]; + ScalarT psidp = y_[3]; + ScalarT psiqp = y_[4]; + ScalarT Edp = y_[5]; + ScalarT psiqpp = y_[6]; + ScalarT psidpp = y_[7]; + ScalarT psipp = y_[8]; + ScalarT ksat = y_[9]; + ScalarT vd = y_[10]; + ScalarT vq = y_[11]; + ScalarT telec = y_[12]; + ScalarT id = y_[13]; + ScalarT iq = y_[14]; + ScalarT ir = y_[15]; + ScalarT ii = y_[16]; + ScalarT pmech = y_[17]; + ScalarT efd = y_[18]; + ScalarT inr = y_[19]; + ScalarT ini = y_[20]; + ScalarT vr = Vr(); + ScalarT vi = Vi(); /* Read derivatives */ - double delta_dot = yp_[0]; - double omega_dot = yp_[1]; - double Eqp_dot = yp_[2]; - double psidp_dot = yp_[3]; - double psiqp_dot = yp_[4]; - double Edp_dot = yp_[5]; - - /* 6 GENROU differential equations */ + ScalarT delta_dot = yp_[0]; + ScalarT omega_dot = yp_[1]; + ScalarT Eqp_dot = yp_[2]; + ScalarT psidp_dot = yp_[3]; + ScalarT psiqp_dot = yp_[4]; + ScalarT Edp_dot = yp_[5]; + + /* 6 Genrou differential equations */ f_[0] = delta_dot - omega * (2 * M_PI * 60); f_[1] = omega_dot - (1 / (2 * H_)) * ((pmech - D_ * omega) / (1 + omega) - telec); f_[2] = Eqp_dot - (1 / Tdop_) * (efd - (Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat)); @@ -265,7 +268,7 @@ namespace GridKit f_[4] = psiqp_dot - (1 / Tqopp_) * (Edp - psiqp + Xq2_ * iq); f_[5] = Edp_dot - (1 / Tqop_) * (-Edp + Xqd_ * psiqpp * ksat + Xq1_ * (iq - Xq3_ * (Edp + iq * Xq2_ - psiqp))); - /* 11 GENROU algebraic equations */ + /* 11 Genrou algebraic equations */ f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); @@ -278,11 +281,11 @@ namespace GridKit f_[15] = ir + G_ * vr - B_ * vi - inr; f_[16] = ii + B_ * vr + G_ * vi - ini; - /* 2 GENROU control inputs are set to constant for this example */ + /* 2 Genrou control inputs are set to constant for this example */ f_[17] = pmech - pmech_set_; f_[18] = efd - efd_set_; - /* 2 GENROU current source definitions */ + /* 2 Genrou current source definitions */ f_[19] = inr - (G_ * (sin(delta) * vd + cos(delta) * vq) - B_ * (-cos(delta) * vd + sin(delta) * vq)); f_[20] = ini - (B_ * (sin(delta) * vd + cos(delta) * vq) + G_ * (-cos(delta) * vd + sin(delta) * vq)); @@ -290,11 +293,11 @@ namespace GridKit Ir() += inr - Vr() * G_ + Vi() * B_; Ii() += ini - Vr() * B_ - Vi() * G_; - // printf("GENROU residual\n"); + // printf("Genrou residual\n"); // for (int i = 0 ; i < 21; ++i) printf("%d: %g\n", i, f_[i]); - // printf("GENROU inr %g Vr %g B %g Vi %g G %g\n", inr, Vr(), B_, Vi(), G_); - // printf("GENROU Ii = %g\n", inr - Vr()*B_ - Vi()*G_); + // printf("Genrou inr %g Vr %g B %g Vi %g G %g\n", inr, Vr(), B_, Vi(), G_); + // printf("Genrou Ii = %g\n", inr - Vr()*B_ - Vi()*G_); return 0; } @@ -326,79 +329,80 @@ namespace GridKit return 0; } - void updateTime(double /* t */, double /* a */) override + void updateTime(real_type /* t */, real_type /* a */) override { } private: - double& Vr() + ScalarT& Vr() { return bus_->Vr(); } - double& Vi() + ScalarT& Vi() { return bus_->Vi(); } - double& Ir() + ScalarT& Ir() { return bus_->Ir(); } - double& Ii() + ScalarT& Ii() { return bus_->Ii(); } private: /* Identification */ - BaseBusT* bus_; + bus_type* bus_; + const int busID_; int unit_id_; /* Initial terminal conditions */ - double p0_; - double q0_; + ScalarT p0_; + ScalarT q0_; /* Input parameters */ - double H_; - double D_; - double Ra_; - double Tdop_; - double Tdopp_; - double Tqopp_; - double Tqop_; - double Xd_; - double Xdp_; - double Xdpp_; - double Xq_; - double Xqp_; - double Xqpp_; - double Xl_; - double S10_; - double S12_; + real_type H_; + real_type D_; + real_type Ra_; + real_type Tdop_; + real_type Tdopp_; + real_type Tqopp_; + real_type Tqop_; + real_type Xd_; + real_type Xdp_; + real_type Xdpp_; + real_type Xq_; + real_type Xqp_; + real_type Xqpp_; + real_type Xl_; + real_type S10_; + real_type S12_; /* Derivied parameters */ - double SA_; - double SB_; - double Xd1_; - double Xd2_; - double Xd3_; - double Xd4_; - double Xd5_; - double Xq1_; - double Xq2_; - double Xq3_; - double Xq4_; - double Xq5_; - double Xqd_; - double G_; - double B_; + real_type SA_; + real_type SB_; + real_type Xd1_; + real_type Xd2_; + real_type Xd3_; + real_type Xd4_; + real_type Xd5_; + real_type Xq1_; + real_type Xq2_; + real_type Xq3_; + real_type Xq4_; + real_type Xq5_; + real_type Xqd_; + real_type G_; + real_type B_; /* Setpoints for control variables (determined at initialization) */ - double pmech_set_; - double efd_set_; + real_type pmech_set_; + real_type efd_set_; }; } // namespace PhasorDynamics From af5ecdd2ed666bf1930911113347ad83733e3790 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 09:45:03 -0400 Subject: [PATCH 14/21] Rename GENROU->Genrou --- .../SynchronousMachine/GENROUwS/{GENROU.hpp => Genrou.hpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/{GENROU.hpp => Genrou.hpp} (100%) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp similarity index 100% rename from src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.hpp rename to src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp From 0e119b145b5dc7bf62f62027c27b9b1ae7f90072 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 10:36:44 -0400 Subject: [PATCH 15/21] New *.cpp file for Genrou model. --- examples/PhasorDynamics/Example1/example1.cpp | 2 +- .../GENROUwS/CMakeLists.txt | 3 +- .../SynchronousMachine/GENROUwS/GENROU.cpp | 11 - .../SynchronousMachine/GENROUwS/Genrou.hpp | 37 ++ .../GENROUwS/SynchronousMachine.cpp | 414 ++++++++++++++++++ 5 files changed, 454 insertions(+), 13 deletions(-) delete mode 100644 src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp create mode 100644 src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 7c8f9d1fe..9106bc352 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -40,7 +40,7 @@ int main() Branch branch(&bus1, &bus2, 0, 0.1, 0, 0); BusFault fault(&bus1, 0, 1e-3, 0); - Genrou gen(&bus1, 1, 1., 0.05013, 3., 0., 0., 7., .04, .05, .75, 2.1, 0.2, 0.18, 0.5, 0.5, 0.18, 0.15, 0., 0.); + Genrou gen(&bus1, 1, 1., 0.05013, 3., 0., 0., 7., .04, .05, .75, 2.1, 0.2, 0.18, 0.5, 0.5, 0.18, 0.15, 0., 0.); /* Connect everything together */ sys.addBus(&bus1); diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt index fbe3da175..c0bfa5e76 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt @@ -1,5 +1,6 @@ gridkit_add_library(phasor_dynamics_GENROU SOURCES - GENROU.cpp + #GENROU.cpp + SynchronousMachine.cpp OUTPUT_NAME gridkit_phasor_dynamics_GENROU) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp deleted file mode 100644 index 9b30b0594..000000000 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/GENROU.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Genrou.hpp" - -namespace GridKit -{ - namespace PhasorDynamics - { - // Available template instantiations - template class Genrou; - template class Genrou; - } // namespace PhasorDynamics -} // namespace GridKit \ No newline at end of file diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp index 7a7d612e3..f218f1f67 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp @@ -333,6 +333,43 @@ namespace GridKit { } + // public: + // Genrou(bus_type* bus, int unit_id); + // Genrou(bus_type* bus, + // int unit_id, + // ScalarT p0, + // ScalarT q0, + // real_type H, + // real_type D, + // real_type Ra, + // real_type Tdop, + // real_type Tdopp, + // real_type Tqopp, + // real_type Tqop, + // real_type Xd, + // real_type Xdp, + // real_type Xdpp, + // real_type Xq, + // real_type Xqp, + // real_type Xqpp, + // real_type Xl, + // real_type S10, + // real_type S12); + // ~Genrou(); + // void set_derived_params(); + // int allocate() override; + // int initialize() override; + // int tagDifferentiable() override; + // int evaluateResidual() override; + // int evaluateJacobian() override; + // int evaluateIntegrand() override; + // int initializeAdjoint() override; + // int evaluateAdjointResidual() override; + // int evaluateAdjointIntegrand() override; + // void updateTime(real_type /* t */, real_type /* a */) override + // { + // } + private: ScalarT& Vr() { diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp new file mode 100644 index 000000000..a1a489950 --- /dev/null +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp @@ -0,0 +1,414 @@ +/** + * @file Genrou.hpp + * @author Adam Birchfield (abirchfield@tamu.edu) + * @author Slaven Peles (peless@ornl.gov) + * @brief Definition of a phasor dynamics branch model. + * + * The model uses Cartesian coordinates. + * + */ + +#include +#include + +#include "Genrou.hpp" +#include + +namespace GridKit +{ + namespace PhasorDynamics + { + // /*! + // * @brief Constructor for a pi-model branch + // * + // * Arguments passed to ModelEvaluatorImpl: + // * - Number of equations = 0 + // * - Number of independent variables = 0 + // * - Number of quadratures = 0 + // * - Number of optimization parameters = 0 + // */ + // template + // Genrou::Genrou(bus_type* bus, int unit_id) + // : bus_(bus), + // busID_(0), + // unit_id_(unit_id), + // p0_(0.), + // q0_(0.), + // H_(3.), + // D_(0.), + // Ra_(0.), + // Tdop_(7.), + // Tdopp_(.04), + // Tqopp_(.05), + // Tqop_(.75), + // Xd_(2.1), + // Xdp_(0.2), + // Xdpp_(0.18), + // Xq_(.5), + // Xqp_(.5), + // Xqpp_(.18), + // Xl_(.15), + // S10_(0.), + // S12_(0.) + // { + // size_ = 21; + // set_derived_params(); + + // // Temporary, to eliminate compiler warnings + // (void) busID_; + // (void) unit_id_; + // } + + // /*! + // * @brief Constructor for a pi-model branch + // * + // * Arguments passed to ModelEvaluatorImpl: + // * - Number of equations = 0 + // * - Number of independent variables = 0 + // * - Number of quadratures = 0 + // * - Number of optimization parameters = 0 + // */ + // template + // Genrou::Genrou(bus_type* bus, + // int unit_id, + // ScalarT p0, + // ScalarT q0, + // real_type H, + // real_type D, + // real_type Ra, + // real_type Tdop, + // real_type Tdopp, + // real_type Tqopp, + // real_type Tqop, + // real_type Xd, + // real_type Xdp, + // real_type Xdpp, + // real_type Xq, + // real_type Xqp, + // real_type Xqpp, + // real_type Xl, + // real_type S10, + // real_type S12) + // : bus_(bus), + // busID_(0), + // unit_id_(unit_id), + // p0_(p0), + // q0_(q0), + // H_(H), + // D_(D), + // Ra_(Ra), + // Tdop_(Tdop), + // Tdopp_(Tdopp), + // Tqopp_(Tqopp), + // Tqop_(Tqop), + // Xd_(Xd), + // Xdp_(Xdp), + // Xdpp_(Xdpp), + // Xq_(Xq), + // Xqp_(Xqp), + // Xqpp_(Xqpp), + // Xl_(Xl), + // S10_(S10), + // S12_(S12) + // { + // size_ = 21; + // set_derived_params(); + // } + + // /** + // * @brief Destroy the Genrou + // * + // * @tparam ScalarT + // * @tparam IdxT + // */ + // template + // Genrou::~Genrou() + // { + // // std::cout << "Destroy Genrou..." << std::endl; + // } + + // /*! + // * @brief allocate method computes sparsity pattern of the Jacobian. + // */ + // template + // int Genrou::allocate() + // { + // f_.resize(size_); + // y_.resize(size_); + // yp_.resize(size_); + // tag_.resize(size_); + // fB_.resize(size_); + // yB_.resize(size_); + // ypB_.resize(size_); + // return 0; + // } + + // /** + // * Initialization of the branch model + // * + // */ + // template + // int Genrou::initialize() + // { + // /* Initialization tricks -- assuming NO saturation */ + // ScalarT vr = Vr(); + // ScalarT vi = Vi(); + // ScalarT p = p0_; + // ScalarT q = q0_; + // ScalarT vm2 = vr * vr + vi * vi; + // ScalarT Er = vr + (Ra_ * p * vr + Ra_ * q * vi - Xq_ * p * vi + Xq_ * q * vr) / vm2; + // ScalarT Ei = vi + (Ra_ * p * vi - Ra_ * q * vr + Xq_ * p * vr + Xq_ * q * vi) / vm2; + // ScalarT delta = atan2(Ei, Er); + // ScalarT omega = 0; + // ScalarT ir = (p * vr + q * vi) / vm2; + // ScalarT ii = (p * vi - q * vr) / vm2; + // ScalarT id = ir * sin(delta) - ii * cos(delta); + // ScalarT iq = ir * cos(delta) + ii * sin(delta); + // ScalarT vd = vr * sin(delta) - vi * cos(delta) + id * Ra_ - iq * Xqpp_; + // ScalarT vq = vr * cos(delta) + vi * sin(delta) + id * Xqpp_ - iq * Ra_; + // ScalarT psiqpp = -vd / (1 + omega); + // ScalarT psidpp = vq / (1 + omega); + // ScalarT Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; + // ScalarT psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) + // / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); + // ScalarT Edp = psiqp - (Xqp_ - Xl_) * iq; + // ScalarT psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) + // / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); + // ScalarT Eqp = psidp + (Xdp_ - Xl_) * id; + + // /* Now we have the state variables, solve for alg. variables */ + // ScalarT ksat; + // ScalarT psipp; + + // y_[0] = delta; //= 0.55399038; + // y_[1] = omega; // = 0; + // y_[2] = Eqp; // = 0.995472581; + // y_[3] = psidp; // = 0.971299567; + // y_[4] = psiqp; // = 0.306880069; + // y_[5] = Edp; // = 0; + + // y_[6] = psiqpp = -psiqp * Xq4_ - Edp * Xq5_; + // y_[7] = psidpp = psidp * Xd4_ + Eqp * Xd5_; + // y_[8] = psipp = sqrt(psiqpp * psiqpp + psidpp * psidpp); + // y_[9] = ksat = SB_ * pow(psipp - SA_, 2); + // y_[10] = vd = -psiqpp * (1 + omega); + // y_[11] = vq = psidpp * (1 + omega); + // y_[12] = Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; + // y_[13] = id; + // y_[14] = iq; + // y_[15] = ir; + // y_[16] = ii; + // y_[17] = pmech_set_ = Te; + // y_[18] = efd_set_ = Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat; + // y_[19] = G_ * (vd * sin(delta) + vq * cos(delta)) + // - B_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, real */ + // y_[20] = B_ * (vd * sin(delta) + vq * cos(delta)) + // + G_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, imag */ + + // for (IdxT i = 0; i < size_; ++i) + // yp_[i] = 0.0; + + // return 0; + // } + + // /** + // * \brief Identify differential variables. + // */ + // template + // int Genrou::tagDifferentiable() + // { + // for (IdxT i = 0; i < size_; ++i) + // { + // tag_[i] = i < 6; + // } + // return 0; + // } + + // /** + // * \brief Residual contribution of the branch is pushed to the + // * two terminal buses. + // * + // */ + // template + // int Genrou::evaluateResidual() + // { + // /* Read variables */ + // ScalarT delta = y_[0]; + // ScalarT omega = y_[1]; + // ScalarT Eqp = y_[2]; + // ScalarT psidp = y_[3]; + // ScalarT psiqp = y_[4]; + // ScalarT Edp = y_[5]; + // ScalarT psiqpp = y_[6]; + // ScalarT psidpp = y_[7]; + // ScalarT psipp = y_[8]; + // ScalarT ksat = y_[9]; + // ScalarT vd = y_[10]; + // ScalarT vq = y_[11]; + // ScalarT telec = y_[12]; + // ScalarT id = y_[13]; + // ScalarT iq = y_[14]; + // ScalarT ir = y_[15]; + // ScalarT ii = y_[16]; + // ScalarT pmech = y_[17]; + // ScalarT efd = y_[18]; + // ScalarT inr = y_[19]; + // ScalarT ini = y_[20]; + // ScalarT vr = Vr(); + // ScalarT vi = Vi(); + + // /* Read derivatives */ + // ScalarT delta_dot = yp_[0]; + // ScalarT omega_dot = yp_[1]; + // ScalarT Eqp_dot = yp_[2]; + // ScalarT psidp_dot = yp_[3]; + // ScalarT psiqp_dot = yp_[4]; + // ScalarT Edp_dot = yp_[5]; + + // /* 6 Genrou differential equations */ + // f_[0] = delta_dot - omega * (2 * M_PI * 60); + // f_[1] = omega_dot - (1 / (2 * H_)) * ((pmech - D_ * omega) / (1 + omega) - telec); + // f_[2] = Eqp_dot - (1 / Tdop_) * (efd - (Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat)); + // f_[3] = psidp_dot - (1 / Tdopp_) * (Eqp - psidp - Xd2_ * id); + // f_[4] = psiqp_dot - (1 / Tqopp_) * (Edp - psiqp + Xq2_ * iq); + // f_[5] = Edp_dot - (1 / Tqop_) * (-Edp + Xqd_ * psiqpp * ksat + Xq1_ * (iq - Xq3_ * (Edp + iq * Xq2_ - psiqp))); + + // /* 11 Genrou algebraic equations */ + // f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); + // f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); + // f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); + // f_[9] = ksat - SB_ * pow(psipp - SA_, 2.0); + // f_[10] = vd + psiqpp * (1 + omega); + // f_[11] = vq - psidpp * (1 + omega); + // f_[12] = telec - ((psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id); + // f_[13] = id - (ir * sin(delta) - ii * cos(delta)); + // f_[14] = iq - (ir * cos(delta) + ii * sin(delta)); + // f_[15] = ir + G_ * vr - B_ * vi - inr; + // f_[16] = ii + B_ * vr + G_ * vi - ini; + + // /* 2 Genrou control inputs are set to constant for this example */ + // f_[17] = pmech - pmech_set_; + // f_[18] = efd - efd_set_; + + // /* 2 Genrou current source definitions */ + // f_[19] = inr - (G_ * (sin(delta) * vd + cos(delta) * vq) - B_ * (-cos(delta) * vd + sin(delta) * vq)); + // f_[20] = ini - (B_ * (sin(delta) * vd + cos(delta) * vq) + G_ * (-cos(delta) * vd + sin(delta) * vq)); + + // /* Current balance */ + // Ir() += inr - Vr() * G_ + Vi() * B_; + // Ii() += ini - Vr() * B_ - Vi() * G_; + + // // std::cout << "Evaluating branch residual ...\n"; + // // real_type b = -X_/(R_*R_ + X_*X_); + // // real_type g = R_/(R_*R_ + X_*X_); + + // return 0; + // } + + // /** + // * @brief Jacobian evaluation not implemented yet + // * + // * @tparam ScalarT - scalar data type + // * @tparam IdxT - matrix index data type + // * @return int - error code, 0 = success + // */ + // template + // int Genrou::evaluateJacobian() + // { + // std::cout << "Evaluate Jacobian for Genrou..." << std::endl; + // std::cout << "Jacobian evaluation not implemented!" << std::endl; + // return 0; + // } + + // /** + // * @brief Integrand (objective) evaluation not implemented yet + // * + // * @tparam ScalarT - scalar data type + // * @tparam IdxT - matrix index data type + // * @return int - error code, 0 = success + // */ + // template + // int Genrou::evaluateIntegrand() + // { + // // std::cout << "Evaluate Integrand for Genrou..." << std::endl; + // return 0; + // } + + // /** + // * @brief Adjoint initialization not implemented yet + // * + // * @tparam ScalarT - scalar data type + // * @tparam IdxT - matrix index data type + // * @return int - error code, 0 = success + // */ + // template + // int Genrou::initializeAdjoint() + // { + // // std::cout << "Initialize adjoint for Genrou..." << std::endl; + // return 0; + // } + + // /** + // * @brief Adjoint residual evaluation not implemented yet + // * + // * @tparam ScalarT - scalar data type + // * @tparam IdxT - matrix index data type + // * @return int - error code, 0 = success + // */ + // template + // int Genrou::evaluateAdjointResidual() + // { + // // std::cout << "Evaluate adjoint residual for Genrou..." << std::endl; + // return 0; + // } + + // /** + // * @brief Adjoint integrand (objective) evaluation not implemented yet + // * + // * @tparam ScalarT - scalar data type + // * @tparam IdxT - matrix index data type + // * @return int - error code, 0 = success + // */ + // template + // int Genrou::evaluateAdjointIntegrand() + // { + // // std::cout << "Evaluate adjoint Integrand for Genrou..." << std::endl; + // return 0; + // } + + // template + // void Genrou::set_derived_params() + // { + // SA_ = 0; + // SB_ = 0; + // if (S12_ != 0) + // { + // real_type s112 = sqrt(S10_ / S12_); + + // SA_ = (1.2 * s112 + 1) / (s112 + 1); + // SB_ = (1.2 * s112 - 1) / (s112 - 1); + // if (SB_ < SA_) + // SA_ = SB_; + // SB_ = S12_ / pow(SA_ - 1.2, 2); + // } + // Xd1_ = Xd_ - Xdp_; + // Xd2_ = Xdp_ - Xl_; + // Xd3_ = (Xdp_ - Xdpp_) / (Xd2_ * Xd2_); + // Xd4_ = (Xdp_ - Xdpp_) / Xd2_; + // Xd5_ = (Xdpp_ - Xl_) / Xd2_; + // Xq1_ = Xq_ - Xqp_; + // Xq2_ = Xqp_ - Xl_; + // Xq3_ = (Xqp_ - Xqpp_) / (Xq2_ * Xq2_); + // Xq4_ = (Xqp_ - Xqpp_) / Xq2_; + // Xq5_ = (Xqpp_ - Xl_) / Xq2_; + // Xqd_ = (Xq_ - Xl_) / (Xd_ - Xl_); + // G_ = Ra_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); + // B_ = -Xqpp_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); + // } + + // Available template instantiations + template class Genrou; + template class Genrou; + + } // namespace PhasorDynamics +} // namespace GridKit From f157a2f23c5d37b74cd86f0f021e99d05cb19c37 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 12:30:00 -0400 Subject: [PATCH 16/21] Create a complete source file Genrou.cpp --- .../PhasorDynamics/Example1/CMakeLists.txt | 4 +- examples/PhasorDynamics/Example1/example1.cpp | 21 +- .../GENROUwS/CMakeLists.txt | 7 +- .../SynchronousMachine/GENROUwS/Genrou.cpp | 410 +++++++++++++++++ .../SynchronousMachine/GENROUwS/Genrou.hpp | 329 +------------- .../GENROUwS/SynchronousMachine.cpp | 414 ------------------ 6 files changed, 452 insertions(+), 733 deletions(-) create mode 100644 src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp delete mode 100644 src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp diff --git a/examples/PhasorDynamics/Example1/CMakeLists.txt b/examples/PhasorDynamics/Example1/CMakeLists.txt index ef0900a0f..dc0cefaf2 100644 --- a/examples/PhasorDynamics/Example1/CMakeLists.txt +++ b/examples/PhasorDynamics/Example1/CMakeLists.txt @@ -1,6 +1,8 @@ add_executable(phasordynamics_example1 example1.cpp) target_link_libraries(phasordynamics_example1 - GRIDKIT::bus + GRIDKIT::phasor_dynamics_bus + GRIDKIT::phasor_dynamics_branch + GRIDKIT::phasor_dynamics_genrou SUNDIALS::sunlinsolklu SUNDIALS::core SUNDIALS::ida diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index 9106bc352..b251f29ca 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -40,7 +40,26 @@ int main() Branch branch(&bus1, &bus2, 0, 0.1, 0, 0); BusFault fault(&bus1, 0, 1e-3, 0); - Genrou gen(&bus1, 1, 1., 0.05013, 3., 0., 0., 7., .04, .05, .75, 2.1, 0.2, 0.18, 0.5, 0.5, 0.18, 0.15, 0., 0.); + Genrou gen(&bus1, + 1, + 1., + 0.05013, + 3., + 0., + 0., + 7., + .04, + .05, + .75, + 2.1, + 0.2, + 0.18, + 0.5, + 0.5, + 0.18, + 0.15, + 0., + 0.); /* Connect everything together */ sys.addBus(&bus1); diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt index c0bfa5e76..11b1e4c58 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/CMakeLists.txt @@ -1,6 +1,5 @@ -gridkit_add_library(phasor_dynamics_GENROU +gridkit_add_library(phasor_dynamics_genrou SOURCES - #GENROU.cpp - SynchronousMachine.cpp + Genrou.cpp OUTPUT_NAME - gridkit_phasor_dynamics_GENROU) + gridkit_phasor_dynamics_genrou) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp new file mode 100644 index 000000000..700024d0b --- /dev/null +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp @@ -0,0 +1,410 @@ +/** + * @file Genrou.hpp + * @author Adam Birchfield (abirchfield@tamu.edu) + * @author Slaven Peles (peless@ornl.gov) + * @brief Definition of a phasor dynamics branch model. + * + * The model uses Cartesian coordinates. + * + */ + +#include +#include + +#include "Genrou.hpp" +#include + +namespace GridKit +{ + namespace PhasorDynamics + { + /*! + * @brief Constructor for a pi-model branch + * + * Arguments passed to ModelEvaluatorImpl: + * - Number of equations = 0 + * - Number of independent variables = 0 + * - Number of quadratures = 0 + * - Number of optimization parameters = 0 + */ + template + Genrou::Genrou(bus_type* bus, int unit_id) + : bus_(bus), + busID_(0), + unit_id_(unit_id), + p0_(0.), + q0_(0.), + H_(3.), + D_(0.), + Ra_(0.), + Tdop_(7.), + Tdopp_(.04), + Tqopp_(.05), + Tqop_(.75), + Xd_(2.1), + Xdp_(0.2), + Xdpp_(0.18), + Xq_(.5), + Xqp_(.5), + Xqpp_(.18), + Xl_(.15), + S10_(0.), + S12_(0.) + { + size_ = 21; + setDerivedParams(); + + // Temporary, to eliminate compiler warnings + (void) busID_; + (void) unit_id_; + } + + /*! + * @brief Constructor for a pi-model branch + * + * Arguments passed to ModelEvaluatorImpl: + * - Number of equations = 0 + * - Number of independent variables = 0 + * - Number of quadratures = 0 + * - Number of optimization parameters = 0 + */ + template + Genrou::Genrou(bus_type* bus, + int unit_id, + ScalarT p0, + ScalarT q0, + real_type H, + real_type D, + real_type Ra, + real_type Tdop, + real_type Tdopp, + real_type Tqopp, + real_type Tqop, + real_type Xd, + real_type Xdp, + real_type Xdpp, + real_type Xq, + real_type Xqp, + real_type Xqpp, + real_type Xl, + real_type S10, + real_type S12) + : bus_(bus), + busID_(0), + unit_id_(unit_id), + p0_(p0), + q0_(q0), + H_(H), + D_(D), + Ra_(Ra), + Tdop_(Tdop), + Tdopp_(Tdopp), + Tqopp_(Tqopp), + Tqop_(Tqop), + Xd_(Xd), + Xdp_(Xdp), + Xdpp_(Xdpp), + Xq_(Xq), + Xqp_(Xqp), + Xqpp_(Xqpp), + Xl_(Xl), + S10_(S10), + S12_(S12) + { + size_ = 21; + setDerivedParams(); + } + + // /** + // * @brief Destroy the Genrou + // * + // * @tparam ScalarT + // * @tparam IdxT + // */ + // template + // Genrou::~Genrou() + // { + // // std::cout << "Destroy Genrou..." << std::endl; + // } + + /*! + * @brief allocate method computes sparsity pattern of the Jacobian. + */ + template + int Genrou::allocate() + { + f_.resize(size_); + y_.resize(size_); + yp_.resize(size_); + tag_.resize(size_); + fB_.resize(size_); + yB_.resize(size_); + ypB_.resize(size_); + return 0; + } + + /** + * Initialization of the branch model + * + */ + template + int Genrou::initialize() + { + /* Initialization tricks -- assuming NO saturation */ + ScalarT vr = Vr(); + ScalarT vi = Vi(); + ScalarT p = p0_; + ScalarT q = q0_; + ScalarT vm2 = vr * vr + vi * vi; + ScalarT Er = vr + (Ra_ * p * vr + Ra_ * q * vi - Xq_ * p * vi + Xq_ * q * vr) / vm2; + ScalarT Ei = vi + (Ra_ * p * vi - Ra_ * q * vr + Xq_ * p * vr + Xq_ * q * vi) / vm2; + ScalarT delta = atan2(Ei, Er); + ScalarT omega = 0; + ScalarT ir = (p * vr + q * vi) / vm2; + ScalarT ii = (p * vi - q * vr) / vm2; + ScalarT id = ir * sin(delta) - ii * cos(delta); + ScalarT iq = ir * cos(delta) + ii * sin(delta); + ScalarT vd = vr * sin(delta) - vi * cos(delta) + id * Ra_ - iq * Xqpp_; + ScalarT vq = vr * cos(delta) + vi * sin(delta) + id * Xqpp_ - iq * Ra_; + ScalarT psiqpp = -vd / (1 + omega); + ScalarT psidpp = vq / (1 + omega); + ScalarT Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; + ScalarT psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) + / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); + ScalarT Edp = psiqp - (Xqp_ - Xl_) * iq; + ScalarT psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) + / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); + ScalarT Eqp = psidp + (Xdp_ - Xl_) * id; + + /* Now we have the state variables, solve for alg. variables */ + ScalarT ksat; + ScalarT psipp; + + y_[0] = delta; //= 0.55399038; + y_[1] = omega; // = 0; + y_[2] = Eqp; // = 0.995472581; + y_[3] = psidp; // = 0.971299567; + y_[4] = psiqp; // = 0.306880069; + y_[5] = Edp; // = 0; + + y_[6] = psiqpp = -psiqp * Xq4_ - Edp * Xq5_; + y_[7] = psidpp = psidp * Xd4_ + Eqp * Xd5_; + y_[8] = psipp = sqrt(psiqpp * psiqpp + psidpp * psidpp); + y_[9] = ksat = SB_ * pow(psipp - SA_, 2); + y_[10] = vd = -psiqpp * (1 + omega); + y_[11] = vq = psidpp * (1 + omega); + y_[12] = Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; + y_[13] = id; + y_[14] = iq; + y_[15] = ir; + y_[16] = ii; + y_[17] = pmech_set_ = Te; + y_[18] = efd_set_ = Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat; + y_[19] = G_ * (vd * sin(delta) + vq * cos(delta)) + - B_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, real */ + y_[20] = B_ * (vd * sin(delta) + vq * cos(delta)) + + G_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, imag */ + + for (IdxT i = 0; i < size_; ++i) + yp_[i] = 0.0; + + return 0; + } + + /** + * \brief Identify differential variables. + */ + template + int Genrou::tagDifferentiable() + { + for (IdxT i = 0; i < size_; ++i) + { + tag_[i] = i < 6; + } + return 0; + } + + /** + * \brief Residual contribution of the branch is pushed to the + * two terminal buses. + * + */ + template + int Genrou::evaluateResidual() + { + /* Read variables */ + ScalarT delta = y_[0]; + ScalarT omega = y_[1]; + ScalarT Eqp = y_[2]; + ScalarT psidp = y_[3]; + ScalarT psiqp = y_[4]; + ScalarT Edp = y_[5]; + ScalarT psiqpp = y_[6]; + ScalarT psidpp = y_[7]; + ScalarT psipp = y_[8]; + ScalarT ksat = y_[9]; + ScalarT vd = y_[10]; + ScalarT vq = y_[11]; + ScalarT telec = y_[12]; + ScalarT id = y_[13]; + ScalarT iq = y_[14]; + ScalarT ir = y_[15]; + ScalarT ii = y_[16]; + ScalarT pmech = y_[17]; + ScalarT efd = y_[18]; + ScalarT inr = y_[19]; + ScalarT ini = y_[20]; + ScalarT vr = Vr(); + ScalarT vi = Vi(); + + /* Read derivatives */ + ScalarT delta_dot = yp_[0]; + ScalarT omega_dot = yp_[1]; + ScalarT Eqp_dot = yp_[2]; + ScalarT psidp_dot = yp_[3]; + ScalarT psiqp_dot = yp_[4]; + ScalarT Edp_dot = yp_[5]; + + /* 6 Genrou differential equations */ + f_[0] = delta_dot - omega * (2 * M_PI * 60); + f_[1] = omega_dot - (1 / (2 * H_)) * ((pmech - D_ * omega) / (1 + omega) - telec); + f_[2] = Eqp_dot - (1 / Tdop_) * (efd - (Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat)); + f_[3] = psidp_dot - (1 / Tdopp_) * (Eqp - psidp - Xd2_ * id); + f_[4] = psiqp_dot - (1 / Tqopp_) * (Edp - psiqp + Xq2_ * iq); + f_[5] = Edp_dot - (1 / Tqop_) * (-Edp + Xqd_ * psiqpp * ksat + Xq1_ * (iq - Xq3_ * (Edp + iq * Xq2_ - psiqp))); + + /* 11 Genrou algebraic equations */ + f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); + f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); + f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); + f_[9] = ksat - SB_ * pow(psipp - SA_, 2.0); + f_[10] = vd + psiqpp * (1 + omega); + f_[11] = vq - psidpp * (1 + omega); + f_[12] = telec - ((psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id); + f_[13] = id - (ir * sin(delta) - ii * cos(delta)); + f_[14] = iq - (ir * cos(delta) + ii * sin(delta)); + f_[15] = ir + G_ * vr - B_ * vi - inr; + f_[16] = ii + B_ * vr + G_ * vi - ini; + + /* 2 Genrou control inputs are set to constant for this example */ + f_[17] = pmech - pmech_set_; + f_[18] = efd - efd_set_; + + /* 2 Genrou current source definitions */ + f_[19] = inr - (G_ * (sin(delta) * vd + cos(delta) * vq) - B_ * (-cos(delta) * vd + sin(delta) * vq)); + f_[20] = ini - (B_ * (sin(delta) * vd + cos(delta) * vq) + G_ * (-cos(delta) * vd + sin(delta) * vq)); + + /* Current balance */ + Ir() += inr - Vr() * G_ + Vi() * B_; + Ii() += ini - Vr() * B_ - Vi() * G_; + + return 0; + } + + /** + * @brief Jacobian evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int Genrou::evaluateJacobian() + { + std::cout << "Evaluate Jacobian for Genrou..." << std::endl; + std::cout << "Jacobian evaluation not implemented!" << std::endl; + return 0; + } + + /** + * @brief Integrand (objective) evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int Genrou::evaluateIntegrand() + { + // std::cout << "Evaluate Integrand for Genrou..." << std::endl; + return 0; + } + + /** + * @brief Adjoint initialization not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int Genrou::initializeAdjoint() + { + // std::cout << "Initialize adjoint for Genrou..." << std::endl; + return 0; + } + + /** + * @brief Adjoint residual evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int Genrou::evaluateAdjointResidual() + { + // std::cout << "Evaluate adjoint residual for Genrou..." << std::endl; + return 0; + } + + /** + * @brief Adjoint integrand (objective) evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int Genrou::evaluateAdjointIntegrand() + { + // std::cout << "Evaluate adjoint Integrand for Genrou..." << std::endl; + return 0; + } + + template + void Genrou::setDerivedParams() + { + SA_ = 0; + SB_ = 0; + if (S12_ != 0) + { + real_type s112 = sqrt(S10_ / S12_); + + SA_ = (1.2 * s112 + 1) / (s112 + 1); + SB_ = (1.2 * s112 - 1) / (s112 - 1); + if (SB_ < SA_) + SA_ = SB_; + SB_ = S12_ / pow(SA_ - 1.2, 2); + } + Xd1_ = Xd_ - Xdp_; + Xd2_ = Xdp_ - Xl_; + Xd3_ = (Xdp_ - Xdpp_) / (Xd2_ * Xd2_); + Xd4_ = (Xdp_ - Xdpp_) / Xd2_; + Xd5_ = (Xdpp_ - Xl_) / Xd2_; + Xq1_ = Xq_ - Xqp_; + Xq2_ = Xqp_ - Xl_; + Xq3_ = (Xqp_ - Xqpp_) / (Xq2_ * Xq2_); + Xq4_ = (Xqp_ - Xqpp_) / Xq2_; + Xq5_ = (Xqpp_ - Xl_) / Xq2_; + Xqd_ = (Xq_ - Xl_) / (Xd_ - Xl_); + G_ = Ra_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); + B_ = -Xqpp_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); + } + + // Available template instantiations + template class Genrou; + template class Genrou; + + } // namespace PhasorDynamics +} // namespace GridKit diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp index f218f1f67..7a27fc7af 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp @@ -32,37 +32,7 @@ namespace GridKit using real_type = typename Component::real_type; public: - Genrou(bus_type* bus, int unit_id) - : bus_(bus), - busID_(0), - unit_id_(unit_id), - p0_(0.), - q0_(0.), - H_(3.), - D_(0.), - Ra_(0.), - Tdop_(7.), - Tdopp_(.04), - Tqopp_(.05), - Tqop_(.75), - Xd_(2.1), - Xdp_(0.2), - Xdpp_(0.18), - Xq_(.5), - Xqp_(.5), - Xqpp_(.18), - Xl_(.15), - S10_(0.), - S12_(0.) - { - size_ = 21; - set_derived_params(); - - // Temporary, to eliminate compiler warnings - (void) busID_; - (void) unit_id_; - } - + Genrou(bus_type* bus, int unit_id); Genrou(bus_type* bus, int unit_id, ScalarT p0, @@ -82,295 +52,28 @@ namespace GridKit real_type Xqpp, real_type Xl, real_type S10, - real_type S12) - : bus_(bus), - busID_(0), - unit_id_(unit_id), - p0_(p0), - q0_(q0), - H_(H), - D_(D), - Ra_(Ra), - Tdop_(Tdop), - Tdopp_(Tdopp), - Tqopp_(Tqopp), - Tqop_(Tqop), - Xd_(Xd), - Xdp_(Xdp), - Xdpp_(Xdpp), - Xq_(Xq), - Xqp_(Xqp), - Xqpp_(Xqpp), - Xl_(Xl), - S10_(S10), - S12_(S12) - { - size_ = 21; - set_derived_params(); - } - - void set_derived_params() - { - SA_ = 0; - SB_ = 0; - if (S12_ != 0) - { - real_type s112 = sqrt(S10_ / S12_); - - SA_ = (1.2 * s112 + 1) / (s112 + 1); - SB_ = (1.2 * s112 - 1) / (s112 - 1); - if (SB_ < SA_) - SA_ = SB_; - SB_ = S12_ / pow(SA_ - 1.2, 2); - } - Xd1_ = Xd_ - Xdp_; - Xd2_ = Xdp_ - Xl_; - Xd3_ = (Xdp_ - Xdpp_) / (Xd2_ * Xd2_); - Xd4_ = (Xdp_ - Xdpp_) / Xd2_; - Xd5_ = (Xdpp_ - Xl_) / Xd2_; - Xq1_ = Xq_ - Xqp_; - Xq2_ = Xqp_ - Xl_; - Xq3_ = (Xqp_ - Xqpp_) / (Xq2_ * Xq2_); - Xq4_ = (Xqp_ - Xqpp_) / Xq2_; - Xq5_ = (Xqpp_ - Xl_) / Xq2_; - Xqd_ = (Xq_ - Xl_) / (Xd_ - Xl_); - G_ = Ra_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); - B_ = -Xqpp_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); - } - - ~Genrou() - { - } - - int allocate() override - { - f_.resize(size_); - y_.resize(size_); - yp_.resize(size_); - tag_.resize(size_); - fB_.resize(size_); - yB_.resize(size_); - ypB_.resize(size_); - return 0; - } - - int initialize() override - { - /* Initialization tricks -- assuming NO saturation */ - ScalarT vr = Vr(); - ScalarT vi = Vi(); - ScalarT p = p0_; - ScalarT q = q0_; - ScalarT vm2 = vr * vr + vi * vi; - ScalarT Er = vr + (Ra_ * p * vr + Ra_ * q * vi - Xq_ * p * vi + Xq_ * q * vr) / vm2; - ScalarT Ei = vi + (Ra_ * p * vi - Ra_ * q * vr + Xq_ * p * vr + Xq_ * q * vi) / vm2; - ScalarT delta = atan2(Ei, Er); - ScalarT omega = 0; - ScalarT ir = (p * vr + q * vi) / vm2; - ScalarT ii = (p * vi - q * vr) / vm2; - ScalarT id = ir * sin(delta) - ii * cos(delta); - ScalarT iq = ir * cos(delta) + ii * sin(delta); - ScalarT vd = vr * sin(delta) - vi * cos(delta) + id * Ra_ - iq * Xqpp_; - ScalarT vq = vr * cos(delta) + vi * sin(delta) + id * Xqpp_ - iq * Ra_; - ScalarT psiqpp = -vd / (1 + omega); - ScalarT psidpp = vq / (1 + omega); - ScalarT Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; - ScalarT psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) - / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); - ScalarT Edp = psiqp - (Xqp_ - Xl_) * iq; - ScalarT psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) - / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); - ScalarT Eqp = psidp + (Xdp_ - Xl_) * id; - - /* Now we have the state variables, solve for alg. variables */ - ScalarT ksat; - ScalarT psipp; - - y_[0] = delta; //= 0.55399038; - y_[1] = omega; // = 0; - y_[2] = Eqp; // = 0.995472581; - y_[3] = psidp; // = 0.971299567; - y_[4] = psiqp; // = 0.306880069; - y_[5] = Edp; // = 0; - - y_[6] = psiqpp = -psiqp * Xq4_ - Edp * Xq5_; - y_[7] = psidpp = psidp * Xd4_ + Eqp * Xd5_; - y_[8] = psipp = sqrt(psiqpp * psiqpp + psidpp * psidpp); - y_[9] = ksat = SB_ * pow(psipp - SA_, 2); - y_[10] = vd = -psiqpp * (1 + omega); - y_[11] = vq = psidpp * (1 + omega); - y_[12] = Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; - y_[13] = id; - y_[14] = iq; - y_[15] = ir; - y_[16] = ii; - y_[17] = pmech_set_ = Te; - y_[18] = efd_set_ = Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat; - y_[19] = G_ * (vd * sin(delta) + vq * cos(delta)) - - B_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, real */ - y_[20] = B_ * (vd * sin(delta) + vq * cos(delta)) - + G_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, imag */ - - for (IdxT i = 0; i < size_; ++i) - yp_[i] = 0.0; - return 0; - } - - int tagDifferentiable() override - { - for (IdxT i = 0; i < size_; ++i) - { - tag_[i] = i < 6; - } - return 0; - } - - int evaluateResidual() override - { - /* Read variables */ - ScalarT delta = y_[0]; - ScalarT omega = y_[1]; - ScalarT Eqp = y_[2]; - ScalarT psidp = y_[3]; - ScalarT psiqp = y_[4]; - ScalarT Edp = y_[5]; - ScalarT psiqpp = y_[6]; - ScalarT psidpp = y_[7]; - ScalarT psipp = y_[8]; - ScalarT ksat = y_[9]; - ScalarT vd = y_[10]; - ScalarT vq = y_[11]; - ScalarT telec = y_[12]; - ScalarT id = y_[13]; - ScalarT iq = y_[14]; - ScalarT ir = y_[15]; - ScalarT ii = y_[16]; - ScalarT pmech = y_[17]; - ScalarT efd = y_[18]; - ScalarT inr = y_[19]; - ScalarT ini = y_[20]; - ScalarT vr = Vr(); - ScalarT vi = Vi(); + real_type S12); + ~Genrou() = default; - /* Read derivatives */ - ScalarT delta_dot = yp_[0]; - ScalarT omega_dot = yp_[1]; - ScalarT Eqp_dot = yp_[2]; - ScalarT psidp_dot = yp_[3]; - ScalarT psiqp_dot = yp_[4]; - ScalarT Edp_dot = yp_[5]; + int allocate() override; + int initialize() override; + int tagDifferentiable() override; + int evaluateResidual() override; - /* 6 Genrou differential equations */ - f_[0] = delta_dot - omega * (2 * M_PI * 60); - f_[1] = omega_dot - (1 / (2 * H_)) * ((pmech - D_ * omega) / (1 + omega) - telec); - f_[2] = Eqp_dot - (1 / Tdop_) * (efd - (Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat)); - f_[3] = psidp_dot - (1 / Tdopp_) * (Eqp - psidp - Xd2_ * id); - f_[4] = psiqp_dot - (1 / Tqopp_) * (Edp - psiqp + Xq2_ * iq); - f_[5] = Edp_dot - (1 / Tqop_) * (-Edp + Xqd_ * psiqpp * ksat + Xq1_ * (iq - Xq3_ * (Edp + iq * Xq2_ - psiqp))); - - /* 11 Genrou algebraic equations */ - f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); - f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); - f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); - f_[9] = ksat - SB_ * pow(psipp - SA_, 2.0); - f_[10] = vd + psiqpp * (1 + omega); - f_[11] = vq - psidpp * (1 + omega); - f_[12] = telec - ((psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id); - f_[13] = id - (ir * sin(delta) - ii * cos(delta)); - f_[14] = iq - (ir * cos(delta) + ii * sin(delta)); - f_[15] = ir + G_ * vr - B_ * vi - inr; - f_[16] = ii + B_ * vr + G_ * vi - ini; - - /* 2 Genrou control inputs are set to constant for this example */ - f_[17] = pmech - pmech_set_; - f_[18] = efd - efd_set_; - - /* 2 Genrou current source definitions */ - f_[19] = inr - (G_ * (sin(delta) * vd + cos(delta) * vq) - B_ * (-cos(delta) * vd + sin(delta) * vq)); - f_[20] = ini - (B_ * (sin(delta) * vd + cos(delta) * vq) + G_ * (-cos(delta) * vd + sin(delta) * vq)); - - /* Current balance */ - Ir() += inr - Vr() * G_ + Vi() * B_; - Ii() += ini - Vr() * B_ - Vi() * G_; - - // printf("Genrou residual\n"); - // for (int i = 0 ; i < 21; ++i) printf("%d: %g\n", i, f_[i]); - - // printf("Genrou inr %g Vr %g B %g Vi %g G %g\n", inr, Vr(), B_, Vi(), G_); - // printf("Genrou Ii = %g\n", inr - Vr()*B_ - Vi()*G_); - - return 0; - } - - int evaluateJacobian() override - { - /* TODO */ - return 0; - } - - /* Don't know what to do with any of these */ - int evaluateIntegrand() override - { - return 0; - } - - int initializeAdjoint() override - { - return 0; - } - - int evaluateAdjointResidual() override - { - return 0; - } - - int evaluateAdjointIntegrand() override - { - return 0; - } + // Still to be implemented + int evaluateJacobian() override; + int evaluateIntegrand() override; + int initializeAdjoint() override; + int evaluateAdjointResidual() override; + int evaluateAdjointIntegrand() override; void updateTime(real_type /* t */, real_type /* a */) override { } - // public: - // Genrou(bus_type* bus, int unit_id); - // Genrou(bus_type* bus, - // int unit_id, - // ScalarT p0, - // ScalarT q0, - // real_type H, - // real_type D, - // real_type Ra, - // real_type Tdop, - // real_type Tdopp, - // real_type Tqopp, - // real_type Tqop, - // real_type Xd, - // real_type Xdp, - // real_type Xdpp, - // real_type Xq, - // real_type Xqp, - // real_type Xqpp, - // real_type Xl, - // real_type S10, - // real_type S12); - // ~Genrou(); - // void set_derived_params(); - // int allocate() override; - // int initialize() override; - // int tagDifferentiable() override; - // int evaluateResidual() override; - // int evaluateJacobian() override; - // int evaluateIntegrand() override; - // int initializeAdjoint() override; - // int evaluateAdjointResidual() override; - // int evaluateAdjointIntegrand() override; - // void updateTime(real_type /* t */, real_type /* a */) override - // { - // } - private: + void setDerivedParams(); + ScalarT& Vr() { return bus_->Vr(); @@ -392,9 +95,9 @@ namespace GridKit } private: + /* Identification */ bus_type* bus_; - const int busID_; int unit_id_; diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp deleted file mode 100644 index a1a489950..000000000 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/SynchronousMachine.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/** - * @file Genrou.hpp - * @author Adam Birchfield (abirchfield@tamu.edu) - * @author Slaven Peles (peless@ornl.gov) - * @brief Definition of a phasor dynamics branch model. - * - * The model uses Cartesian coordinates. - * - */ - -#include -#include - -#include "Genrou.hpp" -#include - -namespace GridKit -{ - namespace PhasorDynamics - { - // /*! - // * @brief Constructor for a pi-model branch - // * - // * Arguments passed to ModelEvaluatorImpl: - // * - Number of equations = 0 - // * - Number of independent variables = 0 - // * - Number of quadratures = 0 - // * - Number of optimization parameters = 0 - // */ - // template - // Genrou::Genrou(bus_type* bus, int unit_id) - // : bus_(bus), - // busID_(0), - // unit_id_(unit_id), - // p0_(0.), - // q0_(0.), - // H_(3.), - // D_(0.), - // Ra_(0.), - // Tdop_(7.), - // Tdopp_(.04), - // Tqopp_(.05), - // Tqop_(.75), - // Xd_(2.1), - // Xdp_(0.2), - // Xdpp_(0.18), - // Xq_(.5), - // Xqp_(.5), - // Xqpp_(.18), - // Xl_(.15), - // S10_(0.), - // S12_(0.) - // { - // size_ = 21; - // set_derived_params(); - - // // Temporary, to eliminate compiler warnings - // (void) busID_; - // (void) unit_id_; - // } - - // /*! - // * @brief Constructor for a pi-model branch - // * - // * Arguments passed to ModelEvaluatorImpl: - // * - Number of equations = 0 - // * - Number of independent variables = 0 - // * - Number of quadratures = 0 - // * - Number of optimization parameters = 0 - // */ - // template - // Genrou::Genrou(bus_type* bus, - // int unit_id, - // ScalarT p0, - // ScalarT q0, - // real_type H, - // real_type D, - // real_type Ra, - // real_type Tdop, - // real_type Tdopp, - // real_type Tqopp, - // real_type Tqop, - // real_type Xd, - // real_type Xdp, - // real_type Xdpp, - // real_type Xq, - // real_type Xqp, - // real_type Xqpp, - // real_type Xl, - // real_type S10, - // real_type S12) - // : bus_(bus), - // busID_(0), - // unit_id_(unit_id), - // p0_(p0), - // q0_(q0), - // H_(H), - // D_(D), - // Ra_(Ra), - // Tdop_(Tdop), - // Tdopp_(Tdopp), - // Tqopp_(Tqopp), - // Tqop_(Tqop), - // Xd_(Xd), - // Xdp_(Xdp), - // Xdpp_(Xdpp), - // Xq_(Xq), - // Xqp_(Xqp), - // Xqpp_(Xqpp), - // Xl_(Xl), - // S10_(S10), - // S12_(S12) - // { - // size_ = 21; - // set_derived_params(); - // } - - // /** - // * @brief Destroy the Genrou - // * - // * @tparam ScalarT - // * @tparam IdxT - // */ - // template - // Genrou::~Genrou() - // { - // // std::cout << "Destroy Genrou..." << std::endl; - // } - - // /*! - // * @brief allocate method computes sparsity pattern of the Jacobian. - // */ - // template - // int Genrou::allocate() - // { - // f_.resize(size_); - // y_.resize(size_); - // yp_.resize(size_); - // tag_.resize(size_); - // fB_.resize(size_); - // yB_.resize(size_); - // ypB_.resize(size_); - // return 0; - // } - - // /** - // * Initialization of the branch model - // * - // */ - // template - // int Genrou::initialize() - // { - // /* Initialization tricks -- assuming NO saturation */ - // ScalarT vr = Vr(); - // ScalarT vi = Vi(); - // ScalarT p = p0_; - // ScalarT q = q0_; - // ScalarT vm2 = vr * vr + vi * vi; - // ScalarT Er = vr + (Ra_ * p * vr + Ra_ * q * vi - Xq_ * p * vi + Xq_ * q * vr) / vm2; - // ScalarT Ei = vi + (Ra_ * p * vi - Ra_ * q * vr + Xq_ * p * vr + Xq_ * q * vi) / vm2; - // ScalarT delta = atan2(Ei, Er); - // ScalarT omega = 0; - // ScalarT ir = (p * vr + q * vi) / vm2; - // ScalarT ii = (p * vi - q * vr) / vm2; - // ScalarT id = ir * sin(delta) - ii * cos(delta); - // ScalarT iq = ir * cos(delta) + ii * sin(delta); - // ScalarT vd = vr * sin(delta) - vi * cos(delta) + id * Ra_ - iq * Xqpp_; - // ScalarT vq = vr * cos(delta) + vi * sin(delta) + id * Xqpp_ - iq * Ra_; - // ScalarT psiqpp = -vd / (1 + omega); - // ScalarT psidpp = vq / (1 + omega); - // ScalarT Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; - // ScalarT psiqp = -(-(Xqp_ - Xl_) * iq + psiqpp * (Xqp_ - Xl_) / (Xqpp_ - Xl_)) - // / (1 + (Xqp_ - Xqpp_) / (Xqpp_ - Xl_)); - // ScalarT Edp = psiqp - (Xqp_ - Xl_) * iq; - // ScalarT psidp = -((Xdp_ - Xl_) * id - psidpp * (Xdp_ - Xl_) / (Xdpp_ - Xl_)) - // / (1 + (Xdp_ - Xdpp_) / (Xdpp_ - Xl_)); - // ScalarT Eqp = psidp + (Xdp_ - Xl_) * id; - - // /* Now we have the state variables, solve for alg. variables */ - // ScalarT ksat; - // ScalarT psipp; - - // y_[0] = delta; //= 0.55399038; - // y_[1] = omega; // = 0; - // y_[2] = Eqp; // = 0.995472581; - // y_[3] = psidp; // = 0.971299567; - // y_[4] = psiqp; // = 0.306880069; - // y_[5] = Edp; // = 0; - - // y_[6] = psiqpp = -psiqp * Xq4_ - Edp * Xq5_; - // y_[7] = psidpp = psidp * Xd4_ + Eqp * Xd5_; - // y_[8] = psipp = sqrt(psiqpp * psiqpp + psidpp * psidpp); - // y_[9] = ksat = SB_ * pow(psipp - SA_, 2); - // y_[10] = vd = -psiqpp * (1 + omega); - // y_[11] = vq = psidpp * (1 + omega); - // y_[12] = Te = (psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id; - // y_[13] = id; - // y_[14] = iq; - // y_[15] = ir; - // y_[16] = ii; - // y_[17] = pmech_set_ = Te; - // y_[18] = efd_set_ = Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat; - // y_[19] = G_ * (vd * sin(delta) + vq * cos(delta)) - // - B_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, real */ - // y_[20] = B_ * (vd * sin(delta) + vq * cos(delta)) - // + G_ * (vd * -cos(delta) + vq * sin(delta)); /* inort, imag */ - - // for (IdxT i = 0; i < size_; ++i) - // yp_[i] = 0.0; - - // return 0; - // } - - // /** - // * \brief Identify differential variables. - // */ - // template - // int Genrou::tagDifferentiable() - // { - // for (IdxT i = 0; i < size_; ++i) - // { - // tag_[i] = i < 6; - // } - // return 0; - // } - - // /** - // * \brief Residual contribution of the branch is pushed to the - // * two terminal buses. - // * - // */ - // template - // int Genrou::evaluateResidual() - // { - // /* Read variables */ - // ScalarT delta = y_[0]; - // ScalarT omega = y_[1]; - // ScalarT Eqp = y_[2]; - // ScalarT psidp = y_[3]; - // ScalarT psiqp = y_[4]; - // ScalarT Edp = y_[5]; - // ScalarT psiqpp = y_[6]; - // ScalarT psidpp = y_[7]; - // ScalarT psipp = y_[8]; - // ScalarT ksat = y_[9]; - // ScalarT vd = y_[10]; - // ScalarT vq = y_[11]; - // ScalarT telec = y_[12]; - // ScalarT id = y_[13]; - // ScalarT iq = y_[14]; - // ScalarT ir = y_[15]; - // ScalarT ii = y_[16]; - // ScalarT pmech = y_[17]; - // ScalarT efd = y_[18]; - // ScalarT inr = y_[19]; - // ScalarT ini = y_[20]; - // ScalarT vr = Vr(); - // ScalarT vi = Vi(); - - // /* Read derivatives */ - // ScalarT delta_dot = yp_[0]; - // ScalarT omega_dot = yp_[1]; - // ScalarT Eqp_dot = yp_[2]; - // ScalarT psidp_dot = yp_[3]; - // ScalarT psiqp_dot = yp_[4]; - // ScalarT Edp_dot = yp_[5]; - - // /* 6 Genrou differential equations */ - // f_[0] = delta_dot - omega * (2 * M_PI * 60); - // f_[1] = omega_dot - (1 / (2 * H_)) * ((pmech - D_ * omega) / (1 + omega) - telec); - // f_[2] = Eqp_dot - (1 / Tdop_) * (efd - (Eqp + Xd1_ * (id + Xd3_ * (Eqp - psidp - Xd2_ * id)) + psidpp * ksat)); - // f_[3] = psidp_dot - (1 / Tdopp_) * (Eqp - psidp - Xd2_ * id); - // f_[4] = psiqp_dot - (1 / Tqopp_) * (Edp - psiqp + Xq2_ * iq); - // f_[5] = Edp_dot - (1 / Tqop_) * (-Edp + Xqd_ * psiqpp * ksat + Xq1_ * (iq - Xq3_ * (Edp + iq * Xq2_ - psiqp))); - - // /* 11 Genrou algebraic equations */ - // f_[6] = psiqpp - (-psiqp * Xq4_ - Edp * Xq5_); - // f_[7] = psidpp - (psidp * Xd4_ + Eqp * Xd5_); - // f_[8] = psipp - sqrt(pow(psidpp, 2.0) + pow(psiqpp, 2.0)); - // f_[9] = ksat - SB_ * pow(psipp - SA_, 2.0); - // f_[10] = vd + psiqpp * (1 + omega); - // f_[11] = vq - psidpp * (1 + omega); - // f_[12] = telec - ((psidpp - id * Xdpp_) * iq - (psiqpp - iq * Xdpp_) * id); - // f_[13] = id - (ir * sin(delta) - ii * cos(delta)); - // f_[14] = iq - (ir * cos(delta) + ii * sin(delta)); - // f_[15] = ir + G_ * vr - B_ * vi - inr; - // f_[16] = ii + B_ * vr + G_ * vi - ini; - - // /* 2 Genrou control inputs are set to constant for this example */ - // f_[17] = pmech - pmech_set_; - // f_[18] = efd - efd_set_; - - // /* 2 Genrou current source definitions */ - // f_[19] = inr - (G_ * (sin(delta) * vd + cos(delta) * vq) - B_ * (-cos(delta) * vd + sin(delta) * vq)); - // f_[20] = ini - (B_ * (sin(delta) * vd + cos(delta) * vq) + G_ * (-cos(delta) * vd + sin(delta) * vq)); - - // /* Current balance */ - // Ir() += inr - Vr() * G_ + Vi() * B_; - // Ii() += ini - Vr() * B_ - Vi() * G_; - - // // std::cout << "Evaluating branch residual ...\n"; - // // real_type b = -X_/(R_*R_ + X_*X_); - // // real_type g = R_/(R_*R_ + X_*X_); - - // return 0; - // } - - // /** - // * @brief Jacobian evaluation not implemented yet - // * - // * @tparam ScalarT - scalar data type - // * @tparam IdxT - matrix index data type - // * @return int - error code, 0 = success - // */ - // template - // int Genrou::evaluateJacobian() - // { - // std::cout << "Evaluate Jacobian for Genrou..." << std::endl; - // std::cout << "Jacobian evaluation not implemented!" << std::endl; - // return 0; - // } - - // /** - // * @brief Integrand (objective) evaluation not implemented yet - // * - // * @tparam ScalarT - scalar data type - // * @tparam IdxT - matrix index data type - // * @return int - error code, 0 = success - // */ - // template - // int Genrou::evaluateIntegrand() - // { - // // std::cout << "Evaluate Integrand for Genrou..." << std::endl; - // return 0; - // } - - // /** - // * @brief Adjoint initialization not implemented yet - // * - // * @tparam ScalarT - scalar data type - // * @tparam IdxT - matrix index data type - // * @return int - error code, 0 = success - // */ - // template - // int Genrou::initializeAdjoint() - // { - // // std::cout << "Initialize adjoint for Genrou..." << std::endl; - // return 0; - // } - - // /** - // * @brief Adjoint residual evaluation not implemented yet - // * - // * @tparam ScalarT - scalar data type - // * @tparam IdxT - matrix index data type - // * @return int - error code, 0 = success - // */ - // template - // int Genrou::evaluateAdjointResidual() - // { - // // std::cout << "Evaluate adjoint residual for Genrou..." << std::endl; - // return 0; - // } - - // /** - // * @brief Adjoint integrand (objective) evaluation not implemented yet - // * - // * @tparam ScalarT - scalar data type - // * @tparam IdxT - matrix index data type - // * @return int - error code, 0 = success - // */ - // template - // int Genrou::evaluateAdjointIntegrand() - // { - // // std::cout << "Evaluate adjoint Integrand for Genrou..." << std::endl; - // return 0; - // } - - // template - // void Genrou::set_derived_params() - // { - // SA_ = 0; - // SB_ = 0; - // if (S12_ != 0) - // { - // real_type s112 = sqrt(S10_ / S12_); - - // SA_ = (1.2 * s112 + 1) / (s112 + 1); - // SB_ = (1.2 * s112 - 1) / (s112 - 1); - // if (SB_ < SA_) - // SA_ = SB_; - // SB_ = S12_ / pow(SA_ - 1.2, 2); - // } - // Xd1_ = Xd_ - Xdp_; - // Xd2_ = Xdp_ - Xl_; - // Xd3_ = (Xdp_ - Xdpp_) / (Xd2_ * Xd2_); - // Xd4_ = (Xdp_ - Xdpp_) / Xd2_; - // Xd5_ = (Xdpp_ - Xl_) / Xd2_; - // Xq1_ = Xq_ - Xqp_; - // Xq2_ = Xqp_ - Xl_; - // Xq3_ = (Xqp_ - Xqpp_) / (Xq2_ * Xq2_); - // Xq4_ = (Xqp_ - Xqpp_) / Xq2_; - // Xq5_ = (Xqpp_ - Xl_) / Xq2_; - // Xqd_ = (Xq_ - Xl_) / (Xd_ - Xl_); - // G_ = Ra_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); - // B_ = -Xqpp_ / (Ra_ * Ra_ + Xqpp_ * Xqpp_); - // } - - // Available template instantiations - template class Genrou; - template class Genrou; - - } // namespace PhasorDynamics -} // namespace GridKit From 3c93156c7e72de3cb522c1d59d24d635f73749bb Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 12:37:05 -0400 Subject: [PATCH 17/21] Update code comments and style. --- .../SynchronousMachine/GENROUwS/Genrou.cpp | 8 ++++---- .../SynchronousMachine/GENROUwS/Genrou.hpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp index 700024d0b..c3c276819 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp @@ -1,17 +1,17 @@ /** - * @file Genrou.hpp + * @file Genrou.cpp * @author Adam Birchfield (abirchfield@tamu.edu) * @author Slaven Peles (peless@ornl.gov) - * @brief Definition of a phasor dynamics branch model. + * @brief Definition of a GENROU generator model. * - * The model uses Cartesian coordinates. * */ +#include "Genrou.hpp" + #include #include -#include "Genrou.hpp" #include namespace GridKit diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp index 7a27fc7af..7b66552af 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp @@ -1,4 +1,11 @@ -/* Genrou Component - Adam Birchfield */ +/** + * @file Genrou.cpp + * @author Adam Birchfield (abirchfield@tamu.edu) + * @author Slaven Peles (peless@ornl.gov) + * @brief Declaration of a GENROU generator model. + * + */ + #pragma once #define _USE_MATH_DEFINES @@ -95,7 +102,6 @@ namespace GridKit } private: - /* Identification */ bus_type* bus_; const int busID_; From e3d6d3534e42b60027c45564f351d590b3fbbb5a Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 13:03:22 -0400 Subject: [PATCH 18/21] Add placeholder for Genrou unit tests. --- .../SynchronousMachine/CMakeLists.txt | 6 - .../SynchronousMachine/GENROUwS/Genrou.cpp | 2 + .../SynchronousMachine/GENROUwS/Genrou.hpp | 12 +- .../SynchronousMachine/SynchronousMachine.cpp | 174 ------------------ .../SynchronousMachine/SynchronousMachine.hpp | 127 ------------- tests/UnitTests/PhasorDynamics/CMakeLists.txt | 8 +- ...ronousMachineTests.hpp => GenrouTests.hpp} | 12 +- ...ousMachineTests.cpp => runGenrouTests.cpp} | 7 +- 8 files changed, 26 insertions(+), 322 deletions(-) delete mode 100644 src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.cpp delete mode 100644 src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.hpp rename tests/UnitTests/PhasorDynamics/{SynchronousMachineTests.hpp => GenrouTests.hpp} (78%) rename tests/UnitTests/PhasorDynamics/{runSynchronousMachineTests.cpp => runGenrouTests.cpp} (53%) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt b/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt index 07667d325..212813aae 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt +++ b/src/Model/PhasorDynamics/SynchronousMachine/CMakeLists.txt @@ -5,10 +5,4 @@ # - Slaven Peles # ]] -gridkit_add_library(phasor_dynamics_synchronous_machine - SOURCES - SynchronousMachine.cpp - OUTPUT_NAME - gridkit_phasor_dynamics_synchronous_machine) - add_subdirectory(GENROUwS) diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp index c3c276819..029f9e9fa 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.cpp @@ -14,6 +14,8 @@ #include +#define _USE_MATH_DEFINES + namespace GridKit { namespace PhasorDynamics diff --git a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp index 7b66552af..1f05fc876 100644 --- a/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp +++ b/src/Model/PhasorDynamics/SynchronousMachine/GENROUwS/Genrou.hpp @@ -8,10 +8,18 @@ #pragma once -#define _USE_MATH_DEFINES -#include #include +// Forward declarations. +namespace GridKit +{ + namespace PhasorDynamics + { + template + class BusBase; + } +} // namespace GridKit + namespace GridKit { namespace PhasorDynamics diff --git a/src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.cpp b/src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.cpp deleted file mode 100644 index 519223cf6..000000000 --- a/src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @file SynchronousMachine.hpp - * @author Slaven Peles (peless@ornl.gov) - * @brief Definition of a phasor dynamics branch model. - * - * The model uses Cartesian coordinates. - * - */ - -#include "SynchronousMachine.hpp" - -#include -#include - -#include -#include - -namespace GridKit -{ - namespace PhasorDynamics - { - /*! - * @brief Constructor for a pi-model branch - * - * Arguments passed to ModelEvaluatorImpl: - * - Number of equations = 0 - * - Number of independent variables = 0 - * - Number of quadratures = 0 - * - Number of optimization parameters = 0 - */ - template - SynchronousMachine::SynchronousMachine(bus_type* bus) - : bus_(bus), - R_(0.0), - X_(0.01), - G_(0.0), - B_(0.0) - { - size_ = 0; - } - - /** - * @brief Destroy the SynchronousMachine - * - * @tparam ScalarT - * @tparam IdxT - */ - template - SynchronousMachine::~SynchronousMachine() - { - // std::cout << "Destroy SynchronousMachine..." << std::endl; - } - - /*! - * @brief allocate method computes sparsity pattern of the Jacobian. - */ - template - int SynchronousMachine::allocate() - { - // std::cout << "Allocate SynchronousMachine..." << std::endl; - return 0; - } - - /** - * Initialization of the branch model - * - */ - template - int SynchronousMachine::initialize() - { - return 0; - } - - /** - * \brief Identify differential variables. - */ - template - int SynchronousMachine::tagDifferentiable() - { - return 0; - } - - /** - * \brief Residual contribution of the branch is pushed to the - * two terminal buses. - * - */ - template - int SynchronousMachine::evaluateResidual() - { - // std::cout << "Evaluating branch residual ...\n"; - // real_type b = -X_/(R_*R_ + X_*X_); - // real_type g = R_/(R_*R_ + X_*X_); - - return 0; - } - - /** - * @brief Jacobian evaluation not implemented yet - * - * @tparam ScalarT - scalar data type - * @tparam IdxT - matrix index data type - * @return int - error code, 0 = success - */ - template - int SynchronousMachine::evaluateJacobian() - { - std::cout << "Evaluate Jacobian for SynchronousMachine..." << std::endl; - std::cout << "Jacobian evaluation not implemented!" << std::endl; - return 0; - } - - /** - * @brief Integrand (objective) evaluation not implemented yet - * - * @tparam ScalarT - scalar data type - * @tparam IdxT - matrix index data type - * @return int - error code, 0 = success - */ - template - int SynchronousMachine::evaluateIntegrand() - { - // std::cout << "Evaluate Integrand for SynchronousMachine..." << std::endl; - return 0; - } - - /** - * @brief Adjoint initialization not implemented yet - * - * @tparam ScalarT - scalar data type - * @tparam IdxT - matrix index data type - * @return int - error code, 0 = success - */ - template - int SynchronousMachine::initializeAdjoint() - { - // std::cout << "Initialize adjoint for SynchronousMachine..." << std::endl; - return 0; - } - - /** - * @brief Adjoint residual evaluation not implemented yet - * - * @tparam ScalarT - scalar data type - * @tparam IdxT - matrix index data type - * @return int - error code, 0 = success - */ - template - int SynchronousMachine::evaluateAdjointResidual() - { - // std::cout << "Evaluate adjoint residual for SynchronousMachine..." << std::endl; - return 0; - } - - /** - * @brief Adjoint integrand (objective) evaluation not implemented yet - * - * @tparam ScalarT - scalar data type - * @tparam IdxT - matrix index data type - * @return int - error code, 0 = success - */ - template - int SynchronousMachine::evaluateAdjointIntegrand() - { - // std::cout << "Evaluate adjoint Integrand for SynchronousMachine..." << std::endl; - return 0; - } - - // Available template instantiations - template class SynchronousMachine; - template class SynchronousMachine; - - } // namespace PhasorDynamics -} // namespace GridKit diff --git a/src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.hpp b/src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.hpp deleted file mode 100644 index 2777cf17c..000000000 --- a/src/Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file SynchronousMachine.hpp - * @author Slaven Peles (peless@ornl.gov) - * @brief Declaration of a phasor dynamics branch model. - * - * The model uses Cartesian coordinates. - * - */ -#pragma once - -#include - -// Forward declarations. -namespace GridKit -{ - namespace PhasorDynamics - { - template - class BusBase; - } -} // namespace GridKit - -namespace GridKit -{ - namespace PhasorDynamics - { - /** - * @brief Implementation of a pi-model branch between two buses. - * - * The model is implemented in Cartesian coordinates. Positive current - * direction is into the busses. - * - */ - template - class SynchronousMachine : public Component - { - using Component::size_; - using Component::nnz_; - using Component::time_; - using Component::alpha_; - using Component::y_; - using Component::yp_; - using Component::tag_; - using Component::f_; - using Component::g_; - using Component::yB_; - using Component::ypB_; - using Component::fB_; - using Component::gB_; - using Component::param_; - - using bus_type = BusBase; - using real_type = typename Component::real_type; - - public: - SynchronousMachine(bus_type* bus); - virtual ~SynchronousMachine(); - - virtual int allocate() override; - virtual int initialize() override; - virtual int tagDifferentiable() override; - virtual int evaluateResidual() override; - virtual int evaluateJacobian() override; - virtual int evaluateIntegrand() override; - - virtual int initializeAdjoint() override; - virtual int evaluateAdjointResidual() override; - // virtual int evaluateAdjointJacobian() override; - virtual int evaluateAdjointIntegrand() override; - - virtual void updateTime(real_type /* t */, real_type /* a */) override - { - } - - public: - void setR(real_type R) - { - R_ = R; - } - - void setX(real_type X) - { - // std::cout << "Setting X ...\n"; - X_ = X; - } - - void setG(real_type G) - { - G_ = G; - } - - void setB(real_type B) - { - B_ = B; - } - - private: - ScalarT& Vr() - { - return bus_->Vr(); - } - - ScalarT& Vi() - { - return bus_->Vi(); - } - - ScalarT& Ir() - { - return bus_->Ir(); - } - - ScalarT& Ii() - { - return bus_->Ii(); - } - - private: - bus_type* bus_; - real_type R_; - real_type X_; - real_type G_; - real_type B_; - }; - - } // namespace PhasorDynamics -} // namespace GridKit diff --git a/tests/UnitTests/PhasorDynamics/CMakeLists.txt b/tests/UnitTests/PhasorDynamics/CMakeLists.txt index 7077c1295..18876a998 100644 --- a/tests/UnitTests/PhasorDynamics/CMakeLists.txt +++ b/tests/UnitTests/PhasorDynamics/CMakeLists.txt @@ -15,8 +15,8 @@ add_executable(test_phasor_load runLoadTests.cpp) target_link_libraries(test_phasor_load GRIDKIT::phasor_dynamics_load GRIDKIT::phasor_dynamics_bus) -add_executable(test_phasor_synchronous_machine runSynchronousMachineTests.cpp) -target_link_libraries(test_phasor_synchronous_machine GRIDKIT::phasor_dynamics_synchronous_machine +add_executable(test_phasor_genrou runGenrouTests.cpp) +target_link_libraries(test_phasor_genrou GRIDKIT::phasor_dynamics_genrou GRIDKIT::phasor_dynamics_bus) @@ -27,12 +27,12 @@ target_link_libraries(test_phasor_system GRIDKIT::phasor_dynamics_load add_test(NAME PhasorDynamicsBusTest COMMAND $) add_test(NAME PhasorDynamicsBranchTest COMMAND $) -add_test(NAME PhasorDynamicsSynchronousMachineTest COMMAND $) +add_test(NAME PhasorDynamicsGenrouTest COMMAND $) add_test(NAME PhasorDynamicsLoadTest COMMAND $) add_test(NAME PhasorDynamicsSystemTest COMMAND $) install(TARGETS test_phasor_bus test_phasor_branch test_phasor_load - test_phasor_synchronous_machine + test_phasor_genrou test_phasor_system RUNTIME DESTINATION bin) diff --git a/tests/UnitTests/PhasorDynamics/SynchronousMachineTests.hpp b/tests/UnitTests/PhasorDynamics/GenrouTests.hpp similarity index 78% rename from tests/UnitTests/PhasorDynamics/SynchronousMachineTests.hpp rename to tests/UnitTests/PhasorDynamics/GenrouTests.hpp index fb100335c..40e9feda4 100644 --- a/tests/UnitTests/PhasorDynamics/SynchronousMachineTests.hpp +++ b/tests/UnitTests/PhasorDynamics/GenrouTests.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -13,14 +13,14 @@ namespace GridKit { template - class SynchronousMachineTests + class GenrouTests { private: using real_type = typename PhasorDynamics::Component::real_type; public: - SynchronousMachineTests() = default; - ~SynchronousMachineTests() = default; + GenrouTests() = default; + ~GenrouTests() = default; TestOutcome constructor() { @@ -29,7 +29,7 @@ namespace GridKit auto* bus = new PhasorDynamics::Bus(1.0, 0.0); PhasorDynamics::Component* machine = - new PhasorDynamics::SynchronousMachine(bus); + new PhasorDynamics::Genrou(bus, 1); success *= (machine != nullptr); @@ -57,7 +57,7 @@ namespace GridKit return success.report(__func__); } - }; // class SynchronousMachineTest + }; // class GenrouTest } // namespace Testing } // namespace GridKit diff --git a/tests/UnitTests/PhasorDynamics/runSynchronousMachineTests.cpp b/tests/UnitTests/PhasorDynamics/runGenrouTests.cpp similarity index 53% rename from tests/UnitTests/PhasorDynamics/runSynchronousMachineTests.cpp rename to tests/UnitTests/PhasorDynamics/runGenrouTests.cpp index f77e97dba..ee8af3f35 100644 --- a/tests/UnitTests/PhasorDynamics/runSynchronousMachineTests.cpp +++ b/tests/UnitTests/PhasorDynamics/runGenrouTests.cpp @@ -1,12 +1,13 @@ -#include "SynchronousMachineTests.hpp" +#include "GenrouTests.hpp" int main() { using namespace GridKit; using namespace GridKit::Testing; - GridKit::Testing::TestingResults result; - GridKit::Testing::SynchronousMachineTests test; + GridKit::Testing::TestingResults result; + + GridKit::Testing::GenrouTests test; result += test.constructor(); result += test.accessors(); From 529f0f675a6745740b3a7e5f70a25f193cb3a2ce Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 13:08:51 -0400 Subject: [PATCH 19/21] Monor simplification of using namespace. --- tests/UnitTests/PhasorDynamics/runGenrouTests.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/UnitTests/PhasorDynamics/runGenrouTests.cpp b/tests/UnitTests/PhasorDynamics/runGenrouTests.cpp index ee8af3f35..0570a73c8 100644 --- a/tests/UnitTests/PhasorDynamics/runGenrouTests.cpp +++ b/tests/UnitTests/PhasorDynamics/runGenrouTests.cpp @@ -2,9 +2,6 @@ int main() { - using namespace GridKit; - using namespace GridKit::Testing; - GridKit::Testing::TestingResults result; GridKit::Testing::GenrouTests test; From c84341cfc285500eeaed5b0f7fca346a6ef07e35 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Sat, 5 Apr 2025 14:59:43 -0400 Subject: [PATCH 20/21] Add BusFault component. --- .../PhasorDynamics/Example1/CMakeLists.txt | 1 + examples/PhasorDynamics/Example1/example1.cpp | 2 +- .../PhasorDynamics/BusFault/BusFault.cpp | 181 ++++++++++++++++ .../PhasorDynamics/BusFault/BusFault.hpp | 195 +++++++----------- .../PhasorDynamics/BusFault/CMakeLists.txt | 4 +- src/Model/PhasorDynamics/CMakeLists.txt | 1 + 6 files changed, 256 insertions(+), 128 deletions(-) diff --git a/examples/PhasorDynamics/Example1/CMakeLists.txt b/examples/PhasorDynamics/Example1/CMakeLists.txt index dc0cefaf2..c04e061ca 100644 --- a/examples/PhasorDynamics/Example1/CMakeLists.txt +++ b/examples/PhasorDynamics/Example1/CMakeLists.txt @@ -1,6 +1,7 @@ add_executable(phasordynamics_example1 example1.cpp) target_link_libraries(phasordynamics_example1 GRIDKIT::phasor_dynamics_bus + GRIDKIT::phasor_dynamics_bus_fault GRIDKIT::phasor_dynamics_branch GRIDKIT::phasor_dynamics_genrou SUNDIALS::sunlinsolklu diff --git a/examples/PhasorDynamics/Example1/example1.cpp b/examples/PhasorDynamics/Example1/example1.cpp index b251f29ca..d3d3bdbfd 100644 --- a/examples/PhasorDynamics/Example1/example1.cpp +++ b/examples/PhasorDynamics/Example1/example1.cpp @@ -38,7 +38,7 @@ int main() Bus bus1(0.9949877346411762, 0.09999703952427966); BusInfinite bus2(1.0, 0.0); Branch branch(&bus1, &bus2, 0, 0.1, 0, 0); - BusFault fault(&bus1, 0, 1e-3, 0); + BusFault fault(&bus1, 0, 1e-3, 0); Genrou gen(&bus1, 1, diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.cpp b/src/Model/PhasorDynamics/BusFault/BusFault.cpp index 277e80e1e..d2f519ee0 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.cpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.cpp @@ -1 +1,182 @@ +/** + * @file BusFault.hpp + * @author Slaven Peles (peless@ornl.gov) + * @brief Definition of a bus fault to ground model. + * + * The model uses Cartesian coordinates. + * + */ + #include "BusFault.hpp" + +#include +#include + +#include +#include + +namespace GridKit +{ + namespace PhasorDynamics + { + /*! + * @brief Constructor for a pi-model branch + * + * Arguments passed to ModelEvaluatorImpl: + * - Number of equations = 0 + * - Number of independent variables = 0 + * - Number of quadratures = 0 + * - Number of optimization parameters = 0 + */ + template + BusFault::BusFault(bus_type* bus) + : bus_(bus), R_(0), X_(0.01), status_(0), busID_(0) + { + (void) busID_; + size_ = 0; + } + + /** + * @brief Construct a new BusFault + * + * @tparam ScalarT - scalar type + * @tparam IdxT - matrix/vector index type + * @param bus1 - pointer to bus-1 + * @param bus2 - pointer to bus-2 + * @param R - line series resistance + * @param X - line series reactance + * @param G - line shunt conductance + * @param B - line shunt charging + */ + template + BusFault::BusFault(bus_type* bus, real_type R, real_type X, int status) + : bus_(bus), R_(R), X_(X), status_(status), busID_(0) + { + size_ = 0; + } + + /*! + * @brief allocate method computes sparsity pattern of the Jacobian. + */ + template + int BusFault::allocate() + { + // std::cout << "Allocate BusFault..." << std::endl; + return 0; + } + + /** + * Initialization of the branch model + * + */ + template + int BusFault::initialize() + { + return 0; + } + + /** + * \brief Identify differential variables. + */ + template + int BusFault::tagDifferentiable() + { + return 0; + } + + /** + * \brief Residual contribution of the branch is pushed to the + * two terminal buses. + * + */ + template + int BusFault::evaluateResidual() + { + if (status_) + { + double B = -X_ / (X_ * X_ + R_ * R_); + double G = R_ / (X_ * X_ + R_ * R_); + + Ir() += -Vr() * G + Vi() * B; + Ii() += -Vr() * B - Vi() * G; + } + return 0; + } + + /** + * @brief Jacobian evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int BusFault::evaluateJacobian() + { + std::cout << "Evaluate Jacobian for BusFault..." << std::endl; + std::cout << "Jacobian evaluation not implemented!" << std::endl; + return 0; + } + + /** + * @brief Integrand (objective) evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int BusFault::evaluateIntegrand() + { + // std::cout << "Evaluate Integrand for BusFault..." << std::endl; + return 0; + } + + /** + * @brief Adjoint initialization not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int BusFault::initializeAdjoint() + { + // std::cout << "Initialize adjoint for BusFault..." << std::endl; + return 0; + } + + /** + * @brief Adjoint residual evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int BusFault::evaluateAdjointResidual() + { + // std::cout << "Evaluate adjoint residual for BusFault..." << std::endl; + return 0; + } + + /** + * @brief Adjoint integrand (objective) evaluation not implemented yet + * + * @tparam ScalarT - scalar data type + * @tparam IdxT - matrix index data type + * @return int - error code, 0 = success + */ + template + int BusFault::evaluateAdjointIntegrand() + { + // std::cout << "Evaluate adjoint Integrand for BusFault..." << std::endl; + return 0; + } + + // Available template instantiations + template class BusFault; + template class BusFault; + + } // namespace PhasorDynamics +} // namespace GridKit diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.hpp b/src/Model/PhasorDynamics/BusFault/BusFault.hpp index 8bb18a6a3..b3bd00262 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.hpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.hpp @@ -8,144 +8,89 @@ namespace GridKit { namespace PhasorDynamics { - using ComponentT = Component; - using BaseBusT = BusBase; - - class BusFault : public ComponentT + template + class BusFault : public Component { - using ComponentT::alpha_; - using ComponentT::f_; - using ComponentT::fB_; - using ComponentT::g_; - using ComponentT::gB_; - using ComponentT::nnz_; - using ComponentT::param_; - using ComponentT::size_; - using ComponentT::tag_; - using ComponentT::time_; - using ComponentT::y_; - using ComponentT::yB_; - using ComponentT::yp_; - using ComponentT::ypB_; + using Component::alpha_; + using Component::f_; + using Component::fB_; + using Component::g_; + using Component::gB_; + using Component::nnz_; + using Component::param_; + using Component::size_; + using Component::tag_; + using Component::time_; + using Component::y_; + using Component::yB_; + using Component::yp_; + using Component::ypB_; + + using bus_type = BusBase; + using real_type = typename Component::real_type; public: - BusFault(BaseBusT* bus) - : bus_(bus), R_(0), X_(0.01), status_(0), busID_(0) - { - (void) busID_; - size_ = 0; - } - - BusFault(BaseBusT* bus, double R, double X, int status) - : bus_(bus), R_(R), X_(X), status_(status), busID_(0) - { - size_ = 0; - } - - ~BusFault() - { - } - - int allocate() override - { - return 0; - } - - int initialize() override - { - return 0; - } - - int tagDifferentiable() override - { - return 0; - } - - int evaluateResidual() override - { - if (status_) + BusFault(bus_type* bus); + BusFault(bus_type* bus, real_type R, real_type X, int status); + ~BusFault() = default; + + int allocate() override; + int initialize() override; + int tagDifferentiable() override; + int evaluateResidual() override; + int evaluateJacobian() override; + int evaluateIntegrand() override; + int initializeAdjoint() override; + int evaluateAdjointResidual() override; + int evaluateAdjointIntegrand() override; + + void updateTime(real_type /* t */, real_type /* a */) override { - double B = -X_ / (X_ * X_ + R_ * R_); - double G = R_ / (X_ * X_ + R_ * R_); - - Ir() += -Vr() * G + Vi() * B; - Ii() += -Vr() * B - Vi() * G; } - return 0; - } - int evaluateJacobian() override - { - return 0; - } - - int evaluateIntegrand() override - { - return 0; - } - - int initializeAdjoint() override - { - return 0; - } - - int evaluateAdjointResidual() override - { - return 0; - } - - int evaluateAdjointIntegrand() override - { - return 0; - } - - void updateTime(double /* t */, double /* a */) override - { - } - - public: - void setR(double R) - { - R_ = R; - } + public: + void setR(real_type R) + { + R_ = R; + } - void setX(double X) - { - X_ = X; - } + void setX(real_type X) + { + X_ = X; + } - void setStatus(int status) - { - status_ = status; - } + void setStatus(int status) + { + status_ = status; + } - private: - double& Vr() - { - return bus_->Vr(); - } + private: + ScalarT& Vr() + { + return bus_->Vr(); + } - double& Vi() - { - return bus_->Vi(); - } + ScalarT& Vi() + { + return bus_->Vi(); + } - double& Ir() - { - return bus_->Ir(); - } + ScalarT& Ir() + { + return bus_->Ir(); + } - double& Ii() - { - return bus_->Ii(); - } + ScalarT& Ii() + { + return bus_->Ii(); + } - private: - BaseBusT* bus_; - double R_; - double X_; - int status_; - const int busID_; + private: + bus_type* bus_; + real_type R_; + real_type X_; + int status_; + const int busID_; }; } // namespace PhasorDynamics diff --git a/src/Model/PhasorDynamics/BusFault/CMakeLists.txt b/src/Model/PhasorDynamics/BusFault/CMakeLists.txt index 57279fe45..48d8c6d79 100644 --- a/src/Model/PhasorDynamics/BusFault/CMakeLists.txt +++ b/src/Model/PhasorDynamics/BusFault/CMakeLists.txt @@ -1,5 +1,5 @@ -gridkit_add_library(phasor_dynamics_BusFault +gridkit_add_library(phasor_dynamics_bus_fault SOURCES BusFault.cpp OUTPUT_NAME - gridkit_phasor_dynamics_BusFault) + gridkit_phasor_dynamics_bus_fault) diff --git a/src/Model/PhasorDynamics/CMakeLists.txt b/src/Model/PhasorDynamics/CMakeLists.txt index 77dc2d3e3..01cd77258 100644 --- a/src/Model/PhasorDynamics/CMakeLists.txt +++ b/src/Model/PhasorDynamics/CMakeLists.txt @@ -5,5 +5,6 @@ add_subdirectory(Branch) add_subdirectory(Bus) +add_subdirectory(BusFault) add_subdirectory(Load) add_subdirectory(SynchronousMachine) From 2e840f8e58a081142768b2aafb00072dc8fd7cd7 Mon Sep 17 00:00:00 2001 From: pelesh Date: Sat, 5 Apr 2025 19:36:49 +0000 Subject: [PATCH 21/21] Apply pre-commmit fixes --- .../PhasorDynamics/BusFault/BusFault.hpp | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.hpp b/src/Model/PhasorDynamics/BusFault/BusFault.hpp index b3bd00262..4df93c123 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.hpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.hpp @@ -34,63 +34,63 @@ namespace GridKit BusFault(bus_type* bus, real_type R, real_type X, int status); ~BusFault() = default; - int allocate() override; - int initialize() override; - int tagDifferentiable() override; - int evaluateResidual() override; - int evaluateJacobian() override; - int evaluateIntegrand() override; - int initializeAdjoint() override; - int evaluateAdjointResidual() override; - int evaluateAdjointIntegrand() override; + int allocate() override; + int initialize() override; + int tagDifferentiable() override; + int evaluateResidual() override; + int evaluateJacobian() override; + int evaluateIntegrand() override; + int initializeAdjoint() override; + int evaluateAdjointResidual() override; + int evaluateAdjointIntegrand() override; - void updateTime(real_type /* t */, real_type /* a */) override - { - } + void updateTime(real_type /* t */, real_type /* a */) override + { + } - public: - void setR(real_type R) - { - R_ = R; - } + public: + void setR(real_type R) + { + R_ = R; + } - void setX(real_type X) - { - X_ = X; - } + void setX(real_type X) + { + X_ = X; + } - void setStatus(int status) - { - status_ = status; - } + void setStatus(int status) + { + status_ = status; + } - private: - ScalarT& Vr() - { - return bus_->Vr(); - } + private: + ScalarT& Vr() + { + return bus_->Vr(); + } - ScalarT& Vi() - { - return bus_->Vi(); - } + ScalarT& Vi() + { + return bus_->Vi(); + } - ScalarT& Ir() - { - return bus_->Ir(); - } + ScalarT& Ir() + { + return bus_->Ir(); + } - ScalarT& Ii() - { - return bus_->Ii(); - } + ScalarT& Ii() + { + return bus_->Ii(); + } - private: - bus_type* bus_; - real_type R_; - real_type X_; - int status_; - const int busID_; + private: + bus_type* bus_; + real_type R_; + real_type X_; + int status_; + const int busID_; }; } // namespace PhasorDynamics