9. Canon ball. A cannon ball m is launched at angle θ and speed v0. It is acted on by gravity g and a viscous drag with magnitude \(\|c
\vec{v}\|\).
(a) Find position vs time analytically.
(b) Find a numerical solution using θ = π/4, v0 = 1 m/s, g = 1 m/s 2 , m = 1 kg, c = 1 kg/ s.
(c) Compare the numeric and analytic solutions. At t = 2 how big is the error? How does the error depend on specified tolerances or step sizes?
(d) Use larger and larger values of v0 and for each trajectory choose a time interval so the canon at least gets back to the ground. Plot the trajectories (using equal scale for the x and y axis. Plot all curves on one plot. As v → ∞ what is the eventual shape? [Hint: the answer is simple and interesting.]
(e) For any given v0 there is a best launch angle θ ∗ for maximizing the range. As v0 → ∞ to what angle does θ ∗ tend? Justify your answer as best you can with careful numerics, analytical work, or both.
This numerical solution gives the following trajectory:
../../media/problem09/numerical_trajectory.png
Compare the numeric and analytics solutions? Plot time vs error. Plot step size and tolerances vs error.
For various initial conditions, the numeric and analytical solutions on the same graph, I was shifting the analytic in x direction by 0.1 unit to be able view both, otherwise they were overlapping with the default tolerances, but then I ended up using a non-dynamic step size explicit solver:
Simply put, it seems reducing both abstol and reltol generally reduces error from the analytic solution very quickly. What is the meaning of both is not yet entirely clear.
Use larger and larger values of v0, plot all of their trajectory till ball hits ground. What happens to the eventual shape as v -> ∞ ?
# ...functionbest_angle_for_speed(speed0, c) launchangles =pi/4.* ((range(-1.0, 1.0, 300)) .^3.0.+1.0) max_range =0 argmax_theta =0for launchangle in launchangles# problem setup prob =problem_setup(launchangle, speed0, c) sol =solve_till_empty(prob) cur_range = sol.u[end][1]if cur_range > max_range max_range = cur_range argmax_theta = launchangleendend argmax_thetaendspeeds =10.0.^range(0.0, 3.1, 100)bestangles = []for speed0 in speeds bestangle =best_angle_for_speed(speed0, 1)push!(bestangles, bestangle)endVisualization.plot_best_angle_for_speeds(speeds, bestangles)# ...
The weird choice for launchangles is for concentrating numeric choices for launchangles near \(\pi \over 4\). This produces:
../../media/problem09/speed_vs_bestangle_c_1.png
../../media/problem09/speed_vs_bestangle_c_10.png
It seems that my intuition was way off. It seems the best angle quickly becomes closer to zero as the initial velocity increases.
Let us plot the relation of drag with the best angle for a high velocity (say v = 1200), in file ./Ballistics/src/Ballistics.jl:
speed0 =1200.0bestangles = []drags =2.0.^range(1.0, 5.0)for c in drags bestangle =best_angle_for_speed(speed0, c)push!(bestangles, bestangle)endVisualization.plot_best_angle_vs_drag(drags, bestangles)
TODO: There isn’t much change in the eventual best angle for large velocities as drag changes. It does not seem right, but the best angle in such case seems to be some constant close to zero. I will explore this more later. The plot generated by above code is: