Skip to content

Commit 0a3d9a5

Browse files
Fix up the linear DAE benchmarks
1 parent c3a8623 commit 0a3d9a5

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

benchmarks/DAE/LinearDAE.jmd

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ rlc_eqs = E_rlc * Dx ~ A_rlc * x + B_rlc .* u(t)
7777
@mtkbuild rlc_sys = ODESystem(rlc_eqs, t)
7878

7979
# Problems using constant voltage input
80-
rlc_prob = ODEProblem(rlc_sys, [], (0.0, 1e-3))
81-
rlc_static_prob = ODEProblem{false}(rlc_sys, SA[], (0.0, 1e-3))
80+
rlc_prob = ODEProblem(rlc_sys, [i_R => 0.0, v_C => 0.0], (0.0, 1e-3))
81+
rlc_static_prob = ODEProblem{false}(rlc_sys, SA[i_R => 0.0, v_C => 0.0], (0.0, 1e-3))
8282
```
8383

8484
## Index-2 DAE: Two Interconnected Rotating Masses
@@ -161,8 +161,8 @@ rl_eqs = E_rl * Dx ~ A_rl * x + B_rl .* u(t)
161161
@mtkbuild rl_sys = ODESystem(rl_eqs, t)
162162

163163
# Problems using current source input
164-
rl_prob = ODEProblem(rl_sys, [], (0.0, 1.0))
165-
rl_static_prob = ODEProblem{false}(rl_sys, SA[], (0.0, 1.0))
164+
rl_prob = ODEProblem(rl_sys, [v_L => 1.0], (0.0, 1.0))
165+
rl_static_prob = ODEProblem{false}(rl_sys, SA[v_L => 1.0], (0.0, 1.0))
166166
```
167167

168168
## Index-3 DAE: Cart Pendulum
@@ -210,8 +210,8 @@ cart_eqs = E_cart * Dx ~ A_cart * x + B_cart .* u(t)
210210
@mtkbuild cart_sys = ODESystem(cart_eqs, t)
211211

212212
# Problems using force input
213-
cart_prob = ODEProblem(cart_sys, [], (0.0, 1.0))
214-
cart_static_prob = ODEProblem{false}(cart_sys, SA[], (0.0, 1.0))
213+
cart_prob = ODEProblem(cart_sys, [dy_cart => 0.0, y_cart => 0.0], (0.0, 1.0))
214+
cart_static_prob = ODEProblem{false}(cart_sys, SA[dy_cart => 0.0, y_cart => 0.0], (0.0, 1.0))
215215
```
216216

217217
## Index-3 DAE: Electric Generator
@@ -252,8 +252,8 @@ gen_eqs = E_gen * Dx ~ A_gen * x + B_gen .* u(t)
252252
@mtkbuild gen_sys = ODESystem(gen_eqs, t)
253253

254254
# Problems using torque input
255-
gen_prob = ODEProblem(gen_sys, [], (0.0, 1.0))
256-
gen_static_prob = ODEProblem{false}(gen_sys, SA[], (0.0, 1.0))
255+
gen_prob = ODEProblem(gen_sys, [ω_gen => 1.0], (0.0, 1.0))
256+
gen_static_prob = ODEProblem{false}(gen_sys, SA[ω_gen => 1.0], (0.0, 1.0))
257257
```
258258

259259
## Index-3 DAE: Damped Mass-Spring System
@@ -308,39 +308,39 @@ x = [x1_spring, x2_spring, v1_spring, v2_spring, λ_spring]
308308
Dx = D.(x)
309309

310310
# Input function: impulse force followed by decay
311-
u(t) = (t < 0.1) ? 10.0 : 0.1*exp(-5*t) # Initial impulse then decay
311+
u(t) = ifelse((t < 0.1), 10.0, 0.1*exp(-5*t)) # Initial impulse then decay
312312

313313
# E*Dx = A*x + B*u
314314
spring_eqs = E_spring_5 * Dx ~ A_spring_5 * x + B_spring_5 .* u(t)
315315

316316
@mtkbuild spring_sys = ODESystem(spring_eqs, t)
317317

318318
# Problems using force input
319-
spring_prob = ODEProblem(spring_sys, [], (0.0, 2.0))
320-
spring_static_prob = ODEProblem{false}(spring_sys, SA[], (0.0, 2.0))
319+
spring_prob = ODEProblem(spring_sys, [λ_spring => 0.0, v1_spring => 0.0], (0.0, 2.0))
320+
spring_static_prob = ODEProblem{false}(spring_sys, SA[λ_spring => 0.0, v1_spring => 0.0], (0.0, 2.0))
321321
```
322322

323323
## Generate Reference Solutions
324324

325325
```julia
326326
# Generate reference solutions for all systems using robust methods
327-
rlc_ref = solve(rlc_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
328-
rlc_static_ref = solve(rlc_static_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
327+
rlc_ref = solve(rlc_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
328+
rlc_static_ref = solve(rlc_static_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
329329

330-
masses_ref = solve(masses_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
331-
masses_static_ref = solve(masses_static_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
330+
masses_ref = solve(masses_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
331+
masses_static_ref = solve(masses_static_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
332332

333-
rl_ref = solve(rl_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
334-
rl_static_ref = solve(rl_static_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
333+
rl_ref = solve(rl_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
334+
rl_static_ref = solve(rl_static_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
335335

336-
cart_ref = solve(cart_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
337-
cart_static_ref = solve(cart_static_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
336+
cart_ref = solve(cart_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
337+
cart_static_ref = solve(cart_static_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
338338

339-
gen_ref = solve(gen_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
340-
gen_static_ref = solve(gen_static_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
339+
gen_ref = solve(gen_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
340+
gen_static_ref = solve(gen_static_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
341341

342-
spring_ref = solve(spring_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
343-
spring_static_ref = solve(spring_static_prob, CVODE_BDF(), abstol=abstol_ref, reltol=reltol_ref)
342+
spring_ref = solve(spring_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
343+
spring_static_ref = solve(spring_static_prob, Rodas5P(), abstol=abstol_ref, reltol=reltol_ref)
344344

345345
# Problem and reference solution arrays
346346
all_probs = [

0 commit comments

Comments
 (0)