1. Set up (define system, draw FBD, write ODEs) a particle problem.
Just one particle. 2D or 3D, your choice. Use a force, or forces that you like (gravity, spring, air friction). Any example of interest. Find a numerical solution. Graph it. Animate it. Try to make an interesting observation.
1 System Description and Free Body Diagram
I think I have chosen a just hard enough interesting problem. A spring pendulum consists of a mass \(m\) attached to a spring of natural length \(l_0\) and spring constant \(k\).
The system experiences:
Spring force \(\vec{F_s} = k(\|{\vec{r}\|}-l_0)(-\hat{r})\)
Gravitational force \(\vec{F_g} = mg(-\hat{j})\)
Damping force \(\vec{F_d} = cv(-\hat{v})\)
../../media/problem01/problem01-fbd.jpeg
Figure 1: Free Object Diagram
2 Equations of Motion
In Cartesian coordinates, the equations of motion are:
functionmakie_animation(sol; filename="sol_animation.gif", title="Animation") sol_matrix =reduce(hcat, sol.u)' x = sol_matrix[:, 1] y = sol_matrix[:, 2] θ =atan.(sol_matrix[:, 2], sol_matrix[:, 1])# coarse boundaries, for continuous(interpolated) boundary see: https://docs.sciml.ai/DiffEqDocs/stable/examples/min_and_max/ xlimits = (minimum(x)-1, maximum(x)+1) ylimits = (minimum(y)-1, maximum(y)+1) time =Observable(0.0) x =@lift(sol($time)[1]) y =@lift(sol($time)[2])# Create observables for line coordinates line_x =@lift([0, $x]) line_y =@lift([0, $y]) animation =Figure() ax =Axis(animation[1, 1], title =@lift("t = $(round($time, digits =1))"), limits=(xlimits, ylimits), aspect=1)scatter!(ax, x, y, color=:red, markersize =15)lines!(ax, line_x, line_y, color=:black) framerate =30 timestamps =range(0, last(sol.t), step=1/framerate)record(animation, filename, timestamps; framerate = framerate) do t time[] = tendreturn animationend
6 Observations
Energy exchange between potential and kinetic forms
Damped oscillations due to viscous friction
For some parameters there is weird behaviour at very small scales. This is probably an artifact of the solver and floating point truncations. I was unable to reproduce this, but I had shown this to Professor Andy and Ganesh Bhaiya.
Increasing c by a little has a drastic effect
The problem was fun to simulate
Julia was fun to code in: Libraries were ergonomic to use, DifferentialEquations.jl, and Makie.jl
I noticed only much later that all of the trajectories for when resting length is zero are elipses.