Skip to content

Commit

Permalink
complete prototype of two verification tests
Browse files Browse the repository at this point in the history
MILP based (results are not correct)
AC OPF
  • Loading branch information
whoiszyc committed Sep 26, 2023
1 parent 9909958 commit e1222dd
Show file tree
Hide file tree
Showing 7 changed files with 627 additions and 255 deletions.

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions project_ppsr/case_118bus/case118.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
3 1 39 10 0 0 1 0.968 11.56 138 1 1.06 0.94;
4 2 39 12 0 0 1 0.998 15.28 138 1 1.06 0.94;
5 1 0 0 0 -40 1 1.002 15.73 138 1 1.06 0.94;
6 2 52 22 0 0 1 0.99 13 138 1 1.06 0.94;
6 2 52 22 0 0 1 0.99 13 138 1 1.06 0.94;
7 1 19 2 0 0 1 0.989 12.56 138 1 1.06 0.94;
8 2 28 0 0 0 1 1.015 20.77 345 1 1.06 0.94;
9 1 0 0 0 0 1 1.043 28.02 345 1 1.06 0.94;
Expand All @@ -47,14 +47,14 @@
18 2 60 34 0 0 1 0.973 11.53 138 1 1.06 0.94;
19 2 45 25 0 0 1 0.963 11.05 138 1 1.06 0.94;
20 1 18 3 0 0 1 0.958 11.93 138 1 1.06 0.94;
21 1 14 8 0 0 1 0.959 13.52 138 1 1.06 0.94;
22 1 10 5 0 0 1 0.97 16.08 138 1 1.06 0.94;
21 2 14 8 0 0 1 0.959 13.52 138 1 1.06 0.94;
22 2 10 5 0 0 1 0.97 16.08 138 1 1.06 0.94;
23 1 7 3 0 0 1 1 21 138 1 1.06 0.94;
24 2 13 0 0 0 1 0.992 20.89 138 1 1.06 0.94;
25 2 0 0 0 0 1 1.05 27.93 138 1 1.06 0.94;
26 2 0 0 0 0 1 1.015 29.71 345 1 1.06 0.94;
27 2 71 13 0 0 1 0.968 15.35 138 1 1.06 0.94;
28 1 17 7 0 0 1 0.962 13.62 138 1 1.06 0.94;
28 2 17 7 0 0 1 0.962 13.62 138 1 1.06 0.94;
29 1 24 4 0 0 1 0.963 12.63 138 1 1.06 0.94;
30 1 0 0 0 0 1 0.968 18.79 345 1 1.06 0.94;
31 2 43 27 0 0 1 0.967 12.75 138 1 1.06 0.94;
Expand All @@ -71,21 +71,21 @@
42 2 96 23 0 0 1 0.985 8.53 138 1 1.06 0.94;
43 1 18 7 0 0 1 0.978 11.28 138 1 1.06 0.94;
44 1 16 8 0 10 1 0.985 13.82 138 1 1.06 0.94;
45 1 53 22 0 10 1 0.987 15.67 138 1 1.06 0.94;
45 2 53 22 0 10 1 0.987 15.67 138 1 1.06 0.94;
46 2 28 10 0 10 1 1.005 18.49 138 1 1.06 0.94;
47 1 34 0 0 0 1 1.017 20.73 138 1 1.06 0.94;
48 1 20 11 0 15 1 1.021 19.93 138 1 1.06 0.94;
49 2 87 30 0 0 1 1.025 20.94 138 1 1.06 0.94;
50 1 17 4 0 0 1 1.001 18.9 138 1 1.06 0.94;
51 1 17 8 0 0 1 0.967 16.28 138 1 1.06 0.94;
51 2 17 8 0 0 1 0.967 16.28 138 1 1.06 0.94;
52 1 18 5 0 0 1 0.957 15.32 138 1 1.06 0.94;
53 1 23 11 0 0 1 0.946 14.35 138 1 1.06 0.94;
54 2 113 32 0 0 1 0.955 15.26 138 1 1.06 0.94;
55 2 63 22 0 0 1 0.952 14.97 138 1 1.06 0.94;
56 2 84 18 0 0 1 0.954 15.16 138 1 1.06 0.94;
57 1 12 3 0 0 1 0.971 16.36 138 1 1.06 0.94;
58 1 12 3 0 0 1 0.959 15.51 138 1 1.06 0.94;
59 2 277 113 0 0 1 0.985 19.37 138 1 1.06 0.94;
59 1 277 113 0 0 1 0.985 19.37 138 1 1.06 0.94;
60 1 78 3 0 0 1 0.993 23.15 138 1 1.06 0.94;
61 2 0 0 0 0 1 0.995 24.04 138 1 1.06 0.94;
62 2 77 14 0 0 1 0.998 23.43 138 1 1.06 0.94;
Expand Down Expand Up @@ -179,7 +179,6 @@
54 48 0 300 -300 0.955 100 1 148 0 0 0 0 0 0 0 0 0 0 0 0;
55 0 0 23 -8 0.952 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0;
56 0 0 15 -8 0.954 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0;
59 155 0 180 -60 0.985 100 1 255 0 0 0 0 0 0 0 0 0 0 0 0;
61 160 0 300 -100 0.995 100 1 260 0 0 0 0 0 0 0 0 0 0 0 0;
62 0 0 20 -20 0.998 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0;
65 391 0 200 -67 1.005 100 1 491 0 0 0 0 0 0 0 0 0 0 0 0;
Expand Down Expand Up @@ -465,7 +464,6 @@
2 0 0 3 0.277777778 20 0;
2 0 0 3 0.01 40 0;
2 0 0 3 0.01 40 0;
2 0 0 3 0.01 40 0;
];

%% bus names
Expand Down
51 changes: 44 additions & 7 deletions project_ppsr/case_118bus/proj_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ function form_gen_plan_enforce(model, ref, stages, plan_gen)
t = Int(t)
g = Int(g)

# enforce status
if plan_gen[g][t] == 0
@constraint(model, model[:pg][g,t] == 0)
else
@constraint(model, model[:y][g,t] == 0)
@constraint(model, model[:pg][g,t] == plan_gen[g][t])
elseif plan_gen[g][t] <= 0
@constraint(model, model[:y][g,t] == 1)
@constraint(model, model[:pg][g,t] == plan_gen[g][t])
elseif plan_gen[g][t] >= 0
@constraint(model, model[:y][g,t] == 1)
@constraint(model, model[:pg][g,t] <= plan_gen[g][t])
@constraint(model, model[:pg][g,t] >= 0)
end

# enforce active power
@constraint(model, model[:pg][g,t] <= plan_gen[g][t])

# reactive power limits associated with the generator status
# # reactive power limits associated with the generator status
@constraint(model, model[:qg][g,t] >= ref[:gen][g]["qmin"] * model[:y][g,t])
@constraint(model, model[:qg][g,t] <= ref[:gen][g]["qmax"] * model[:y][g,t])
end
Expand All @@ -104,6 +106,41 @@ function form_gen_plan_enforce(model, ref, stages, plan_gen)
return model
end

function form_load_plan_enforce(model, ref, stages, plan_load)

println("Formulating load plan enforcement constraint")

# generate an array of the plan_load key
key_plan_load = [k for (k,v) in plan_load]

for t in stages
for i in keys(ref[:load])
t = Int(t)
i = Int(i)
pl = model[:pl]
u = model[:u]

# check if the load is a critical load
# only critical load is in the plan
if isempty(findall(x->x==i, key_plan_load))
# not in the plan: make the load dispatch if the bus is energized

# find bus index
idx_bus = ref[:load][i]["load_bus"]
@constraint(model, pl[i,t] >= 0)
@constraint(model, pl[i,t] <= ref[:load][i]["pd"] * u[idx_bus,t])
else
# otherwise: enforce status
@constraint(model, model[:pl][i,t] == plan_load[i][t])
end


end
end

return model
end


function form_bus_plan_enforce(model, ref, stages, plan_bus)

Expand Down
44 changes: 0 additions & 44 deletions project_ppsr/case_118bus/test_powerflow.jl

This file was deleted.

Loading

0 comments on commit e1222dd

Please sign in to comment.