Skip to content
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

Draft: Aligning the code with contributing guidelines #42

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
5 changes: 3 additions & 2 deletions CircuitGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ size_t CircuitGraph<N, E>::amountHyperEdges()
}

/**
* @brief Printing
* @brief Print the bipartite graph
*
* @todo need to add verbose printing for connections display
*
* @tparam IdxT
* @param verbose
* @param[in] verbose if true will print connections,
* otherwise just the number of nodes and edges
*/

template <typename N, typename E>
Expand Down
6 changes: 3 additions & 3 deletions ComponentLib/PowerElectronics/Capacitor/Capacitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ int Capacitor<ScalarT, IdxT>::evaluateResidual()
template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::evaluateJacobian()
{
J_.zeroMatrix();
jac_.zeroMatrix();
//Create dF/dy
std::vector<IdxT> rcord{2,2,2};
std::vector<IdxT> ccord{0,1,2};
std::vector<ScalarT> vals{1.0, -1.0, -1.0};
J_.setValues(rcord, ccord, vals);
jac_.setValues(rcord, ccord, vals);

//Create dF/dy'
std::vector<IdxT> rcordder{0,1,2};
Expand All @@ -104,7 +104,7 @@ int Capacitor<ScalarT, IdxT>::evaluateJacobian()
COO_Matrix<ScalarT,IdxT> Jacder = COO_Matrix<ScalarT, IdxT>(rcordder, ccordder, valsder,3,3);

//Perform dF/dy + \alpha dF/dy'
J_.axpy(alpha_, Jacder);
jac_.axpy(alpha_, Jacder);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion ComponentLib/PowerElectronics/Capacitor/Capacitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ModelLib
using CircuitComponent<ScalarT, IdxT>::ypB_;
using CircuitComponent<ScalarT, IdxT>::fB_;
using CircuitComponent<ScalarT, IdxT>::gB_;
using CircuitComponent<ScalarT, IdxT>::J_;
using CircuitComponent<ScalarT, IdxT>::jac_;
using CircuitComponent<ScalarT, IdxT>::param_;
using CircuitComponent<ScalarT, IdxT>::idc_;

Expand Down
2 changes: 1 addition & 1 deletion ComponentLib/PowerElectronics/CircuitComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ModelLib
}

/**
* @brief Create the mappings from local to global indexes
* @brief Create the mappings from local to global indices
*
* @param local_index
* @param global_index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ int DistributedGenerator<ScalarT, IdxT>::evaluateResidual()
template <class ScalarT, typename IdxT>
int DistributedGenerator<ScalarT, IdxT>::evaluateJacobian()
{
J_.zeroMatrix();
jac_.zeroMatrix();
//Create dF/dy'
std::vector<IdxT> rcordder(13);
std::vector<ScalarT> valsder(13, -1.0);
Expand All @@ -203,23 +203,23 @@ int DistributedGenerator<ScalarT, IdxT>::evaluateJacobian()
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(1);
valtemp = { - sin(y_[3]) * y_[14] - cos(y_[3]) * y_[15], cos(y_[3]),-sin(y_[3])};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 2

ctemp = {3, 14, 15};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(2);
valtemp = { cos(y_[3]) * y_[14] - sin(y_[3]) * y_[15], sin(y_[3]),cos(y_[3])};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 3

ctemp = {0, 4};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(3);
valtemp = {-1.0, -mp_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 0
if (refframe_)
Expand All @@ -228,7 +228,7 @@ int DistributedGenerator<ScalarT, IdxT>::evaluateJacobian()
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(0);
valtemp = {-1.0, -mp_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);
}


Expand All @@ -237,92 +237,92 @@ int DistributedGenerator<ScalarT, IdxT>::evaluateJacobian()
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(4);
valtemp = {-wc_, wc_*y_[14], wc_*y_[15], wc_*y_[12], wc_*y_[13]};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 5
ctemp = {5, 12, 13, 14, 15};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(5);
valtemp = {-wc_, -wc_*y_[15], wc_*y_[14], wc_*y_[13], -wc_*y_[12]};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 6
ctemp = {5, 12};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(6);
valtemp = {-nq_, -1.0};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 7
ctemp = {13};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(7);
valtemp = {-1.0};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 8
ctemp = {5,6,10,12,13,14};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(8);
valtemp = {-Kpv_*nq_, Kiv_, -1.0, -Kpv_, -Cf_*wb_, F_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 9
ctemp = {7, 11, 12, 13, 15};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(9);
valtemp = {Kiv_, -1.0, Cf_*wb_,-Kpv_,F_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 10
ctemp = {4, 5, 6, 8, 10, 11, 12, 13, 14};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(10);
valtemp = {-mp_ * y_[11], -(Kpc_ * Kpv_ * nq_) / Lf_, (Kpc_ * Kiv_) / Lf_, Kic_ / Lf_, -(Kpc_ + rLf_) / Lf_, -mp_ * y_[4], -(Kpc_ * Kpv_ + 1.0) / Lf_, -(Cf_ * Kpc_ * wb_) / Lf_, (F_ * Kpc_) / Lf_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 11
ctemp = {4, 7, 9, 10, 11, 12, 13, 15};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(11);
valtemp = {mp_ * y_[10], (Kiv_ * Kpc_) / Lf_, Kic_ / Lf_, mp_ * y_[4], -(Kpc_ + rLf_) / Lf_, (Cf_ * Kpc_ * wb_) / Lf_, -(Kpc_ * Kpv_ + 1.0) / Lf_, (F_ * Kpc_) / Lf_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);

//r = 12
ctemp = {4, 10, 13, 14};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(12);
valtemp = {-mp_ * y_[13], 1.0 / Cf_, wb_ - mp_ * y_[4], -1.0 / Cf_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);


//r = 13
ctemp = {4, 11, 12, 15};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(13);
valtemp = {mp_ * y_[12], 1.0 / Cf_, -wb_ + mp_ * y_[4], -1.0 / Cf_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);


//r = 14
ctemp = {1, 2, 3, 4, 12, 14, 15};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(14);
valtemp = {(1.0/Lc_) * -cos(y_[3]) , (1.0/Lc_) * -sin(y_[3]) , (1.0/Lc_) * (sin(y_[3]) * y_[1] - cos(y_[3]) * y_[2]), -mp_ * y_[15], 1.0 / Lc_, -rLc_ / Lc_, wb_ - mp_ * y_[4]};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);


//r = 15
ctemp = {1, 2, 3, 4, 13, 14, 15};
rtemp.clear();
for (size_t i = 0; i < ctemp.size(); i++) rtemp.push_back(15);
valtemp = {(1.0/Lc_) * sin(y_[3]) , (1.0/Lc_) * -cos(y_[3]), (1.0/Lc_) * (cos(y_[3]) * y_[1] + sin(y_[3]) * y_[2]), mp_ * y_[14], 1.0 / Lc_, -wb_ + mp_ * y_[4], -rLc_ / Lc_};
J_.setValues(rtemp, ctemp, valtemp);
jac_.setValues(rtemp, ctemp, valtemp);


//Perform dF/dy + \alpha dF/dy'

J_.axpy(alpha_, Jacder);
jac_.axpy(alpha_, Jacder);

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace ModelLib
using CircuitComponent<ScalarT, IdxT>::ypB_;
using CircuitComponent<ScalarT, IdxT>::fB_;
using CircuitComponent<ScalarT, IdxT>::gB_;
using CircuitComponent<ScalarT, IdxT>::J_;
using CircuitComponent<ScalarT, IdxT>::jac_;
using CircuitComponent<ScalarT, IdxT>::param_;
using CircuitComponent<ScalarT, IdxT>::idc_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ InductionMotor<ScalarT, IdxT>::InductionMotor(IdxT id, ScalarT Lls, ScalarT Rs,
Llr_(Llr),
Rr_(Rr),
Lms_(Lms),
RJ_(RJ),
Rjac_(RJ),
P_(P)
{
size_ = 10;
Expand Down Expand Up @@ -82,7 +82,7 @@ int InductionMotor<ScalarT, IdxT>::evaluateResidual()
f_[0] = y_[5] + y_[7];
f_[1] = (-1.0/2.0) * y_[5] - (sqrt(3.0)/2.0)*y_[6] + y_[7];
f_[2] = (-1.0/2.0) * y_[5] + (sqrt(3.0)/2.0)*y_[6] + y_[7];
f_[3] = RJ_ * yp_[3] - (3.0/4.0)*P_*Lms_ * (y_[5]*y_[9] - y_[6]*y_[8]);
f_[3] = Rjac_ * yp_[3] - (3.0/4.0)*P_*Lms_ * (y_[5]*y_[9] - y_[6]*y_[8]);
f_[4] = yp_[4] - y_[3];
f_[5] = (1.0/3.0)*(2.0* y_[0] - y_[1] - y_[2]) - Rs_*y_[5] - (Lls_ + Lms_) * yp_[5] - Lms_ * yp_[6];
f_[6] = (1.0/sqrt(3.0))*(-y_[1] + y_[2]) - Rs_*y_[6] - (Lls_ + Lms_) * yp_[6] - Lms_ * yp_[5];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ModelLib
using CircuitComponent<ScalarT, IdxT>::ypB_;
using CircuitComponent<ScalarT, IdxT>::fB_;
using CircuitComponent<ScalarT, IdxT>::gB_;
using CircuitComponent<ScalarT, IdxT>::J_;
using CircuitComponent<ScalarT, IdxT>::jac_;
using CircuitComponent<ScalarT, IdxT>::param_;
using CircuitComponent<ScalarT, IdxT>::idc_;

Expand Down Expand Up @@ -66,7 +66,7 @@ namespace ModelLib
ScalarT Llr_;
ScalarT Rr_;
ScalarT Lms_;
ScalarT RJ_;
ScalarT Rjac_;
ScalarT P_;
};
}
Expand Down
6 changes: 3 additions & 3 deletions ComponentLib/PowerElectronics/Inductor/Inductor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ int Inductor<ScalarT, IdxT>::evaluateResidual()
template <class ScalarT, typename IdxT>
int Inductor<ScalarT, IdxT>::evaluateJacobian()
{
J_.zeroMatrix();
jac_.zeroMatrix();

//Create dF/dy
std::vector<IdxT> rcord{0,1,2,2};
std::vector<IdxT> ccord{2,2,0,1};
std::vector<ScalarT> vals{-1.0, 1.0, -1.0, 1.0};
J_.setValues(rcord, ccord, vals);
jac_.setValues(rcord, ccord, vals);

//Create dF/dy'
std::vector<IdxT> rcordder{2};
Expand All @@ -103,7 +103,7 @@ int Inductor<ScalarT, IdxT>::evaluateJacobian()
COO_Matrix<ScalarT,IdxT> Jacder = COO_Matrix<ScalarT, IdxT>(rcordder, ccordder, valsder,3,3);

//Perform dF/dy + \alpha dF/dy'
J_.axpy(alpha_, Jacder);
jac_.axpy(alpha_, Jacder);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion ComponentLib/PowerElectronics/Inductor/Inductor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ModelLib
using CircuitComponent<ScalarT, IdxT>::ypB_;
using CircuitComponent<ScalarT, IdxT>::fB_;
using CircuitComponent<ScalarT, IdxT>::gB_;
using CircuitComponent<ScalarT, IdxT>::J_;
using CircuitComponent<ScalarT, IdxT>::jac_;
using CircuitComponent<ScalarT, IdxT>::param_;
using CircuitComponent<ScalarT, IdxT>::idc_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ModelLib
using CircuitComponent<ScalarT, IdxT>::ypB_;
using CircuitComponent<ScalarT, IdxT>::fB_;
using CircuitComponent<ScalarT, IdxT>::gB_;
using CircuitComponent<ScalarT, IdxT>::J_;
using CircuitComponent<ScalarT, IdxT>::jac_;
using CircuitComponent<ScalarT, IdxT>::param_;
using CircuitComponent<ScalarT, IdxT>::idc_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ int MicrogridBusDQ<ScalarT, IdxT>::evaluateResidual()
template <class ScalarT, typename IdxT>
int MicrogridBusDQ<ScalarT, IdxT>::evaluateJacobian()
{
J_.zeroMatrix();
jac_.zeroMatrix();

//Create dF/dy
std::vector<IdxT> rtemp{0,1};
std::vector<IdxT> ctemp{0,1};
std::vector<ScalarT> vals{-1.0 / RN_,-1.0 / RN_};
J_.setValues(rtemp, ctemp, vals);
jac_.setValues(rtemp, ctemp, vals);

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ModelLib
using CircuitComponent<ScalarT, IdxT>::ypB_;
using CircuitComponent<ScalarT, IdxT>::fB_;
using CircuitComponent<ScalarT, IdxT>::gB_;
using CircuitComponent<ScalarT, IdxT>::J_;
using CircuitComponent<ScalarT, IdxT>::jac_;
using CircuitComponent<ScalarT, IdxT>::param_;
using CircuitComponent<ScalarT, IdxT>::idc_;

Expand Down
10 changes: 5 additions & 5 deletions ComponentLib/PowerElectronics/MicrogridLine/MicrogridLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,26 @@ int MicrogridLine<ScalarT, IdxT>::evaluateResidual()
template <class ScalarT, typename IdxT>
int MicrogridLine<ScalarT, IdxT>::evaluateJacobian()
{
J_.zeroMatrix();
jac_.zeroMatrix();

//Create dF/dy
std::vector<IdxT> rtemp{1,2,3,4};
std::vector<IdxT> ctemp{5,6,5,6};
std::vector<ScalarT> vals{-1.0,-1.0,1.0,1.0};
J_.setValues(rtemp, ctemp, vals);
jac_.setValues(rtemp, ctemp, vals);


std::vector<IdxT> ccord{0, 1, 3, 5, 6};

std::vector<IdxT> rcord(ccord.size(),5);
vals = {y_[6], (1.0 / L_) , -(1.0 / L_), - (R_ / L_) , y_[0]};
J_.setValues(rcord, ccord, vals);
jac_.setValues(rcord, ccord, vals);


std::vector<IdxT> ccor2{0, 2, 4, 5, 6};
std::fill(rcord.begin(), rcord.end(), 6);
vals = {-y_[5], (1.0 / L_) , -(1.0 / L_), -y_[0], - (R_ / L_)};
J_.setValues(rcord, ccor2, vals);
jac_.setValues(rcord, ccor2, vals);


//Create -dF/dy'
Expand All @@ -134,7 +134,7 @@ int MicrogridLine<ScalarT, IdxT>::evaluateJacobian()
COO_Matrix<ScalarT,IdxT> Jacder = COO_Matrix<ScalarT, IdxT>(rcordder, ccordder, valsder,7,7);

//Perform dF/dy + \alpha dF/dy'
J_.axpy(alpha_, Jacder);
jac_.axpy(alpha_, Jacder);


return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace ModelLib
using CircuitComponent<ScalarT, IdxT>::ypB_;
using CircuitComponent<ScalarT, IdxT>::fB_;
using CircuitComponent<ScalarT, IdxT>::gB_;
using CircuitComponent<ScalarT, IdxT>::J_;
using CircuitComponent<ScalarT, IdxT>::jac_;
using CircuitComponent<ScalarT, IdxT>::param_;
using CircuitComponent<ScalarT, IdxT>::idc_;

Expand Down
Loading
Loading