Skip to content
Draft
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: 3 additions & 1 deletion GridKit/Model/Evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ namespace GridKit
* @brief Abstract class describing a model.
*
*/
template <class ScalarT, typename IdxT>
template <class scalar_type, typename index_type>
class Evaluator
{
public:
using ScalarT = scalar_type;
using IdxT = index_type;
using RealT = typename GridKit::ScalarTraits<ScalarT>::RealT;
using MatrixT = GridKit::LinearAlgebra::COO_Matrix<RealT, IdxT>; //\todo Use CsrMatrix
using CsrMatrixT = GridKit::LinearAlgebra::CsrMatrix<RealT, IdxT>;
Expand Down
6 changes: 2 additions & 4 deletions GridKit/Model/PhasorDynamics/Branch/Branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ namespace GridKit
/**
* @brief Jacobian evaluation not implemented
*
* @tparam ScalarT - scalar data type
* @tparam IdxT - matrix index data type
* @return int - error code, 0 = success
*/
template <class ScalarT, typename IdxT>
int Branch<ScalarT, IdxT>::evaluateJacobian()
template <typename scalar_type, typename index_type>
int Branch<scalar_type, index_type>::evaluateJacobian()
{
Log::misc() << "Evaluate Jacobian for Branch..." << std::endl;
Log::misc() << "Jacobian evaluation is not implemented!" << std::endl;
Expand Down
78 changes: 40 additions & 38 deletions GridKit/Model/PhasorDynamics/Branch/Branch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace GridKit
{
namespace PhasorDynamics
{
template <class ScalarT, typename IdxT>
template <typename scalar_type, typename index_type>
class BusBase;

template <typename RealT, typename IdxT>
template <typename real_type, typename index_type>
struct BranchData;
} // namespace PhasorDynamics
} // namespace GridKit
Expand All @@ -37,36 +37,38 @@ namespace GridKit
* direction is into the busses.
*
*/
template <class ScalarT, typename IdxT>
class Branch : public Component<ScalarT, IdxT>
template <typename scalar_type, typename index_type>
class Branch : public Component<scalar_type, index_type>
{
using Component<ScalarT, IdxT>::gridkit_component_id_;
using Component<ScalarT, IdxT>::size_;
using Component<ScalarT, IdxT>::nnz_;
using Component<ScalarT, IdxT>::time_;
using Component<ScalarT, IdxT>::alpha_;
using Component<ScalarT, IdxT>::y_;
using Component<ScalarT, IdxT>::yp_;
using Component<ScalarT, IdxT>::tag_;
using Component<ScalarT, IdxT>::f_;
using Component<ScalarT, IdxT>::wb_;
using Component<ScalarT, IdxT>::h_;
using Component<ScalarT, IdxT>::J_;
using Component<ScalarT, IdxT>::J_rows_buffer_;
using Component<ScalarT, IdxT>::J_cols_buffer_;
using Component<ScalarT, IdxT>::J_vals_buffer_;
using Component<ScalarT, IdxT>::variable_indices_;
using Component<ScalarT, IdxT>::residual_indices_;
using Component<scalar_type, index_type>::gridkit_component_id_;
using Component<scalar_type, index_type>::size_;
using Component<scalar_type, index_type>::nnz_;
using Component<scalar_type, index_type>::time_;
using Component<scalar_type, index_type>::alpha_;
using Component<scalar_type, index_type>::y_;
using Component<scalar_type, index_type>::yp_;
using Component<scalar_type, index_type>::tag_;
using Component<scalar_type, index_type>::f_;
using Component<scalar_type, index_type>::wb_;
using Component<scalar_type, index_type>::h_;
using Component<scalar_type, index_type>::J_;
using Component<scalar_type, index_type>::J_rows_buffer_;
using Component<scalar_type, index_type>::J_cols_buffer_;
using Component<scalar_type, index_type>::J_vals_buffer_;
using Component<scalar_type, index_type>::variable_indices_;
using Component<scalar_type, index_type>::residual_indices_;

public:
using RealT = typename Component<ScalarT, IdxT>::RealT;
using bus_type = BusBase<ScalarT, IdxT>;
using model_data_type = BranchData<RealT, IdxT>;
using MonitorT = Model::VariableMonitor<Branch, BranchData>;

Branch(bus_type* bus1, bus_type* bus2);
Branch(bus_type* bus1, bus_type* bus2, RealT R, RealT X, RealT G, RealT B);
Branch(bus_type* bus1, bus_type* bus2, const model_data_type& data);
using ScalarT = scalar_type;
using IdxT = index_type;
using RealT = typename Component<ScalarT, IdxT>::RealT;
using BusT = BusBase<ScalarT, IdxT>;
using ModelDataT = BranchData<RealT, IdxT>;
using MonitorT = Model::VariableMonitor<Branch, BranchData>;

Branch(BusT* bus1, BusT* bus2);
Branch(BusT* bus1, BusT* bus2, RealT R, RealT X, RealT G, RealT B);
Branch(BusT* bus1, BusT* bus2, const ModelDataT& data);
virtual ~Branch();

virtual int setGridKitComponentID(IdxT) override final;
Expand Down Expand Up @@ -109,7 +111,7 @@ namespace GridKit
const Model::VariableMonitorBase* getMonitor() const override;

private:
void initializeParameters(const model_data_type& data);
void initializeParameters(const ModelDataT& data);
void initializeMonitor();
void setDerivedParams();

Expand Down Expand Up @@ -160,14 +162,14 @@ namespace GridKit
__attribute__((always_inline)) inline int evaluateBusResidual22(ScalarT*, ScalarT*, ScalarT*, ScalarT*);

private:
bus_type* bus1_;
bus_type* bus2_;
RealT R_{0.0};
RealT X_{0.0};
RealT G_{0.0};
RealT B_{0.0};
IdxT bus1_id_{0};
IdxT bus2_id_{0};
BusT* bus1_;
BusT* bus2_;
RealT R_{0.0};
RealT X_{0.0};
RealT G_{0.0};
RealT B_{0.0};
IdxT bus1_id_{0};
IdxT bus2_id_{0};

/* Derived parameters */
RealT b_;
Expand Down
10 changes: 5 additions & 5 deletions GridKit/Model/PhasorDynamics/Branch/BranchData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ namespace GridKit
/**
* @brief Contains modeling data for a Branch
*
* @tparam RealT Real parameter data type
* @tparam IdxT Integer parameter data type
* @tparam real_type Real parameter data type
* @tparam index_type Integer parameter data type
*
* Integer parameters are of the same type as matrix and vector indices.
*/
template <typename RealT, typename IdxT>
struct BranchData : public ComponentData<RealT,
IdxT,
template <typename real_type, typename index_type>
struct BranchData : public ComponentData<real_type,
index_type,
BranchParameters,
BranchPorts,
BranchMonitorableVariables>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ namespace GridKit
/**
* @brief Jacobian evaluation not implemented
*
* @tparam ScalarT - scalar data type
* @tparam IdxT - matrix index data type
* @return int - error code, 0 = success
*/
template <class ScalarT, typename IdxT>
int Branch<ScalarT, IdxT>::evaluateJacobian()
template <typename scalar_type, typename index_type>
int Branch<scalar_type, index_type>::evaluateJacobian()
{
Log::misc() << "Evaluate Jacobian for Branch..." << std::endl;
Log::misc() << "Jacobian evaluation is not implemented!" << std::endl;
Expand Down
6 changes: 2 additions & 4 deletions GridKit/Model/PhasorDynamics/Branch/BranchEnzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ namespace GridKit
/**
* @brief Jacobian evaluation experimental
*
* @tparam ScalarT - scalar data type
* @tparam IdxT - matrix index data type
* @return int - error code, 0 = success
*/
template <class ScalarT, typename IdxT>
int Branch<ScalarT, IdxT>::evaluateJacobian()
template <typename scalar_type, typename index_type>
int Branch<scalar_type, index_type>::evaluateJacobian()
{
Log::misc() << "Evaluate Jacobian for Branch..." << std::endl;
Log::misc() << "Jacobian evaluation is experimental!" << std::endl;
Expand Down
Loading
Loading