Skip to content

Commit

Permalink
fixing some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Mar 15, 2024
1 parent daf8a93 commit db3ef35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/powerflow_algorithm/BaseFDPFAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class BaseFDPFAlgo: public BaseAlgo
// solution of the problem
Bp_ = Eigen::SparseMatrix<real_type> (); // the B prime matrix (size n_pvpq)
Bpp_ = Eigen::SparseMatrix<real_type>(); // the B double prime matrix (size n_pq)
grid_Bp_ = Eigen::SparseMatrix<real_type> (); // the B prime matrix (size n_pvpq)
grid_Bpp_ = Eigen::SparseMatrix<real_type>(); // the B double prime matrix (size n_pq)
p_ = RealVect();
q_ = RealVect();
need_factorize_ = true;
Expand Down Expand Up @@ -200,6 +202,8 @@ class BaseFDPFAlgo: public BaseAlgo
LinearSolver _linear_solver_Bpp;

// solution of the problem
Eigen::SparseMatrix<real_type> grid_Bp_;
Eigen::SparseMatrix<real_type> grid_Bpp_;
Eigen::SparseMatrix<real_type> Bp_; // the B prime matrix (size n_pvpq)
Eigen::SparseMatrix<real_type> Bpp_; // the B double prime matrix (size n_pq)
RealVect p_; // (size n_pvpq)
Expand Down
13 changes: 6 additions & 7 deletions src/powerflow_algorithm/BaseFDPFAlgo.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ bool BaseFDPFAlgo<LinearSolver, XB_BX>::compute_pf(const Eigen::SparseMatrix<cpl
_solver_control.has_ybus_some_coeffs_zero() ||
_solver_control.need_recompute_ybus() ||
){
// extract Bp and Bpp for the whole grid
Eigen::SparseMatrix<real_type> grid_Bp;
Eigen::SparseMatrix<real_type> grid_Bpp;
fillBp_Bpp(grid_Bp, grid_Bpp);
// need to extract Bp and Bpp for the whole grid
grid_Bp_ = Eigen::SparseMatrix<real_type> ();
grid_Bpp_ = Eigen::SparseMatrix<real_type>();
fillBp_Bpp(grid_Bp_, grid_Bpp_);
}

// init "my" matrices
// fill the solver matrices Bp_ and Bpp_
// Bp_ = Bp[array([pvpq]).T, pvpq].tocsc()
Expand All @@ -97,12 +97,11 @@ bool BaseFDPFAlgo<LinearSolver, XB_BX>::compute_pf(const Eigen::SparseMatrix<cpl
_solver_control.has_pv_changed() ||
_solver_control.has_pq_changed()
){

std::vector<int> pvpq_inv(V.size(), -1);
for(int inv_id=0; inv_id < n_pvpq; ++inv_id) pvpq_inv[pvpq(inv_id)] = inv_id;
std::vector<int> pq_inv(V.size(), -1);
for(int inv_id=0; inv_id < n_pq; ++inv_id) pq_inv[pq(inv_id)] = inv_id;
fill_sparse_matrices(grid_Bp, grid_Bpp, pvpq_inv, pq_inv, n_pvpq, n_pq);
fill_sparse_matrices(grid_Bp_, grid_Bpp_, pvpq_inv, pq_inv, n_pvpq, n_pq);
}

V_ = V; // V = V0
Expand Down

0 comments on commit db3ef35

Please sign in to comment.