Skip to content

Commit

Permalink
Enabled OPF solver
Browse files Browse the repository at this point in the history
  • Loading branch information
David P. Chassin committed Feb 22, 2024
1 parent 88a7989 commit f8f56c8
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 142 deletions.
21 changes: 19 additions & 2 deletions converters/py2glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,30 @@ def convert(ifile,ofile,py_type):
bus = "bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin",
gen = "bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf",
branch = "fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax",
# gencost = "TODO"
).items():
glm.write(f"{NL}//{NL}// {name}{NL}//{NL}")
for line in data[name]:
glm.write(f"""object {name}
glm.write(f"""object pypower.{name}
{{
{NL.join([f" {x} {line[n]};" for n,x in enumerate(spec.split())])}
}}
""")
if 'gencost' in data:
glm.write("\n//\n// gencost\n//\n")
for line in data['gencost']:
model = line[0]
startup = line[1]
shutdown = line[2]
count = line[3]
costs = line[4:]
assert(len(costs)==count)
glm.write(f"""object pypower.gencost
{{
model {int(model)};
startup {startup};
shutdown {shutdown};
costs "{','.join([str(x) for x in costs])}";
}}
""")

if __name__ == '__main__':
Expand Down
13 changes: 11 additions & 2 deletions module/powerflow/substation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,22 @@ int substation::init(OBJECT *parent)
}
else if ( gl_object_isa(parent,"load","pypower") )
{
// TODO: link to pypower bus object
fetch_complex(&pPositiveSequenceVoltage,"V",parent);
fetch_complex(&pConstantPowerLoad,"P",parent);
fetch_complex(&pConstantCurrentLoad,"I",parent);
fetch_complex(&pConstantImpedanceLoad,"Z",parent);
fetch_double(&pTransNominalVoltage,"Vn",parent);
// throw "substation does not support pypower bus linkage yet";
if (fabs(*pTransNominalVoltage-nominal_voltage)>0.001)
{
gl_error("pypower load bus nominal voltage (Vn %.1f V) and substation (nominal_voltage %.1f V) do not match to within 0.001 V",*pTransNominalVoltage,nominal_voltage);
return 0;
}
if (bustype != SWING)
{
warning("substation attached to pypower load and not a SWING bus - forcing bustype SWING");
bustype = SWING;
}
has_parent = 1;
}
else //Parent isn't a pw_load, so we just become a normal node - let it handle things
{
Expand Down
Loading

0 comments on commit f8f56c8

Please sign in to comment.