aboutsummaryrefslogtreecommitdiff
path: root/examples/FallingBall3.jl
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2024-04-27 04:25:23 -0400
committersotech117 <michael_foiani@brown.edu>2024-04-27 04:25:23 -0400
commite650ed1e1e908e51c78c1b047bec0da7c4fea366 (patch)
tree1fe238de7ca199b7fdee9bc29395080b3c4790e7 /examples/FallingBall3.jl
parent02756d17bca6f2b3bafa3f7b9fb6e5af438e94a0 (diff)
testing
Diffstat (limited to 'examples/FallingBall3.jl')
-rw-r--r--examples/FallingBall3.jl16
1 files changed, 9 insertions, 7 deletions
diff --git a/examples/FallingBall3.jl b/examples/FallingBall3.jl
index 123a19a..823adfb 100644
--- a/examples/FallingBall3.jl
+++ b/examples/FallingBall3.jl
@@ -8,13 +8,15 @@ g = 9.8 # acceleration of gravity in m/s^2
t_final = 1.0 # final time of trajectory
p = 0.0 # parameters (not used here)
-function tendency!(dyv::Vector{Float64}, yv::Vector{Float64}, p, t::Float64) # ! notation tells us that arguments will be modified
- y = yv[1] # 2D phase space; use vcat(x, v) to combine 2 vectors
- v = yv[2] # dy/dt = v
- a = -g # dv/dt = -g
+function tendency!(dyv::Vector{Float64}, yv::Vector{Float64}, p, t) # ! notation tells us that arguments will be modified
+ y = yv[1] # 2D phase space; use vcat(x, v) to combine 2 vectors
+ v = yv[2] # dy/dt = v
+ a = -g # dv/dt = -g
- dyv[1] = v
- dyv[2] = a
+ dyv[1] = v
+ dyv[2] = a
+
+ println("t = ", t, " y = ", y, " v = ", v)
end
y0 = 10.0 # initial position in meters
@@ -23,7 +25,7 @@ yv0 = [y0, v0] # initial condition in phase space
tspan = (0.0, t_final) # span of time to simulate
prob = ODEProblem(tendency!, yv0, tspan, p) # specify ODE
-sol = solve(prob, Tsit5(), reltol=1e-8, abstol=1e-8) # solve using Tsit5 algorithm to specified accuracy
+sol = solve(prob, Tsit5(), reltol = 1e-8, abstol = 1e-8) # solve using Tsit5 algorithm to specified accuracy
println("\n\t Results")
println("final time = ", sol.t[end])