- Published on
Numerical Simulation of a Golf Shot - Part 2
- Authors
- Name
- Tinker Assist
I should have mentioned it in part 1, but it is important that we are able to compute the ball path angle relative to the x-y plane at each time step. Since we will have the velocity vector for each step, we can compute this angle as follows
Initial Conditions
It's important to define initial conditions for the problem. You can think of these as step 0
, which we will use to find step 1
. You have to start somewhere!
The things that we are solving for using previous states in the problem are
launch angle This will be a user provided variable. Some common golf ball launch angles from a golf ball are about 5 degrees to 40 degrees.
position This one is easy. We will say that the initial location of our golf ball is at the origin of the x,y plane (0,0)
velocity Velocity is another user defined variable. We can use basic trigonometry to decompose the magnitude of our velocity into x and y components.
acceleration It's not very intuitive, but we are going to simplify acceleration in this case and say we only have acceleration due to gravity and no lift or drag acceleration. In reality, we should be computing drag and lift at step 0 because the ball has non-zero velocity, but it will make a negligibly impact on our simulation.
Simulation Approach
Euler's Method
We will be using Euler's Method to compute each step in our simulation. To explain Euler's method in simple terms, imagine the below plot is a golf ball trajectory. We don't know the position at future points in time (t+1), but we know the velocity at the current point in time (dotted line @ t). Thus, we assume the velocity stays relatively constant between t and t+1.
In the case of this plot, the slope of the line changes dramatically between t and t+1, but our large time step is meant to exaggerate be an exaggeration. As time steps t and t+1 converge closer and closer together, our assumption of a constant velocity becomes better and better.
We'll use Euler's Method to solve for velocity and postion at the next time step in each step of our simulation. We'll use the current velocity and acceleration (time = t), to compute these future position and velocity (time = t+1) values.
Parameters
Some important parameters to define in numerical integration include
Time step (dt) - Choosing this parameter is a balance between having sufficient fidelity in our model and not wasting compute for minimal fidelity gains. In this case, we can intuitively say that we should have somewhere on the order of 100 - 1000 time steps / second.
Simulation time - How long should my simulation run? In this case, we can intuitively think of an appropriate time. A golf ball would likely not be in the air for longer than 8 - 12 seconds, so we can set our run time to 12 seconds to be safe. ( Ultimately, we will stop the simulation when the golf ball "hits the ground" or the y-component of position falls below 0.)
Simulation Steps
So, here is what each step of our simulation will look like
- Compute magnitude of the velocity vector
- Compute Reynolds Number
- Compute Drag Coefficient
- Compute acceleration due to drag
- Compute non-dimensional spin factor
- Compute lift coefficient
- Compute acceleration due to lift
- Compute ball trajectory angle
- Compute acceleration components in the x,y plane
- Compute velocity at the next time step
- Compute position at the next time step
That's it! At each time step, we will save our position and velocity data in a state history array, and at the end we can plot our history.
In Part 3, we will implement these concepts in python and run a simulation.