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: 2 additions & 2 deletions GridKit/AutomaticDifferentiation/Enzyme/ModelWrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace GridKit
const ScalarT* wb,
ScalarT* f)
{
model->evaluateInternalResidual(y, yp, wb, f);
model->evaluateInternalResidualKernel(y, yp, wb, f);
}
};

Expand Down Expand Up @@ -91,7 +91,7 @@ namespace GridKit
const ScalarT* ws,
ScalarT* f)
{
model->evaluateInternalResidual(y, yp, wb, ws, f);
model->evaluateInternalResidualKernel(y, yp, wb, ws, f);
}
};

Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/BusFault/BusFault.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace GridKit
public:
__attribute__((always_inline)) inline int evaluateBusResidual(
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);

private:
Expand Down
6 changes: 3 additions & 3 deletions GridKit/Model/PhasorDynamics/BusFault/BusFaultImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ namespace GridKit
*
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) int BusFault<scalar_type, index_type>::evaluateInternalResidual(
__attribute__((always_inline)) int BusFault<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
[[maybe_unused]] const ScalarT* yp,
const ScalarT* wb,
Expand Down Expand Up @@ -259,7 +259,7 @@ namespace GridKit
const auto* y = y_.getData();
const auto* yp = yp_.getData();
auto* f = f_.getData();
evaluateInternalResidual(y, yp, wb_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), f);
evaluateBusResidual(y, yp, wb_.data(), h_.data());
Ir() += h_[0];
Ii() += h_[1];
Expand All @@ -275,7 +275,7 @@ namespace GridKit
const auto* y = y_.getData();
const auto* yp = yp_.getData();
auto* f = f_.getData();
evaluateInternalResidual(y, yp, wb_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), f);
}

f_.setDataUpdated();
Expand Down
20 changes: 20 additions & 0 deletions GridKit/Model/PhasorDynamics/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ namespace GridKit

virtual int verify() const = 0;

/**
* @brief Evaluate this component's internal residual.
*
* The default preserves the existing single-phase residual evaluation
* for components that have not yet separated internal and external
* residuals.
*/
virtual int evaluateInternalResidual()
{
return this->evaluateResidual();
}

/**
* @brief Evaluate contributions to residuals owned elsewhere.
*/
virtual int evaluateExternalResidual()
{
return 0;
}

IdxT size() override final
{
return size_;
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Controller/REECB/Reecb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

[[gnu::always_inline]] inline int evaluateInternalResidual(
[[gnu::always_inline]] inline int evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Controller/REECB/ReecbImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ namespace GridKit
wb_[0] = Vr();
wb_[1] = Vi();

evaluateInternalResidual(y_.getData(), yp_.getData(), wb_.data(), ws_.data(), f_.getData());
evaluateInternalResidualKernel(y_.getData(), yp_.getData(), wb_.data(), ws_.data(), f_.getData());
f_.setDataUpdated();
return 0;
}
Expand Down Expand Up @@ -895,7 +895,7 @@ namespace GridKit
*/
template <typename scalar_type, typename index_type>
[[gnu::always_inline]] inline int
Reecb<scalar_type, index_type>::evaluateInternalResidual(
Reecb<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Controller/REPCA/Repca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

[[gnu::always_inline]] inline int evaluateInternalResidual(
[[gnu::always_inline]] inline int evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Controller/REPCA/RepcaImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ namespace GridKit
const auto* yp = yp_.getData();
auto* f = f_.getData();

evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);
f_.setDataUpdated();
return 0;
}
Expand Down Expand Up @@ -723,7 +723,7 @@ namespace GridKit
*/
template <typename scalar_type, typename index_type>
[[gnu::always_inline]] inline int
Repca<scalar_type, index_type>::evaluateInternalResidual(
Repca<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Converter/REGCA/Regca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT* y, const ScalarT* yp, const ScalarT* wb, const ScalarT* ws, ScalarT* f);

__attribute__((always_inline)) inline int evaluateBusResidual(
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Converter/REGCA/RegcaImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ namespace GridKit
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) inline int
Regca<scalar_type, index_type>::evaluateInternalResidual(
Regca<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down Expand Up @@ -754,7 +754,7 @@ namespace GridKit
const auto* yp = yp_.getData();
auto* f = f_.getData();

evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);
evaluateBusResidual(y, yp, wb_.data(), h_.data());
f_.setDataUpdated();

Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1aImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ namespace GridKit
const auto* yp = yp_.getData();
auto* f = f_.getData();

evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);
f_.setDataUpdated();
return 0;
}
Expand Down Expand Up @@ -527,7 +527,7 @@ namespace GridKit
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) inline int
Esdc1a<scalar_type, index_type>::evaluateInternalResidual(
Esdc1a<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT*, const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);

private:
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ namespace GridKit
*
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) inline int Ieeet1<scalar_type, index_type>::evaluateInternalResidual(
__attribute__((always_inline)) inline int Ieeet1<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down Expand Up @@ -416,7 +416,7 @@ namespace GridKit
const auto* y = y_.getData();
const auto* yp = yp_.getData();
auto* f = f_.getData();
evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);

f_.setDataUpdated();

Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Exciter/SEXS-PTI/SexsPti.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT*, const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);

private:
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Exciter/SEXS-PTI/SexsPtiImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace GridKit
}

template <typename scalar_type, typename index_type>
__attribute__((always_inline)) inline int SexsPti<scalar_type, index_type>::evaluateInternalResidual(
__attribute__((always_inline)) inline int SexsPti<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down Expand Up @@ -253,7 +253,7 @@ namespace GridKit
const auto* y = y_.getData();
const auto* yp = yp_.getData();
auto* f = f_.getData();
evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);

f_.setDataUpdated();

Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPti.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

[[gnu::always_inline]] inline int evaluateInternalResidual(
[[gnu::always_inline]] inline int evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPtiImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ namespace GridKit
const auto* yp = yp_.getData();
auto* f = f_.getData();

evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);
f_.setDataUpdated();
return 0;
}
Expand Down Expand Up @@ -533,7 +533,7 @@ namespace GridKit
*/
template <typename scalar_type, typename index_type>
[[gnu::always_inline]] inline int
GastPti<scalar_type, index_type>::evaluateInternalResidual(
GastPti<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Governor/HYGOV/Hygov.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
const ScalarT* wb,
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Governor/HYGOV/HygovImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ namespace GridKit
const auto* yp = yp_.getData();
auto* f = f_.getData();

evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);
f_.setDataUpdated();
return 0;
}
Expand Down Expand Up @@ -567,7 +567,7 @@ namespace GridKit
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) inline int
Hygov<scalar_type, index_type>::evaluateInternalResidual(
Hygov<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
[[maybe_unused]] const ScalarT* wb,
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace GridKit
}

public:
__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT*, const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);

private:
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ namespace GridKit
*
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) inline int Tgov1<scalar_type, index_type>::evaluateInternalResidual(
__attribute__((always_inline)) inline int Tgov1<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
const ScalarT* yp,
[[maybe_unused]] const ScalarT* wb,
Expand Down Expand Up @@ -412,7 +412,7 @@ namespace GridKit
const auto* y = y_.getData();
const auto* yp = yp_.getData();
auto* f = f_.getData();
evaluateInternalResidual(y, yp, wb_.data(), ws_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), ws_.data(), f);

f_.setDataUpdated();

Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Load/LoadZ/LoadZ.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace GridKit
public:
__attribute__((always_inline)) inline int evaluateBusResidual(
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);

private:
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Load/LoadZ/LoadZImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace GridKit
*
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) int LoadZ<scalar_type, index_type>::evaluateInternalResidual(
__attribute__((always_inline)) int LoadZ<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
[[maybe_unused]] const ScalarT* yp,
const ScalarT* wb,
Expand Down Expand Up @@ -218,7 +218,7 @@ namespace GridKit
const auto* y = y_.getData();
const auto* yp = yp_.getData();
auto* f = f_.getData();
evaluateInternalResidual(y, yp, wb_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), f);
evaluateBusResidual(y, yp, wb_.data(), h_.data());
Ir() += h_[0];
Ii() += h_[1];
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Load/LoadZIP/LoadZIP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace GridKit
public:
__attribute__((always_inline)) inline int evaluateBusResidual(
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);

private:
Expand Down
4 changes: 2 additions & 2 deletions GridKit/Model/PhasorDynamics/Load/LoadZIP/LoadZIPImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ namespace GridKit
const auto* y = y_.getData();
const auto* yp = yp_.getData();
auto* f = f_.getData();
evaluateInternalResidual(y, yp, wb_.data(), f);
evaluateInternalResidualKernel(y, yp, wb_.data(), f);
evaluateBusResidual(y, yp, wb_.data(), h_.data());
Ir() += h_[0];
Ii() += h_[1];
Expand All @@ -236,7 +236,7 @@ namespace GridKit
*
*/
template <typename scalar_type, typename index_type>
__attribute__((always_inline)) int LoadZIP<scalar_type, index_type>::evaluateInternalResidual(
__attribute__((always_inline)) int LoadZIP<scalar_type, index_type>::evaluateInternalResidualKernel(
const ScalarT* y,
[[maybe_unused]] const ScalarT* yp,
const ScalarT* wb,
Expand Down
2 changes: 1 addition & 1 deletion GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/Ieeest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace GridKit

const Model::VariableMonitorBase* getMonitor() const override;

__attribute__((always_inline)) inline int evaluateInternalResidual(
__attribute__((always_inline)) inline int evaluateInternalResidualKernel(
const ScalarT*,
const ScalarT*,
const ScalarT*,
Expand Down
Loading
Loading