Skip to content

Create phasor dynamics model data structures #115

New issue

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

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

Already on GitHub? Sign in to your account

Closed
Closed
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
4 changes: 2 additions & 2 deletions examples/PowerFlow/Grid3Bus/Grid3BusSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include <Model/PowerFlow/Bus/BusFactory.hpp>
#include <Model/PowerFlow/Generator/GeneratorFactory.hpp>
#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/SystemModelPowerFlow.hpp>
#include <PowerSystemData.hpp>
#include <Solver/SteadyState/Kinsol.hpp>
#include <Utilities/FileIO.hpp>
#include <Utilities/Testing.hpp>

static const std::string BUS3_DATA_STRING = R"(
Expand Down
2 changes: 1 addition & 1 deletion 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 <PowerSystemData.hpp>
#include <Model/PowerFlow/PowerSystemData.hpp>
#include <Utilities/Testing.hpp>

namespace
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
@@ -1,8 +1,8 @@
#include <iostream>

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

using namespace GridKit;
using namespace GridKit::Testing;
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
@@ -1,8 +1,8 @@
#include <iostream>

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

using namespace GridKit;
using namespace GridKit::Testing;
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
@@ -1,8 +1,8 @@
#include <iostream>

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

using namespace GridKit;
using namespace GridKit::Testing;
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
@@ -1,8 +1,8 @@
#include <iostream>

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

using namespace GridKit;
using namespace GridKit::Testing;
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
@@ -1,8 +1,8 @@
#include <iostream>

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

using namespace GridKit;
using namespace GridKit::Testing;
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 <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
38 changes: 16 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,21 @@ 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 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 +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
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 <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)
{
// std::cout << "Create Bus..." << std::endl;
// std::cout << "Number of equations is " << size_ << std::endl;
Expand Down
46 changes: 3 additions & 43 deletions src/Model/PhasorDynamics/Bus/Bus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Forward declaration of BusData structure
namespace GridKit
{
namespace PowerSystemData
namespace PhasorDynamics
{
template <typename RealT, typename IdxT>
struct BusData;
Expand Down Expand Up @@ -39,11 +39,11 @@ namespace GridKit

public:
using real_type = typename BusBase<ScalarT, IdxT>::real_type;
using BusData = GridKit::PowerSystemData::BusData<real_type, IdxT>;
using DataT = BusData<real_type, IdxT>;

Bus();
Bus(ScalarT Vr, ScalarT Vi);
Bus(BusData& data);
Bus(DataT& data);
virtual ~Bus();

virtual int allocate() override;
Expand Down Expand Up @@ -101,46 +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};
ScalarT Vi0_{0.0};
Expand Down
32 changes: 32 additions & 0 deletions src/Model/PhasorDynamics/Bus/BusData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @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 <typename RealT, typename IdxT>
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
};
} // namespace PhasorDynamics
} // namespace GridKit
10 changes: 5 additions & 5 deletions src/Model/PhasorDynamics/Bus/BusInfinite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cmath>
#include <iostream>

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

namespace GridKit
{
Expand Down Expand Up @@ -66,10 +66,10 @@ namespace GridKit
* @param[in] data - structure with bus data
*/
template <class ScalarT, typename IdxT>
BusInfinite<ScalarT, IdxT>::BusInfinite(BusData& data)
: BusBase<ScalarT, IdxT>(data.bus_i),
Vr_(data.Vm * cos(data.Va)),
Vi_(data.Vm * sin(data.Va))
BusInfinite<ScalarT, IdxT>::BusInfinite(DataT& data)
: BusBase<ScalarT, IdxT>(data.bus_id),
Vr_(data.Vr0),
Vi_(data.Vi0)
{
size_ = 0;
}
Expand Down
Loading
Loading