-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathscopflow.h
198 lines (177 loc) · 9.11 KB
/
scopflow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
* Public header file for security constrained optimal power flow application.
*
*/
#ifndef SCOPFLOW_H
#define SCOPFLOW_H
#include <opflow.h>
#include <ps.h>
/* Models */
#define SCOPFLOWMODEL_GENRAMP "GENRAMP"
/* Model for multi-period SCOPFLOW */
#define SCOPFLOWMODEL_GENRAMPT "GENRAMPT"
/* Solvers */
#define SCOPFLOWSOLVER_IPOPT "IPOPT"
/* Embarassingly parallel solver - solves each OPFLOW independently */
#define SCOPFLOWSOLVER_EMPAR "EMPAR"
/* Primal decomposition-based HiOp solver */
#define SCOPFLOWSOLVER_HIOP "HIOP"
/* Initialization and Parameters*/
#define SCOPFLOW_INITIALIZATION "ACPF"
#define SCOPFLOW_GENBUSVOLTAGE "VARIABLE_WITHIN_BOUNDS"
typedef struct _p_SCOPFLOW *SCOPFLOW;
namespace SCOPFLOWOptions {
const auto model = ExaGOStringOption("-scopflow_model", "SCOPFLOW model type",
"GENRAMP", {"GENRAMPT"});
const auto solver =
ExaGOStringOption("-scopflow_solver", "SCOPFLOW solver type",
#if defined(EXAGO_ENABLE_IPOPT) && defined(EXAGO_ENABLE_HIOP)
"IPOPT", {"EMPAR", "HIOP"});
#else
#if defined(EXAGO_ENABLE_IPOPT)
"IPOPT", {"EMPAR"});
#elif defined(EXAGO_ENABLE_HIOP)
"HIOP", {"EMPAR"});
#else
#error "At least one solver must be enabled!"
#endif
#endif
const auto subproblem_model = ExaGOStringOption(
"-scopflow_subproblem_model", "SCOPFLOW subproblem model type",
OPFLOWOptions::model.default_value, OPFLOWOptions::model.possible_values);
const auto subproblem_solver = ExaGOStringOption(
"-scopflow_subproblem_solver", "SCOPFLOW subproblem solver type",
OPFLOWOptions::solver.default_value, OPFLOWOptions::solver.possible_values);
#ifdef EXAGO_ENABLE_HIOP
const auto compute_mode =
ExaGOStringOption("-hiop_compute_mode", "SCOPFLOW subproblem compute mode",
OPFLOWOptions::hiop_compute_mode.default_value,
OPFLOWOptions::hiop_compute_mode.possible_values);
const auto verbosity_level = ExaGOIntOption(
"-hiop_verbosity_level", "SCOPFLOW subproblem verbosity level",
OPFLOWOptions::hiop_verbosity_level.default_value);
const auto hiop_mem_space =
ExaGOStringOption("-hiop_mem_space", "Set memory space for HiOp solver",
OPFLOWOptions::hiop_mem_space.default_value,
OPFLOWOptions::hiop_mem_space.possible_values);
#endif
const auto iscoupling = ExaGOBoolOption(
"-scopflow_iscoupling",
"Include coupling between first stage and second stage", PETSC_TRUE);
const auto Nc =
ExaGOIntOption("-scopflow_Nc", "Number of second-stage scenarios", 0);
const auto mode = ExaGOIntOption(
"-scopflow_mode", "Operation mode: Preventive (0) or Corrective (1)", 1);
const auto enable_multiperiod = ExaGOBoolOption(
"-scopflow_enable_multiperiod", "Multi-period SCOPFLOW?", PETSC_FALSE);
const auto enable_powerimbalance =
ExaGOBoolOption("-opflow_include_powerimbalance_variables",
"Allow power imbalance", PETSC_FALSE);
const auto ignore_lineflow_constraints = ExaGOBoolOption(
"-opflow_ignore_lineflow_constraints", "Allow power imbalance",
OPFLOWOptions::ignore_lineflow_constraints.default_value);
const auto tolerance =
ExaGORealOption("-scopflow_tolerance", "Optimization tolerance",
OPFLOWOptions::tolerance.default_value);
namespace {
static const std::string onlymultiperiod =
" (only when multiperiod is enabled)";
}
/* Options only relevant when multiperiod is enabled */
const auto windgenprofile = ExaGOStringOption(
"-scopflow_windgenprofile", "Wind generation file" + onlymultiperiod,
"/path/to/windgenprofile", {});
const auto ploadprofile = ExaGOStringOption(
"-scopflow_ploadprofile", "Active power load profile" + onlymultiperiod,
"/path/to/ploadprofile", {});
const auto qloadprofile = ExaGOStringOption(
"-scopflow_qloadprofile", "Reactive power load profile" + onlymultiperiod,
"/path/to/qloadprofile", {});
const auto dT = ExaGORealOption(
"-scopflow_dT", "Length of time-step (minutes)" + onlymultiperiod, 1.0);
const auto duration = ExaGORealOption(
"-scopflow_duration", "Time horizon (hours)" + onlymultiperiod, 1.0);
} // namespace SCOPFLOWOptions
PETSC_EXTERN PetscErrorCode SCOPFLOWEnableMultiPeriod(SCOPFLOW, PetscBool);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetModel(SCOPFLOW, const std::string);
PETSC_EXTERN PetscErrorCode SCOPFLOWModelRegister(
SCOPFLOW, const char[], PetscErrorCode (*create)(SCOPFLOW));
PETSC_EXTERN PetscErrorCode SCOPFLOWSetSolver(SCOPFLOW, const std::string);
PETSC_EXTERN PetscErrorCode SCOPFLOWCreate(MPI_Comm, SCOPFLOW *);
PETSC_EXTERN PetscErrorCode SCOPFLOWDestroy(SCOPFLOW *);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetNetworkData(SCOPFLOW, const char[]);
PETSC_EXTERN PetscErrorCode
SCOPFLOWSetInitilizationType(SCOPFLOW, OPFLOWInitializationType type);
PETSC_EXTERN PetscErrorCode
SCOPFLOWSetGenBusVoltageType(SCOPFLOW, OPFLOWGenBusVoltageType);
/*
* The native format for Contingency input file is as follows:
* Notes: Each field in the contingency file has the following format
* Num,Type,Bus,Fbus,Tbus,Id,Status,prob
* Num - Contingency number
* Type - Type of contingency (Generator, Branch, Transformer, Load)
* Bus - The equipment bus number
* Fbus - From bus number (only for branch and transformer contingencies)
* Tbus - To bus number (only for branch and transformer contingencies)
* Id - The equipment ID (2-char string)
* Status - The status to be set for the outaged equipment
* Prob - the probability of the outage
Examples:
(Outage generator at bus 1 with Id 1, probability = 0.1)
1,0,1,0,0,1 ,0,0.1
(Outage branch connecting buses 8-9 with Id 1, probability = 0.1)
2,1,0,8,9,1 ,0,0.1
(Multiple outages
generator at bus 1 with Id 1, probability = 0.1
branch connecting buses 8-9 with Id 1, probability = 0.1)
3,0,1,0,0,1 ,0,0.1
3,1,0,8,9,1 ,0,0.1
*/
PETSC_EXTERN PetscErrorCode
SCOPFLOWSetContingencyData(SCOPFLOW, ContingencyFileInputFormat, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetPLoadData(SCOPFLOW, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetQLoadData(SCOPFLOW, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetWindGenProfile(SCOPFLOW, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetTimeStep(SCOPFLOW, PetscReal);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetDuration(SCOPFLOW, PetscReal);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetUp(SCOPFLOW);
PETSC_EXTERN PetscErrorCode SCOPFLOWCreateGlobalVector(SCOPFLOW, Vec *);
PETSC_EXTERN PetscErrorCode SCOPFLOWCreateMatrix(SCOPFLOW, Mat *);
PETSC_EXTERN PetscErrorCode SCOPFLOWSolve(SCOPFLOW);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetNumContingencies(SCOPFLOW, PetscInt);
PETSC_EXTERN PetscErrorCode SCOPFLOWGetTotalObjective(SCOPFLOW, PetscReal *);
PETSC_EXTERN PetscErrorCode SCOPFLOWGetBaseObjective(SCOPFLOW, PetscReal *);
PETSC_EXTERN PetscErrorCode SCOPFLOWGetSolution(SCOPFLOW, PetscInt, Vec *);
PETSC_EXTERN PetscErrorCode SCOPFLOWPrintSolution(SCOPFLOW, PetscInt);
PETSC_EXTERN PetscErrorCode SCOPFLOWSaveSolution(SCOPFLOW, PetscInt,
OutputFormat, const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSaveSolutionDefault(SCOPFLOW, PetscInt,
const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSaveSolutionAll(SCOPFLOW, OutputFormat,
const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSaveSolutionAllDefault(SCOPFLOW,
const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWGetConvergenceStatus(SCOPFLOW, PetscBool *);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetMode(SCOPFLOW, PetscInt);
PETSC_EXTERN PetscErrorCode SCOPFLOWGetNumIterations(SCOPFLOW, PetscInt *);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetTolerance(SCOPFLOW, PetscReal);
PETSC_EXTERN PetscErrorCode SCOPFLOWGetTolerance(SCOPFLOW, PetscReal *);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetTimeStepandDuration(SCOPFLOW, PetscReal,
PetscReal);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetLoadProfiles(SCOPFLOW, const char[],
const char[]);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetSubproblemModel(SCOPFLOW,
const std::string);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetSubproblemSolver(SCOPFLOW,
const std::string);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetSubproblemComputeMode(SCOPFLOW,
const std::string);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetSubproblemVerbosityLevel(SCOPFLOW,
PetscInt);
PETSC_EXTERN PetscErrorCode SCOPFLOWSetSubproblemMemSpace(SCOPFLOW,
const std::string);
PETSC_EXTERN PetscErrorCode SCOPFLOWEnablePowerImbalanceVariables(SCOPFLOW,
PetscBool);
PETSC_EXTERN PetscErrorCode SCOPFLOWIgnoreLineflowConstraints(SCOPFLOW,
PetscBool);
#endif