Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
fail-fast: false
matrix:
julia-version: ['1']
# Each backend, and the GOC3 smoke test, run as their own job so that the wall
# clock is the slowest slice rather than the sum of all of them.
selection: ['nothing', 'cpu', 'cuda', 'goc3']
# Each backend, GOC3, and AOT run as their own job so that the wall clock is the
# slowest slice rather than the sum of all of them.
selection: ['nothing', 'cpu', 'cuda', 'goc3', 'aot']
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ uuid = "2fff4b78-0b6c-428d-bac8-85ccea8c4bdf"
version = "0.4.0"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
ExaModels = "1037b233-b668-4ce9-9b63-f9f681f55dd2"
ExaPowerIO = "14903efe-9500-4d7f-a589-7ab7e15da6de"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
PowerIO = "05ed8b54-f668-4096-9d0d-e8c3dd9dc169"

[weakdeps]
ExaModelsCompiler = "3d1e9a26-5b74-4f0c-9a2b-7c8f4e11d3a7"
Expand All @@ -18,6 +18,7 @@ ExaModelsPowerExaModelsCompilerExt = "ExaModelsCompiler"
ExaModels = "0.11"
ExaPowerIO = "0.3"
JSON = "0.21"
PowerIO = "0.9"
julia = "1.11"

[sources]
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@ ExaModelsPower.jl is an optimal power flow models using ExaModels.jl
[![doc](https://img.shields.io/badge/docs-dev-blue.svg)](https://madsuite.org/ExaModelsPower.jl/dev/)
[![codecov](https://codecov.io/gh/MadNLP/ExaModelsPower.jl/graph/badge.svg?token=ybOObxcXhB)](https://codecov.io/gh/MadNLP/ExaModelsPower.jl)

## Case files

Every model constructor takes a path. Case files are read through
[PowerIO](https://github.com/eigenergy/PowerIO.jl), so MATPOWER (`.m`), PSS/E raw
(`.raw`), PowerWorld aux (`.aux`), PowerModels JSON, PSLF (`.epc`), pandapower JSON,
egret and GOC3 JSON all work. The format is inferred from the extension; pass `from` when
it cannot be, as for a `.json` file:

```julia
model, vars, cons = ac_opf_model("case118.json"; from = "powermodels")
```

A bare name that is not a file in the working directory is looked up in the bundled
PGLib-OPF library, which is what `"pglib_opf_case118_ieee.m"` below resolves through.
Paths with a directory component are passed to PowerIO unchanged.

## Usage
### Static optimal power flow
```julia
using ExaModelsPower, MadNLP, MadNLPGPU, CUDA, ExaModels, GOC3Benchmark, JSON
using ExaModelsPower, MadNLP, MadNLPGPU, CUDA, ExaModels, JSON


model, vars, cons = ac_opf_model(
Expand Down Expand Up @@ -60,6 +76,12 @@ result = madnlp(model; tol=1e-4)
```

### Multi-period optimal power flow

The `.Pd` / `.Qd` files hold **MW**, one row per bus in the case's own bus order and one
column per period; they are converted to per unit on the case's base MVA. To pass the same
matrices in memory rather than on disk, give both `pd` and `qd` as keywords — one without
the other is an error rather than a silent half-applied load.

```julia
model, vars, cons = mpopf_model(
"pglib_opf_case118_ieee.m", # static network data
Expand Down
9 changes: 4 additions & 5 deletions src/ExaModelsPower.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module ExaModelsPower

import ExaModels: ExaModels, ExaCore, @add_var, @add_par, @add_con, @add_obj, @add_con!, ExaModel, convert_array, solution
using DelimitedFiles
using ExaPowerIO
using ExaPowerIO # the bundled PGLib-OPF directory, and nothing else
using JSON
using PowerIO

# Parsers and data stay separate from the models that consume them.
include("parser.jl") # matpower -> the tables every model is built from
include("parser.jl") # case file -> the tables every model is built from
include("constraint.jl") # the algebraic expressions, shared by all three
include("goc3_parser.jl") # GOC3-specific parsing
include("sc_parser.jl") # "
include("sc_parser.jl") # GOC3-specific parsing

include("opf.jl") # static: polar, rect, DC
include("mpopf.jl") # multi-period: polar, rect, DC
Expand Down
6 changes: 2 additions & 4 deletions src/goc3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ function goc3_model(


uc_data = JSON.parsefile(uc_filename)
data = get_data_from_file(filename)
data_json = JSON.parsefile(filename)
sc_data, lengths, producers_first = parse_sc_data(data, uc_data, data_json)
sc_data, lengths = parse_sc_data(read(filename, String), uc_data)
@info "parsed data"

(L_J_xf, L_J_ln, L_J_ac, L_J_dc, L_J_br, L_J_cs,
(; L_J_xf, L_J_ln, L_J_ac, L_J_dc, L_J_br, L_J_cs,
L_J_pr, L_J_cspr, L_J_sh, I, L_T, L_N_p, L_N_q, L_W_en_min_pr,
L_W_en_min_cs, L_W_en_max_pr, L_W_en_max_cs, K) = lengths

Expand Down
105 changes: 0 additions & 105 deletions src/goc3_parser.jl

This file was deleted.

Loading
Loading