60 std::unordered_map<std::string, Eigen::MatrixXd>
create_ac(
const std::string& case_name);
67 std::unordered_map<std::string, Eigen::MatrixXd>
create_dc(
const std::string& case_name);
76 void addBusAC(std::vector<std::vector<std::string>>& dict_ac,
77 Bus* bus, std::map<std::string, double>& global_params,
bool print_info =
false);
86 void addBusDC(std::vector<std::vector<std::string>>& dict_dc,
87 Bus* bus, std::map<std::string, double>& global_params,
bool print_info =
false);
96 bool print_info =
false);
105 bool print_info =
false);
114 bool print_info =
false);
122 void make_RES(
Element* element, std::map<std::string, double>& global_params,
123 bool print_info =
false);
131 void make_Load(
Element* element, std::map<std::string, double>& global_params,
132 bool print_info =
false);
141 bool print_info =
false);
152 void make_OPF(
Network* net, std::map<std::string, double>& global_params,
bool vscControl =
true,
bool writeTxt =
false,
153 bool plotResult =
false,
bool print_info =
false,
bool include_dc =
true);
161 void make_AC_OPF(
Network* net, std::map<std::string, double>& global_params,
bool writeTxt =
false,
162 bool plotResult =
false,
bool print_info =
false);
169 void load_params_ac(
const std::string& acgrid_name,
const std::unordered_map<std::string, Eigen::MatrixXd>& dataOPF);
176 void load_params_dc(
const std::string& dcgrid_name,
const std::unordered_map<std::string, Eigen::MatrixXd>& dataOPF);
188 void solve_opf(
const std::string& dc_name,
189 const std::string& ac_name, std::unordered_map<std::string, Eigen::MatrixXd>* dataOPF,
190 bool vscControl,
bool writeTxt,
bool plotResult,
bool print_info);
211 const std::map<std::string, double>& global_params)
const;
217 std::unordered_map<std::string, Eigen::MatrixXd> network_ac;
219 Eigen::MatrixXd bus_entire_ac, branch_entire_ac, gen_entire_ac, gencost_entire_ac, res_entire_ac;
221 std::vector<Eigen::MatrixXd> bus_ac, branch_ac, generator_ac, gencost_ac, res_ac;
222 std::vector<std::vector<int>> recRef;
223 std::vector<Eigen::VectorXd> pd_ac, qd_ac, sres_ac;
224 std::vector<int> nbuses_ac, nbranches_ac, ngens_ac, nress_ac;
225 std::vector<Eigen::SparseMatrix<double>> GG_ac, BB_ac, GG_ft_ac, BB_ft_ac, GG_tf_ac, BB_tf_ac;
226 std::vector<Eigen::VectorXi> fbus_ac, tbus_ac;
227 std::vector<Eigen::MatrixXd> anglelim_rad;
228 std::vector<Eigen::VectorXi> IDtoCountmap;
229 std::vector<int> refbuscount_ac;
231 std::unordered_map<std::string, Eigen::MatrixXd> network_dc;
232 double baseMW_dc, pol_dc;
233 int nbuses_dc, nbranches_dc, nconvs_dc;
234 Eigen::MatrixXd bus_dc, branch_dc, conv_dc;
235 Eigen::SparseMatrix<std::complex<double>> Y_dc;
236 Eigen::SparseMatrix<double> y_dc;
237 Eigen::VectorXcd ztfc_dc;
238 Eigen::VectorXd rtf_dc, xtf_dc, bf_dc, rc_dc, xc_dc;
239 Eigen::VectorXd gtfc_dc, btfc_dc, aloss_dc, bloss_dc, closs_dc;
240 Eigen::VectorXd basekV_dc;
241 Eigen::VectorXi convState_dc;
242 Eigen::VectorXi fbus_dc, tbus_dc;
244 Eigen::VectorXd pn_dc, Ic_dc, lc_dc;
245 Eigen::VectorXd Ctt_dc, Ccc_dc, Ctc_dc, Stc_dc, Cct_dc, Sct_dc, convPloss_dc;
247 std::vector<int> nbuses_ac_viz, ngens_ac_viz;
248 int nconvs_dc_viz, nbuses_dc_viz, ngrids_viz;
250 std::map<std::string, std::map<std::string, std::map<std::string, double>>> data;
252 std::unordered_map<std::string, int> busName2Id_;
254 Eigen::MatrixXd readCSVtoCpp(
const std::string& filename);
255 Eigen::SparseMatrix<std::complex<double>> makeYbus(
double baseMVA,
const Eigen::MatrixXd& bus,
const Eigen::MatrixXd& branch);
257 Eigen::VectorXd vn2_dc_k;
258 Eigen::VectorXd pn_dc_k;
259 Eigen::MatrixXd pij_dc_k;
260 Eigen::MatrixXd lij_dc_k;
261 Eigen::VectorXd ps_dc_k, qs_dc_k;
262 Eigen::VectorXd pc_dc_k, qc_dc_k;
263 Eigen::VectorXd theta_s_k, theta_c_k;
264 Eigen::VectorXd v2s_dc_k, v2c_dc_k;
265 Eigen::VectorXd convPloss_dc_k;
267 std::vector<Eigen::VectorXd> vn2_ac_k;
268 std::vector<Eigen::VectorXd> theta_ac_k;
269 std::vector<Eigen::VectorXd> pn_ac_k;
270 std::vector<Eigen::VectorXd> qn_ac_k;
271 std::vector<Eigen::VectorXd> pgen_ac_k;
272 std::vector<Eigen::VectorXd> qgen_ac_k;
273 std::vector<Eigen::MatrixXd> pij_ac_k;
274 std::vector<Eigen::MatrixXd> qij_ac_k;
275 std::vector<Eigen::MatrixXd> ss_ac_k;
276 std::vector<Eigen::MatrixXd> cc_ac_k;
278 std::vector<Element*> conv_point;
280 double opf_user_base_mva_ = 100.0;
281 bool opf_solved_ =
false;