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
18 changes: 10 additions & 8 deletions GridKit/Model/Evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ namespace GridKit
{
}

virtual int allocate() = 0;
virtual int initialize() = 0;
virtual int tagDifferentiable() = 0;
virtual int evaluateResidual() = 0;
virtual int evaluateJacobian() = 0;
virtual int evaluateIntegrand() = 0;
virtual int allocate() = 0;
virtual int initialize() = 0;
virtual int tagDifferentiable() = 0;
virtual int setAbsoluteTolerance() = 0;
virtual int evaluateResidual() = 0;
virtual int evaluateJacobian() = 0;
virtual int evaluateIntegrand() = 0;

virtual int initializeAdjoint() = 0;
virtual int evaluateAdjointResidual() = 0;
Expand Down Expand Up @@ -94,8 +95,9 @@ namespace GridKit
virtual IdxT sizeQuadrature() = 0;
virtual IdxT sizeParams() = 0;
virtual void updateTime(RealT t, RealT a) = 0;
virtual void setTolerances(RealT& rtol, RealT& atol) const = 0;
virtual void setMaxSteps(IdxT& msa) const = 0;

virtual std::vector<ScalarT>& absoluteTolerance() = 0;
virtual const std::vector<ScalarT>& absoluteTolerance() const = 0;

virtual std::vector<ScalarT>& y() = 0;
virtual const std::vector<ScalarT>& y() const = 0;
Expand Down
1 change: 1 addition & 0 deletions GridKit/Model/PhasorDynamics/Branch/Branch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace GridKit
virtual int allocate() override;
virtual int initialize() override;
virtual int tagDifferentiable() override;
virtual int setAbsoluteTolerance() override;
virtual int evaluateResidual() override;
virtual int evaluateJacobian() override;

Expand Down
9 changes: 9 additions & 0 deletions GridKit/Model/PhasorDynamics/Branch/BranchImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ namespace GridKit
return 0;
}

/**
* @brief Set absolute tolerance
*/
template <class ScalarT, typename IdxT>
int Branch<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

/**
* @brief Bus 1 residual contribution from bus 1 variables
*
Expand Down
2 changes: 2 additions & 0 deletions GridKit/Model/PhasorDynamics/Bus/Bus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace GridKit
using BusBase<ScalarT, IdxT>::f_;
using BusBase<ScalarT, IdxT>::J_;
using BusBase<ScalarT, IdxT>::tag_;
using BusBase<ScalarT, IdxT>::absTol_;
using BusBase<ScalarT, IdxT>::variable_indices_;
using BusBase<ScalarT, IdxT>::residual_indices_;

Expand All @@ -41,6 +42,7 @@ namespace GridKit
virtual int setBusID(IdxT) override;
virtual int allocate() override;
virtual int tagDifferentiable() override;
virtual int setAbsoluteTolerance() override;
virtual int initialize() override;
virtual int evaluateResidual() override;
virtual int evaluateJacobian() override;
Expand Down
10 changes: 10 additions & 0 deletions GridKit/Model/PhasorDynamics/Bus/BusImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace GridKit
y_.resize(size);
yp_.resize(size);
tag_.resize(size);
absTol_.resize(size);

// Default variable and residual index mapping to local index
for (IdxT j = 0; j < size_; ++j)
Expand Down Expand Up @@ -118,6 +119,15 @@ namespace GridKit
return 0;
}

/**
* @brief Set absolute tolerance
*/
template <class ScalarT, typename IdxT>
int Bus<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

/*!
* @brief initialize method sets bus variables to stored initial values.
*/
Expand Down
1 change: 1 addition & 0 deletions GridKit/Model/PhasorDynamics/Bus/BusInfinite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace GridKit
virtual int setBusID(IdxT) override;
virtual int allocate() override;
virtual int tagDifferentiable() override;
virtual int setAbsoluteTolerance() override;
virtual int initialize() override;
virtual int evaluateResidual() override;
virtual int evaluateJacobian() override;
Expand Down
9 changes: 9 additions & 0 deletions GridKit/Model/PhasorDynamics/Bus/BusInfiniteImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ namespace GridKit
return 0;
}

/**
* \brief Specify absolute tolerance
*/
template <class ScalarT, typename IdxT>
int BusInfinite<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

/*!
* @brief initialize method sets bus variables to stored initial values.
*/
Expand Down
22 changes: 11 additions & 11 deletions GridKit/Model/PhasorDynamics/BusBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ namespace GridKit
// No time to update in bus models
}

virtual void setTolerances(RealT& rtol, RealT& atol) const override
{
rtol = rtol_;
atol = atol_;
}

virtual void setMaxSteps(IdxT& msa) const override
{
msa = max_steps_;
}

virtual ScalarT& Vr() = 0;
virtual const ScalarT& Vr() const = 0;
virtual ScalarT& Vi() = 0;
Expand Down Expand Up @@ -108,6 +97,16 @@ namespace GridKit
return tag_;
}

std::vector<ScalarT>& absoluteTolerance() override
{
return absTol_;
}

const std::vector<ScalarT>& absoluteTolerance() const override
{
return absTol_;
}

MatrixT& getJacobian() override
{
return J_;
Expand Down Expand Up @@ -175,6 +174,7 @@ namespace GridKit
std::vector<ScalarT> y_;
std::vector<ScalarT> yp_;
std::vector<bool> tag_;
std::vector<ScalarT> absTol_;
std::vector<ScalarT> f_;

MatrixT J_;
Expand Down
1 change: 1 addition & 0 deletions GridKit/Model/PhasorDynamics/BusFault/BusFault.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace GridKit
int allocate() override;
int initialize() override;
int tagDifferentiable() override;
int setAbsoluteTolerance() override;
int evaluateResidual() override;
int evaluateJacobian() override;

Expand Down
9 changes: 9 additions & 0 deletions GridKit/Model/PhasorDynamics/BusFault/BusFaultImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ namespace GridKit
return 0;
}

/**
* \brief Specify absolute tolerance
*/
template <class ScalarT, typename IdxT>
int BusFault<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

/**
* @brief Bus residual
*
Expand Down
12 changes: 5 additions & 7 deletions GridKit/Model/PhasorDynamics/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ namespace GridKit
// std::cout << "updateTime: t = " << time_ << "\n";
// }

virtual void setTolerances(RealT& rtol, RealT& atol) const override
std::vector<ScalarT>& absoluteTolerance() override
{
rtol = rel_tol_;
atol = abs_tol_;
return absTol_;
}

virtual void setMaxSteps(IdxT& msa) const override
const std::vector<ScalarT>& absoluteTolerance() const override
{
msa = max_steps_;
return absTol_;
}

std::vector<ScalarT>& y() override
Expand Down Expand Up @@ -161,6 +160,7 @@ namespace GridKit
std::vector<ScalarT> y_;
std::vector<ScalarT> yp_;
std::vector<bool> tag_;
std::vector<ScalarT> absTol_;
std::vector<ScalarT> f_;
std::vector<ScalarT> g_;
std::vector<ScalarT> wb_;
Expand All @@ -174,8 +174,6 @@ namespace GridKit
RealT rel_tol_;
RealT abs_tol_;

IdxT max_steps_;

/*

------ WARNING: Temporary ------
Expand Down
2 changes: 2 additions & 0 deletions GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace GridKit
using Component<ScalarT, IdxT>::nnz_;
using Component<ScalarT, IdxT>::size_;
using Component<ScalarT, IdxT>::tag_;
using Component<ScalarT, IdxT>::absTol_;
using Component<ScalarT, IdxT>::time_;
using Component<ScalarT, IdxT>::y_;
using Component<ScalarT, IdxT>::yp_;
Expand All @@ -97,6 +98,7 @@ namespace GridKit
int verify() const override;
int initialize() override;
int tagDifferentiable() override;
int setAbsoluteTolerance() override;
int evaluateResidual() override;
int evaluateJacobian() override;

Expand Down
10 changes: 10 additions & 0 deletions GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ namespace GridKit
y_.resize(size);
yp_.resize(size);
tag_.resize(size);
absTol_.resize(size);

// Default variable and residual index mapping to local index
for (IdxT j = 0; j < size_; ++j)
Expand Down Expand Up @@ -248,6 +249,15 @@ namespace GridKit
return 0;
}

/**
* @brief Set absolute tolerance
*/
template <class ScalarT, typename IdxT>
int Ieeet1<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

/**
* @brief Residuals of system equations
*
Expand Down
2 changes: 2 additions & 0 deletions GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace GridKit
using Component<ScalarT, IdxT>::nnz_;
using Component<ScalarT, IdxT>::size_;
using Component<ScalarT, IdxT>::tag_;
using Component<ScalarT, IdxT>::absTol_;
using Component<ScalarT, IdxT>::time_;
using Component<ScalarT, IdxT>::y_;
using Component<ScalarT, IdxT>::yp_;
Expand All @@ -86,6 +87,7 @@ namespace GridKit
int verify() const override;
int initialize() override;
int tagDifferentiable() override;
int setAbsoluteTolerance() override;
int evaluateResidual() override;

// Still to be implemented
Expand Down
10 changes: 10 additions & 0 deletions GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ namespace GridKit
y_.resize(size);
yp_.resize(size);
tag_.resize(size);
absTol_.resize(size_);

// Resize external variable data
ws_.resize(1);
Expand Down Expand Up @@ -229,6 +230,15 @@ namespace GridKit
return 0;
}

/**
* @brief Set absolute tolerance
*/
template <class ScalarT, typename IdxT>
int Tgov1<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

/**
* @brief Internal residuals
*
Expand Down
1 change: 1 addition & 0 deletions GridKit/Model/PhasorDynamics/Load/Load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace GridKit
virtual int allocate() override;
virtual int initialize() override;
virtual int tagDifferentiable() override;
virtual int setAbsoluteTolerance() override;
virtual int evaluateResidual() override;
virtual int evaluateJacobian() override;

Expand Down
9 changes: 9 additions & 0 deletions GridKit/Model/PhasorDynamics/Load/LoadImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ namespace GridKit
return 0;
}

/**
* @brief Set absolute tolerance
*/
template <class ScalarT, typename IdxT>
int Load<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

/**
* @brief Bus residual
*
Expand Down
23 changes: 12 additions & 11 deletions GridKit/Model/PhasorDynamics/SignalNode/SignalNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace GridKit
virtual int allocate() override;
virtual int initialize() override;
virtual int tagDifferentiable() override;
virtual int setAbsoluteTolerance() override;
virtual int evaluateResidual() override;
virtual int evaluateJacobian() override;

Expand Down Expand Up @@ -70,17 +71,6 @@ namespace GridKit
// No time to update in bus models
}

virtual void setTolerances(RealT& rtol, RealT& atol) const override
{
rtol = rtol_;
atol = atol_;
}

virtual void setMaxSteps(IdxT& msa) const override
{
msa = max_steps_;
}

std::vector<ScalarT>& y() override
{
return y_;
Expand Down Expand Up @@ -111,6 +101,16 @@ namespace GridKit
return tag_;
}

std::vector<ScalarT>& absoluteTolerance() override
{
return absTol_;
}

const std::vector<ScalarT>& absoluteTolerance() const override
{
return absTol_;
}

MatrixT& getJacobian() override
{
return J_;
Expand Down Expand Up @@ -140,6 +140,7 @@ namespace GridKit
std::vector<ScalarT> y_;
std::vector<ScalarT> yp_;
std::vector<bool> tag_;
std::vector<ScalarT> absTol_;
std::vector<ScalarT> f_;

MatrixT J_;
Expand Down
6 changes: 6 additions & 0 deletions GridKit/Model/PhasorDynamics/SignalNode/SignalNodeImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ namespace GridKit
return 0;
}

template <class ScalarT, typename IdxT>
int SignalNode<ScalarT, IdxT>::setAbsoluteTolerance()
{
return 0;
}

template <class ScalarT, typename IdxT>
int SignalNode<ScalarT, IdxT>::evaluateResidual()
{
Expand Down
Loading