From e650ed1e1e908e51c78c1b047bec0da7c4fea366 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Sat, 27 Apr 2024 04:25:23 -0400 Subject: testing --- examples/FallingBall3.jl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'examples') 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]) -- cgit v1.2.3-70-g09d2