diff --git a/include/opflow.h b/include/opflow.h index 655d69ee..bb9b7bfe 100644 --- a/include/opflow.h +++ b/include/opflow.h @@ -155,6 +155,10 @@ const auto include_powerimbalance_variables = const auto powerimbalance_penalty = ExaGORealOption( "-opflow_powerimbalance_penalty", "Power imbalance penalty", 1e4); +const auto load_scaling_factor = + ExaGORealOption("-opflow_load_scaling_factor", "Scale factor for load", 1.0); + + #ifdef EXAGO_ENABLE_HIOP const auto hiop_compute_mode = ExaGOStringOption("-hiop_compute_mode", "Set compute mode for HiOp solver", @@ -281,6 +285,7 @@ PETSC_EXTERN PetscErrorCode OPFLOWSetBusPowerImbalancePenalty(OPFLOW, PetscReal); PETSC_EXTERN PetscErrorCode OPFLOWGetBusPowerImbalancePenalty(OPFLOW, PetscReal *); +PETSC_EXTERN PetscErrorCode OPFLOWSetLoadScalingFactor(OPFLOW, PetscReal); PETSC_EXTERN PetscErrorCode OPFLOWSetWeight(OPFLOW, PetscScalar); PETSC_EXTERN PetscErrorCode OPFLOWSkipOptions(OPFLOW, PetscBool); diff --git a/include/private/opflowimpl.h b/include/private/opflowimpl.h index 39359f04..7dfc9e0f 100644 --- a/include/private/opflowimpl.h +++ b/include/private/opflowimpl.h @@ -247,6 +247,8 @@ struct _p_OPFLOW { imbalance */ PetscReal powerimbalance_penalty; + PetscReal load_scaling_factor; /* scaling factor for load */ + PetscBool has_powersetpoint; /* Use real power set-point */ PetscInt numits; /* Number of solver iterations */ diff --git a/src/opflow/interface/opflow.cpp b/src/opflow/interface/opflow.cpp index e5deb3ff..d38c671c 100644 --- a/src/opflow/interface/opflow.cpp +++ b/src/opflow/interface/opflow.cpp @@ -272,6 +272,24 @@ PetscErrorCode OPFLOWSetBusPowerImbalancePenalty(OPFLOW opflow, PetscFunctionReturn(0); } +/* + OPFLOWSetLoadScalingFactor - Set load scaling factor + + Input Parameters: ++ opflow - OPFLOW object +- penalty - load scaling factor (same for all loads) + + Command-line option: -opflow_load_scaling_factor + Notes: Should be called before OPFLOWSetUp + +*/ +PetscErrorCode OPFLOWSetLoadScalingFactor(OPFLOW opflow, PetscReal factor) { + PetscFunctionBegin; + opflow->load_scaling_factor = factor; + PetscFunctionReturn(0); +} + + /* OPFLOWGetBusPowerImbalancePenalty - Get bus power imbalance penalty @@ -482,6 +500,10 @@ PetscErrorCode OPFLOWCopyOptions(OPFLOW opflow, OPFLOW opflowout) ierr = OPFLOWSetLoadLossPenalty(opflowout, opflow->loadloss_penalty); CHKERRQ(ierr); + ierr = OPFLOWSetLoadScalingFactor(opflowout, opflow->load_scaling_factor); + CHKERRQ(ierr); + + ierr = OPFLOWHasBusPowerImbalance(opflowout, opflow->include_powerimbalance_variables); CHKERRQ(ierr); @@ -842,6 +864,8 @@ PetscErrorCode OPFLOWCreate(MPI_Comm mpicomm, OPFLOW *opflowout) { OPFLOWOptions::include_loadloss_variables.default_value; opflow->include_powerimbalance_variables = OPFLOWOptions::include_powerimbalance_variables.default_value; + opflow->load_scaling_factor = + OPFLOWOptions::load_scaling_factor.default_value; opflow->loadloss_penalty = OPFLOWOptions::loadloss_penalty.default_value; opflow->powerimbalance_penalty = @@ -1598,6 +1622,13 @@ PetscErrorCode OPFLOWSetUp(OPFLOW opflow) { opflow->loadloss_penalty, &opflow->loadloss_penalty, NULL); CHKERRQ(ierr); + + ierr = PetscOptionsReal(OPFLOWOptions::load_scaling_factor.opt.c_str(), + OPFLOWOptions::load_scaling_factor.desc.c_str(), "", + opflow->load_scaling_factor, &opflow->load_scaling_factor, + NULL); + CHKERRQ(ierr); + ierr = PetscOptionsBool( OPFLOWOptions::include_powerimbalance_variables.opt.c_str(), OPFLOWOptions::include_powerimbalance_variables.desc.c_str(), "", @@ -1680,13 +1711,21 @@ PetscErrorCode OPFLOWSetUp(OPFLOW opflow) { CHKERRQ(ierr); } + /* Scaling of load (note by default load scaling factor is 1.0 */ + for (int i = 0; i < ps->nbus; i++) { + PSBUS bus = &(ps->bus[i]); + for (int l = 0; l < bus->nload; l++) { + PSLOAD load; + ierr = PSBUSGetLoad(bus, l, &load); + CHKERRQ(ierr); + load->pl *= opflow->load_scaling_factor; + load->ql *= opflow->load_scaling_factor; + } + } + /* Set individual load cost parameters to the blanket values if they were not read from the input network */ if (opflow->include_loadloss_variables) { - PS ps; - ierr = OPFLOWGetPS(opflow, &ps); - CHKERRQ(ierr); - if (!ps->read_load_cost) { for (int i = 0; i < ps->nbus; i++) { PSBUS bus = &(ps->bus[i]);