Skip to content

Commit 653a425

Browse files
authored
Merge pull request #1192 from NREL-Sienna/rh/fix_multiple_issues
Close multiple simple issues in PSY
2 parents 0515d58 + 7fc254a commit 653a425

File tree

11 files changed

+82
-17
lines changed

11 files changed

+82
-17
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ The `PowerSystems.jl` package provides a rigorous data model using Julia structu
1313
## Version Advisory
1414

1515
- PowerSystems will work with Julia v1.6+.
16-
- If you are planning to use `PowerSystems.jl` in your package, check the [roadmap to version 4.0](https://github.com/NREL-Sienna/PowerSystems.jl/projects/4) for upcoming changes
1716

1817
## Device data enabled in PowerSystems
1918

src/base.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const SYSTEM_KWARGS = Set((
1010
:generator_mapping,
1111
:internal,
1212
:load_name_formatter,
13-
:load_zone_formatter,
13+
:loadzone_name_formatter,
1414
:runchecks,
1515
:shunt_name_formatter,
1616
:time_series_directory,
@@ -2449,6 +2449,7 @@ function convert_component!(
24492449
(from_to = line.rating, to_from = line.rating),
24502450
line.rating,
24512451
line.angle_limits,
2452+
line.g,
24522453
line.services,
24532454
line.ext,
24542455
_copy_internal_for_conversion(line),
@@ -2492,6 +2493,7 @@ function convert_component!(
24922493
line.b,
24932494
line.rating,
24942495
line.angle_limits,
2496+
line.g,
24952497
line.services,
24962498
line.ext,
24972499
_copy_internal_for_conversion(line),

src/descriptors/power_system_structs.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,18 @@
480480
},
481481
"validation_action": "error"
482482
},
483+
{
484+
"name": "g",
485+
"null_value": "(from=0.0, to=0.0)",
486+
"data_type": "FromTo",
487+
"comment": "Shunt conductance in pu ([`SYSTEM_BASE`](@ref per_unit)), specified both on the `from` and `to` ends of the line. These are commonly modeled with the same value",
488+
"valid_range": {
489+
"min": 0,
490+
"max": 100
491+
},
492+
"validation_action": "warn",
493+
"default": "(from=0.0, to=0.0)"
494+
},
483495
{
484496
"name": "services",
485497
"data_type": "Vector{Service}",
@@ -599,6 +611,18 @@
599611
},
600612
"validation_action": "error"
601613
},
614+
{
615+
"name": "g",
616+
"null_value": "(from=0.0, to=0.0)",
617+
"data_type": "FromTo",
618+
"comment": "Shunt conductance in pu ([`SYSTEM_BASE`](@ref per_unit)), specified both on the `from` and `to` ends of the line. These are commonly modeled with the same value",
619+
"valid_range": {
620+
"min": 0,
621+
"max": 100
622+
},
623+
"validation_action": "warn",
624+
"default": "(from=0.0, to=0.0)"
625+
},
602626
{
603627
"name": "services",
604628
"data_type": "Vector{Service}",

src/models/generated/Line.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This file is auto-generated. Do not edit.
1616
b::FromTo
1717
rating::Float64
1818
angle_limits::MinMax
19+
g::FromTo
1920
services::Vector{Service}
2021
ext::Dict{String, Any}
2122
internal::InfrastructureSystemsInternal
@@ -34,6 +35,7 @@ An AC transmission line
3435
- `b::FromTo`: Shunt susceptance in pu ([`SYSTEM_BASE`](@ref per_unit)), specified both on the `from` and `to` ends of the line. These are commonly modeled with the same value, validation range: `(0, 100)`
3536
- `rating::Float64`: Thermal rating (MVA). Flow on the line must be between -`rating` and `rating`. When defining a line before it is attached to a `System`, `rating` must be in per-unit divided by the base power of the `System` it will be attached to
3637
- `angle_limits::MinMax`: Minimum and maximum angle limits (radians), validation range: `(-1.571, 1.571)`
38+
- `g::FromTo`: (default: `(from=0.0, to=0.0)`) Shunt conductance in pu ([`SYSTEM_BASE`](@ref per_unit)), specified both on the `from` and `to` ends of the line. These are commonly modeled with the same value, validation range: `(0, 100)`
3739
- `services::Vector{Service}`: (default: `Device[]`) Services that this device contributes to
3840
- `ext::Dict{String, Any}`: (default: `Dict{String, Any}()`) An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude.
3941
- `internal::InfrastructureSystemsInternal`: (**Do not modify.**) PowerSystems.jl internal reference
@@ -59,6 +61,8 @@ mutable struct Line <: ACBranch
5961
rating::Float64
6062
"Minimum and maximum angle limits (radians)"
6163
angle_limits::MinMax
64+
"Shunt conductance in pu ([`SYSTEM_BASE`](@ref per_unit)), specified both on the `from` and `to` ends of the line. These are commonly modeled with the same value"
65+
g::FromTo
6266
"Services that this device contributes to"
6367
services::Vector{Service}
6468
"An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude."
@@ -67,12 +71,12 @@ mutable struct Line <: ACBranch
6771
internal::InfrastructureSystemsInternal
6872
end
6973

70-
function Line(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, services=Device[], ext=Dict{String, Any}(), )
71-
Line(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, services, ext, InfrastructureSystemsInternal(), )
74+
function Line(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, g=(from=0.0, to=0.0), services=Device[], ext=Dict{String, Any}(), )
75+
Line(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, g, services, ext, InfrastructureSystemsInternal(), )
7276
end
7377

74-
function Line(; name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, services=Device[], ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
75-
Line(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, services, ext, internal, )
78+
function Line(; name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, g=(from=0.0, to=0.0), services=Device[], ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
79+
Line(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, rating, angle_limits, g, services, ext, internal, )
7680
end
7781

7882
# Constructor for demo purposes; non-functional.
@@ -88,6 +92,7 @@ function Line(::Nothing)
8892
b=(from=0.0, to=0.0),
8993
rating=0.0,
9094
angle_limits=(min=-1.571, max=1.571),
95+
g=(from=0.0, to=0.0),
9196
services=Device[],
9297
ext=Dict{String, Any}(),
9398
)
@@ -113,6 +118,8 @@ get_b(value::Line) = value.b
113118
get_rating(value::Line) = get_value(value, value.rating)
114119
"""Get [`Line`](@ref) `angle_limits`."""
115120
get_angle_limits(value::Line) = value.angle_limits
121+
"""Get [`Line`](@ref) `g`."""
122+
get_g(value::Line) = value.g
116123
"""Get [`Line`](@ref) `services`."""
117124
get_services(value::Line) = value.services
118125
"""Get [`Line`](@ref) `ext`."""
@@ -138,6 +145,8 @@ set_b!(value::Line, val) = value.b = val
138145
set_rating!(value::Line, val) = value.rating = set_value(value, val)
139146
"""Set [`Line`](@ref) `angle_limits`."""
140147
set_angle_limits!(value::Line, val) = value.angle_limits = val
148+
"""Set [`Line`](@ref) `g`."""
149+
set_g!(value::Line, val) = value.g = val
141150
"""Set [`Line`](@ref) `services`."""
142151
set_services!(value::Line, val) = value.services = val
143152
"""Set [`Line`](@ref) `ext`."""

src/models/generated/MonitoredLine.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This file is auto-generated. Do not edit.
1717
flow_limits::FromTo_ToFrom
1818
rating::Float64
1919
angle_limits::MinMax
20+
g::FromTo
2021
services::Vector{Service}
2122
ext::Dict{String, Any}
2223
internal::InfrastructureSystemsInternal
@@ -38,6 +39,7 @@ For example, monitored lines can be used to restrict line flow following a conti
3839
- `flow_limits::FromTo_ToFrom`: Minimum and maximum permissable flow on the line (MVA), if different from the thermal rating defined in `rating`
3940
- `rating::Float64`: Thermal rating (MVA). Flow through the transformer must be between -`rating` and `rating`. When defining a line before it is attached to a `System`, `rating` must be in per-unit divided by the base power of the `System` it will be attached to
4041
- `angle_limits::MinMax`: Minimum and maximum angle limits (radians), validation range: `(-1.571, 1.571)`
42+
- `g::FromTo`: (default: `(from=0.0, to=0.0)`) Shunt conductance in pu ([`SYSTEM_BASE`](@ref per_unit)), specified both on the `from` and `to` ends of the line. These are commonly modeled with the same value, validation range: `(0, 100)`
4143
- `services::Vector{Service}`: (default: `Device[]`) Services that this device contributes to
4244
- `ext::Dict{String, Any}`: (default: `Dict{String, Any}()`) An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude.
4345
- `internal::InfrastructureSystemsInternal`: (**Do not modify.**) PowerSystems.jl internal reference
@@ -65,6 +67,8 @@ mutable struct MonitoredLine <: ACBranch
6567
rating::Float64
6668
"Minimum and maximum angle limits (radians)"
6769
angle_limits::MinMax
70+
"Shunt conductance in pu ([`SYSTEM_BASE`](@ref per_unit)), specified both on the `from` and `to` ends of the line. These are commonly modeled with the same value"
71+
g::FromTo
6872
"Services that this device contributes to"
6973
services::Vector{Service}
7074
"An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude."
@@ -73,12 +77,12 @@ mutable struct MonitoredLine <: ACBranch
7377
internal::InfrastructureSystemsInternal
7478
end
7579

76-
function MonitoredLine(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, services=Device[], ext=Dict{String, Any}(), )
77-
MonitoredLine(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, services, ext, InfrastructureSystemsInternal(), )
80+
function MonitoredLine(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, g=(from=0.0, to=0.0), services=Device[], ext=Dict{String, Any}(), )
81+
MonitoredLine(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, g, services, ext, InfrastructureSystemsInternal(), )
7882
end
7983

80-
function MonitoredLine(; name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, services=Device[], ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
81-
MonitoredLine(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, services, ext, internal, )
84+
function MonitoredLine(; name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, g=(from=0.0, to=0.0), services=Device[], ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
85+
MonitoredLine(name, available, active_power_flow, reactive_power_flow, arc, r, x, b, flow_limits, rating, angle_limits, g, services, ext, internal, )
8286
end
8387

8488
# Constructor for demo purposes; non-functional.
@@ -95,6 +99,7 @@ function MonitoredLine(::Nothing)
9599
flow_limits=(from_to=0.0, to_from=0.0),
96100
rating=0.0,
97101
angle_limits=(min=-1.571, max=1.571),
102+
g=(from=0.0, to=0.0),
98103
services=Device[],
99104
ext=Dict{String, Any}(),
100105
)
@@ -122,6 +127,8 @@ get_flow_limits(value::MonitoredLine) = get_value(value, value.flow_limits)
122127
get_rating(value::MonitoredLine) = get_value(value, value.rating)
123128
"""Get [`MonitoredLine`](@ref) `angle_limits`."""
124129
get_angle_limits(value::MonitoredLine) = value.angle_limits
130+
"""Get [`MonitoredLine`](@ref) `g`."""
131+
get_g(value::MonitoredLine) = value.g
125132
"""Get [`MonitoredLine`](@ref) `services`."""
126133
get_services(value::MonitoredLine) = value.services
127134
"""Get [`MonitoredLine`](@ref) `ext`."""
@@ -149,6 +156,8 @@ set_flow_limits!(value::MonitoredLine, val) = value.flow_limits = set_value(valu
149156
set_rating!(value::MonitoredLine, val) = value.rating = set_value(value, val)
150157
"""Set [`MonitoredLine`](@ref) `angle_limits`."""
151158
set_angle_limits!(value::MonitoredLine, val) = value.angle_limits = val
159+
"""Set [`MonitoredLine`](@ref) `g`."""
160+
set_g!(value::MonitoredLine, val) = value.g = val
152161
"""Set [`MonitoredLine`](@ref) `services`."""
153162
set_services!(value::MonitoredLine, val) = value.services = val
154163
"""Set [`MonitoredLine`](@ref) `ext`."""

src/models/generated/includes.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ export get_from_branch_control
528528
export get_fs
529529
export get_fuel
530530
export get_fuel_flag
531+
export get_g
531532
export get_gate_openings
532533
export get_gate_position_limits
533534
export get_hysteresis_binary_logic
@@ -1093,6 +1094,7 @@ export set_from_branch_control!
10931094
export set_fs!
10941095
export set_fuel!
10951096
export set_fuel_flag!
1097+
export set_g!
10961098
export set_gate_openings!
10971099
export set_gate_position_limits!
10981100
export set_hysteresis_binary_logic!

src/parsers/pm_io/data.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,10 +1695,7 @@ function correct_bus_types!(data::Dict{String, <:Any})
16951695
end
16961696

16971697
if bus_gens_count != 0 && bus["bus_type"] != 2
1698-
@info "active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 2" maxlog =
1699-
PS_MAX_LOG
1700-
bus["bus_type"] = 2
1701-
push!(modified, bus["index"])
1698+
@warn "active generators found at bus $(bus["bus_i"]) on bus type $(bus["bus_type"]), i.e. different than 2 (PV). Consider checking your data inputs."
17021699
end
17031700
end
17041701
end

src/parsers/power_models_data.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ function read_loadzones!(
326326
kwargs...,
327327
)
328328
@info "Reading LoadZones data in PowerModels dict to populate System ..."
329-
_get_name = get(kwargs, :loadzone_name_formatter, _get_pm_dict_name)
330329
zones = Set{Int}()
331330
zone_bus_map = Dict{Int, Vector}()
332331
for (_, bus) in data["bus"]
@@ -346,9 +345,15 @@ function read_loadzones!(
346345
load_zone_map[zone]["pd"] += get(load, "py", 0.0)
347346
load_zone_map[zone]["qd"] += get(load, "qy", 0.0)
348347
end
348+
349+
default_loadzone_naming = string
350+
# The formatter for loadzone_name should be a function that transform the LoadZone Int to a String
351+
_get_name = get(kwargs, :loadzone_name_formatter, default_loadzone_naming)
352+
349353
for zone in zones
354+
name = _get_name(zone)
350355
load_zone = make_loadzone(
351-
string(zone),
356+
name,
352357
load_zone_map[zone]["pd"],
353358
load_zone_map[zone]["qd"];
354359
kwargs...,

src/utils/IO/system_checks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Sum of system generator and storage ratings.
123123
function total_capacity_rating(sys::System)
124124
total = 0
125125
for component_type in (Generator, Storage)
126-
components = get_components(Generator, sys)
126+
components = get_components(component_type, sys)
127127
if !isempty(components)
128128
component_total = sum(get_rating.(components)) * get_base_power(sys)
129129
@debug "total rating for $component_type = $component_total" _group =

src/utils/print.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,10 @@ show_components(
298298
additional_columns::Union{Dict, Vector} = Dict();
299299
kwargs...,
300300
) = show_components(io, sys, component_type, additional_columns; kwargs...)
301+
302+
"""
303+
Show a table with the summary of time series attached to the system.
304+
"""
305+
function show_time_series(sys::System)
306+
IS.show_time_series_data(stdout, sys.data)
307+
end

0 commit comments

Comments
 (0)