Skip to content
Open
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 }}
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@latest
with:
version: '1'
Expand Down
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
PolyhedralRelaxations = "2e741578-48fa-11ea-2d62-b52c946f73a0"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Expand All @@ -30,11 +29,10 @@ InfrastructureModels = "0.7.3, 0.7.5"
Ipopt = "1"
JSON = "0.18, 0.19, 0.20, 0.21"
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"
25 changes: 20 additions & 5 deletions src/PowerModelsDistribution.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module PowerModelsDistribution
# test change
# File path utilities
import Glob
import FilePaths
Expand All @@ -17,7 +18,6 @@ module PowerModelsDistribution

# Logging Utilities
import Logging
import LoggingExtras

# Stdlib Imports
import Dates
Expand All @@ -44,11 +44,26 @@ module PowerModelsDistribution
# Setup Logging
include("core/logging.jl")
function __init__()
global _DEFAULT_LOGGER = Logging.current_logger()
global _LOGGER = Logging.ConsoleLogger(; meta_formatter=PowerModelsDistribution._pmd_metafmt)

Logging.global_logger(_LOGGER)
reset_logging_level!()
return
end

const _PKG_ROOT = dirname(dirname(pathof(PowerModelsDistribution)))
const CASE3B = joinpath(
_PKG_ROOT,
"test",
"data",
"opendss",
"case3_balanced.dss",
)

const CASE3U = joinpath(
_PKG_ROOT,
"test",
"data",
"opendss",
"case3_unbalanced.dss",
)

include("core/base.jl")
include("core/types.jl")
Expand Down
10 changes: 5 additions & 5 deletions src/core/constraint_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function constraint_mc_ohms_yt_from(pm::AbstractUnbalancedPowerModel, i::Int; nw
t_idx = (i, t_bus, f_bus)

if all(all(isapprox.(branch[k], 0.0)) for k in ["br_r", "br_x", "g_fr", "g_to", "b_fr", "b_to"])
@debug "branch $(branch["source_id"]) being treated as superconducting (effective zero impedance)"
@_debug "branch $(branch["source_id"]) being treated as superconducting (effective zero impedance)"
if !haskey(con(pm, nw), :branch_flow)
con(pm, nw)[:branch_flow] = Dict{Int,Vector{Vector{<:JuMP.ConstraintRef}}}()
end
Expand Down Expand Up @@ -502,7 +502,7 @@ function constraint_mc_ohms_yt_to(pm::AbstractUnbalancedPowerModel, i::Int; nw::
t_idx = (i, t_bus, f_bus)

if all(all(isapprox.(branch[k], 0.0)) for k in ["br_r", "br_x", "g_fr", "g_to", "b_fr", "b_to"])
@debug "branch $(branch["source_id"]) being treated as superconducting (effective zero impedance)"
@_debug "branch $(branch["source_id"]) being treated as superconducting (effective zero impedance)"
if !haskey(con(pm, nw), :branch_flow)
con(pm, nw)[:branch_flow] = Dict{Int,Vector{Vector{<:JuMP.ConstraintRef}}}()
end
Expand Down Expand Up @@ -1008,7 +1008,7 @@ function constraint_storage_state(pm::AbstractUnbalancedPowerModel, i::Int; nw::
if haskey(ref(pm, nw), :time_elapsed)
time_elapsed = ref(pm, nw, :time_elapsed)
else
@warn "network data should specify time_elapsed in hours, using 1.0 as a default"
@_warn "network data should specify time_elapsed in hours, using 1.0 as a default"
time_elapsed = 1.0
end

Expand All @@ -1028,15 +1028,15 @@ function constraint_storage_state(pm::AbstractUnbalancedPowerModel, i::Int, nw_1
if haskey(ref(pm, nw_2), :time_elapsed)
time_elapsed = ref(pm, nw_2, :time_elapsed)
else
@warn "network $(nw_2) should specify time_elapsed in hours, using 1.0 as a default"
@_warn "network $(nw_2) should specify time_elapsed in hours, using 1.0 as a default"
time_elapsed = 1.0
end

if haskey(ref(pm, nw_1, :storage), i)
constraint_storage_state(pm, nw_1, nw_2, i, storage["charge_efficiency"], storage["discharge_efficiency"], time_elapsed)
else
# if the storage device has status=0 in nw_1, then the stored energy variable will not exist. Initialize storage from data model instead.
@warn "storage component $(i) was not found in network $(nw_1) while building constraint_storage_state between networks $(nw_1) and $(nw_2). Using the energy value from the storage component in network $(nw_2) instead"
@_warn "storage component $(i) was not found in network $(nw_1) while building constraint_storage_state between networks $(nw_1) and $(nw_2). Using the energy value from the storage component in network $(nw_2) instead"
constraint_storage_state_initial(pm, nw_2, i, storage["energy"], storage["charge_efficiency"], storage["discharge_efficiency"], time_elapsed)
end
nothing
Expand Down
38 changes: 19 additions & 19 deletions src/core/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -840,21 +840,21 @@ function _correct_mc_voltage_angle_differences!(nw::Dict{String,<:Any}, default_
angmax = branch["angmax"]

if any(angmin .<= -pi/2)
@warn "this code only supports angmin values in -90 deg. to 90 deg., tightening the value on branch $(i) from $(rad2deg(angmin)) to -$(default_pad_deg) deg."
@_warn "this code only supports angmin values in -90 deg. to 90 deg., tightening the value on branch $(i) from $(rad2deg(angmin)) to -$(default_pad_deg) deg."
branch["angmin"][angmin .<= -pi/2] .= -default_pad

push!(modified, branch["index"])
end

if any(angmax .>= pi/2)
@warn "this code only supports angmax values in -90 deg. to 90 deg., tightening the value on branch $(i) from $(rad2deg(angmax)) to $(default_pad_deg) deg."
@_warn "this code only supports angmax values in -90 deg. to 90 deg., tightening the value on branch $(i) from $(rad2deg(angmax)) to $(default_pad_deg) deg."
branch["angmax"][angmax .>= pi/2] .= default_pad

push!(modified, branch["index"])
end

if any((angmin .== 0.0) .& (angmax .== 0.0))
@warn "angmin and angmax values are 0, widening these values on branch $(i) to +/- $(default_pad_deg) deg."
@_warn "angmin and angmax values are 0, widening these values on branch $(i) to +/- $(default_pad_deg) deg."
branch["angmin"][(angmin .== 0.0) .& (angmax .== 0.0)] .= -default_pad
branch["angmax"][(angmin .== 0.0) .& (angmax .== 0.0)] .= default_pad

Expand Down Expand Up @@ -902,7 +902,7 @@ function _correct_mc_thermal_limits!(nw::Dict{String,<:Any})::Set{Int}

if all(isapprox.(rate_value, 0.0))
delete!(branch, rate_key)
@warn "removing zero $(rate_key) limit on branch $(branch["index"])"
@_warn "removing zero $(rate_key) limit on branch $(branch["index"])"

push!(modified, branch["index"])
end
Expand Down Expand Up @@ -1129,7 +1129,7 @@ function _rescale_cost_model!(comp::Dict{String,<:Any}, scale::Real)
comp["cost"][i] = item*(scale^(degree-i))
end
else
@warn "Skipping cost model of type $(comp["model"]) in per unit transformation"
@_warn "Skipping cost model of type $(comp["model"]) in per unit transformation"
end
end
end
Expand All @@ -1153,7 +1153,7 @@ function _correct_branch_directions!(pm_data::Dict{String,<:Any})
orientation_rev = (branch["t_bus"], branch["f_bus"])

if in(orientation_rev, orientations)
@warn "reversing the orientation of branch $(i) $(orientation) to be consistent with other parallel branches"
@_warn "reversing the orientation of branch $(i) $(orientation) to be consistent with other parallel branches"
branch_orginal = copy(branch)
branch["f_bus"] = branch_orginal["t_bus"]
branch["t_bus"] = branch_orginal["f_bus"]
Expand Down Expand Up @@ -1303,21 +1303,21 @@ function _correct_bus_types!(pm_data::Dict{String,<:Any})::Set{Int}
for (i, bus) in filter(x->x.second["bus_i"] in island, pm_data["bus"])
if bus["bus_type"] == 1
if !isempty(bus_gens[i]) # PQ
@info "active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 2"
@_info "active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 2"
bus["bus_type"] = 2
push!(modified, bus["bus_i"])
end
elseif bus["bus_type"] == 2 # PV
if isempty(bus_gens[i])
@info "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1"
@_info "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1"
bus["bus_type"] = 1
push!(modified, bus["bus_i"])
end
elseif bus["bus_type"] == 3 # Slack
if !isempty(bus_gens[i])
slack_found = true
else
@info "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1"
@_info "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1"
bus["bus_type"] = 1
push!(modified, bus["bus_i"])
end
Expand All @@ -1328,7 +1328,7 @@ function _correct_bus_types!(pm_data::Dict{String,<:Any})::Set{Int}
if length(bus_gens[i]) != 0
new_bus_type = 2
end
@info "bus $(bus["bus_i"]) has an unrecongized bus_type $(bus["bus_type"]), updating to bus_type $(new_bus_type)"
@_info "bus $(bus["bus_i"]) has an unrecongized bus_type $(bus["bus_type"]), updating to bus_type $(new_bus_type)"
bus["bus_type"] = new_bus_type
push!(modified, bus["bus_i"])
end
Expand All @@ -1340,9 +1340,9 @@ function _correct_bus_types!(pm_data::Dict{String,<:Any})::Set{Int}
ref_bus = pm_data["bus"]["$(der["bus"])"]
ref_bus["bus_type"] = 3
push!(modified, der["bus"])
@info "no reference bus found, setting bus $(der["bus"]) as reference based on $(der["type"]) $(der["id"])"
@_info "no reference bus found, setting bus $(der["bus"]) as reference based on $(der["type"]) $(der["id"])"
else
@info "no generators found in the given network data, disabling island"
@_info "no generators found in the given network data, disabling island"
for bus in island
pm_data["bus"]["$bus"]["bus_type"] = 4
push!(modified, bus)
Expand All @@ -1358,7 +1358,7 @@ end
"finds the largest active generation asset (gen, storage) in an island"
function _biggest_der(pm_data::Dict{String,<:Any}; island::Set{Int}=Set{Int}([bus["bus_i"] for (_,bus) in get(pm_data, "bus", Dict())]))::Dict{String,Any}
if length(filter(x->x.second["gen_bus"] in island && x.second["gen_status"] == 1, get(pm_data, "gen", Dict()))) + length(filter(x->x.second["storage_bus"] in island && x.second["status"] == 1, get(pm_data, "storage", Dict()))) == 0
@debug "there are no active DERs in the island $island"
@_debug "there are no active DERs in the island $island"
end

biggest_der = Dict{String,Any}()
Expand Down Expand Up @@ -1493,7 +1493,7 @@ function _correct_cost_function!(id, comp, type_name, pmin_key, pmax_key)
error("ncost of $(comp["ncost"]) not consistent with $(length(comp["cost"])) cost values on $(type_name) $(id)")
end
else
@warn "Unknown cost model of type $(comp["model"]) on $(type_name) $(id)"
@_warn "Unknown cost model of type $(comp["model"]) on $(type_name) $(id)"
end
end

Expand All @@ -1517,7 +1517,7 @@ function _remove_pwl_cost_duplicates!(id, comp, type_name; tolerance=1e-2)
end

if length(unique_costs) < length(comp["cost"])
@warn "removing duplicate points from pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(unique_costs)"
@_warn "removing duplicate points from pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(unique_costs)"
comp["cost"] = unique_costs
comp["ncost"] = div(length(unique_costs), 2)
return true
Expand Down Expand Up @@ -1557,7 +1557,7 @@ function _simplify_pwl_cost!(id, comp, type_name; tolerance=1e-2)
push!(smpl_cost, y2)

if length(smpl_cost) < length(comp["cost"])
@warn "simplifying pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(smpl_cost)"
@_warn "simplifying pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(smpl_cost)"
comp["cost"] = smpl_cost
comp["ncost"] = div(length(smpl_cost), 2)
return true
Expand Down Expand Up @@ -1592,7 +1592,7 @@ function _simplify_cost_terms!(pm_data::Dict{String,<:Any})
end
if length(gen["cost"]) != ncost
gen["ncost"] = length(gen["cost"])
@info "removing $(ncost - gen["ncost"]) cost terms from generator $(i): $(gen["cost"])"
@_info "removing $(ncost - gen["ncost"]) cost terms from generator $(i): $(gen["cost"])"
end
end
end
Expand Down Expand Up @@ -1640,7 +1640,7 @@ function standardize_cost_terms!(data::Dict{String,<:Any}; order=-1)
comp_max_order = order+1
else
if order != -1 # if not the default
@warn "a standard cost order of $(order) was requested but the given data requires an order of at least $(comp_max_order-1)"
@_warn "a standard cost order of $(order) was requested but the given data requires an order of at least $(comp_max_order-1)"
end
end

Expand Down Expand Up @@ -1669,7 +1669,7 @@ function _standardize_cost_terms!(components::Dict{String,<:Any}, comp_order::In
#println("std gen cost: $(comp["cost"])")

subnet = !isempty(nw) ? " on subnetwork $nw" : ""
@info "updated $(cost_comp_name) $(comp["index"])$(subnet) cost function with order $(length(current_cost)) to a function of order $(comp_order): $(comp["cost"])"
@_info "updated $(cost_comp_name) $(comp["index"])$(subnet) cost function with order $(length(current_cost)) to a function of order $(comp_order): $(comp["cost"])"
push!(modified, comp["index"])
end
end
Expand Down
Loading
Loading