Skip to content

Commit

Permalink
Supporting setting GIC file for SCOPFLOW.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhyshr committed Dec 20, 2024
1 parent a25d58d commit de87d9e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
14 changes: 13 additions & 1 deletion applications/scopflow_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ int main(int argc, char **argv) {
SCOPFLOW scopflow;
char file[PETSC_MAX_PATH_LEN];
char ctgcfile[PETSC_MAX_PATH_LEN];
char gicfile[PETSC_MAX_PATH_LEN];
char outputdir[PETSC_MAX_PATH_LEN];
PetscBool outputdir_set;
PetscBool flg = PETSC_FALSE, flgctgc = PETSC_FALSE;
PetscBool flg = PETSC_FALSE, flgctgc = PETSC_FALSE, flggic = PETSC_FALSE;
PetscBool print_output = PETSC_FALSE, save_output = PETSC_FALSE;
PetscLogStage stages[3];
char appname[] = "scopflow";
Expand Down Expand Up @@ -53,6 +54,11 @@ int main(int argc, char **argv) {
PETSC_MAX_PATH_LEN, &flgctgc);
CHKERRQ(ierr);

/* Get gic data file from command line */
ierr = PetscOptionsGetString(NULL, NULL, "-gicfile", gicfile,
PETSC_MAX_PATH_LEN, &flggic);
ExaGOCheckError(ierr);

/* Stage 1 - Application creation and reading data */
ierr = PetscLogStagePush(stages[0]);
CHKERRQ(ierr);
Expand Down Expand Up @@ -86,6 +92,12 @@ int main(int argc, char **argv) {
CHKERRQ(ierr);
}

/* Set gicdata */
if (flggic) {
ierr = SCOPFLOWSetGICData(scopflow, gicfile);
ExaGOCheckError(ierr);
}

/* Set a subset of contingencies to be selected. Can use the option
* -scopflow_Nc instead */
/* ierr = SCOPFLOWSetNumContingencies(scopflow,2);CHKERRQ(ierr); */
Expand Down
4 changes: 4 additions & 0 deletions include/private/scopflowimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ struct _p_SCOPFLOW {

ContingencyFileInputFormat ctgcfileformat;

/* GIC data */
PetscBool gicfileset; /* Is the GIC file set? */
char gicfile[PETSC_MAX_PATH_LEN];

PetscBool ismultiperiod; /* Are we doing a multi-period OPF? */

Scenario *scen; /* Used by SOPFLOW to pass the scenario information */
Expand Down
1 change: 1 addition & 0 deletions include/scopflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ PETSC_EXTERN PetscErrorCode
*/
PETSC_EXTERN PetscErrorCode
SCOPFLOWSetContingencyData(SCOPFLOW, ContingencyFileInputFormat, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetGICData(SCOPFLOW, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetPLoadData(SCOPFLOW, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetQLoadData(SCOPFLOW, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetWindGenProfile(SCOPFLOW, const char[]);
Expand Down
3 changes: 1 addition & 2 deletions src/ps/psreaddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,7 @@ PetscErrorCode PSReadMatPowerData(PS ps, const char netfile[]) {
Bus[busi].Vmax = Bus[busi].Vmax == 0 ? 1.1 : Bus[busi].Vmax;
Bus[busi].Vmin = Bus[busi].Vmin == 0 ? 0.9 : Bus[busi].Vmin;
/* Sanity check for voltage limits */
if ((Bus[busi].Vmax < Bus[busi].Vmin) || (Bus[busi].Vmax > 1.1) ||
(Bus[busi].Vmin < 0.9)) {
if ((Bus[busi].Vmax < Bus[busi].Vmin)) {
bad_data = PETSC_TRUE;
ierr = PetscPrintf(
ps->comm->type,
Expand Down
31 changes: 31 additions & 0 deletions src/scopflow/interface/scopflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ PetscErrorCode SCOPFLOWCreate(MPI_Comm mpicomm, SCOPFLOW *scopflowout) {
scopflow->ctgclist = NULL;
scopflow->ctgcfileset = PETSC_FALSE;

scopflow->gicfileset = PETSC_FALSE;

/* Default subproblem model and solver */
#if 0
(void)std::strncpy(scopflow->subproblem_model,
Expand Down Expand Up @@ -769,6 +771,12 @@ PetscErrorCode SCOPFLOWSetUp(SCOPFLOW scopflow) {
CHKERRQ(ierr);
}

/* Set any GIC file data */
if(scopflow->gicfileset) {
ierr = OPFLOWSetGICData(scopflow->opflows[c],scopflow->gicfile);
CHKERRQ(ierr);
}

/* Set contingencies */
if (scopflow->ctgcfileset && scopflow->Nc > 1) {
Contingency ctgc = scopflow->ctgclist->cont[scopflow->cstart + c];
Expand Down Expand Up @@ -1371,6 +1379,29 @@ SCOPFLOWSetContingencyData(SCOPFLOW scopflow,
PetscFunctionReturn(0);
}

/*
* @brief Set the gic data file for SCOPFLOW
*
* @param[in] scopflow application object
* @param[in] name of the gic file
*
* gicfile has the coordinates and the substation information. Used for visualization
*/
PetscErrorCode SCOPFLOWSetGICData(SCOPFLOW scopflow,const char gicfile[])
{
PetscErrorCode ierr;

PetscFunctionBegin;

ierr = PetscMemcpy(scopflow->gicfile, gicfile,
PETSC_MAX_PATH_LEN * sizeof(char));
CHKERRQ(ierr);
scopflow->gicfileset = PETSC_TRUE;

PetscFunctionReturn(0);
}


/*
SCOPFLOWSetSubproblemModel - Set subproblem model
Expand Down

0 comments on commit de87d9e

Please sign in to comment.