-
Notifications
You must be signed in to change notification settings - Fork 70
/
VirtualInertia.jl
92 lines (83 loc) · 3.14 KB
/
VirtualInertia.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
#=
This file is auto-generated. Do not edit.
=#
#! format: off
"""
mutable struct VirtualInertia <: ActivePowerControl
Ta::Float64
kd::Float64
kω::Float64
P_ref::Float64
ext::Dict{String, Any}
states::Vector{Symbol}
n_states::Int
end
Parameters of a Virtual Inertia with SRF using VSM for active power controller
# Arguments
- `Ta::Float64`: VSM inertia constant, validation range: `(0, nothing)`
- `kd::Float64`: VSM damping constant, validation range: `(0, nothing)`
- `kω::Float64`: frequency droop gain, validation range: `(0, nothing)`
- `P_ref::Float64`: Reference Power Set-point, validation range: `(0, nothing)`
- `ext::Dict{String, Any}`
- `states::Vector{Symbol}`: The states of the VirtualInertia model are:
θ_oc: Phase angle displacement of the virtual synchronous generator model
ω_oc: Speed of the rotating reference frame of the virtual synchronous generator model
- `n_states::Int`: VirtualInertia has two states
"""
mutable struct VirtualInertia <: ActivePowerControl
"VSM inertia constant"
Ta::Float64
"VSM damping constant"
kd::Float64
"frequency droop gain"
kω::Float64
"Reference Power Set-point"
P_ref::Float64
ext::Dict{String, Any}
"The states of the VirtualInertia model are:
θ_oc: Phase angle displacement of the virtual synchronous generator model
ω_oc: Speed of the rotating reference frame of the virtual synchronous generator model"
states::Vector{Symbol}
"VirtualInertia has two states"
n_states::Int
end
function VirtualInertia(Ta, kd, kω, P_ref=1.0, ext=Dict{String, Any}(), )
VirtualInertia(Ta, kd, kω, P_ref, ext, [:θ_oc, :ω_oc], 2, )
end
function VirtualInertia(; Ta, kd, kω, P_ref=1.0, ext=Dict{String, Any}(), states=[:θ_oc, :ω_oc], n_states=2, )
VirtualInertia(Ta, kd, kω, P_ref, ext, states, n_states, )
end
# Constructor for demo purposes; non-functional.
function VirtualInertia(::Nothing)
VirtualInertia(;
Ta=0,
kd=0,
kω=0,
P_ref=0,
ext=Dict{String, Any}(),
)
end
"""Get [`VirtualInertia`](@ref) `Ta`."""
get_Ta(value::VirtualInertia) = value.Ta
"""Get [`VirtualInertia`](@ref) `kd`."""
get_kd(value::VirtualInertia) = value.kd
"""Get [`VirtualInertia`](@ref) `kω`."""
get_kω(value::VirtualInertia) = value.kω
"""Get [`VirtualInertia`](@ref) `P_ref`."""
get_P_ref(value::VirtualInertia) = value.P_ref
"""Get [`VirtualInertia`](@ref) `ext`."""
get_ext(value::VirtualInertia) = value.ext
"""Get [`VirtualInertia`](@ref) `states`."""
get_states(value::VirtualInertia) = value.states
"""Get [`VirtualInertia`](@ref) `n_states`."""
get_n_states(value::VirtualInertia) = value.n_states
"""Set [`VirtualInertia`](@ref) `Ta`."""
set_Ta!(value::VirtualInertia, val) = value.Ta = val
"""Set [`VirtualInertia`](@ref) `kd`."""
set_kd!(value::VirtualInertia, val) = value.kd = val
"""Set [`VirtualInertia`](@ref) `kω`."""
set_kω!(value::VirtualInertia, val) = value.kω = val
"""Set [`VirtualInertia`](@ref) `P_ref`."""
set_P_ref!(value::VirtualInertia, val) = value.P_ref = val
"""Set [`VirtualInertia`](@ref) `ext`."""
set_ext!(value::VirtualInertia, val) = value.ext = val