-
Notifications
You must be signed in to change notification settings - Fork 70
/
system_checks.jl
137 lines (119 loc) · 3.88 KB
/
system_checks.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
### Utility Functions needed for the construction of the Power System, mostly used for consistency checking ####
## Check that all the buses have a type defintion ##
function buscheck(buses)
for b in buses
if isnothing(b.bustype)
@warn "Bus/Nodes data does not contain information to build an a network" maxlog =
10
end
end
return
end
## Slack Bus Definition ##
function slack_bus_check(buses)
slack = -9
for b in buses
if b.bustype == ACBusTypes.REF
slack = b.number
break
end
end
if slack == -9
@error "Model doesn't contain a slack bus"
end
return
end
# TODO: Check for islanded Buses
# check for minimum timediff
function minimumtimestep(time_series::Array{T}) where {T <: TimeSeriesData}
if length(time_series[1].data) > 1
timeseries = time_series[1].data
n = length(timeseries) - 1
ts = []
for i in 1:n
push!(
ts,
TimeSeries.timestamp(timeseries)[n + 1] -
TimeSeries.timestamp(timeseries)[n],
)
end
return minimum(ts)
else
ts = Dates.Dates.Minute(1)
return ts
end
end
function critical_components_check(sys::System)
critical_component_types = [ACBus, Generator, ElectricLoad]
for component_type in critical_component_types
components = get_components(component_type, sys)
if length(components) == 0
@warn "There are no $(component_type) Components in the System"
end
end
end
"""
adequacy_check(sys::System)
Checks the system for sum(generator ratings) >= sum(load ratings).
# Arguments
- `sys::System`: system
"""
function adequacy_check(sys::System)
gen = total_capacity_rating(sys)
load = total_load_rating(sys)
load > gen && @warn "System peak load ($load) exceeds total capacity capability ($gen)."
return
end
"""
total_load_rating(sys::System)
Checks the system for sum(generator ratings) >= sum(load ratings).
# Arguments
- `sys::System`: system
"""
function total_load_rating(sys::System)
base_power = get_base_power(sys)
controllable_loads = get_components(ControllableLoad, sys)
cl =
if isempty(controllable_loads)
0.0
else
sum(get_max_active_power.(controllable_loads)) * base_power
end
@debug "System has $cl MW of ControllableLoad" _group = IS.LOG_GROUP_SYSTEM_CHECKS
static_loads = get_components(StaticLoad, sys)
sl = isempty(static_loads) ? 0.0 : sum(get_max_active_power.(static_loads)) * base_power
@debug "System has $sl MW of StaticLoad" _group = IS.LOG_GROUP_SYSTEM_CHECKS
# Total load calculation assumes P = Real(V^2/Y) assuming V=1.0
fa_loads = get_components(FixedAdmittance, sys)
fa =
if isempty(fa_loads)
0.0
else
sum(real.(get_base_voltage.(get_bus.(fa_loads)) .^ 2 ./ get_Y.(fa_loads)))
end
@debug "System has $fa MW of FixedAdmittance assuming admittance values are in P.U." _group =
IS.LOG_GROUP_SYSTEM_CHECKS
total_load = cl + sl + fa
@debug "Total System Load: $total_load" _group = IS.LOG_GROUP_SYSTEM_CHECKS
return total_load
end
"""
total_capacity_rating(sys::System)
Sum of system generator and storage ratings.
# Arguments
- `sys::System`: system
"""
function total_capacity_rating(sys::System)
total = 0
for component_type in (Generator, Storage)
components = get_components(Generator, sys)
if !isempty(components)
component_total = sum(get_rating.(components)) * get_base_power(sys)
@debug "total rating for $component_type = $component_total" _group =
IS.LOG_GROUP_SYSTEM_CHECKS
total += component_total
end
end
@debug "Total System capacity: $total" _group = IS.LOG_GROUP_SYSTEM_CHECKS
return total
end