Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/opflow/model/power_bal_hiop/paramsrajahiop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ int BUSParamsRajaHiop::destroy(OPFLOW opflow) {
h_allocator_.deallocate(bl);
h_allocator_.deallocate(xidx);
h_allocator_.deallocate(gidx);
h_allocator_.deallocate(eqjacsp_selfidx);
if (opflow->include_powerimbalance_variables) {
h_allocator_.deallocate(xidxpimb);
h_allocator_.deallocate(powerimbalance_penalty);
Expand All @@ -45,6 +46,7 @@ int BUSParamsRajaHiop::destroy(OPFLOW opflow) {
d_allocator_.deallocate(bl_dev_);
d_allocator_.deallocate(xidx_dev_);
d_allocator_.deallocate(gidx_dev_);
d_allocator_.deallocate(eqjacsp_selfidx_dev_);
if (opflow->include_powerimbalance_variables) {
d_allocator_.deallocate(xidxpimb_dev_);
d_allocator_.deallocate(powerimbalance_penalty_dev_);
Expand Down Expand Up @@ -84,6 +86,7 @@ int BUSParamsRajaHiop::copy(OPFLOW opflow) {

resmgr.copy(xidx_dev_, xidx);
resmgr.copy(gidx_dev_, gidx);
resmgr.copy(eqjacsp_selfidx_dev_, eqjacsp_selfidx);
if (opflow->include_powerimbalance_variables) {
resmgr.copy(xidxpimb_dev_, xidxpimb);
resmgr.copy(jacsp_idx_dev_, jacsp_idx);
Expand All @@ -108,6 +111,7 @@ int BUSParamsRajaHiop::copy(OPFLOW opflow) {
xidx_dev_ = xidx;
xidxpimb_dev_ = xidxpimb;
gidx_dev_ = gidx;
eqjacsp_selfidx_dev_ = eqjacsp_selfidx;
jacsp_idx_dev_ = jacsp_idx;
jacsq_idx_dev_ = jacsq_idx;
powerimbalance_penalty_dev_ = powerimbalance_penalty;
Expand Down Expand Up @@ -145,6 +149,7 @@ int BUSParamsRajaHiop::allocate(OPFLOW opflow) {

xidx = paramAlloc<int>(h_allocator_, nbus);
gidx = paramAlloc<int>(h_allocator_, nbus);
eqjacsp_selfidx = paramAlloc<int>(h_allocator_, 2 * nbus);

if (opflow->include_powerimbalance_variables) {
xidxpimb = paramAlloc<int>(h_allocator_, nbus);
Expand Down Expand Up @@ -232,6 +237,7 @@ int BUSParamsRajaHiop::allocate(OPFLOW opflow) {

xidx_dev_ = paramAlloc<int>(d_allocator_, nbus);
gidx_dev_ = paramAlloc<int>(d_allocator_, nbus);
eqjacsp_selfidx_dev_ = paramAlloc<int>(d_allocator_, 2 * nbus);

if (opflow->include_powerimbalance_variables) {
xidxpimb_dev_ = paramAlloc<int>(d_allocator_, nbus);
Expand Down Expand Up @@ -278,6 +284,9 @@ int LINEParamsRajaHiop::copy(OPFLOW opflow) {
resmgr.copy(ineqjacsp_idx_dev_, ineqjacsp_idx);
resmgr.copy(xslackidx_dev_, xslackidx);
}
resmgr.copy(eqjacsp_idx_dev_, eqjacsp_idx);
resmgr.copy(eqjacsp_diag_idx_dev_, eqjacsp_diag_idx);
resmgr.copy(isdcline_dev_, isdcline);
#else
Gff_dev_ = Gff;
Bff_dev_ = Bff;
Expand All @@ -299,6 +308,9 @@ int LINEParamsRajaHiop::copy(OPFLOW opflow) {
ineqjacsp_idx_dev_ = ineqjacsp_idx;
xslackidx_dev_ = xslackidx;
}
eqjacsp_idx_dev_ = eqjacsp_idx;
eqjacsp_diag_idx_dev_ = eqjacsp_diag_idx;
isdcline_dev_ = isdcline;
#endif
return 0;
}
Expand Down Expand Up @@ -328,6 +340,9 @@ int LINEParamsRajaHiop::destroy(OPFLOW opflow) {
h_allocator_.deallocate(ineqjacsp_idx);
h_allocator_.deallocate(xslackidx);
}
h_allocator_.deallocate(eqjacsp_idx);
h_allocator_.deallocate(eqjacsp_diag_idx);
h_allocator_.deallocate(isdcline);

#ifdef EXAGO_ENABLE_GPU
// Destroy parameter arrays on the device
Expand All @@ -354,6 +369,9 @@ int LINEParamsRajaHiop::destroy(OPFLOW opflow) {
d_allocator_.deallocate(ineqjacsp_idx_dev_);
d_allocator_.deallocate(xslackidx_dev_);
}
d_allocator_.deallocate(eqjacsp_idx_dev_);
d_allocator_.deallocate(eqjacsp_diag_idx_dev_);
d_allocator_.deallocate(isdcline_dev_);
#endif

return 0;
Expand Down Expand Up @@ -404,6 +422,10 @@ int LINEParamsRajaHiop::allocate(OPFLOW opflow) {
xslackidx = paramAlloc<int>(h_allocator_, nlinelim);
}

eqjacsp_idx = paramAlloc<int>(h_allocator_, nlineON);
eqjacsp_diag_idx = paramAlloc<int>(h_allocator_, 4 * nlineON);
isdcline = paramAlloc<int>(h_allocator_, nlineON);

PetscInt j = 0;
/* Populate arrays */
for (i = 0; i < ps->nline; i++) {
Expand Down Expand Up @@ -451,6 +473,7 @@ int LINEParamsRajaHiop::allocate(OPFLOW opflow) {
j++;
}

isdcline[linei] = (int)line->isdcline;
linei++;
}

Expand Down Expand Up @@ -480,6 +503,10 @@ int LINEParamsRajaHiop::allocate(OPFLOW opflow) {
ineqjacsp_idx_dev_ = paramAlloc<int>(d_allocator_, nlinelim);
xslackidx_dev_ = paramAlloc<int>(d_allocator_, nlinelim);
}

eqjacsp_idx_dev_ = paramAlloc<int>(d_allocator_, nlineON);
eqjacsp_diag_idx_dev_ = paramAlloc<int>(d_allocator_, 4 * nlineON);
isdcline_dev_ = paramAlloc<int>(d_allocator_, nlineON);
#endif
return 0;
}
Expand Down Expand Up @@ -621,6 +648,7 @@ int GENParamsRajaHiop::destroy(OPFLOW opflow) {
h_allocator_.deallocate(vs);
h_allocator_.deallocate(xidx);
h_allocator_.deallocate(xpdevidx);
h_allocator_.deallocate(xpsetidx);
h_allocator_.deallocate(gidxbus);
h_allocator_.deallocate(eqjacspbus_idx);
h_allocator_.deallocate(eqjacsqbus_idx);
Expand All @@ -647,6 +675,7 @@ int GENParamsRajaHiop::destroy(OPFLOW opflow) {
d_allocator_.deallocate(vs_dev_);
d_allocator_.deallocate(xidx_dev_);
d_allocator_.deallocate(xpdevidx_dev_);
d_allocator_.deallocate(xpsetidx_dev_);
d_allocator_.deallocate(gidxbus_dev_);
d_allocator_.deallocate(eqjacspbus_idx_dev_);
d_allocator_.deallocate(eqjacsqbus_idx_dev_);
Expand Down Expand Up @@ -685,6 +714,7 @@ int GENParamsRajaHiop::copy(OPFLOW opflow) {

resmgr.copy(xidx_dev_, xidx);
resmgr.copy(xpdevidx_dev_, xpdevidx);
resmgr.copy(xpsetidx_dev_, xpsetidx);
resmgr.copy(gidxbus_dev_, gidxbus);

resmgr.copy(eqjacspbus_idx_dev_, eqjacspbus_idx);
Expand All @@ -711,6 +741,7 @@ int GENParamsRajaHiop::copy(OPFLOW opflow) {
vs_dev_ = vs;
xidx_dev_ = xidx;
xpdevidx_dev_ = xpdevidx;
xpsetidx_dev_ = xpsetidx;
gidxbus_dev_ = gidxbus;
eqjacspbus_idx_dev_ = eqjacspbus_idx;
eqjacsqbus_idx_dev_ = eqjacsqbus_idx;
Expand Down Expand Up @@ -758,6 +789,7 @@ int GENParamsRajaHiop::allocate(OPFLOW opflow) {

xidx = paramAlloc<int>(h_allocator_, ngenON);
xpdevidx = paramAlloc<int>(h_allocator_, ngenON);
xpsetidx = paramAlloc<int>(h_allocator_, ngenON);
gidxbus = paramAlloc<int>(h_allocator_, ngenON);

eqjacspbus_idx = paramAlloc<int>(h_allocator_, ngenON);
Expand Down Expand Up @@ -798,6 +830,10 @@ int GENParamsRajaHiop::allocate(OPFLOW opflow) {
vs[geni] = gen->vs;
if (opflow->has_gensetpoint) {
pgs[geni] = gen->pgs;
if (!gen->isrenewable) {
xpdevidx[geni] = opflow->idxn2sd_map[gen->startxpdevloc];
xpsetidx[geni] = opflow->idxn2sd_map[gen->startxpsetloc];
}
}

xidx[geni] = opflow->idxn2sd_map[loc];
Expand Down Expand Up @@ -832,6 +868,7 @@ int GENParamsRajaHiop::allocate(OPFLOW opflow) {

xidx_dev_ = paramAlloc<int>(d_allocator_, ngenON);
xpdevidx_dev_ = paramAlloc<int>(d_allocator_, ngenON);
xpsetidx_dev_ = paramAlloc<int>(d_allocator_, ngenON);
gidxbus_dev_ = paramAlloc<int>(d_allocator_, ngenON);

eqjacspbus_idx_dev_ = paramAlloc<int>(d_allocator_, ngenON);
Expand Down
40 changes: 27 additions & 13 deletions src/opflow/model/power_bal_hiop/paramsrajahiop.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ struct BUSParamsRajaHiop {
int *jacsp_idx; /* Location number in the sparse Jacobian for Pimb */
int *jacsq_idx; /* Location number in the sparse Jacobian for Qimb */
int *hesssp_idx; /* KS: Hessian indices */
int *ispv; /* KS: ispv[i] = 1 if bus is PV bus */
int *gineqidx; /* KS: starting position of bus ineq constraints */
int *ineqjacsp_idx; /* KS: index in flat sparse ineq Jacobian array */
int *genoffset; /* KS: Offset into flattened gen array for this bus */
int *ngenONbus; /* KS: Number of ON generators on this bus */
int *eqjacsp_selfidx; /* Flat-array position for bus self-admittance in eq
Jacobian. [2*i] = P-row base, [2*i+1] = Q-row base */
int *ispv; /* KS: ispv[i] = 1 if bus is PV bus */
int *gineqidx; /* KS: starting position of bus ineq constraints */
int *ineqjacsp_idx; /* KS: index in flat sparse ineq Jacobian array */
int *genoffset; /* KS: Offset into flattened gen array for this bus */
int *ngenONbus; /* KS: Number of ON generators on this bus */

// Device data
int *isref_dev_; /* isref[i] = 1 if bus is reference bus */
Expand All @@ -51,14 +53,15 @@ struct BUSParamsRajaHiop {
X vector */
int *gidx_dev_; /* starting locations for bus balance equations in constraint
vector */
int *jacsp_idx_dev_; /* Location number in the sparse Jacobian for Pimb */
int *jacsq_idx_dev_; /* Location number in the sparse Jacobian for Qimb */
int *hesssp_idx_dev_; /* Location number in the Hessian */
int *ispv_dev_; /* KS: dev counterpart of ispv */
int *gineqidx_dev_; /* KS: dev counterpart of gineqidx */
int *ineqjacsp_idx_dev_; /* KS: device counterpart of ineqjacsp_idx_ */
int *genoffset_dev_; /* KS: dev counterpart of genoffset */
int *ngenONbus_dev_; /* KS: dev counterpart of ngenONbus */
int *jacsp_idx_dev_; /* Location number in the sparse Jacobian for Pimb */
int *jacsq_idx_dev_; /* Location number in the sparse Jacobian for Qimb */
int *hesssp_idx_dev_; /* Location number in the Hessian */
int *eqjacsp_selfidx_dev_; /* KS: eqjacsp_selfidx device counterpart */
int *ispv_dev_; /* KS: dev counterpart of ispv */
int *gineqidx_dev_; /* KS: dev counterpart of gineqidx */
int *ineqjacsp_idx_dev_; /* KS: device counterpart of ineqjacsp_idx_ */
int *genoffset_dev_; /* KS: dev counterpart of genoffset */
int *ngenONbus_dev_; /* KS: dev counterpart of ngenONbus */

int allocate(OPFLOW);
int destroy(OPFLOW);
Expand Down Expand Up @@ -88,6 +91,8 @@ struct GENParamsRajaHiop {

int *xidx; /* starting locations in X vector */
int *xpdevidx; /* KS: tarting locations of deviation variables in X vector */
int *
xpsetidx; /* KS: Starting locations in X vector for set-point variables */
int *
gidxbus; /* starting locations in constraint vector for bus constraints */
int *geqidxgen; /* starting locations in equality constraint vector for gen
Expand Down Expand Up @@ -123,6 +128,7 @@ struct GENParamsRajaHiop {

int *xidx_dev_; /* starting locations in X vector */
int *xpdevidx_dev_; /* KS: device coutnerpart of xpdevidx*/
int *xpsetidx_dev_; /* KS: xpsetidx device counterpart */
int *gidxbus_dev_; /* starting locations in constraint vector for bus
constraints */
int *geqidxgen_dev_; /* starting locations in equality constraint vector for
Expand Down Expand Up @@ -213,6 +219,11 @@ struct LINEParamsRajaHiop {
int *linelimidx; /* Indices for subset of lines that have finite limits */
int *ineqjacsp_idx; /* KS: Position in flat sparse ineq Jacobian array */
int *xslackidx; /* Starting location of slack variables in X vector */
int *eqjacsp_idx; /* Flat-array offset for off-diagonal eq Jacobian entries */
int *eqjacsp_diag_idx; /* Flat-array positions for diagonal entries per line
[4*l+0]=from P-row, [4*l+1]=from Q-row,
[4*l+2]=to P-row, [4*l+3]=to Q-row */
int *isdcline; /* isdcline[i] = 1 if line is a DC line */

// Device data
double *Gff_dev_; /* From side self conductance */
Expand All @@ -238,6 +249,9 @@ struct LINEParamsRajaHiop {
linelimidx_dev_; /* Indices for subset of lines that have finite limits */
int *ineqjacsp_idx_dev_; /* KS: Position in flat sparse ineq Jacobian array */
int *xslackidx_dev_; /* Starting location of slack variables in X vector */
int *eqjacsp_idx_dev_;
int *eqjacsp_diag_idx_dev_;
int *isdcline_dev_;

int allocate(OPFLOW);
int destroy(OPFLOW);
Expand Down
Loading
Loading