Skip to content

Commit

Permalink
Formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianManriqueM committed Sep 17, 2024
1 parent c9d885d commit d2440bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/initialization/generator_components/init_tg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ function initialize_tg!(
return
end


function initialize_tg!(
device_states,
static::PSY.StaticInjection,
Expand All @@ -419,7 +418,7 @@ function initialize_tg!(
τm0 = inner_vars[τm_var]
τe0 = inner_vars[τe_var]
P0 = PSY.get_active_power(static)

#Get parameters
tg = PSY.get_prime_mover(dynamic_device)
reg = PSY.get_reg(tg)
Expand Down Expand Up @@ -452,8 +451,9 @@ function initialize_tg!(
pi_out, dxg2_dt = pi_block(pid_input, x_g2, Kp_prime, Ki_prime)
pd_out, dxg4_dt = high_pass(pid_input, x_g4, Kd_prime, Ta)

power_at_gate = three_level_gate_to_power_map(x_g6, gate_openings, power_gate_openings)

power_at_gate =
three_level_gate_to_power_map(x_g6, gate_openings, power_gate_openings)

y_LL_out, dxg7_dt = lead_lag(power_at_gate, x_g7, 1.0, -Tw, Tw / 2.0)

out[1] = y_LL_out - τm0
Expand All @@ -470,7 +470,7 @@ function initialize_tg!(
xg1_guess = τe0 - P_ref_guess

#x0 = [P_ref_guess, xg1_guess, 0.0, 0.0, 0.0, 0.0, gate0, 3.0 * τm0]
x0 = [P_ref_guess,0.0, gate0, gate0, 0.0, gate0, gate0, 3.0 * τm0]
x0 = [P_ref_guess, 0.0, gate0, gate0, 0.0, gate0, gate0, 3.0 * τm0]
sol = NLsolve.nlsolve(f!, x0; ftol = STRICT_NLSOLVE_F_TOLERANCE)
if !NLsolve.converged(sol)
@warn("Initialization of Turbine Governor $(PSY.get_name(static)) failed")
Expand Down
15 changes: 6 additions & 9 deletions src/models/generator_models/tg_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function mass_matrix_tg_entries!(
return
end


function mass_matrix_tg_entries!(
mass_matrix,
tg::PSY.WPIDHY,
Expand Down Expand Up @@ -473,13 +472,13 @@ function mdl_tg_ode!(
Kp_prime = (-Ta * Ki) + Kp
Kd_prime = (Ta^2 * Ki) - (Ta * Kp) + Kd
Ki_prime = Ki

x_in = τ_e - P_ref
#Compute block derivatives
_, dxg1_dt = low_pass_mass_matrix(x_in, x_g1, reg, T_reg)
pid_input = x_g1 - (ω[1] - ω_sys)
pi_out, dxg2_dt = pi_block(pid_input, x_g2, Kp_prime, Ki_prime)
pd_out, dxg4_dt = high_pass(pid_input, x_g4, Kd_prime, Ta)
pd_out, dxg4_dt = high_pass(pid_input, x_g4, Kd_prime, Ta)
pid_out = pi_out + pd_out
_, dxg3_dt = low_pass(pid_out, x_g3, 1.0, Ta)
_, dxg5_dt = low_pass(x_g3, x_g5, 1.0, Tb)
Expand All @@ -490,14 +489,15 @@ function mdl_tg_ode!(
# Compute integrator
xg6_sat, dxg6_dt = integrator_windup(G_vel_sat, x_g6, 1.0, 1.0, G_min, G_max)

power_at_gate = three_level_gate_to_power_map(xg6_sat, gate_openings, power_gate_openings)
power_at_gate =
three_level_gate_to_power_map(xg6_sat, gate_openings, power_gate_openings)

# Compute Lead-Lag Block
ll_out, dxg7_dt = lead_lag(power_at_gate, x_g7, 1.0, -Tw, Tw / 2.0)
Power_sat = clamp(ll_out, P_min, P_max)

#Compute output torque
P_m = Power_sat - ( D * (ω[1] - ω_sys) )
P_m = Power_sat - (D * (ω[1] - ω_sys))

#Compute 1 State TG ODE:
output_ode[local_ix[1]] = dxg1_dt
Expand All @@ -514,9 +514,6 @@ function mdl_tg_ode!(
return
end




function mdl_tg_ode!(
device_states::AbstractArray{<:ACCEPTED_REAL_TYPES},
output_ode::AbstractArray{<:ACCEPTED_REAL_TYPES},
Expand Down

0 comments on commit d2440bc

Please sign in to comment.