Hi,
The AVRTypeI thrid equation (16.12c) in Power System Modelling and Scripting is not right.
It treat Se(vf) as a gain. But in fact is not.
Therefore the right code should like
`function mdl_avr_ode!(
device_states::AbstractArray{<:ACCEPTED_REAL_TYPES},
output_ode::AbstractArray{<:ACCEPTED_REAL_TYPES},
inner_vars::AbstractArray{<:ACCEPTED_REAL_TYPES},
dynamic_device::DynamicWrapper{PSY.DynamicGenerator{M, S, PSY.AVRTypeI, TG, P}},
h,
t,
) where {M <: PSY.Machine, S <: PSY.Shaft, TG <: PSY.TurbineGov, P <: PSY.PSS}
#Obtain references
V0_ref = get_V_ref(dynamic_device)
#Obtain indices for component w/r to device
local_ix = get_local_state_ix(dynamic_device, PSY.AVRTypeI)
#Define inner states for component
internal_states = @view device_states[local_ix]
Vf = internal_states[1]
Vr1 = internal_states[2]
Vr2 = internal_states[3]
Vm = internal_states[4]
#Define external states for device
V_th = sqrt(inner_vars[VR_gen_var]^2 + inner_vars[VI_gen_var]^2)
Vs = inner_vars[V_pss_var]
#Get parameters
avr = PSY.get_avr(dynamic_device)
Ka = PSY.get_Ka(avr)
Ke = PSY.get_Ke(avr)
Kf = PSY.get_Kf(avr)
Ta = PSY.get_Ta(avr)
Te = PSY.get_Te(avr)
Tf = PSY.get_Tf(avr)
Tr = PSY.get_Tr(avr)
Ae = PSY.get_Ae(avr)
Be = PSY.get_Be(avr)
#Compute auxiliary parameters
Se_Vf = Ae * exp(Be * abs(Vf)) #16.13
V_ref = V0_ref + Vs
# Compute block derivatives
_, dVm_dt = low_pass(V_th, Vm, 1.0, Tr)
y_hp, dVr2_dt = high_pass(Vf, Vr2, Kf, Tf)
_, dVr1_dt = low_pass(V_ref - Vm - y_hp, Vr1, Ka, Ta)
v3 = Vr1 - Se_Vf - Ke * Vf
_, dVf_dt = integrator_nonwindup(v3, Vf, 1.0, Te, 0.0, Inf)
#Compute 4 States AVR ODE:
output_ode[local_ix[1]] = dVf_dt #16.12c
output_ode[local_ix[2]] = dVr1_dt #16.12a
output_ode[local_ix[3]] = dVr2_dt #16.12b
output_ode[local_ix[4]] = dVm_dt #16.11
#Update inner_vars
inner_vars[Vf_var] = Vf
return
end`
Hi,
The AVRTypeI thrid equation (16.12c) in Power System Modelling and Scripting is not right.
It treat Se(vf) as a gain. But in fact is not.
Therefore the right code should like
`function mdl_avr_ode!(
device_states::AbstractArray{<:ACCEPTED_REAL_TYPES},
output_ode::AbstractArray{<:ACCEPTED_REAL_TYPES},
inner_vars::AbstractArray{<:ACCEPTED_REAL_TYPES},
dynamic_device::DynamicWrapper{PSY.DynamicGenerator{M, S, PSY.AVRTypeI, TG, P}},
h,
t,
) where {M <: PSY.Machine, S <: PSY.Shaft, TG <: PSY.TurbineGov, P <: PSY.PSS}
end`