From 889dbd766d05f81eed299ea69704b5d05b4d30cc Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Mon, 26 May 2025 23:44:48 -0400 Subject: [PATCH 1/7] Create phasor dynamics bus and branch data structures. --- src/Model/PhasorDynamics/Branch/Branch.cpp | 12 ++--- src/Model/PhasorDynamics/Branch/Branch.hpp | 22 ++++----- .../PhasorDynamics/Branch/BranchData.hpp | 36 +++++++++++++++ src/Model/PhasorDynamics/Bus/Bus.cpp | 10 ++--- src/Model/PhasorDynamics/Bus/Bus.hpp | 45 ++----------------- src/Model/PhasorDynamics/Bus/BusData.hpp | 33 ++++++++++++++ 6 files changed, 94 insertions(+), 64 deletions(-) create mode 100644 src/Model/PhasorDynamics/Branch/BranchData.hpp create mode 100644 src/Model/PhasorDynamics/Bus/BusData.hpp diff --git a/src/Model/PhasorDynamics/Branch/Branch.cpp b/src/Model/PhasorDynamics/Branch/Branch.cpp index c65b3367e..26ac9902d 100644 --- a/src/Model/PhasorDynamics/Branch/Branch.cpp +++ b/src/Model/PhasorDynamics/Branch/Branch.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include namespace GridKit { @@ -73,13 +73,13 @@ namespace GridKit } template - Branch::Branch(bus_type* bus1, bus_type* bus2, BranchData& data) + Branch::Branch(bus_type* bus1, bus_type* bus2, model_data_type& data) : bus1_(bus1), bus2_(bus2), - R_(data.r), - X_(data.x), - G_(0.0), - B_(data.b), + R_(data.R), + X_(data.X), + G_(data.G), + B_(data.B), bus1ID_(data.fbus), bus2ID_(data.tbus) { diff --git a/src/Model/PhasorDynamics/Branch/Branch.hpp b/src/Model/PhasorDynamics/Branch/Branch.hpp index 9d6ac38d9..5ca14744b 100644 --- a/src/Model/PhasorDynamics/Branch/Branch.hpp +++ b/src/Model/PhasorDynamics/Branch/Branch.hpp @@ -13,7 +13,7 @@ // Forward declarations. namespace GridKit { - namespace PowerSystemData + namespace PhasorDynamics { template struct BranchData; @@ -51,21 +51,21 @@ namespace GridKit 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 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; - using BranchData = GridKit::PowerSystemData::BranchData; + using real_type = typename Component::real_type; + using bus_type = BusBase; + using model_data_type = BranchData; public: Branch(bus_type* bus1, bus_type* bus2); Branch(bus_type* bus1, bus_type* bus2, real_type R, real_type X, real_type G, real_type B); - Branch(bus_type* bus1, bus_type* bus2, BranchData& data); + Branch(bus_type* bus1, bus_type* bus2, model_data_type& data); virtual ~Branch(); virtual int allocate() override; diff --git a/src/Model/PhasorDynamics/Branch/BranchData.hpp b/src/Model/PhasorDynamics/Branch/BranchData.hpp new file mode 100644 index 000000000..fdfc0f40b --- /dev/null +++ b/src/Model/PhasorDynamics/Branch/BranchData.hpp @@ -0,0 +1,36 @@ +/** + * @file BranchData.hpp + * @author Slaven Peles (peless@ornl.gov) + * @brief Modeling data for branches (transmission lines) + * + */ +#pragma once + + +namespace GridKit +{ + namespace PhasorDynamics + { + /** + * @brief Contains modeling data for a Branch + * + * @tparam RealT Real parameter data type + * @tparam IdxT Integer parameter data type + * + * Integer parameters are of the same type as matrix and vector indices. + * + * @todo Decide on naming scheme for model parameters. + */ + template + struct BranchData + { + RealT R{0.0}; ///< line series resistance + RealT X{0.0}; ///< line series reactance + RealT G{0.0}; ///< line shunt conductance + RealT B{0.0}; ///< line shunt charging + + IdxT fbus{0}; ///< Unique ID of bus 1 + IdxT tbus{0}; ///< Unique ID of bus 2 + }; + } +} \ No newline at end of file diff --git a/src/Model/PhasorDynamics/Bus/Bus.cpp b/src/Model/PhasorDynamics/Bus/Bus.cpp index 3dfaad6ee..4aa83f9ca 100644 --- a/src/Model/PhasorDynamics/Bus/Bus.cpp +++ b/src/Model/PhasorDynamics/Bus/Bus.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include namespace GridKit { @@ -61,10 +61,10 @@ namespace GridKit * @param[in] data - structure with bus data */ template - Bus::Bus(BusData& data) - : BusBase(data.bus_i), - Vr0_(data.Vm * cos(data.Va)), - Vi0_(data.Vm * sin(data.Va)) + Bus::Bus(DataT& data) + : BusBase(data.bus_id), + Vr0_(data.Vr0), + Vi0_(data.Vi0) { // std::cout << "Create Bus..." << std::endl; // std::cout << "Number of equations is " << size_ << std::endl; diff --git a/src/Model/PhasorDynamics/Bus/Bus.hpp b/src/Model/PhasorDynamics/Bus/Bus.hpp index aedaa2a82..aef4f593a 100644 --- a/src/Model/PhasorDynamics/Bus/Bus.hpp +++ b/src/Model/PhasorDynamics/Bus/Bus.hpp @@ -6,7 +6,7 @@ // Forward declaration of BusData structure namespace GridKit { - namespace PowerSystemData + namespace PhasorDynamics { template struct BusData; @@ -39,11 +39,11 @@ namespace GridKit public: using real_type = typename BusBase::real_type; - using BusData = GridKit::PowerSystemData::BusData; + using DataT = BusData; Bus(); Bus(ScalarT Vr, ScalarT Vi); - Bus(BusData& data); + Bus(DataT& data); virtual ~Bus(); virtual int allocate() override; @@ -101,45 +101,6 @@ namespace GridKit return f_[1]; } - // virtual ScalarT& VrB() override - // { - // return yB_[0]; - // } - - // virtual const ScalarT& VrB() const override - // { - // return yB_[0]; - // } - - // virtual ScalarT& ViB() override - // { - // return yB_[1]; - // } - - // virtual const ScalarT& ViB() const override - // { - // return yB_[1]; - // } - - // virtual ScalarT& IrB() override - // { - // return fB_[0]; - // } - - // virtual const ScalarT& IrB() const override - // { - // return fB_[0]; - // } - - // virtual ScalarT& IiB() override - // { - // return fB_[1]; - // } - - // virtual const ScalarT& IiB() const override - // { - // return fB_[1]; - // } private: ScalarT Vr0_{0.0}; diff --git a/src/Model/PhasorDynamics/Bus/BusData.hpp b/src/Model/PhasorDynamics/Bus/BusData.hpp new file mode 100644 index 000000000..35956d983 --- /dev/null +++ b/src/Model/PhasorDynamics/Bus/BusData.hpp @@ -0,0 +1,33 @@ +/** + * @file BusData.hpp + * @author Slaven Peles (peless@ornl.gov) + * @brief Modeling data for branches (transmission lines) + * + */ +#pragma once + + +namespace GridKit +{ + namespace PhasorDynamics + { + /** + * @brief Contains modeling data for a Bus + * + * @tparam RealT Real parameter data type + * @tparam IdxT Integer parameter data type + * + * Integer parameters are of the same type as matrix and vector indices. + * + * @todo Decide on naming scheme for model parameters. + */ + template + struct BusData + { + RealT Vr0{0.0}; ///< Initial value for real bus voltage + RealT Vi0{0.0}; ///< Initial value for imaginary bus voltage + + IdxT bus_id{0}; ///< Unique ID of bus 1 + }; + } +} \ No newline at end of file From ec42ea906b24462cb894b80800d086fe7164ca1c Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 27 May 2025 00:15:21 -0400 Subject: [PATCH 2/7] Add load data structure. --- src/Model/PhasorDynamics/Branch/Branch.cpp | 12 +++---- src/Model/PhasorDynamics/Branch/Branch.hpp | 16 +++------ .../PhasorDynamics/Branch/BranchData.hpp | 4 +-- src/Model/PhasorDynamics/Bus/BusData.hpp | 2 +- src/Model/PhasorDynamics/Load/Load.cpp | 3 +- src/Model/PhasorDynamics/Load/Load.hpp | 22 ++++++++----- src/Model/PhasorDynamics/Load/LoadData.hpp | 33 +++++++++++++++++++ 7 files changed, 61 insertions(+), 31 deletions(-) create mode 100644 src/Model/PhasorDynamics/Load/LoadData.hpp diff --git a/src/Model/PhasorDynamics/Branch/Branch.cpp b/src/Model/PhasorDynamics/Branch/Branch.cpp index 26ac9902d..a22ca09f7 100644 --- a/src/Model/PhasorDynamics/Branch/Branch.cpp +++ b/src/Model/PhasorDynamics/Branch/Branch.cpp @@ -36,8 +36,8 @@ namespace GridKit X_(0.01), G_(0.0), B_(0.0), - bus1ID_(0), - bus2ID_(0) + bus1_id_(0), + bus2_id_(0) { size_ = 0; } @@ -67,8 +67,8 @@ namespace GridKit X_(X), G_(G), B_(B), - bus1ID_(0), - bus2ID_(0) + bus1_id_(0), + bus2_id_(0) { } @@ -80,8 +80,8 @@ namespace GridKit X_(data.X), G_(data.G), B_(data.B), - bus1ID_(data.fbus), - bus2ID_(data.tbus) + bus1_id_(data.bus1_id), + bus2_id_(data.bus2_id) { size_ = 0; } diff --git a/src/Model/PhasorDynamics/Branch/Branch.hpp b/src/Model/PhasorDynamics/Branch/Branch.hpp index 5ca14744b..2f41e688d 100644 --- a/src/Model/PhasorDynamics/Branch/Branch.hpp +++ b/src/Model/PhasorDynamics/Branch/Branch.hpp @@ -11,21 +11,15 @@ #include // Forward declarations. -namespace GridKit -{ - namespace PhasorDynamics - { - template - struct BranchData; - } -} // namespace GridKit - namespace GridKit { namespace PhasorDynamics { template class BusBase; + + template + struct BranchData; } } // namespace GridKit @@ -154,8 +148,8 @@ namespace GridKit real_type X_; real_type G_; real_type B_; - const IdxT bus1ID_; - const IdxT bus2ID_; + const IdxT bus1_id_; + const IdxT bus2_id_; }; } // namespace PhasorDynamics diff --git a/src/Model/PhasorDynamics/Branch/BranchData.hpp b/src/Model/PhasorDynamics/Branch/BranchData.hpp index fdfc0f40b..4c531bae1 100644 --- a/src/Model/PhasorDynamics/Branch/BranchData.hpp +++ b/src/Model/PhasorDynamics/Branch/BranchData.hpp @@ -29,8 +29,8 @@ namespace GridKit RealT G{0.0}; ///< line shunt conductance RealT B{0.0}; ///< line shunt charging - IdxT fbus{0}; ///< Unique ID of bus 1 - IdxT tbus{0}; ///< Unique ID of bus 2 + IdxT bus1_id{0}; ///< Unique ID of bus 1 + IdxT bus2_id{0}; ///< Unique ID of bus 2 }; } } \ No newline at end of file diff --git a/src/Model/PhasorDynamics/Bus/BusData.hpp b/src/Model/PhasorDynamics/Bus/BusData.hpp index 35956d983..664dc6535 100644 --- a/src/Model/PhasorDynamics/Bus/BusData.hpp +++ b/src/Model/PhasorDynamics/Bus/BusData.hpp @@ -1,7 +1,7 @@ /** * @file BusData.hpp * @author Slaven Peles (peless@ornl.gov) - * @brief Modeling data for branches (transmission lines) + * @brief Modeling data for buses (nodes) * */ #pragma once diff --git a/src/Model/PhasorDynamics/Load/Load.cpp b/src/Model/PhasorDynamics/Load/Load.cpp index e1ccb26cb..4dcb23728 100644 --- a/src/Model/PhasorDynamics/Load/Load.cpp +++ b/src/Model/PhasorDynamics/Load/Load.cpp @@ -5,6 +5,7 @@ #include #include +#include namespace GridKit { @@ -34,14 +35,12 @@ namespace GridKit : bus_(bus), R_(R), X_(X) - { } template Load::Load(bus_type* bus, IdxT component_id) : bus_(bus) - { size_ = 0; component_id_ = component_id; diff --git a/src/Model/PhasorDynamics/Load/Load.hpp b/src/Model/PhasorDynamics/Load/Load.hpp index d85355093..30a653f5d 100644 --- a/src/Model/PhasorDynamics/Load/Load.hpp +++ b/src/Model/PhasorDynamics/Load/Load.hpp @@ -11,7 +11,10 @@ namespace GridKit { template class BusBase; - } + + template + struct LoadData; + } // namespace PhasorDynamics } // namespace GridKit namespace GridKit @@ -33,16 +36,17 @@ namespace GridKit 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 Component::g_; + // using Component::yB_; + // using Component::ypB_; + // using Component::fB_; + // using Component::gB_; + // using Component::param_; using Component::component_id_; - using bus_type = BusBase; - using real_type = typename Component::real_type; + using real_type = typename Component::real_type; + using bus_type = BusBase; + using model_data_type = LoadData; public: Load(bus_type* bus); diff --git a/src/Model/PhasorDynamics/Load/LoadData.hpp b/src/Model/PhasorDynamics/Load/LoadData.hpp new file mode 100644 index 000000000..cde0d1536 --- /dev/null +++ b/src/Model/PhasorDynamics/Load/LoadData.hpp @@ -0,0 +1,33 @@ +/** + * @file LoadData.hpp + * @author Slaven Peles (peless@ornl.gov) + * @brief Modeling data for loads + * + */ +#pragma once + + +namespace GridKit +{ + namespace PhasorDynamics + { + /** + * @brief Contains modeling data for a Load + * + * @tparam RealT Real parameter data type + * @tparam IdxT Integer parameter data type + * + * Integer parameters are of the same type as matrix and vector indices. + * + * @todo Decide on naming scheme for model parameters. + */ + template + struct LoadData + { + RealT R{0.0}; ///< load resistance + RealT X{0.0}; ///< load reactance + + IdxT bus_id{0}; ///< Unique ID of bus 1 + }; + } +} \ No newline at end of file From e56d5e574e70f0fbfeaadc1da6b620e505271137 Mon Sep 17 00:00:00 2001 From: pelesh Date: Tue, 27 May 2025 04:18:58 +0000 Subject: [PATCH 3/7] Apply pre-commmit fixes --- src/Model/PhasorDynamics/Branch/Branch.cpp | 2 +- src/Model/PhasorDynamics/Branch/Branch.hpp | 2 +- src/Model/PhasorDynamics/Branch/BranchData.hpp | 15 +++++++-------- src/Model/PhasorDynamics/Bus/Bus.hpp | 1 - src/Model/PhasorDynamics/Bus/BusData.hpp | 13 ++++++------- src/Model/PhasorDynamics/Load/LoadData.hpp | 13 ++++++------- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/Model/PhasorDynamics/Branch/Branch.cpp b/src/Model/PhasorDynamics/Branch/Branch.cpp index a22ca09f7..a2277dfcc 100644 --- a/src/Model/PhasorDynamics/Branch/Branch.cpp +++ b/src/Model/PhasorDynamics/Branch/Branch.cpp @@ -12,8 +12,8 @@ #include #include -#include #include +#include namespace GridKit { diff --git a/src/Model/PhasorDynamics/Branch/Branch.hpp b/src/Model/PhasorDynamics/Branch/Branch.hpp index 2f41e688d..88ac13aa0 100644 --- a/src/Model/PhasorDynamics/Branch/Branch.hpp +++ b/src/Model/PhasorDynamics/Branch/Branch.hpp @@ -20,7 +20,7 @@ namespace GridKit template struct BranchData; - } + } // namespace PhasorDynamics } // namespace GridKit namespace GridKit diff --git a/src/Model/PhasorDynamics/Branch/BranchData.hpp b/src/Model/PhasorDynamics/Branch/BranchData.hpp index 4c531bae1..9f66fd28c 100644 --- a/src/Model/PhasorDynamics/Branch/BranchData.hpp +++ b/src/Model/PhasorDynamics/Branch/BranchData.hpp @@ -2,23 +2,22 @@ * @file BranchData.hpp * @author Slaven Peles (peless@ornl.gov) * @brief Modeling data for branches (transmission lines) - * + * */ #pragma once - namespace GridKit { namespace PhasorDynamics { /** * @brief Contains modeling data for a Branch - * + * * @tparam RealT Real parameter data type * @tparam IdxT Integer parameter data type - * + * * Integer parameters are of the same type as matrix and vector indices. - * + * * @todo Decide on naming scheme for model parameters. */ template @@ -27,10 +26,10 @@ namespace GridKit RealT R{0.0}; ///< line series resistance RealT X{0.0}; ///< line series reactance RealT G{0.0}; ///< line shunt conductance - RealT B{0.0}; ///< line shunt charging + RealT B{0.0}; ///< line shunt charging IdxT bus1_id{0}; ///< Unique ID of bus 1 IdxT bus2_id{0}; ///< Unique ID of bus 2 }; - } -} \ No newline at end of file + } // namespace PhasorDynamics +} // namespace GridKit diff --git a/src/Model/PhasorDynamics/Bus/Bus.hpp b/src/Model/PhasorDynamics/Bus/Bus.hpp index aef4f593a..57828ef01 100644 --- a/src/Model/PhasorDynamics/Bus/Bus.hpp +++ b/src/Model/PhasorDynamics/Bus/Bus.hpp @@ -101,7 +101,6 @@ namespace GridKit return f_[1]; } - private: ScalarT Vr0_{0.0}; ScalarT Vi0_{0.0}; diff --git a/src/Model/PhasorDynamics/Bus/BusData.hpp b/src/Model/PhasorDynamics/Bus/BusData.hpp index 664dc6535..abd8ab595 100644 --- a/src/Model/PhasorDynamics/Bus/BusData.hpp +++ b/src/Model/PhasorDynamics/Bus/BusData.hpp @@ -2,23 +2,22 @@ * @file BusData.hpp * @author Slaven Peles (peless@ornl.gov) * @brief Modeling data for buses (nodes) - * + * */ #pragma once - namespace GridKit { namespace PhasorDynamics { /** * @brief Contains modeling data for a Bus - * + * * @tparam RealT Real parameter data type * @tparam IdxT Integer parameter data type - * + * * Integer parameters are of the same type as matrix and vector indices. - * + * * @todo Decide on naming scheme for model parameters. */ template @@ -29,5 +28,5 @@ namespace GridKit IdxT bus_id{0}; ///< Unique ID of bus 1 }; - } -} \ No newline at end of file + } // namespace PhasorDynamics +} // namespace GridKit diff --git a/src/Model/PhasorDynamics/Load/LoadData.hpp b/src/Model/PhasorDynamics/Load/LoadData.hpp index cde0d1536..f28929274 100644 --- a/src/Model/PhasorDynamics/Load/LoadData.hpp +++ b/src/Model/PhasorDynamics/Load/LoadData.hpp @@ -2,23 +2,22 @@ * @file LoadData.hpp * @author Slaven Peles (peless@ornl.gov) * @brief Modeling data for loads - * + * */ #pragma once - namespace GridKit { namespace PhasorDynamics { /** * @brief Contains modeling data for a Load - * + * * @tparam RealT Real parameter data type * @tparam IdxT Integer parameter data type - * + * * Integer parameters are of the same type as matrix and vector indices. - * + * * @todo Decide on naming scheme for model parameters. */ template @@ -29,5 +28,5 @@ namespace GridKit IdxT bus_id{0}; ///< Unique ID of bus 1 }; - } -} \ No newline at end of file + } // namespace PhasorDynamics +} // namespace GridKit From fe2b67b5fce07ee391ac20f760809ee3ebbd2d83 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Tue, 27 May 2025 00:31:26 -0400 Subject: [PATCH 4/7] Use BusData with BusInfinite. --- src/Model/PhasorDynamics/Bus/BusInfinite.cpp | 10 ++-- src/Model/PhasorDynamics/Bus/BusInfinite.hpp | 46 ++----------------- .../PhasorDynamics/BusFault/BusFault.cpp | 1 - 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/src/Model/PhasorDynamics/Bus/BusInfinite.cpp b/src/Model/PhasorDynamics/Bus/BusInfinite.cpp index 61fa5d202..e8a231d13 100644 --- a/src/Model/PhasorDynamics/Bus/BusInfinite.cpp +++ b/src/Model/PhasorDynamics/Bus/BusInfinite.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include namespace GridKit { @@ -66,10 +66,10 @@ namespace GridKit * @param[in] data - structure with bus data */ template - BusInfinite::BusInfinite(BusData& data) - : BusBase(data.bus_i), - Vr_(data.Vm * cos(data.Va)), - Vi_(data.Vm * sin(data.Va)) + BusInfinite::BusInfinite(DataT& data) + : BusBase(data.bus_id), + Vr_(data.Vr0), + Vi_(data.Vi0) { size_ = 0; } diff --git a/src/Model/PhasorDynamics/Bus/BusInfinite.hpp b/src/Model/PhasorDynamics/Bus/BusInfinite.hpp index 6acdd7c6a..0657ec374 100644 --- a/src/Model/PhasorDynamics/Bus/BusInfinite.hpp +++ b/src/Model/PhasorDynamics/Bus/BusInfinite.hpp @@ -6,7 +6,7 @@ // Forward declaration of BusData structure namespace GridKit { - namespace PowerSystemData + namespace PhasorDynamics { template struct BusData; @@ -37,11 +37,11 @@ namespace GridKit public: using real_type = typename BusBase::real_type; - using BusData = GridKit::PowerSystemData::BusData; + using DataT = BusData; BusInfinite(); BusInfinite(ScalarT Vr, ScalarT Vi); - BusInfinite(BusData& data); + BusInfinite(DataT& data); virtual ~BusInfinite(); virtual int allocate() override; @@ -99,46 +99,6 @@ namespace GridKit return Ii_; } - // virtual ScalarT& VrB() override - // { - // return VrB_; - // } - - // virtual const ScalarT& VrB() const override - // { - // return VrB_; - // } - - // virtual ScalarT& ViB() override - // { - // return ViB_; - // } - - // virtual const ScalarT& ViB() const override - // { - // return ViB_; - // } - - // virtual ScalarT& IrB() override - // { - // return IrB_; - // } - - // virtual const ScalarT& IrB() const override - // { - // return IrB_; - // } - - // virtual ScalarT& IiB() override - // { - // return IiB_; - // } - - // virtual const ScalarT& IiB() const override - // { - // return IiB_; - // } - private: ScalarT Vr_{0.0}; ScalarT Vi_{0.0}; diff --git a/src/Model/PhasorDynamics/BusFault/BusFault.cpp b/src/Model/PhasorDynamics/BusFault/BusFault.cpp index 7b12af307..d38324073 100644 --- a/src/Model/PhasorDynamics/BusFault/BusFault.cpp +++ b/src/Model/PhasorDynamics/BusFault/BusFault.cpp @@ -13,7 +13,6 @@ #include #include -#include namespace GridKit { From 8fcb3255e3aced03440edce7b27c59fe30b7e357 Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Fri, 30 May 2025 17:23:00 -0400 Subject: [PATCH 5/7] Remove commented out code. --- src/Model/PhasorDynamics/Branch/Branch.hpp | 6 ------ src/Model/PhasorDynamics/Load/Load.hpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/Model/PhasorDynamics/Branch/Branch.hpp b/src/Model/PhasorDynamics/Branch/Branch.hpp index 88ac13aa0..cf3cba0e1 100644 --- a/src/Model/PhasorDynamics/Branch/Branch.hpp +++ b/src/Model/PhasorDynamics/Branch/Branch.hpp @@ -45,12 +45,6 @@ namespace GridKit 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 real_type = typename Component::real_type; using bus_type = BusBase; diff --git a/src/Model/PhasorDynamics/Load/Load.hpp b/src/Model/PhasorDynamics/Load/Load.hpp index 30a653f5d..221f21043 100644 --- a/src/Model/PhasorDynamics/Load/Load.hpp +++ b/src/Model/PhasorDynamics/Load/Load.hpp @@ -36,12 +36,6 @@ namespace GridKit 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 Component::component_id_; using real_type = typename Component::real_type; From 042ebcdf911e05120837bdb97ee89567f2c2748e Mon Sep 17 00:00:00 2001 From: Slaven Peles Date: Fri, 30 May 2025 17:27:13 -0400 Subject: [PATCH 6/7] Renamed PowerSystemData -> PowerFlowData --- examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp | 6 ++--- .../MatPowerTesting/MatPowerTesting.hpp | 26 +++++++++---------- .../MatPowerTesting/test_parse_branch_row.cpp | 4 +-- .../MatPowerTesting/test_parse_bus_row.cpp | 4 +-- .../MatPowerTesting/test_parse_gen_row.cpp | 4 +-- .../test_parse_gencost_row.cpp | 4 +-- .../MatPowerTesting/test_parse_matpower.cpp | 4 +-- src/Model/PowerFlow/Branch/Branch.cpp | 2 +- src/Model/PowerFlow/Branch/Branch.hpp | 4 +-- src/Model/PowerFlow/Bus/BusFactory.hpp | 4 +-- src/Model/PowerFlow/Bus/BusPQ.hpp | 4 +-- src/Model/PowerFlow/Bus/BusPV.hpp | 4 +-- src/Model/PowerFlow/Bus/BusSlack.hpp | 4 +-- .../PowerFlow/Generator/GeneratorFactory.hpp | 4 +-- src/Model/PowerFlow/Generator/GeneratorPQ.hpp | 4 +-- src/Model/PowerFlow/Generator/GeneratorPV.hpp | 4 +-- .../PowerFlow/Generator/GeneratorSlack.hpp | 4 +-- src/Model/PowerFlow/Load/Load.hpp | 4 +-- src/Model/PowerFlow/MatpowerParser.hpp | 4 +-- ...{PowerSystemData.hpp => PowerFlowData.hpp} | 6 ++--- src/Model/PowerFlow/SystemModelPowerFlow.hpp | 2 +- 21 files changed, 53 insertions(+), 53 deletions(-) rename src/Model/PowerFlow/{PowerSystemData.hpp => PowerFlowData.hpp} (98%) diff --git a/examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp b/examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp index b5d830764..be8dafb0b 100644 --- a/examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp +++ b/examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -79,7 +79,7 @@ using namespace GridKit; using namespace AnalysisManager::Sundials; using namespace AnalysisManager; using namespace GridKit::Testing; -using namespace GridKit::PowerSystemData; +using namespace GridKit::PowerFlowData; constexpr double theta2_ref = -4.87979; // [deg] constexpr double V2_ref = 1.08281; // [p.u.] @@ -149,7 +149,7 @@ int parserCase() std::cout << "Solving same problem, but assembled from components via a parser ...\n\n"; // Data File Reading - GridKit::PowerSystemData::SystemModelData mp; + GridKit::PowerFlowData::SystemModelData mp; std::istringstream iss(BUS3_DATA_STRING); GridKit::readMatPower(mp, iss); diff --git a/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp b/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp index 648296a42..3f1f319d2 100644 --- a/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp +++ b/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include namespace @@ -34,8 +34,8 @@ namespace GridKit { template - inline bool isEqual(PowerSystemData::GenCostData a, - PowerSystemData::GenCostData b, + inline bool isEqual(PowerFlowData::GenCostData a, + PowerFlowData::GenCostData b, RealT tol = tol_) { (void) tol; // suppress warning @@ -52,8 +52,8 @@ namespace GridKit } template - inline bool isEqual(PowerSystemData::GenData a, - PowerSystemData::GenData b, + inline bool isEqual(PowerFlowData::GenData a, + PowerFlowData::GenData b, RealT tol = tol_) { int fail = 0; @@ -88,8 +88,8 @@ namespace GridKit } template - inline bool isEqual(PowerSystemData::BusData a, - PowerSystemData::BusData b, + inline bool isEqual(PowerFlowData::BusData a, + PowerFlowData::BusData b, RealT tol = tol_) { int fail = 0; @@ -124,8 +124,8 @@ namespace GridKit } template - inline bool isEqual(PowerSystemData::LoadData a, - PowerSystemData::LoadData b, + inline bool isEqual(PowerFlowData::LoadData a, + PowerFlowData::LoadData b, RealT tol = tol_) { int fail = 0; @@ -144,8 +144,8 @@ namespace GridKit } template - inline bool isEqual(PowerSystemData::BranchData a, - PowerSystemData::BranchData b, + inline bool isEqual(PowerFlowData::BranchData a, + PowerFlowData::BranchData b, RealT tol = tol_) { int fail = 0; @@ -197,8 +197,8 @@ namespace GridKit } template - inline bool isEqual(PowerSystemData::SystemModelData a, - PowerSystemData::SystemModelData b) + inline bool isEqual(PowerFlowData::SystemModelData a, + PowerFlowData::SystemModelData b) { int fail = 0; diff --git a/examples/PowerFlow/MatPowerTesting/test_parse_branch_row.cpp b/examples/PowerFlow/MatPowerTesting/test_parse_branch_row.cpp index 442dda532..af353b8d7 100644 --- a/examples/PowerFlow/MatPowerTesting/test_parse_branch_row.cpp +++ b/examples/PowerFlow/MatPowerTesting/test_parse_branch_row.cpp @@ -2,11 +2,11 @@ #include "MatPowerTesting.hpp" #include -#include +#include using namespace GridKit; using namespace GridKit::Testing; -using namespace GridKit::PowerSystemData; +using namespace GridKit::PowerFlowData; namespace { diff --git a/examples/PowerFlow/MatPowerTesting/test_parse_bus_row.cpp b/examples/PowerFlow/MatPowerTesting/test_parse_bus_row.cpp index ff874dcfb..e8a535a58 100644 --- a/examples/PowerFlow/MatPowerTesting/test_parse_bus_row.cpp +++ b/examples/PowerFlow/MatPowerTesting/test_parse_bus_row.cpp @@ -2,11 +2,11 @@ #include "MatPowerTesting.hpp" #include -#include +#include using namespace GridKit; using namespace GridKit::Testing; -using namespace GridKit::PowerSystemData; +using namespace GridKit::PowerFlowData; namespace { diff --git a/examples/PowerFlow/MatPowerTesting/test_parse_gen_row.cpp b/examples/PowerFlow/MatPowerTesting/test_parse_gen_row.cpp index 437f0af7f..2ce6e4aa5 100644 --- a/examples/PowerFlow/MatPowerTesting/test_parse_gen_row.cpp +++ b/examples/PowerFlow/MatPowerTesting/test_parse_gen_row.cpp @@ -2,11 +2,11 @@ #include "MatPowerTesting.hpp" #include -#include +#include using namespace GridKit; using namespace GridKit::Testing; -using namespace GridKit::PowerSystemData; +using namespace GridKit::PowerFlowData; namespace { diff --git a/examples/PowerFlow/MatPowerTesting/test_parse_gencost_row.cpp b/examples/PowerFlow/MatPowerTesting/test_parse_gencost_row.cpp index 68dad3456..19e552023 100644 --- a/examples/PowerFlow/MatPowerTesting/test_parse_gencost_row.cpp +++ b/examples/PowerFlow/MatPowerTesting/test_parse_gencost_row.cpp @@ -2,11 +2,11 @@ #include "MatPowerTesting.hpp" #include -#include +#include using namespace GridKit; using namespace GridKit::Testing; -using namespace GridKit::PowerSystemData; +using namespace GridKit::PowerFlowData; namespace { diff --git a/examples/PowerFlow/MatPowerTesting/test_parse_matpower.cpp b/examples/PowerFlow/MatPowerTesting/test_parse_matpower.cpp index c384743f0..856b9cb00 100644 --- a/examples/PowerFlow/MatPowerTesting/test_parse_matpower.cpp +++ b/examples/PowerFlow/MatPowerTesting/test_parse_matpower.cpp @@ -2,11 +2,11 @@ #include "MatPowerTesting.hpp" #include -#include +#include using namespace GridKit; using namespace GridKit::Testing; -using namespace GridKit::PowerSystemData; +using namespace GridKit::PowerFlowData; namespace { diff --git a/src/Model/PowerFlow/Branch/Branch.cpp b/src/Model/PowerFlow/Branch/Branch.cpp index ecbc1b6d2..407db8152 100644 --- a/src/Model/PowerFlow/Branch/Branch.cpp +++ b/src/Model/PowerFlow/Branch/Branch.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include namespace GridKit { diff --git a/src/Model/PowerFlow/Branch/Branch.hpp b/src/Model/PowerFlow/Branch/Branch.hpp index c7eca8046..1a586a830 100644 --- a/src/Model/PowerFlow/Branch/Branch.hpp +++ b/src/Model/PowerFlow/Branch/Branch.hpp @@ -10,7 +10,7 @@ namespace GridKit template class BaseBus; - namespace PowerSystemData + namespace PowerFlowData { template struct BranchData; @@ -43,7 +43,7 @@ namespace GridKit using bus_type = BaseBus; using real_type = typename ModelEvaluatorImpl::real_type; - using BranchData = GridKit::PowerSystemData::BranchData; + using BranchData = GridKit::PowerFlowData::BranchData; public: Branch(bus_type* bus1, bus_type* bus2); diff --git a/src/Model/PowerFlow/Bus/BusFactory.hpp b/src/Model/PowerFlow/Bus/BusFactory.hpp index dc91c38b7..afd16c685 100644 --- a/src/Model/PowerFlow/Bus/BusFactory.hpp +++ b/src/Model/PowerFlow/Bus/BusFactory.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace GridKit { @@ -14,7 +14,7 @@ namespace GridKit { public: using real_type = typename ModelEvaluatorImpl::real_type; - using BusData = GridKit::PowerSystemData::BusData; + using BusData = GridKit::PowerFlowData::BusData; BusFactory() = delete; diff --git a/src/Model/PowerFlow/Bus/BusPQ.hpp b/src/Model/PowerFlow/Bus/BusPQ.hpp index e0b76b169..903fe9d5b 100644 --- a/src/Model/PowerFlow/Bus/BusPQ.hpp +++ b/src/Model/PowerFlow/Bus/BusPQ.hpp @@ -3,7 +3,7 @@ #define _BUS_PQ_HPP_ #include "BaseBus.hpp" -#include +#include namespace GridKit { @@ -29,7 +29,7 @@ namespace GridKit public: using real_type = typename ModelEvaluatorImpl::real_type; - using BusData = GridKit::PowerSystemData::BusData; + using BusData = GridKit::PowerFlowData::BusData; BusPQ(); BusPQ(ScalarT V, ScalarT theta); diff --git a/src/Model/PowerFlow/Bus/BusPV.hpp b/src/Model/PowerFlow/Bus/BusPV.hpp index b4ea8fd87..bbfe87aad 100644 --- a/src/Model/PowerFlow/Bus/BusPV.hpp +++ b/src/Model/PowerFlow/Bus/BusPV.hpp @@ -5,7 +5,7 @@ #include #include "BaseBus.hpp" -#include +#include namespace GridKit { @@ -31,7 +31,7 @@ namespace GridKit public: using real_type = typename ModelEvaluatorImpl::real_type; - using BusData = GridKit::PowerSystemData::BusData; + using BusData = GridKit::PowerFlowData::BusData; BusPV(); BusPV(ScalarT V, ScalarT theta0); diff --git a/src/Model/PowerFlow/Bus/BusSlack.hpp b/src/Model/PowerFlow/Bus/BusSlack.hpp index 4a693e434..aeaf0a62b 100644 --- a/src/Model/PowerFlow/Bus/BusSlack.hpp +++ b/src/Model/PowerFlow/Bus/BusSlack.hpp @@ -3,7 +3,7 @@ #define _BUS_SLACK_HPP_ #include "BaseBus.hpp" -#include +#include namespace GridKit { @@ -29,7 +29,7 @@ namespace GridKit public: using real_type = typename ModelEvaluatorImpl::real_type; - using BusData = GridKit::PowerSystemData::BusData; + using BusData = GridKit::PowerFlowData::BusData; BusSlack(); BusSlack(ScalarT V, ScalarT theta); diff --git a/src/Model/PowerFlow/Generator/GeneratorFactory.hpp b/src/Model/PowerFlow/Generator/GeneratorFactory.hpp index daedd23b4..fcf5ba41f 100644 --- a/src/Model/PowerFlow/Generator/GeneratorFactory.hpp +++ b/src/Model/PowerFlow/Generator/GeneratorFactory.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include namespace GridKit { @@ -15,7 +15,7 @@ namespace GridKit { public: using real_type = typename ModelEvaluatorImpl::real_type; - using GenData = GridKit::PowerSystemData::GenData; + using GenData = GridKit::PowerFlowData::GenData; GeneratorFactory() = delete; diff --git a/src/Model/PowerFlow/Generator/GeneratorPQ.hpp b/src/Model/PowerFlow/Generator/GeneratorPQ.hpp index 0628257e2..db763069f 100644 --- a/src/Model/PowerFlow/Generator/GeneratorPQ.hpp +++ b/src/Model/PowerFlow/Generator/GeneratorPQ.hpp @@ -5,7 +5,7 @@ #include "GeneratorBase.hpp" #include -#include +#include namespace GridKit { @@ -39,7 +39,7 @@ namespace GridKit using bus_type = BaseBus; using real_type = typename ModelEvaluatorImpl::real_type; - using GenData = GridKit::PowerSystemData::GenData; + using GenData = GridKit::PowerFlowData::GenData; public: GeneratorPQ(bus_type* bus, GenData& data); diff --git a/src/Model/PowerFlow/Generator/GeneratorPV.hpp b/src/Model/PowerFlow/Generator/GeneratorPV.hpp index efe629f19..677c6034a 100644 --- a/src/Model/PowerFlow/Generator/GeneratorPV.hpp +++ b/src/Model/PowerFlow/Generator/GeneratorPV.hpp @@ -5,7 +5,7 @@ #include "GeneratorBase.hpp" #include -#include +#include namespace GridKit { @@ -39,7 +39,7 @@ namespace GridKit using bus_type = BaseBus; using real_type = typename ModelEvaluatorImpl::real_type; - using GenData = GridKit::PowerSystemData::GenData; + using GenData = GridKit::PowerFlowData::GenData; public: GeneratorPV(bus_type* bus, GenData& data); diff --git a/src/Model/PowerFlow/Generator/GeneratorSlack.hpp b/src/Model/PowerFlow/Generator/GeneratorSlack.hpp index 43a7c3212..d2665d24b 100644 --- a/src/Model/PowerFlow/Generator/GeneratorSlack.hpp +++ b/src/Model/PowerFlow/Generator/GeneratorSlack.hpp @@ -4,7 +4,7 @@ #include #include "GeneratorBase.hpp" -#include +#include namespace GridKit { @@ -38,7 +38,7 @@ namespace GridKit using bus_type = BaseBus; using real_type = typename ModelEvaluatorImpl::real_type; - using GenData = GridKit::PowerSystemData::GenData; + using GenData = GridKit::PowerFlowData::GenData; // typedef typename ModelEvaluatorImpl::real_type real_type; // typedef BaseBus bus_type; diff --git a/src/Model/PowerFlow/Load/Load.hpp b/src/Model/PowerFlow/Load/Load.hpp index 5091761c9..b13cb1340 100644 --- a/src/Model/PowerFlow/Load/Load.hpp +++ b/src/Model/PowerFlow/Load/Load.hpp @@ -3,7 +3,7 @@ #define _LOAD_HPP_ #include -#include +#include namespace GridKit { @@ -39,7 +39,7 @@ namespace GridKit // typedef BaseBus bus_type; using bus_type = BaseBus; using real_type = typename ModelEvaluatorImpl::real_type; - using LoadData = GridKit::PowerSystemData::LoadData; + using LoadData = GridKit::PowerFlowData::LoadData; public: Load(bus_type* bus, ScalarT P, ScalarT Q); diff --git a/src/Model/PowerFlow/MatpowerParser.hpp b/src/Model/PowerFlow/MatpowerParser.hpp index dcf926ef9..ae374b8aa 100644 --- a/src/Model/PowerFlow/MatpowerParser.hpp +++ b/src/Model/PowerFlow/MatpowerParser.hpp @@ -17,11 +17,11 @@ #include #include -#include +#include namespace GridKit { - using namespace GridKit::PowerSystemData; + using namespace GridKit::PowerFlowData; static const std::string matlab_syntax_error{ "Only a subset of Matlab syntax is supported." diff --git a/src/Model/PowerFlow/PowerSystemData.hpp b/src/Model/PowerFlow/PowerFlowData.hpp similarity index 98% rename from src/Model/PowerFlow/PowerSystemData.hpp rename to src/Model/PowerFlow/PowerFlowData.hpp index 1a71be0a8..2c674a7a6 100644 --- a/src/Model/PowerFlow/PowerSystemData.hpp +++ b/src/Model/PowerFlow/PowerFlowData.hpp @@ -6,7 +6,7 @@ /** * - * @file PowerSystemData.hpp + * @file PowerFlowData.hpp * @author Asher Mancinelli * * @remark `std::stringstream` is preferred over `operator+(std::string, ...)` @@ -17,7 +17,7 @@ namespace GridKit { - namespace PowerSystemData + namespace PowerFlowData { template @@ -238,5 +238,5 @@ namespace GridKit } }; // struct SystemModelData - } // namespace PowerSystemData + } // namespace PowerFlowData } // namespace GridKit diff --git a/src/Model/PowerFlow/SystemModelPowerFlow.hpp b/src/Model/PowerFlow/SystemModelPowerFlow.hpp index d43883f6c..ce4148eb7 100644 --- a/src/Model/PowerFlow/SystemModelPowerFlow.hpp +++ b/src/Model/PowerFlow/SystemModelPowerFlow.hpp @@ -75,7 +75,7 @@ namespace GridKit * * @param mp model data */ - SystemSteadyStateModel(GridKit::PowerSystemData::SystemModelData mp) + SystemSteadyStateModel(GridKit::PowerFlowData::SystemModelData mp) : ModelEvaluatorImpl(0, 0, 0) { rel_tol_ = 1e-5; From c9a7a82c2a70c246cf6e5da78d3c1697afd1c1b5 Mon Sep 17 00:00:00 2001 From: pelesh Date: Fri, 30 May 2025 21:35:49 +0000 Subject: [PATCH 7/7] Apply pre-commmit fixes --- examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp | 10 +++++----- .../SynchronousMachine/SynchronousMachine.cpp | 2 +- .../PowerFlow/Generator4Param/Generator4Param.cpp | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp b/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp index 3f1f319d2..36ecfffdc 100644 --- a/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp +++ b/examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp @@ -36,7 +36,7 @@ namespace GridKit template inline bool isEqual(PowerFlowData::GenCostData a, PowerFlowData::GenCostData b, - RealT tol = tol_) + RealT tol = tol_) { (void) tol; // suppress warning int fail = 0; @@ -54,7 +54,7 @@ namespace GridKit template inline bool isEqual(PowerFlowData::GenData a, PowerFlowData::GenData b, - RealT tol = tol_) + RealT tol = tol_) { int fail = 0; @@ -90,7 +90,7 @@ namespace GridKit template inline bool isEqual(PowerFlowData::BusData a, PowerFlowData::BusData b, - RealT tol = tol_) + RealT tol = tol_) { int fail = 0; @@ -126,7 +126,7 @@ namespace GridKit template inline bool isEqual(PowerFlowData::LoadData a, PowerFlowData::LoadData b, - RealT tol = tol_) + RealT tol = tol_) { int fail = 0; @@ -146,7 +146,7 @@ namespace GridKit template inline bool isEqual(PowerFlowData::BranchData a, PowerFlowData::BranchData b, - RealT tol = tol_) + RealT tol = tol_) { int fail = 0; diff --git a/src/Model/PowerElectronics/SynchronousMachine/SynchronousMachine.cpp b/src/Model/PowerElectronics/SynchronousMachine/SynchronousMachine.cpp index f007ce8c0..9dc535cd3 100644 --- a/src/Model/PowerElectronics/SynchronousMachine/SynchronousMachine.cpp +++ b/src/Model/PowerElectronics/SynchronousMachine/SynchronousMachine.cpp @@ -101,7 +101,7 @@ namespace GridKit template int SynchronousMachine::evaluateResidual() { - ScalarT rkq1 = std::get<0>(Rkq_); + ScalarT rkq1 = std::get<0>(Rkq_); [[maybe_unused]] ScalarT rkq2 = std::get<1>(Rkq_); ScalarT llkq1 = std::get<0>(Llkq_); diff --git a/src/Model/PowerFlow/Generator4Param/Generator4Param.cpp b/src/Model/PowerFlow/Generator4Param/Generator4Param.cpp index 86e903cfe..b1dd73f20 100644 --- a/src/Model/PowerFlow/Generator4Param/Generator4Param.cpp +++ b/src/Model/PowerFlow/Generator4Param/Generator4Param.cpp @@ -1,9 +1,10 @@ #define _USE_MATH_DEFINES +#include "Generator4Param.hpp" + #include #include -#include "Generator4Param.hpp" #include namespace GridKit