Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <Model/PowerFlow/Load/Load.hpp>
#include <Model/PowerFlow/MatpowerParser.hpp>
#include <Model/PowerFlow/MiniGrid/MiniGrid.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>
#include <Model/PowerFlow/SystemModelPowerFlow.hpp>
#include <Solver/SteadyState/Kinsol.hpp>
#include <Utilities/Testing.hpp>
Expand Down Expand Up @@ -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.]
Expand Down Expand Up @@ -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<double, size_t> mp;
GridKit::PowerFlowData::SystemModelData<double, size_t> mp;

std::istringstream iss(BUS3_DATA_STRING);
GridKit::readMatPower(mp, iss);
Expand Down
36 changes: 18 additions & 18 deletions examples/PowerFlow/MatPowerTesting/MatPowerTesting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <limits>
#include <vector>

#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>
#include <Utilities/Testing.hpp>

namespace
Expand All @@ -34,9 +34,9 @@ namespace GridKit
{

template <typename RealT = double, typename IdxT = int>
inline bool isEqual(PowerSystemData::GenCostData<RealT, IdxT> a,
PowerSystemData::GenCostData<RealT, IdxT> b,
RealT tol = tol_)
inline bool isEqual(PowerFlowData::GenCostData<RealT, IdxT> a,
PowerFlowData::GenCostData<RealT, IdxT> b,
RealT tol = tol_)
{
(void) tol; // suppress warning
int fail = 0;
Expand All @@ -52,9 +52,9 @@ namespace GridKit
}

template <typename RealT = double, typename IdxT = int>
inline bool isEqual(PowerSystemData::GenData<RealT, IdxT> a,
PowerSystemData::GenData<RealT, IdxT> b,
RealT tol = tol_)
inline bool isEqual(PowerFlowData::GenData<RealT, IdxT> a,
PowerFlowData::GenData<RealT, IdxT> b,
RealT tol = tol_)
{
int fail = 0;

Expand Down Expand Up @@ -88,9 +88,9 @@ namespace GridKit
}

template <typename RealT = double, typename IdxT = int>
inline bool isEqual(PowerSystemData::BusData<RealT, IdxT> a,
PowerSystemData::BusData<RealT, IdxT> b,
RealT tol = tol_)
inline bool isEqual(PowerFlowData::BusData<RealT, IdxT> a,
PowerFlowData::BusData<RealT, IdxT> b,
RealT tol = tol_)
{
int fail = 0;

Expand Down Expand Up @@ -124,9 +124,9 @@ namespace GridKit
}

template <typename RealT = double, typename IdxT = int>
inline bool isEqual(PowerSystemData::LoadData<RealT, IdxT> a,
PowerSystemData::LoadData<RealT, IdxT> b,
RealT tol = tol_)
inline bool isEqual(PowerFlowData::LoadData<RealT, IdxT> a,
PowerFlowData::LoadData<RealT, IdxT> b,
RealT tol = tol_)
{
int fail = 0;

Expand All @@ -144,9 +144,9 @@ namespace GridKit
}

template <typename RealT = double, typename IdxT = int>
inline bool isEqual(PowerSystemData::BranchData<RealT, IdxT> a,
PowerSystemData::BranchData<RealT, IdxT> b,
RealT tol = tol_)
inline bool isEqual(PowerFlowData::BranchData<RealT, IdxT> a,
PowerFlowData::BranchData<RealT, IdxT> b,
RealT tol = tol_)
{
int fail = 0;

Expand Down Expand Up @@ -197,8 +197,8 @@ namespace GridKit
}

template <typename RealT = double, typename IdxT = int>
inline bool isEqual(PowerSystemData::SystemModelData<RealT, IdxT> a,
PowerSystemData::SystemModelData<RealT, IdxT> b)
inline bool isEqual(PowerFlowData::SystemModelData<RealT, IdxT> a,
PowerFlowData::SystemModelData<RealT, IdxT> b)
{
int fail = 0;

Expand Down
4 changes: 2 additions & 2 deletions examples/PowerFlow/MatPowerTesting/test_parse_branch_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "MatPowerTesting.hpp"
#include <Model/PowerFlow/MatpowerParser.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>

using namespace GridKit;
using namespace GridKit::Testing;
using namespace GridKit::PowerSystemData;
using namespace GridKit::PowerFlowData;

namespace
{
Expand Down
4 changes: 2 additions & 2 deletions examples/PowerFlow/MatPowerTesting/test_parse_bus_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "MatPowerTesting.hpp"
#include <Model/PowerFlow/MatpowerParser.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>

using namespace GridKit;
using namespace GridKit::Testing;
using namespace GridKit::PowerSystemData;
using namespace GridKit::PowerFlowData;

namespace
{
Expand Down
4 changes: 2 additions & 2 deletions examples/PowerFlow/MatPowerTesting/test_parse_gen_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "MatPowerTesting.hpp"
#include <Model/PowerFlow/MatpowerParser.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>

using namespace GridKit;
using namespace GridKit::Testing;
using namespace GridKit::PowerSystemData;
using namespace GridKit::PowerFlowData;

namespace
{
Expand Down
4 changes: 2 additions & 2 deletions examples/PowerFlow/MatPowerTesting/test_parse_gencost_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "MatPowerTesting.hpp"
#include <Model/PowerFlow/MatpowerParser.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>

using namespace GridKit;
using namespace GridKit::Testing;
using namespace GridKit::PowerSystemData;
using namespace GridKit::PowerFlowData;

namespace
{
Expand Down
4 changes: 2 additions & 2 deletions examples/PowerFlow/MatPowerTesting/test_parse_matpower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "MatPowerTesting.hpp"
#include <Model/PowerFlow/MatpowerParser.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PowerFlow/PowerFlowData.hpp>

using namespace GridKit;
using namespace GridKit::Testing;
using namespace GridKit::PowerSystemData;
using namespace GridKit::PowerFlowData;

namespace
{
Expand Down
24 changes: 12 additions & 12 deletions src/Model/PhasorDynamics/Branch/Branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <cmath>
#include <iostream>

#include <Model/PhasorDynamics/Branch/BranchData.hpp>
#include <Model/PhasorDynamics/Bus/Bus.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>

namespace GridKit
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -67,21 +67,21 @@ namespace GridKit
X_(X),
G_(G),
B_(B),
bus1ID_(0),
bus2ID_(0)
bus1_id_(0),
bus2_id_(0)
{
}

template <class ScalarT, typename IdxT>
Branch<ScalarT, IdxT>::Branch(bus_type* bus1, bus_type* bus2, BranchData& data)
Branch<ScalarT, IdxT>::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),
bus1ID_(data.fbus),
bus2ID_(data.tbus)
R_(data.R),
X_(data.X),
G_(data.G),
B_(data.B),
bus1_id_(data.bus1_id),
bus2_id_(data.bus2_id)
{
size_ = 0;
}
Expand Down
32 changes: 10 additions & 22 deletions src/Model/PhasorDynamics/Branch/Branch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,16 @@
#include <Model/PhasorDynamics/Component.hpp>

// Forward declarations.
namespace GridKit
{
namespace PowerSystemData
{
template <typename RealT, typename IdxT>
struct BranchData;
}
} // namespace GridKit

namespace GridKit
{
namespace PhasorDynamics
{
template <class ScalarT, typename IdxT>
class BusBase;
}

template <typename RealT, typename IdxT>
struct BranchData;
} // namespace PhasorDynamics
} // namespace GridKit

namespace GridKit
Expand All @@ -51,21 +45,15 @@ namespace GridKit
using Component<ScalarT, IdxT>::yp_;
using Component<ScalarT, IdxT>::tag_;
using Component<ScalarT, IdxT>::f_;
using Component<ScalarT, IdxT>::g_;
using Component<ScalarT, IdxT>::yB_;
using Component<ScalarT, IdxT>::ypB_;
using Component<ScalarT, IdxT>::fB_;
using Component<ScalarT, IdxT>::gB_;
using Component<ScalarT, IdxT>::param_;

using bus_type = BusBase<ScalarT, IdxT>;
using real_type = typename Component<ScalarT, IdxT>::real_type;
using BranchData = GridKit::PowerSystemData::BranchData<real_type, IdxT>;
using real_type = typename Component<ScalarT, IdxT>::real_type;
using bus_type = BusBase<ScalarT, IdxT>;
using model_data_type = BranchData<real_type, IdxT>;

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;
Expand Down Expand Up @@ -154,8 +142,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
Expand Down
35 changes: 35 additions & 0 deletions src/Model/PhasorDynamics/Branch/BranchData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @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 <typename RealT, typename IdxT>
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 bus1_id{0}; ///< Unique ID of bus 1
IdxT bus2_id{0}; ///< Unique ID of bus 2
};
} // namespace PhasorDynamics
} // namespace GridKit
10 changes: 5 additions & 5 deletions src/Model/PhasorDynamics/Bus/Bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cmath>
#include <iostream>

#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Model/PhasorDynamics/Bus/BusData.hpp>

namespace GridKit
{
Expand Down Expand Up @@ -61,10 +61,10 @@ namespace GridKit
* @param[in] data - structure with bus data
*/
template <class ScalarT, typename IdxT>
Bus<ScalarT, IdxT>::Bus(BusData& data)
: BusBase<ScalarT, IdxT>(data.bus_i),
Vr0_(data.Vm * cos(data.Va)),
Vi0_(data.Vm * sin(data.Va))
Bus<ScalarT, IdxT>::Bus(DataT& data)
: BusBase<ScalarT, IdxT>(data.bus_id),
Vr0_(data.Vr0),
Vi0_(data.Vi0)
Comment thread
pelesh marked this conversation as resolved.
{
// std::cout << "Create Bus..." << std::endl;
// std::cout << "Number of equations is " << size_ << std::endl;
Expand Down
Loading