Skip to content

Commit

Permalink
Add bench.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed Mar 16, 2024
1 parent 6ae0cc0 commit 7fd9d42
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions examples/bench.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Printf
using KiteModels, KitePodModels, KiteUtils

if ! @isdefined kcu; const kcu = KCU(se()); end
if ! @isdefined kps4; const kps4 = KPS4(kcu); end

# the following values can be changed to match your interest
dt = 0.05
STEPS = 600
PLOT = false
FRONT_VIEW = false
ZOOM = true
PRINT = false
STATISTIC = false
# end of user parameter section #

function simulate(integrator, steps, plot=false)
start = integrator.p.iter
for i in 1:steps
if PRINT
lift, drag = KiteModels.lift_drag(kps4)
@printf "%.2f: " round(integrator.t, digits=2)
println("lift, drag [N]: $(round(lift, digits=2)), $(round(drag, digits=2))")
end

KiteModels.next_step!(kps4, integrator, dt=dt)
end
(integrator.p.iter - start) / steps
end

integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.04, prn=STATISTIC)

println("\nStarting simulation...")
simulate(integrator, 100)
runtime = @elapsed av_steps = simulate(integrator, STEPS-100)
println("\nTotal simulation time: $(round(runtime, digits=3)) s")
speed = (STEPS-100) / runtime * dt
println("Simulation speed: $(round(speed, digits=2)) times realtime.")
lift, drag = KiteModels.lift_drag(kps4)
println("lift, drag [N]: $(round(lift, digits=2)), $(round(drag, digits=2))")
println("Average number of callbacks per time step: $av_steps")

# Ryzen 7950X, GMRES solver
# Total simulation time: 0.712 s
# Simulation speed: 35.11 times realtime.
# lift, drag [N]: 597.4, 129.32
# Average number of callbacks per time step: 378.918

# Ryzen 7950X, LapackDense solver
# Total simulation time: 2.216 s
# Simulation speed: 11.28 times realtime.
# lift, drag [N]: 597.56, 129.31
# Average number of callbacks per time step: 1413.298

0 comments on commit 7fd9d42

Please sign in to comment.