Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- Remove data copying between system and components in `PowerElectronics` models.
- Added multi-contingency analysis application.
- Added `BusToSignalAdapter` component for communicating bus voltages and injection currents.
- Added support for running IDA with fixed time steps

## v0.1

Expand Down
48 changes: 37 additions & 11 deletions GridKit/Model/Evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,23 @@ 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;
/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
virtual int setAbsoluteTolerance(RealT rel_tol) = 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 @@ -103,11 +114,26 @@ namespace GridKit
*/
virtual bool hasJacobian() = 0;

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 IdxT sizeQuadrature() = 0;
virtual IdxT sizeParams() = 0;
virtual void updateTime(RealT t, RealT a) = 0;

/**
* @brief Get the absolute tolerance for each variable in the model
*
* @return a reference to the absolute tolerance vector.
*
* @pre `setAbsoluteTolerance` must have been called first.
*/
virtual std::vector<ScalarT>& absoluteTolerance() = 0;
/**
* @brief Get the absolute tolerance for each variable in the model
*
* @return a const reference to the absolute tolerance vector.
*
* @pre `setAbsoluteTolerance` must have been called first.
*/
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 @@ -73,6 +73,7 @@ namespace GridKit
virtual int allocate() override final;
virtual int initialize() override final;
virtual int tagDifferentiable() override final;
virtual int setAbsoluteTolerance(RealT rel_tol) override final;
virtual int evaluateResidual() override final;
virtual int evaluateJacobian() override final;

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

/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @tparam ScalarT Scalar data type
* @tparam IdxT Index data type
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
template <class ScalarT, typename IdxT>
int Branch<ScalarT, IdxT>::setAbsoluteTolerance(RealT)
{
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 @@ -28,6 +28,7 @@ namespace GridKit
using BusBase<ScalarT, IdxT>::J_cols_buffer_;
using BusBase<ScalarT, IdxT>::J_vals_buffer_;
using BusBase<ScalarT, IdxT>::tag_;
using BusBase<ScalarT, IdxT>::abs_tol_;
using BusBase<ScalarT, IdxT>::variable_indices_;
using BusBase<ScalarT, IdxT>::residual_indices_;

Expand All @@ -44,6 +45,7 @@ namespace GridKit
virtual int setBusID(IdxT) override final;
virtual int allocate() override final;
virtual int tagDifferentiable() override final;
virtual int setAbsoluteTolerance(RealT rel_tol) override final;
virtual int initialize() override final;
virtual int evaluateResidual() override final;
virtual int evaluateJacobian() override final;
Expand Down
20 changes: 20 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);
abs_tol_.resize(size);
variable_indices_.resize(size);
residual_indices_.resize(size);

Expand Down Expand Up @@ -120,6 +121,25 @@ namespace GridKit
return 0;
}

/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @tparam ScalarT Scalar data type
* @tparam IdxT Index data type
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
template <class ScalarT, typename IdxT>
int Bus<ScalarT, IdxT>::setAbsoluteTolerance(RealT rel_tol)
{
std::fill(abs_tol_.begin(), abs_tol_.end(), rel_tol);
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 @@ -38,6 +38,7 @@ namespace GridKit
virtual int setBusID(IdxT) override final;
virtual int allocate() override final;
virtual int tagDifferentiable() override final;
virtual int setAbsoluteTolerance(RealT rel_tol) override final;
virtual int initialize() override final;
virtual int evaluateResidual() override final;
virtual int evaluateJacobian() override final;
Expand Down
18 changes: 18 additions & 0 deletions GridKit/Model/PhasorDynamics/Bus/BusInfiniteImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ namespace GridKit
return 0;
}

/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @tparam ScalarT Scalar data type
* @tparam IdxT Index data type
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
template <class ScalarT, typename IdxT>
int BusInfinite<ScalarT, IdxT>::setAbsoluteTolerance(RealT)
{
return 0;
}

/*!
* @brief initialize method sets bus variables to stored initial values.
*/
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 @@ -52,6 +52,7 @@ namespace GridKit
int allocate() override final;
int initialize() override final;
int tagDifferentiable() override final;
int setAbsoluteTolerance(RealT rel_tol) override final;
int evaluateResidual() override final;
int evaluateJacobian() override final;

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

/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @tparam ScalarT Scalar data type
* @tparam IdxT Index data type
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
template <class ScalarT, typename IdxT>
int BusFault<ScalarT, IdxT>::setAbsoluteTolerance(RealT)
{
return 0;
}

/**
* @brief Bus residual
*
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 @@ -73,6 +73,7 @@ namespace GridKit
using Component<ScalarT, IdxT>::nnz_;
using Component<ScalarT, IdxT>::size_;
using Component<ScalarT, IdxT>::tag_;
using Component<ScalarT, IdxT>::abs_tol_;
using Component<ScalarT, IdxT>::time_;
using Component<ScalarT, IdxT>::y_;
using Component<ScalarT, IdxT>::yp_;
Expand Down Expand Up @@ -105,6 +106,7 @@ namespace GridKit
int verify() const override final;
int initialize() override final;
int tagDifferentiable() override final;
int setAbsoluteTolerance(RealT rel_tol) override final;
int evaluateResidual() override final;
int evaluateJacobian() override final;

Expand Down
20 changes: 20 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);
abs_tol_.resize(size);
variable_indices_.resize(size);
residual_indices_.resize(size);

Expand Down Expand Up @@ -283,6 +284,25 @@ namespace GridKit
return 0;
}

/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @tparam ScalarT Scalar data type
* @tparam IdxT Index data type
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
template <class ScalarT, typename IdxT>
int Ieeet1<ScalarT, IdxT>::setAbsoluteTolerance(RealT rel_tol)
{
std::fill(abs_tol_.begin(), abs_tol_.end(), rel_tol);
return 0;
}

/**
* @brief Internal Residual
*
Expand Down
2 changes: 2 additions & 0 deletions GridKit/Model/PhasorDynamics/Exciter/SEXS-PTI/SexsPti.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace GridKit
using Component<ScalarT, IdxT>::nnz_;
using Component<ScalarT, IdxT>::size_;
using Component<ScalarT, IdxT>::tag_;
using Component<ScalarT, IdxT>::abs_tol_;
using Component<ScalarT, IdxT>::time_;
using Component<ScalarT, IdxT>::y_;
using Component<ScalarT, IdxT>::yp_;
Expand Down Expand Up @@ -87,6 +88,7 @@ namespace GridKit
int verify() const override final;
int initialize() override final;
int tagDifferentiable() override final;
int setAbsoluteTolerance(RealT rel_tol) override final;
int evaluateResidual() override final;
int evaluateJacobian() override final;

Expand Down
20 changes: 20 additions & 0 deletions GridKit/Model/PhasorDynamics/Exciter/SEXS-PTI/SexsPtiImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace GridKit
y_.resize(size);
yp_.resize(size);
tag_.resize(size);
abs_tol_.resize(size);
variable_indices_.resize(size);
residual_indices_.resize(size);

Expand Down Expand Up @@ -180,6 +181,25 @@ namespace GridKit
return 0;
}

/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @tparam ScalarT Scalar data type
* @tparam IdxT Index data type
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
template <class ScalarT, typename IdxT>
int SexsPti<ScalarT, IdxT>::setAbsoluteTolerance(RealT rel_tol)
{
std::fill(abs_tol_.begin(), abs_tol_.end(), rel_tol);
return 0;
}

template <class ScalarT, typename IdxT>
__attribute__((always_inline)) inline int SexsPti<ScalarT, IdxT>::evaluateInternalResidual(
ScalarT* y,
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>::abs_tol_;
using Component<ScalarT, IdxT>::time_;
using Component<ScalarT, IdxT>::y_;
using Component<ScalarT, IdxT>::yp_;
Expand Down Expand Up @@ -91,6 +92,7 @@ namespace GridKit
int verify() const override final;
int initialize() override final;
int tagDifferentiable() override final;
int setAbsoluteTolerance(RealT) override final;
int evaluateResidual() override final;

// Still to be implemented
Expand Down
20 changes: 20 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);
abs_tol_.resize(size);
variable_indices_.resize(size);
residual_indices_.resize(size);

Expand Down Expand Up @@ -232,6 +233,25 @@ namespace GridKit
return 0;
}

/**
* @brief Compute the absolute tolerance for each variable in the model
*
* @param rel_tol The relative tolerance which can be used to pick the
* absolute tolerance.
* @tparam ScalarT Scalar data type
* @tparam IdxT Index data type
* @return int 0 if successful, non-zero otherwise.
*
* This represents a "noise" level close to zero for which pure relative
* error cannot be used.
*/
template <class ScalarT, typename IdxT>
int Tgov1<ScalarT, IdxT>::setAbsoluteTolerance(RealT rel_tol)
{
std::fill(abs_tol_.begin(), abs_tol_.end(), rel_tol);
return 0;
}

/**
* @brief Internal residuals
*
Expand Down
Loading
Loading