Skip to content

Commit de87d9e

Browse files
committed
Supporting setting GIC file for SCOPFLOW.
1 parent a25d58d commit de87d9e

File tree

5 files changed

+50
-3
lines changed

5 files changed

+50
-3
lines changed

applications/scopflow_main.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ int main(int argc, char **argv) {
99
SCOPFLOW scopflow;
1010
char file[PETSC_MAX_PATH_LEN];
1111
char ctgcfile[PETSC_MAX_PATH_LEN];
12+
char gicfile[PETSC_MAX_PATH_LEN];
1213
char outputdir[PETSC_MAX_PATH_LEN];
1314
PetscBool outputdir_set;
14-
PetscBool flg = PETSC_FALSE, flgctgc = PETSC_FALSE;
15+
PetscBool flg = PETSC_FALSE, flgctgc = PETSC_FALSE, flggic = PETSC_FALSE;
1516
PetscBool print_output = PETSC_FALSE, save_output = PETSC_FALSE;
1617
PetscLogStage stages[3];
1718
char appname[] = "scopflow";
@@ -53,6 +54,11 @@ int main(int argc, char **argv) {
5354
PETSC_MAX_PATH_LEN, &flgctgc);
5455
CHKERRQ(ierr);
5556

57+
/* Get gic data file from command line */
58+
ierr = PetscOptionsGetString(NULL, NULL, "-gicfile", gicfile,
59+
PETSC_MAX_PATH_LEN, &flggic);
60+
ExaGOCheckError(ierr);
61+
5662
/* Stage 1 - Application creation and reading data */
5763
ierr = PetscLogStagePush(stages[0]);
5864
CHKERRQ(ierr);
@@ -86,6 +92,12 @@ int main(int argc, char **argv) {
8692
CHKERRQ(ierr);
8793
}
8894

95+
/* Set gicdata */
96+
if (flggic) {
97+
ierr = SCOPFLOWSetGICData(scopflow, gicfile);
98+
ExaGOCheckError(ierr);
99+
}
100+
89101
/* Set a subset of contingencies to be selected. Can use the option
90102
* -scopflow_Nc instead */
91103
/* ierr = SCOPFLOWSetNumContingencies(scopflow,2);CHKERRQ(ierr); */

include/private/scopflowimpl.h

+4
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ struct _p_SCOPFLOW {
196196

197197
ContingencyFileInputFormat ctgcfileformat;
198198

199+
/* GIC data */
200+
PetscBool gicfileset; /* Is the GIC file set? */
201+
char gicfile[PETSC_MAX_PATH_LEN];
202+
199203
PetscBool ismultiperiod; /* Are we doing a multi-period OPF? */
200204

201205
Scenario *scen; /* Used by SOPFLOW to pass the scenario information */

include/scopflow.h

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ PETSC_EXTERN PetscErrorCode
148148
*/
149149
PETSC_EXTERN PetscErrorCode
150150
SCOPFLOWSetContingencyData(SCOPFLOW, ContingencyFileInputFormat, const char[]);
151+
PETSC_EXTERN PetscErrorCode SCOPFLOWSetGICData(SCOPFLOW, const char[]);
151152
PETSC_EXTERN PetscErrorCode SCOPFLOWSetPLoadData(SCOPFLOW, const char[]);
152153
PETSC_EXTERN PetscErrorCode SCOPFLOWSetQLoadData(SCOPFLOW, const char[]);
153154
PETSC_EXTERN PetscErrorCode SCOPFLOWSetWindGenProfile(SCOPFLOW, const char[]);

src/ps/psreaddata.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,7 @@ PetscErrorCode PSReadMatPowerData(PS ps, const char netfile[]) {
767767
Bus[busi].Vmax = Bus[busi].Vmax == 0 ? 1.1 : Bus[busi].Vmax;
768768
Bus[busi].Vmin = Bus[busi].Vmin == 0 ? 0.9 : Bus[busi].Vmin;
769769
/* Sanity check for voltage limits */
770-
if ((Bus[busi].Vmax < Bus[busi].Vmin) || (Bus[busi].Vmax > 1.1) ||
771-
(Bus[busi].Vmin < 0.9)) {
770+
if ((Bus[busi].Vmax < Bus[busi].Vmin)) {
772771
bad_data = PETSC_TRUE;
773772
ierr = PetscPrintf(
774773
ps->comm->type,

src/scopflow/interface/scopflow.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ PetscErrorCode SCOPFLOWCreate(MPI_Comm mpicomm, SCOPFLOW *scopflowout) {
7272
scopflow->ctgclist = NULL;
7373
scopflow->ctgcfileset = PETSC_FALSE;
7474

75+
scopflow->gicfileset = PETSC_FALSE;
76+
7577
/* Default subproblem model and solver */
7678
#if 0
7779
(void)std::strncpy(scopflow->subproblem_model,
@@ -769,6 +771,12 @@ PetscErrorCode SCOPFLOWSetUp(SCOPFLOW scopflow) {
769771
CHKERRQ(ierr);
770772
}
771773

774+
/* Set any GIC file data */
775+
if(scopflow->gicfileset) {
776+
ierr = OPFLOWSetGICData(scopflow->opflows[c],scopflow->gicfile);
777+
CHKERRQ(ierr);
778+
}
779+
772780
/* Set contingencies */
773781
if (scopflow->ctgcfileset && scopflow->Nc > 1) {
774782
Contingency ctgc = scopflow->ctgclist->cont[scopflow->cstart + c];
@@ -1371,6 +1379,29 @@ SCOPFLOWSetContingencyData(SCOPFLOW scopflow,
13711379
PetscFunctionReturn(0);
13721380
}
13731381

1382+
/*
1383+
* @brief Set the gic data file for SCOPFLOW
1384+
*
1385+
* @param[in] scopflow application object
1386+
* @param[in] name of the gic file
1387+
*
1388+
* gicfile has the coordinates and the substation information. Used for visualization
1389+
*/
1390+
PetscErrorCode SCOPFLOWSetGICData(SCOPFLOW scopflow,const char gicfile[])
1391+
{
1392+
PetscErrorCode ierr;
1393+
1394+
PetscFunctionBegin;
1395+
1396+
ierr = PetscMemcpy(scopflow->gicfile, gicfile,
1397+
PETSC_MAX_PATH_LEN * sizeof(char));
1398+
CHKERRQ(ierr);
1399+
scopflow->gicfileset = PETSC_TRUE;
1400+
1401+
PetscFunctionReturn(0);
1402+
}
1403+
1404+
13741405
/*
13751406
SCOPFLOWSetSubproblemModel - Set subproblem model
13761407

0 commit comments

Comments
 (0)