Skip to content

Commit

Permalink
Add post processing
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianManriqueM committed Sep 17, 2024
1 parent d2440bc commit 232f332
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/post_processing/post_proc_generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1116,3 +1116,34 @@ function _mechanical_torque(
τm = Pe ./ ω
return ts, τm
end

function _mechanical_torque(
tg::PSY.WPIDHY,
name::String,
res::SimulationResults,
dt::Union{Nothing, Float64, Vector{Float64}},
)
# Get params
D = PSY.get_D(tg)
gate_openings = PSY.get_gate_openings(tg)
power_gate_openings = PSY.get_power_gate_openings(tg)
Tw = PSY.get_Tw(tg)
setpoints = get_setpoints(res)
ω_ref = setpoints[name]["ω_ref"]

# Get state results
ts, x_g7 = post_proc_state_series(res, (name, :x_g7), dt)
_, x_g6 = post_proc_state_series(res, (name, :x_g6), dt)
_, ω = post_proc_state_series(res, (name, ), dt)
Pm = similar(x_g7)

for (ix, x7) in enumerate(x_g7)
x6 = x_g6[ix]
power_at_gate =
three_level_gate_to_power_map(x6, gate_openings, power_gate_openings)
ll_out, _ = lead_lag(power_at_gate, x7, 1.0, -Tw, Tw / 2.0)
Pm[ix] = ll_out - D * (ω[ix] - ω_ref)
end
τm = Pm ./ ω
return ts, τm
end

0 comments on commit 232f332

Please sign in to comment.