From 25f749e240d2ba9c079cb69124d830c843cbd24c Mon Sep 17 00:00:00 2001 From: Shri Date: Tue, 21 Nov 2023 10:26:22 -0600 Subject: [PATCH] Fix ignoring contingencies when the from bus number is greater than than to bus number (#70) * Fix ignoring contingencies when the from bus number is greater than to bus #26 When the from bus number is greater than the to bus number for a branch, the PS branch object stores it in the reverse order. This is done so that the from bus number is always less than to bus number. The reason for doing this is IPOPT complains for Hessian if this is not done. However, this was causing the contingencies with from bus > to bus to be ignored. * Apply pre-commmit fixes * Update CMakeLists.txt --------- Co-authored-by: abhyshr Co-authored-by: Cameron Rutherford --- src/ps/ps.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ps/ps.cpp b/src/ps/ps.cpp index 54594e49..dbfc34a1 100644 --- a/src/ps/ps.cpp +++ b/src/ps/ps.cpp @@ -279,7 +279,9 @@ PetscErrorCode PSGetLine(PS ps, PetscInt fbus, PetscInt tbus, const char *id, ierr = PSBUSGetSupportingLines(bus, &nsupplines, &supplines); CHKERRQ(ierr); for (i = 0; i < nsupplines; i++) { - if (supplines[i]->fbus == fbus && supplines[i]->tbus == tbus) { + if ((supplines[i]->fbus == fbus && supplines[i]->tbus == tbus) || + (supplines[i]->reversed_ends & + (supplines[i]->fbus == tbus && supplines[i]->tbus == fbus))) { ierr = PetscStrcmp(id, supplines[i]->ckt, &flg); CHKERRQ(ierr); if (flg) {