Skip to content

Commit

Permalink
Added load scaling factor
Browse files Browse the repository at this point in the history
  • Loading branch information
abhyshr committed Sep 21, 2024
1 parent 17045e3 commit b74c74a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
5 changes: 5 additions & 0 deletions include/opflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions include/private/opflowimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
47 changes: 43 additions & 4 deletions src/opflow/interface/opflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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(), "",
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit b74c74a

Please sign in to comment.