Skip to content
Merged
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
33 changes: 16 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
name: CI
on:
- push
- pull_request
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
# needed to allow julia-actions/cache to delete old caches that it has created
permissions:
actions: write
contents: read
jobs:
test:
if: "!contains(github.event.head_commit.message, 'skip ci')"
Expand All @@ -11,7 +18,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.10'
- '1'
- 'nightly'
os:
Expand All @@ -21,26 +28,18 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@latest
continue-on-error: ${{ matrix.version == 'nightly' }}
- uses: julia-actions/julia-runtest@latest
continue-on-error: ${{ matrix.version == 'nightly' }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v6
with:
file: lcov.info
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ CSV = "0.8.5, 0.9, 0.10"
FilePaths = "0.8.3"
Glob = "1.3"
Graphs = "1"
InfrastructureModels = "0.7.3, 0.7.5"
InfrastructureModels = "~0.7"
Ipopt = "1"
JSON = "0.18, 0.19, 0.20, 0.21"
JSON = "~0.18, ~0.19, ~0.20, ~0.21, ~1"
JuMP = "1.23.2"
LoggingExtras = "0.4.7, 1"
PolyhedralRelaxations = "0.3.5"
SCS = "0.9, 1.0, 1.1"
SpecialFunctions = "2"
julia = "1.6"
julia = "^1.10"

[extras]
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
[compat]
Documenter = "0.27"
Gumbo = "0.8"
Pluto = "0.19"
Pluto = "0.19, 0.20"
22 changes: 12 additions & 10 deletions src/io/json/json.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
parses json files that were dumped via JSON.print (or PMD.print_file)
"""
function parse_json(io::IO)
data = JSON.parse(io)
data = JSON.parse(io; dicttype=Dict{String, Any})
correct_json_import!(data)

return data
Expand All @@ -28,21 +28,23 @@ end

helper function to correct data imported from json
"""
function correct_json_import!(data::Dict{String,<:Any})
function correct_json_import!(data::AbstractDict{String,<:Any})
_fix_dtypes!(data)
end


"recursive function to fix data types from data imported from json"
function _fix_dtypes!(data::Dict)
function _fix_dtypes!(data::AbstractDict)
for (k, v) in data
if isa(v, Dict)
if v isa AbstractDict
_fix_dtypes!(v)
else
_fix_enums!(data, k, data[k])
_fix_arrays!(data, k, data[k])
_fix_nulls!(data, k, data[k])
elseif v isa Vector
for item in v
item isa AbstractDict && _fix_dtypes!(item)
end
end

_fix_enums!(data, k, data[k])
_fix_arrays!(data, k, data[k])
_fix_nulls!(data, k, data[k])
end
end

Expand Down
15 changes: 7 additions & 8 deletions test/en_pf_native_validation.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@info "running explicit neutral power flow tests with native julia power flow solver"


function conductor_correction!(data_eng)
function conductor_correction!(data_eng::AbstractDict)
nw = data_eng
if neutral_idx ∈ nw["conductor_ids"]
filter!(e -> e ≠ neutral_idx, nw["conductor_ids"])
Expand Down Expand Up @@ -45,7 +45,7 @@ end



function sourcebus_voltage_vector_correction!(data_math::Dict{String,Any}; explicit_neutral=true)
function sourcebus_voltage_vector_correction!(data_math::AbstractDict; explicit_neutral=true)
if haskey(data_math, "multinetwork")
for (n, nw) in data_math["nw"]
for (i, bus) in data_math["nw"]["bus"]
Expand Down Expand Up @@ -255,7 +255,7 @@ filter!(e -> e ≠ "case3_balanced_battery_3ph", cases)

# obtain solution from dss
sol_dss = open("$solution_dir/$case.json", "r") do f
JSON.parse(f)
Dict{String, Any}(JSON.parse(f))
end

sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
Expand Down Expand Up @@ -285,7 +285,7 @@ filter!(e -> e ≠ "case3_balanced_battery_3ph", cases)
res = compute_mc_pf(pfd)

sol_dss = open("$solution_dir/$case.json", "r") do f
JSON.parse(f)
Dict{String, Any}(JSON.parse(f))
end

sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
Expand Down Expand Up @@ -323,7 +323,7 @@ cases = ["test_trans_dy_3w", "test_trans_yy_3w", "ut_trans_3w_dyy_1", "ut_trans_

# obtain solution from dss
sol_dss = open("$solution_dir/$case.json", "r") do f
JSON.parse(f)
Dict{String, Any}(JSON.parse(f))
end

sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
Expand Down Expand Up @@ -388,11 +388,10 @@ solution_dir = "data/opendss_solutions"
@test res["termination_status"]["10"] == PF_CONVERGED

sol_dss = open("$solution_dir/$case.json", "r") do f
JSON.parse(f)
Dict{String, Any}(JSON.parse(f))
end

sol_pmd = transform_solution(res["solution"], data_math, make_si=true)

v_maxerr_pu = compare_sol_dss_pmd(sol_dss, sol_pmd["nw"]["10"], eng_ts["nw"]["10"], data_math["nw"]["10"], verbose=false, compare_math=true)
@test v_maxerr_pu <= 1E-1 # This tolerance is selected for the multinetwork to pass, must be tightened later. The problem may be with OpenDSS json result.

Expand All @@ -419,7 +418,7 @@ filter!(e -> e ≠ "case3_unbalanced_delta_loads", cases)

# obtain solution from dss
sol_dss = open("$solution_dir/$case.json", "r") do f
JSON.parse(f)
Dict{String, Any}(JSON.parse(f))
end

sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
Expand Down
2 changes: 1 addition & 1 deletion test/en_pf_validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ case_transformations = Dict(

# obtain solution from dss
sol_dss = open("$solution_dir/$case.json", "r") do f
JSON.parse(f)
Dict{String, Any}(JSON.parse(f))
end

# add lb on neutrals to prevent issues with ACR formulations
Expand Down
2 changes: 1 addition & 1 deletion test/opf_bf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

result = solve_mc_opf(data, LPUBFDiagPowerModel, ipopt_solver; solution_processors=[sol_data_model!])

@test result["termination_status"] == LOCALLY_SOLVED
@test result["primal_status"] == FEASIBLE_POINT

@test isapprox(sum(result["solution"]["voltage_source"]["source"]["pg"]), 40.26874; atol=1)
@test isapprox(sum(result["solution"]["voltage_source"]["source"]["qg"]), 17.1721; atol=1)
Expand Down
Loading