Those who are new to scientific computing often underestimate the importance of verification and validation (V&V). Verification is the process of ensuring that your code solves the governing equations correctly, whereas validation involves demonstrating that your model accurately simulates reality by comparing to empirical data. V&V is the cornerstone of computational modeling and should be done every time you create a computational model. The process should be done carefully and methodically, building confidence in your model.
In this post, I will discuss the process of verification and will show how I use verification to build confidence in a model I created. The model I use in the example that follows computes the trajectory of a 2D object undergoing projectile motion and coming in contact with a flat surface. The model is a simpler version of a 3D model I am creating to simulate the trajectory of firebrands (i.e., embers from a wildfire) coming in contact with a roof.
Formulation

Before we can talk about verification, we need a computational model. Consider a 2D object with initial position and velocity
. When the object is in the air, it is subjected to the forces of gravity
and drag
, as shown in the figure. Here, m is mass, g is gravitational acceleration,
is the density of air, A is the area perpendicular to the motion,
is the drag coefficient, and v is velocity.
The equations of motion are
where and
are the x and y components of the resultant force acting on the object. Additionally,
When the object comes in contact with a flat surface oriented at angle with respect to the global x axis, we define two behaviors: bouncing and sliding. In reality, the object may roll as well, but we will ignore that behavior for the time-being.
For bouncing, we define e as the coefficient of restitution, which is a number between 0 and 1 that accounts for the degree of inelasticity in the collision (i.e., e=1 means a perfectly elastic collision and e=0 means a perfectly inelastic collision). The velocities before (“1”) and after (“2”) impact are transformed into their normal n and tangential t components. From vector algebra,
The velocities before and after impact are shown in the figure below.

Then,
Note that friction forces are also present when the object is in contact with the surface. As shown in the figure below, the friction force is , where
is the coefficient of kinetic friction. The friction force is included in the net force acting on the object during times that the object is in contact with the surface.

Numerical Model
The equations of motion are solved numerically using the fourth-order Runge-Kutta method [1]. In the Runge Kutta method, the function is projected forward with a slope that depends on the order of the analysis. For this type of analysis, the time step must be specified. By using an approximate slope and discretizing time in this manner, the analysis is no longer exact, although errors can be managed.
The equations of motion are dependent on whether the object is in contact with the surface or not. It is assumed that the object is in free fall until contact is detected (which is based on whether its computed coordinates pass the surface’s boundary within a specified tolerance . Mathematically, contact occurs when
Since it is possible that the computed coordinates overshoot the boundary, the bisection method [1] is used to determine a precise time when the object is within to tolerance.

Once contact has been identified, the normal and tangential velocity equations that define friction and sliding behaviors are invoked. To provide some stability to the solution, the velocity is set to zero when its magnitude is less than the tolerance, and once the velocity is zero, it remains zero.
The details of the calculations are left out for brevity. The computational model was implemented in Python, and the code was systematically debugged using the verification cases shown below.
Verification Process
Verification is an iterative process, and the problems chosen for verification should be analyzed anytime a change in the code is made. Because you are verifying that your code is solving the equations correctly, you should be able to test the convergence properties of your model.
Two types of verification problems exist. In the first case, an analytical solution is available, meaning that you are comparing your model to an “exact” answer. In the second case, you may have a problem that is too complex to solve analytically. Here, you might seek to compare your model to an existing model. Note that you can no longer show that your answer converges to the true solution. However, you can have some level of confidence if you can arrive at the same answer as someone else.
In assessing the accuracy of your solution, it is necessary to express your solution in terms of a percent error, either the true error (when an analytical solution exists) or an approximate error (when comparing to another model). The formula for calculating error is
When selecting verification cases, you should select problems that isolate the various levels of complexity in your model. For the model shown here, we have the following:
- Projectile motion without/with air resistance: Does the object reach the ground at the correct time and location? Does the trajectory match the theoretical solution?
- Bouncing: Does the distance traveled and the time for the object to come to a stop match the theoretical solution?
- Sliding with friction: For an object on an incline, does the distance traveled and the time for the object to come to a stop match the theoretical solution?
For each of these cases, it is important to demonstrate the convergence behavior of the model. Namely, as you successively cut the time step in half, the error should systematically reduce according to the order of the model. The order can be observed on a log-log plot of time step versus the absolute value of the error for varying time steps. I don’t show this in the example that follows but there are plenty of examples on the web.
Verification of the Current Model
Projectile Motion without Air Resistance
Consider a spherical object with mass m = 145 g and radius r = 3.75 cm with initial velocity of 30 m/s launched from the ground at an angle of . Ignoring drag, the time and distance traveled until the object hits the ground is
s
m
This solution can be found in most physics textbooks.
Using the code, the ball is expected to first hit the ground at s with a distance traveled of
m. The error is negligible (i.e., less than the tolerance). Note that time step has little influence on the accuracy of the simulation up to the first impact. The figure below shows the trajectory for time steps ranging from 0.1 s to 0.0001 s, and there is virtually no difference in the computed solution. Furthermore, due to the use of the bisection algorithm, time step has no influence on the accuracy of
and
.

Projectile Motion with Air Resistance
The drag force changes the trajectory of an object and reduces the distance traveled and time to impact. Chudinov [2] derived analytical expressions for several parameters that define the trajectory of objects in projectile motion with air resistance, namely, the peak ascent of the object H, the time to impact , and the flight range
, among others. Specifically,
where is a constant and the velocity at the apex
is given by
Consider again a spherical object with mass m = 145 g and radius r = 3.75 cm with initial velocity of 30 m/s launched from the ground at an angle of .
kg/m
and
.
The table below shows the time at impact and the horizontal distance traveled in comparison to the analytical solution. You can see that errors are within 1 percent. Moreover, refining the time step does not improve the solution due to the process used in the bisection algorithm.
Error (%) | Error (%) | |||
3.7533 | -0.9488 | 57.167 | 0.1377 | |
3.7533 | -0.9488 | 57.167 | 0.1377 | |
Analytical | 3.7892 | 57.088 |
Bouncing
According to Nagurka [3], a ball with zero initial velocity dropped on a flat surface from height with coefficient of restitution e will theoretically bounce until
The total distance traveled along the path s is
In the equations provided by Nagurka, drag and friction forces are neglected.
Consider now an object with m and e = 0.8. According to theory, the particle will stop bouncing at t = 4.064 s. The vertical distance traveled is s = 4.556 m.
The figure below shows the computed height of the particle as a function of time for various time steps. Good agreement is achieved for most of the analysis. Deviations occur as time progresses, with bounces becoming more out of sync as the particle approaches a stationary configuration.

The following table shows the computed time until the particle stops bouncing as well as the total distance traveled along the path. You can see that the computational model gives good agreement, with errors less than one percent for s.
t (s) | Error (%) | s (m) | Error (%) | |
3.032 | -25.40 | 4.185 | -8.126 | |
3.829 | -5.770 | 4.478 | -1.691 | |
4.040 | -0.5939 | 4.539 | -0.1129 | |
Exact | 4.064 | 4.556 |
Sliding with Friction
To verify the friction force calculation, consider a block on an incline at angle with initial velocity
and a coefficient of kinetic friction
. You can look in most textbooks and find that the block moves with acceleration
The distance s traveled before the block comes to rest is
The time until the block comes to rest is
The distance traveled and the time to reach zero velocity for angles were analyzed using the code. The table below shows the result for
, in which the initial velocity was 10 m/s up the slope. The coefficient of kinetic friction is
. Similar levels of accuracy were obtained for
, with the initial velocity of 10 m/s down the slope. You can see that a time step of 0.01 s gives results within 1 percent accuracy.
t (s) | Error (%) | s (m) | Error (%) | |
1.100 | 6.106 | 5.177 | -0.1254 | |
1.040 | 0.3202 | 5.183 | -0.004166 | |
Exact | 1.037 | 5.184 |
Conclusions
Through the process of verification, I was able to find and correct bugs in my code. I am confident now that the code is accurate for simulating the 2D problem I set out to model. When you do verification, I recommend that you systematically refine your mesh and time step and calculate errors. This will show you that your model is converging to the true solution. As you move forward, you may wonder, what is the best time step or mesh density for my model? Honestly, it is ultimately up to you, the modeler. You need to balance accuracy with computational efficiency. In the simple model shown here, the simulation times were negligible, but if I attempt to model a larger or more complex problem, then I will need to think about the computational resources needed to run a simulation. That’s a topic for a different time 🙂
References
[1] Chapra, S.C., and Canale, R.P. (2010). Numerical Methods for Engineers, McGraw Hill: New York, NY.
[2] Chudinov, P.S. (2004). “Analytical investigation of point mass motion in midair,” European Journal of Physics, 25, 73-79.
[3] Nagurka, M. (2003) “Aerodynamic effects in a dropped ping-pong ball experiment,” International Journal of Engineering Education, 19, 623-630.
Leave a Reply