From 17045e3b8adc714d379bda885b1a72d53468bc14 Mon Sep 17 00:00:00 2001 From: Shri Date: Thu, 19 Sep 2024 22:32:12 -0500 Subject: [PATCH] Avoid shedding for loads that have negative values in datafile --- include/private/psimpl.h | 2 +- src/opflow/interface/opflow.cpp | 6 +++++- src/ps/psreaddata.cpp | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/private/psimpl.h b/include/private/psimpl.h index 8b3f8035..c4826a57 100644 --- a/include/private/psimpl.h +++ b/include/private/psimpl.h @@ -24,7 +24,7 @@ /** * @brief A bogus value for load loss cost */ -#define BOGUSLOSSCOST -1234.0 +#define BOGUSLOSSCOST 12345.0 /** * @brief private bus data struct diff --git a/src/opflow/interface/opflow.cpp b/src/opflow/interface/opflow.cpp index d330df56..e5deb3ff 100644 --- a/src/opflow/interface/opflow.cpp +++ b/src/opflow/interface/opflow.cpp @@ -1694,7 +1694,11 @@ PetscErrorCode OPFLOWSetUp(OPFLOW opflow) { PSLOAD load; ierr = PSBUSGetLoad(bus, l, &load); CHKERRQ(ierr); - load->loss_frac = 1.0; + if(load->pl < 0.0 || load->ql < 0.0) { + load->loss_frac = 0.0; + } else { + load->loss_frac = 1.0; + } load->loss_cost = opflow->loadloss_penalty; } } diff --git a/src/ps/psreaddata.cpp b/src/ps/psreaddata.cpp index 0e060587..b5d336d3 100644 --- a/src/ps/psreaddata.cpp +++ b/src/ps/psreaddata.cpp @@ -797,7 +797,11 @@ PetscErrorCode PSReadMatPowerData(PS ps, const char netfile[]) { Load[loadi].pl = Pd / ps->MVAbase; Load[loadi].ql = Qd / ps->MVAbase; /* Some defaults for load shed */ - Load[loadi].loss_frac = 1.0; + if(Pd < 0.0 || Qd <= 0.0) { + Load[loadi].loss_frac = 0.0; + } else { + Load[loadi].loss_frac = 1.0; + } Load[loadi].loss_cost = BOGUSLOSSCOST; Load[loadi].area = Bus[busi].area; Load[loadi].internal_i = busi;