Skip to content

Commit b97bfb3

Browse files
SanjayJohnson02sanjayjo
andauthored
GOC3 scopf implementation (#14)
Co-authored-by: sanjayjo <[email protected]>
1 parent 219642d commit b97bfb3

File tree

10 files changed

+1961
-652
lines changed

10 files changed

+1961
-652
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ jobs:
3434
key: compiled-${{ runner.os }}-${{ hashFiles('**/Project.toml') }}-${{ hashFiles('**/Manifest.toml') }}
3535
restore-keys: compiled-${{ runner.os }}-
3636

37+
3738
- name: Install package dependencies
3839
run: |
39-
julia --project=. -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
40+
julia --project=. -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/lanl-ansi/GOC3Benchmark.jl")); Pkg.instantiate(); Pkg.precompile()'
4041
4142
- name: Check for CUDA availability
4243
id: check-cuda

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
version: '1'
1919
- name: Install dependencies
20-
run: julia --project=docs/ -e 'using Pkg; Pkg.Registry.update(); Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
20+
run: julia --project=docs/ -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/lanl-ansi/GOC3Benchmark.jl")); Pkg.Registry.update(); Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); Pkg.precompile()'
2121
- name: Build and deploy
2222
env:
2323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PGLib = "07a8691f-3d11-4330-951b-3c50f98338be"
99
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
1010
ExaModels = "1037b233-b668-4ce9-9b63-f9f681f55dd2"
1111
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
12+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
13+
GOC3Benchmark = "3a45b339-860d-44d0-a64b-5f943cdd120b"
14+
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
1215

1316
[compat]
1417
ExaModels = "~0.9"

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ ExaModelsPower.jl is an optimal power flow models using ExaModels.jl
99
## Usage
1010
### Static optimal power flow
1111
```julia
12-
using ExaModelsPower, MadNLP, MadNLPGPU, CUDA
12+
using ExaModelsPower, MadNLP, MadNLPGPU, CUDA, ExaModels, GOC3Benchmark, JSON
13+
1314

1415
model, vars, cons = opf_model(
1516
"pglib_opf_case118_ieee.m";
@@ -21,11 +22,32 @@ result = madnlp(model; tol=1e-6)
2122

2223
### Security-constrained optimal power flow
2324
```julia
24-
model, vars, cons = scopf_model(
25-
"pglib_opf_case118_ieee.m"; contingencies = [1,2],
25+
#This model is based on the GOC3 formulation of the SCOPF problem
26+
#https://www.pnnl.gov/publications/grid-optimization-competition-challenge-3-problem-formulation
27+
28+
#The current implementation requires a UC solution to be provided, which is then parsed with
29+
#the other input data to generate a structure of named tuples which can then interface with
30+
#ExaModels to generate the full model. We do not make any relaxations or decompositions for this problem
31+
32+
model, sc_data, vars, lengths = scopf_model(
33+
"data/C3E4N00073D1_scenario_303.json", "data/C3E4N00073D1_scenario_303_solution.json";
2634
backend = CUDABackend()
2735
)
28-
result = madnlp(model; tol=1e-6) # currently failing
36+
result = madnlp(model; tol=1e-4)
37+
38+
#Solution from GPU can be used to warm start a CPU solution or vice versa
39+
model_cpu, sc_data, vars, lengths = scopf_model(
40+
"data/C3E4N00073D1_scenario_303.json", "data/C3E4N00073D1_scenario_303_solution.json";
41+
result_set = [result, vars]
42+
)
43+
result_cpu = ipopt(model_cpu; tol=1e-8)
44+
45+
#Additionally, the SC problem can be evaluated without contingencies
46+
model, sc_data, vars, lengths = scopf_model(
47+
"data/C3E4N00073D1_scenario_303.json", "data/C3E4N00073D1_scenario_303_solution.json";
48+
backend = CUDABackend(), include_ctg = false
49+
)
50+
result = madnlp(model; tol=1e-4)
2951
```
3052

3153
### Multi-period optimal power flow
@@ -59,7 +81,7 @@ result = madnlp(model; tol=1e-6)
5981

6082
#Alternatively, provide a smooth function for the charge/discharge efficiency to remove complementarity constraint
6183
function example_func(d, srating)
62-
return d + .2/srating*d^2
84+
return -((s_rating/2)^d)+1
6385
end
6486

6587
model, vars, cons = mpopf_model(

src/ExaModelsPower.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
module ExaModelsPower
22

33
import JLD2
4+
import Downloads
5+
import ExaModels: ExaCore, variable, constraint, ExaModel, objective, constraint!, convert_array, solution
46
import PGLib
5-
import ExaModels: ExaCore, variable, constraint, ExaModel, objective, constraint!, convert_array
67
import PowerModels
78

9+
810
include("parser.jl")
911
include("opf.jl")
1012
include("scopf.jl")
1113
include("mpopf.jl")
1214
include("constraint.jl")
15+
include("sc_parser.jl")
1316

1417
const NAMES = filter(names(@__MODULE__; all = true)) do x
1518
str = string(x)

0 commit comments

Comments
 (0)