Validation 05 - Two Generator, Two Bus, Two Load, One Branch, Line Constraint¶
In [38]:
%matplotlib inline
In [39]:
import psst
In [40]:
from psst.case import read_matpower
from psst.network import create_network
Validation of case 1¶
In [41]:
case = read_matpower('./cases/case5.m')
In [42]:
network = create_network(case, prog='neato')
network.draw()
In [43]:
case
Out[43]:
<psst.case.PSSTCase(name=case, Generators=2, Buses=2, Branches=1)>
In [44]:
case.bus
Out[44]:
TYPE | PD | QD | GS | BS | AREA | VM | VA | BASEKV | ZONE | VMAX | VMIN | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Bus1 | 3 | 100 | 131.47 | 0 | 0 | 1 | 1 | 0 | 230 | 1 | 1.1 | 0.9 |
Bus2 | 2 | 300 | 0.00 | 0 | 0 | 1 | 1 | 0 | 230 | 1 | 1.1 | 0.9 |
In [45]:
case.branch
Out[45]:
F_BUS | T_BUS | BR_R | BR_X | BR_B | RATE_A | RATE_B | RATE_C | TAP | SHIFT | BR_STATUS | ANGMIN | ANGMAX | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Bus1 | Bus2 | 0.00281 | 0.0281 | 0.00712 | 50 | 50 | 50 | 0 | 0 | 1 | -360 | 360 |
In [46]:
case.gen
Out[46]:
GEN_BUS | PG | QG | QMAX | QMIN | VG | MBASE | GEN_STATUS | PMAX | PMIN | PC1 | PC2 | QC1MIN | QC1MAX | QC2MIN | QC2MAX | RAMP_AGC | RAMP_10 | RAMP_30 | RAMP_Q | APF | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GenCo0 | Bus1 | 200 | 0 | 30 | -30 | 1 | 100 | 1 | 200 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
GenCo1 | Bus2 | 500 | 0 | 30 | -30 | 1 | 100 | 1 | 500 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
In [47]:
case.gencost
Out[47]:
MODEL | STARTUP | SHUTDOWN | NCOST | COST_1 | COST_0 | |
---|---|---|---|---|---|---|
GenCo0 | 1 | 0 | 0 | 2 | 10 | 0 |
GenCo1 | 1 | 0 | 0 | 2 | 14 | 0 |
In [48]:
case.load
Out[48]:
Bus1 | Bus2 | |
---|---|---|
0 | 100.0 | 300.0 |
In [49]:
from psst.model import build_model
In [50]:
model = build_model(case)
In [51]:
model
Out[51]:
<psst.model.PSSTModel(status=None)>
In [52]:
model.solve(solver='cbc', verbose=True)
Welcome to the CBC MILP Solver
Version: 2.9.6
Build Date: May 27 2016
command line - /usr/local/bin/cbc -mipgap 0.01 -printingOptions all -import /var/folders/wk/lcf0vgd90bx0vq1873tn04knk_djr3/T/tmp4jcOLU.pyomo.lp -import -stat=1 -solve -solu /var/folders/wk/lcf0vgd90bx0vq1873tn04knk_djr3/T/tmp4jcOLU.pyomo.soln (default strategy 1)
No match for mipgap - ? for list of commands
No match for 0.01 - ? for list of commands
Option for printingOptions changed from normal to all
Current default (if $ as parameter) for import is /var/folders/wk/lcf0vgd90bx0vq1873tn04knk_djr3/T/tmp4jcOLU.pyomo.lp
Presolve 7 (-41) rows, 13 (-27) columns and 22 (-77) elements
Statistics for presolved model
Original problem has 2 integers (2 of which binary)
Problem has 7 rows, 13 columns (8 with objective) and 22 elements
There are 8 singletons with objective
Column breakdown:
10 of type 0.0->inf, 2 of type 0.0->up, 0 of type lo->inf,
1 of type lo->up, 0 of type free, 0 of type fixed,
0 of type -inf->0.0, 0 of type -inf->up, 0 of type 0.0->1.0
Row breakdown:
0 of type E 0.0, 0 of type E 1.0, 0 of type E -1.0,
3 of type E other, 0 of type G 0.0, 0 of type G 1.0,
0 of type G other, 2 of type L 0.0, 0 of type L 1.0,
2 of type L other, 0 of type Range 0.0->1.0, 0 of type Range other,
0 of type Free
Continuous objective value is 5000 - 0.00 seconds
Cgl0004I processed model has 7 rows, 13 columns (0 integer (0 of which binary)) and 20 elements
Cbc3007W No integer variables - nothing to do
Cuts at root node changed objective from 5000 to -1.79769e+308
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: 5000.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 0.00
Time (Wallclock seconds): 0.00
Total time (CPU seconds): 0.00 (Wallclock seconds): 0.01
Input data¶
In [53]:
import pandas as pd
In [54]:
pd.DataFrame(case.gen['PMAX'])
Out[54]:
PMAX | |
---|---|
GenCo0 | 200 |
GenCo1 | 500 |
In [55]:
case.load
Out[55]:
Bus1 | Bus2 | |
---|---|---|
0 | 100.0 | 300.0 |
Model Results¶
In [56]:
model.results.unit_commitment
Out[56]:
GenCo0 | GenCo1 | |
---|---|---|
0 | 1 | 1 |
In [57]:
model.results.power_generated
Out[57]:
GenCo0 | GenCo1 | |
---|---|---|
0 | 150 | 250 |
In [58]:
model.results.production_cost
Out[58]:
5000
In [64]:
print(case.gencost.loc['GenCo0', 'COST_1']*model.results.power_generated['GenCo0'].values[0])
print(case.gencost.loc['GenCo1', 'COST_1']*model.results.power_generated['GenCo1'].values[0])
1500
3500
In [60]:
model.results.line_power
Out[60]:
0 | |
---|---|
0 | 50 |
In [61]:
model.results.lmp
Out[61]:
Bus1 | Bus2 | |
---|---|---|
0 | 10 | 14 |
In [62]:
from psst.plot import line_power
In [63]:
line_power(network, model.results, hour=0)
Out[63]:
<matplotlib.axes._subplots.AxesSubplot at 0x111067c90>