Skip to content

Commit 5999ac4

Browse files
committed
add inhomogenous model
1 parent 0ab9f91 commit 5999ac4

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

benchmark/benchmark_cases.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,29 @@ BENCHMARK_CASES = [
7777
# [10,20],
7878
[100, 1_000, 10_000, 100_000],
7979
"Power grid network with PQ nodes and generators"
80+
),
81+
82+
BenchmarkCase(
83+
"powergrid_inhomogeneous_pq",
84+
N -> begin
85+
g = watts_strogatz(N, 3, 0.8; rng=StableRNG(1))
86+
rng = StableRNG(1)
87+
88+
# Create fixed P/Q values for half the nodes
89+
pq_count = N ÷ 2
90+
P_vals = -1*rand(rng, pq_count)
91+
Q_vals = -1*rand(rng, pq_count)
92+
93+
# Create vertex models with baked-in P/Q values
94+
pq_vertices = [pqnode_inhomogeneous(P_vals[i], Q_vals[i]) for i in 1:pq_count]
95+
gen_vertices = [generator() for _ in 1:(N-pq_count)]
96+
97+
# Shuffle the vertex types
98+
vertices = shuffle(rng, vcat(pq_vertices, gen_vertices))
99+
100+
Network(g, vertices, piline())
101+
end,
102+
[100, 1_000, 10_000, 100_000],
103+
"Power grid with heterogeneous PQ nodes having fixed P/Q values"
80104
)
81105
]

benchmark/benchmark_models.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,15 @@ Base.@propagate_inbounds function gen!(dv, v, isum, p, T)
109109
end
110110
generator() = VertexModel(; f=gen!, sym=[:u_r, :u_i, , ], g=StateMask(1:2),
111111
psym=[:H, :P, :D, , :E_f, :T_d_dash, :T_q_dash, :X_d_dash, :X_q_dash, :X_d, :X_q])
112+
113+
function pqnode_inhomogeneous(P, Q)
114+
Base.@propagate_inbounds function pq!(du, u, isum, _, t)
115+
ic = Complex(isum[1], isum[2])
116+
S = Complex(P, Q)
117+
uc = S/conj(ic)
118+
du[1] = real(uc)
119+
du[2] = imag(uc)
120+
nothing
121+
end
122+
VertexModel(; f=pq!, sym=[:u_r, :u_i], g=StateMask(1:2), psym=[], mass_matrix=0)
123+
end

benchmark/benchmark_utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,11 @@ function plot_over_N(target, baseline=nothing)
244244
comp = target
245245
end
246246

247-
fig = Makie.Figure(size=(2000,2000))
247+
fig = Makie.Figure(size=(2000,2500))
248248

249249
bmkeys = [
250250
"powergrid",
251+
"powergrid_inhomogeneous_pq",
251252
"diffusion_static_edge",
252253
"diffusion_ode_edge",
253254
"kuramoto_homogeneous",

0 commit comments

Comments
 (0)