Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate pypower solver #172

Merged
merged 125 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
038d5a7
Add pypower module
dchassin Feb 19, 2024
9bdacda
Fix compile errors
dchassin Feb 19, 2024
1d6ec63
Stub in pypower classes
dchassin Feb 19, 2024
e355ff9
Add pypower to glm converter
dchassin Feb 19, 2024
ab4e1ac
Add pypower test case 14
dchassin Feb 19, 2024
87f02c0
Added more pypower test cases
dchassin Feb 19, 2024
cdbf859
Update requirements.csv
dchassin Feb 19, 2024
edaba5c
Add initialization and solver update
dchassin Feb 20, 2024
665ac48
Added solver
dchassin Feb 20, 2024
bbc8a7d
work update
dchassin Feb 20, 2024
3c4562f
Move pypower_solver.py from runtime to module/pypower
Feb 20, 2024
f4ffb90
Simplify autotest case structure
Feb 20, 2024
d0c2ea6
Update Makefile.mk
Feb 20, 2024
4110e73
Update pypower.cpp
Feb 20, 2024
ee16ff6
Update branch.cpp
Feb 20, 2024
9131dd3
Fix autotests
Feb 20, 2024
2c480f1
Add documentation
Feb 20, 2024
695a224
Update pypower.cpp
Feb 20, 2024
1b1a1e4
Update pypower_solver.py
Feb 20, 2024
da1bde1
Update Pypower.md
Feb 20, 2024
7077383
Update substation.cpp
Feb 20, 2024
a944a62
Update pypower.cpp
dchassin Feb 21, 2024
fc73336
Publish OPF values
dchassin Feb 21, 2024
ba3a7cb
Add pypower load object
dchassin Feb 21, 2024
ec85155
Add pypower load object
dchassin Feb 21, 2024
88a7989
Add support for linking substation through load object
Feb 21, 2024
f8f56c8
Enabled OPF solver
Feb 22, 2024
91de775
Fixed OPF solver bug
dchassin Feb 22, 2024
2607d03
Add pypower module
dchassin Feb 19, 2024
bec797b
Fix compile errors
dchassin Feb 19, 2024
f812786
Stub in pypower classes
dchassin Feb 19, 2024
83ff1a9
Add pypower to glm converter
dchassin Feb 19, 2024
817e691
Add pypower test case 14
dchassin Feb 19, 2024
e84f031
Added more pypower test cases
dchassin Feb 19, 2024
057b10a
Update requirements.csv
dchassin Feb 19, 2024
2c11c45
Add initialization and solver update
dchassin Feb 20, 2024
038aa92
Added solver
dchassin Feb 20, 2024
356e7b8
work update
dchassin Feb 20, 2024
85b3a40
Move pypower_solver.py from runtime to module/pypower
Feb 20, 2024
3dadbe3
Simplify autotest case structure
Feb 20, 2024
f1242e5
Update Makefile.mk
Feb 20, 2024
5f12026
Update pypower.cpp
Feb 20, 2024
fd3fc07
Update branch.cpp
Feb 20, 2024
8680654
Fix autotests
Feb 20, 2024
a67d4b4
Add documentation
Feb 20, 2024
77db9b4
Update pypower.cpp
Feb 20, 2024
612e6c0
Update pypower_solver.py
Feb 20, 2024
73dff2d
Update Pypower.md
Feb 20, 2024
1e8aec0
Update substation.cpp
Feb 20, 2024
ecfb14b
Update pypower.cpp
dchassin Feb 21, 2024
59450ff
Publish OPF values
dchassin Feb 21, 2024
8783101
Add pypower load object
dchassin Feb 21, 2024
55a82fa
Add pypower load object
dchassin Feb 21, 2024
fa6afdf
Add support for linking substation through load object
Feb 21, 2024
af056bf
Enabled OPF solver
Feb 22, 2024
d3259d1
Fixed OPF solver bug
dchassin Feb 22, 2024
93d3976
Add pypower options
Feb 22, 2024
4c30ab4
Fix autotests
Feb 22, 2024
40ea7b2
Merge branch 'develop-regrow-task3' of https://github.com/dchassin/gr…
dchassin Feb 22, 2024
a51df54
Remove case glm files
dchassin Feb 23, 2024
0ee9c1d
Create check_case.py
dchassin Feb 23, 2024
0323d62
Fixed autotests
dchassin Feb 23, 2024
a05737d
Add case failure autotest
Feb 23, 2024
ef63c57
Add powerplant
Feb 24, 2024
c93efbc
Update powerplant model data
Feb 24, 2024
68230ba
Add powerplant properties
dchassin Feb 24, 2024
9ac6e78
Updated main solver error handling
dchassin Feb 24, 2024
452dbf9
Fix load sync event handlers when no parent is specified
dchassin Feb 24, 2024
c277077
Update powerplant implementation
dchassin Feb 24, 2024
d3ded48
Change substation test to load test
dchassin Feb 24, 2024
31513cf
Fix load update method
dchassin Feb 24, 2024
0e448c2
Link powerplant to bus
dchassin Feb 24, 2024
ce11d69
Update test_case14_powerplant.glm
dchassin Feb 25, 2024
1a6f5f2
Update Pypower.md
Feb 25, 2024
19e7503
Add controller support
dchassin Feb 25, 2024
0586839
Update Pypower.md
dchassin Feb 25, 2024
8f4a175
Merge branch 'develop-regrow-task3' of https://github.com/dchassin/gr…
dchassin Feb 25, 2024
45eb359
Update convert.cpp
dchassin Feb 26, 2024
f73e510
Update controllers
dchassin Feb 26, 2024
f0c0d89
Update controllers.py
dchassin Feb 26, 2024
80f0e46
Update test_case14_controller.glm
dchassin Feb 26, 2024
68560ea
Update powerplant.cpp
dchassin Feb 26, 2024
67b0063
Working on fixing solver exceptions
dchassin Feb 26, 2024
7f5a302
Create test_case14_ts.glm
Feb 26, 2024
7c023c5
Update pypower.cpp
Feb 26, 2024
37e315b
Update pypower.cpp
Feb 26, 2024
75de511
Fix remaining autotest errors
Feb 27, 2024
e51b458
Update develop.yml
Feb 27, 2024
f6d4c61
Fix initial tuple set item problems
Feb 27, 2024
f35c62e
Remove feeble attempt to get a core dump
Feb 27, 2024
32d0261
Fix more setitem errors
Feb 27, 2024
c307672
Add powerline class
Feb 28, 2024
31be361
Update powerline.cpp
Feb 28, 2024
7fd6f48
Update Pypower.md
Feb 28, 2024
fb6fdfb
Create test_case14_powerline.glm
Feb 28, 2024
e1a7810
Add sync iteration check
dchassin Feb 28, 2024
afca55c
Merge branch 'develop' into develop-regrow-task3
Feb 28, 2024
a4686a2
Update powerplant.cpp
Feb 28, 2024
2964c2c
Create README.md
Feb 28, 2024
c5d619b
Update pypower.cpp
Feb 28, 2024
7c2d614
Update powerplant.cpp
Feb 28, 2024
e7ece5c
Update pypower.cpp
Feb 29, 2024
0c42ff2
Update controllers.py
Feb 29, 2024
d07820a
Update pypower.cpp
Feb 29, 2024
df96aa3
Update Pypower.md
Feb 29, 2024
b571016
Update test_case14_err.glm
Feb 29, 2024
82c4aad
Add transformer and relay classes
dchassin Feb 29, 2024
60b6931
Update README.md
Feb 29, 2024
07e86e3
Add PSS/E RAW to GLM converter
Feb 29, 2024
140c2a9
Update scada class
Feb 29, 2024
9ff01f5
Update wecc240.glm
dchassin Mar 1, 2024
9fb975b
Work in progress on PSS/E to PyPower converter
dchassin Mar 1, 2024
45ee456
Working progress on RAW to GLM converter
Mar 1, 2024
bbce204
Work progress on RAW to GLM converter
Mar 2, 2024
60701df
Update raw2glm.py
Mar 4, 2024
5b71785
Fix database compile error
dchassin Mar 4, 2024
182b20c
Update raw2glm.py
dchassin Mar 4, 2024
f57487e
Update wecc240.glm
dchassin Mar 4, 2024
e81ed03
Update raw2glm converter
dchassin Mar 13, 2024
a0bbf1a
Fix solver failure handling
dchassin Mar 13, 2024
a8d7d04
Update transformer.cpp
dchassin Mar 13, 2024
06a4d67
Save solver success/failure status as a global
dchassin Mar 13, 2024
b3f00a4
Remove PSS/E-specific functionality until a new branch can implement …
dchassin Mar 13, 2024
46a5696
Update pypower.cpp
dchassin Mar 13, 2024
31cb868
Update Pypower.md
dchassin Mar 13, 2024
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
3 changes: 3 additions & 0 deletions converters/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ dist_pkgdata_DATA += converters/mdb-table2glm-player.py
# omd -> glm
dist_pkgdata_DATA += converters/omd2glm.py

# py->glm
dist_pkgdata_DATA += converters/py2glm.py

# tmy3 -> glm
dist_pkgdata_DATA += converters/tmy32glm.py

Expand Down
2 changes: 2 additions & 0 deletions converters/autotest/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ solver_nr_profile.csv
table2glm_input_noclass.glm
table2glm_input_noname.glm
table2glm_input.glm
pypower_casedata.py
pypower_results.py
133 changes: 133 additions & 0 deletions converters/py2glm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import json
import os
import sys, getopt
import datetime
import importlib, copy
from importlib import util


config = {"input":"py","output":"glm","type":["pypower"]}

def help():
return """py2glm.py -i <inputfile> -o <outputfile> [options...]
-c|--config output converter configuration data
-h|--help output this help
-i|--ifile <filename> [REQUIRED] PY input file
-o|--ofile <filename> [OPTIONAL] GLM output file name
-t|--type type of input file
-N|--name do not autoname objects
"""

def main():
filename_py = None
filename_glm = None
py_type = 'pypower'
autoname = True
try :
opts, args = getopt.getopt(sys.argv[1:],
"chi:o:t:N",
["config","help","ifile=","ofile=","type=","name"],
)
except getopt.GetoptError:
sys.exit(2)
if not opts :
print('ERROR [py2glm.py]: missing command arguments')
sys.exit(2)
for opt, arg in opts:
if opt in ("-c","--config"):
print(config)
sys.exit()
elif opt in ("-h","--help"):
print(help())
sys.exit()
elif opt in ("-i", "--ifile"):
filename_py = arg
elif opt in ("-o", "--ofile"):
filename_glm = arg
elif opt in ("-t", "--type"):
py_type = arg
elif opt in ("-N","--name"):
autoname = False
else :
print(f"ERROR [py2glm.py]: {opt}={arg} is not a valid option")
sys.exit(1)

if not filename_py:
print(f"ERROR [py2glm.py]: input filename not specified")
sys.exit(1)

try:
convert(
ifile = filename_py,
ofile = filename_glm,
options = dict(
py_type = py_type,
autoname = autoname),
)
except Exception as err:
print(f"ERROR [py2glm.py]: {err}")
import traceback
traceback.print_exception(err,file=sys.stderr)
sys.exit(9)

def convert(ifile,ofile,options={}):
"""Default converter is pypower case"""

py_type = options['py_type'] if 'py_type' in options else "pypower"
autoname = options['autoname'] if 'autoname' in options else True

assert(py_type in ['pypower'])

modspec = util.spec_from_file_location("glm",ifile)
modname = os.path.splitext(ifile)[0]
mod = importlib.import_module(os.path.basename(modname))
casedef = getattr(mod,os.path.basename(modname))
data = casedef()

NL='\n'
with open(ofile,"w") as glm:
glm.write(f"""// generated by {' '.join(sys.argv)}
module pypower
{{
version {data['version']};
baseMVA {data['baseMVA']};
}}
""")

for name,spec in dict(
# pypower properties must be in the save order as the case array columns
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",
).items():
glm.write(f"{NL}//{NL}// {name}{NL}//{NL}")
for n,line in enumerate(data[name]):
oname = f"{NL} name pp_{name}_{n+1};" if autoname else ""
glm.write(f"""object pypower.{name}
{{{oname}
{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 n,line in enumerate(data['gencost']):
model = line[0]
startup = line[1]
shutdown = line[2]
count = line[3]
costs = line[4:]
assert(len(costs)==count)
oname = f"{NL} name pp_gencost_{n};" if autoname else ""
glm.write(f"""object pypower.gencost
{{{oname}
model {int(model)};
startup {startup};
shutdown {shutdown};
costs "{','.join([str(x) for x in costs])}";
}}
""")

if __name__ == '__main__':
main()

24 changes: 24 additions & 0 deletions docs/Converters/Import/PyPower_cases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[[/Converters/Import/Ami_data]] -- AMI data import

# Synopsis

GLM:

~~~
#input "casefile.py" -t pypower [-N|--name]
~~~

Shell:

~~~
$ gridlabd convert -i inputfile.py -o outputfile.glm -t pypower [-N|--name]
~~~

# Description

The `py2glm.py` converter support conversion of PyPower case files to GLM
models. The `-N|--name` option suppresses autonaming of PyPower objects.

# See also

* [[/Module/Pypower]]
Loading
Loading