Programming A Model Rocket Flight Simulator

Joshua Klontz and Brian Go

Bethesda Chevy-Chase High Sschool

Abstract

A program was built to simulate the flight of a model rocket. Previous software has been developed for use with real rockets, however the quality of those written for model rockets is often inadequate for practical and more advanced purposes. While both real and model rockets share the same velocity equation, for model rockets orbital mechanics are not needed. The simulator was composed of two parts, one written in C++ to calculate the flight of the rocket, and the other part was written in Visual Basic to allow a useable Graphical User Interface and a method for graphing the results. At the heart of the program is a brute-force integrator that takes into account the effects of engine thrust, gravity loss, and drag loss over time in order to plot graphs of the rockets velocity and altitude over time. To test the program six different rockets of varying sizes and shapes were launched three times each. The altitude for each launch was measured at three different tracking points to ensure accuracy. As opposed to placing controls on rocket specifications, a wide variety of rockets were used, to ensure that the program would remain accurate for all rocket designs. The results of the tests confirmed that the simulator accurately modeled rocket flight for conventional rockets, however it had trouble accurately predicting more eccentric models.

RESEARCH QUESTION

Will the rocket flight simulator we design reflect experimental rocket flight data?

ENGINEERING GOAL

The goal for this project is to create an effective computer model of model rocket flight.

Model Rocket Flight Simulator Overview

I. Programming Languages

The Model Rocket Flight Simulator was built using a combination of C++ and Microsoft Visual Basic version 4.0. The C++ module serves to take in input and calculate the rocket flight predictions. It then saves the data to files that the Visual Basic module can access. The simulator uses batch files to interface between the C++ and VB module. The VB module uses the data files to construct graphs for user viewing. A separate component, also written in Visual Basic, is the parachute descent calculator, which calculates the necessary parachute diameter for a desired rocket mass and impact velocity.

The C++ module makes use of the ANSI standard libraries iostream.h (input/output functions), stdlib.h (windows API functions that allow interfacing with the VB program), and math.h (math operations such as logarithms, exponents, etc). The C++ module also makes use of some of the College Board AP Computer Science libraries: apvector.h, for manipulation of multidimensional vectors, apmatrix.h for an advanced matrix data type, and apstring.h for an advanced string data type. Finally, the C++ module’s main.cpp file interfaces with the following includes that were programmed specifically for this project. Graphing.h includes the functions necessary to save to a data file the information that the VB program will graph. Thrustcurve.h includes the functions necessary to approximate the engine thrust curve based on user-inputted points. Rocket.h contains an abstracted rocket data type and subtypes (the outline of classes is as follows: every rocket has a nosecone and one or more stage. Every stage has an engine, every engine has a thrust curve. Each individual class has a number of data elements (ex, a thrustcurve holds a vector containing x and y coordinates of the thrustcurve). RocketGUI.h contains the functions that make up the user interface, controlling input, output, and error catching. It is worthy to note that this setup allows for an easy change from a console-based application to a more graphical one; all that would require modifying would be the GUI functions, as all user interactions with the program are interfaced through them. RocketCruncher.h derives its name for the fact that it is at the heart of the program – it crunches the numbers to convert the user-inputted data into the velocity and altitude graphs that are then sent to the VB modules by graphing.h. Matrixmath.h includes matrix operations such as scalar multiplying, matrix multiplying, inversing, and finding the determinant. This is necessary for the part of the program that fits a curve to the engine thrust curve points inputted by the user.

II. The Runtime Processes

At runtime, the program enters into a step-by-step process to determine the velocity and altitude graphs that are its end result. The first step is to gather input from the user on the rocket specifications. Weight, length, diameter, and drag information are collected, as well as extensive information on the engine characteristics. Next, the engine thrust curve(s) are calculated. The user inputted points are fitted to a quartic curve, but because this results in an unwanted dip between the second and third local maximums, that part of the graph is fitted linearly. With that, the program moves the data from a local scale to a larger scale, “putting together” the rocket, so that all thrust curves are stored in one global set of x-y vectors, all weight v. time, etc. vectors stored likewise. The program is now prepared to make its calculations. It first runs a loop that calculates the specific impulse (ISP) of the rocket, in increments of 1000 steps per second, over the cumulative flight time. What this means is that the point on the ISP curve halfway through the rocket’s flight time will reflect the average thrust for the first half of flight time over the flow rate for the first half of flight time (ISP is defined as thrust over flow rate). This is necessary to ensure accurate results. With the ISP calculated, the simulator can then predict an “ideal velocity” curve. The ideal velocity is what the velocity of the rocket would be if it were launched in space, free of air friction and gravity. It is represented by the equation: V = ISP * g * ln(W0/W), where V is the ideal velocity, ISP is specific impulse, g is the speed of gravity, 9.8 m/s2, and W0 and W are the initial and current weights, respectively. The next two calculations made are the gravity and drag loss. These are both calculated over the same 1000 increments per second as the ideal velocity. The drag loss derives data from wind tunnel testing of various nosecone shapes. Finally, the predicted velocity is determined by subtracting the gravity and drag loss from the ideal velocity. After that, the altitude curve is a simple matter of multiplying the velocity by the time over which it occurs. Once that is complete, the data is saved to a data file where the VB program can access it and display the results.

III. The Development of the Simulator

The simulator was originally to be programmed all in Visual Basic, but it was soon realized that the complexity of the number crunching required a more suitable language, and so it was decided that C++ would be used. The first problems arose in approximating the thrust curve; as it was surprisingly hard to find an open-source C library for matrix manipulation, so one had to be written for the project. Once that was done and the thrust curves were adequately approximated, there was a long issue about the ISP and subsequent ideal velocity calculations. The problem was that ISP and weight values were being taken over single time-steps, so that the W0 in the ideal velocity equation was interpreted as the weight at the beginning of the time-step, and the ISP curve was being calculated similarly. The breakthrough came in the adoption of the system that was outlined above, whereby the calculations are made as a sum of all forces acting on the rocket from the launch to the current time-step. It is as if the program were to stop the rocket x number of seconds into its flight and ask, “how high is it now?” (see the journal entry of 12/29/03 for a more detailed description). The final hurdle in creating the simulator was the drag loss. While we used empirical wind tunnel data to determine nose cone drag coefficients, the fact remains that different body shapes will contribute different amounts of drag to the overall force of drag on the rocket. It was decided that it would be best to present the user with an “average” body drag coefficient (0.75 for most rockets), but to allow the user to input their own coefficient if desired. With that complete, the simulator was finished and ready for testing.

Discussion of Results

The results of the experiment confirmed that for model rockets of standard dimensions, the simulator accurately predicts the maximum attained altitude, but that the descent calculations are unreliable and therefore the flight time predictions are inaccurate. The deviation between predicted and observed values for all but the Quark and Fireflash rocket was an average of a mere 17 meters. When the designs were simulated using NASA’s Glenn Research Center’s RocketModeler 1.2, the average deviation from observed values was a whopping 246 meters. The deviations between the predictions for the Fireflash design and the actual observed values can be accounted for by the fact that the program assumes that the inputted design is stable and therefore does not take into account the flight path angle of the rocket. The Fireflash rocket was less stable and therefore the program was not able to accurately model it. In the case of the Quark rocket, the calculations might also have been thrown off in the segment of the program where the engine thrust curve is approximated. Due to the fact that the Quark used a small engine, even minor deviations in the thrust curve approximation from the actual curve may have thrown off the predictions.

This program can be used to aid model rocketeers, especially in design contests where a rocket is required to achieve a specific altitude. Also included in with the program is a smaller module that calculates an appropriate diameter for a rocket’s parachute, given the rocket’s mass and the desired impact velocity. This too could aid designers in determining what sized parachute to use. The core of the model is the same of that of any simulator used to predict rocket flight path; a simulator of space-bound rockets performs the same functions as this simulator, with some added complexity.

Error sources in the program may arise in three of the steps of calculation. The first of these is the approximation of the thrust curve. While the approximations are for the most part extremely precise, abnormal or very small thrust curves will throw off the approximations, leading to an inflated thrust curve. As mentioned earlier, we expect that this was the cause of the inaccurate predictions in the case of the Quark. The second possibility of error arises from the drag calculations. The program allows the user to enter a rocket body drag coefficient, which for most rockets is approximately 0.75. However, nonstandard designs may have different body drag coefficients, and the user may have trouble determining them, as doing so requires wind tunnel testing. The final source of error arises in the gravity loss calculations. The program assumes that the user has designed a stable rocket which will not keel over during flight. If the rocket is unstable, the gravity loss will be calculated incorrectly and therefore the program may predict a higher altitude than that which is actually observed, as in the case of the Fireflash.

In conclusion, the rocket flight simulator that was designed for this experiment can, with reasonable accuracy, predict the velocity curve and maximum altitude of a model rocket. We hope that our simulator will assist model rocketeers in planning and designing their rockets.

PROCEDURE

Creating Model Rocket Flight Simulator

1-Purchase Visual Basic 4.0
2-Download Dev C++ from Download.com
3-Using velocity equation (see journal) write a program in C++ that will analyze a rocket's flight given specific parameters.
4-Debug flight analysis program.
5-Run flight analysis program.
6-Repeat steps 4-5 until flight analysis program runs properly.
7-Using the data from the C++ project write a program in Visual Basic 6.0 that will graph the data.
8-Debug graphing program.
9-Run graphing program.
10-Repeat steps 8-9 until graphing program runs properly.
11-Write a Visual Basic 6.0 program that will serve as a main program to which the other two programs are run.

Setting Up The Experiment

1-Purchase Fat Boy, Monarch, Mongoose, Quark, Menace, and Fireflash Model Rocket Kits.
2-Purchase Estes B6-2, B4-4, B6-0, B6-6, A10-3T, B6-4, and C6-5 Engine Packs.
3-Purchase three Estes Model Rocket Altitude Trackers.
4-Gather all other necessary materials (see Materials page for details).
5-Construct model rockets kits using the instructions given with rocket.

Launching The Rockets

1-Set up Estes launch pad at a designated area using given instructions.
2-Measure and mark 128 feet in three directions from the launch pad.
3-Ready rocket for launch.
4-Count down out loud from 5 to 0.
5-Launch rocket.
6-Track the flight angle from the three stations using the altitude tracker.
7-Record results.
8-Repeat steps 3-7 two more times for the same rocket.
9-Repeat steps 3-7 five more times for the other rockets.

Readying A Rocket For Launch

1-Open up the nose cone and add 1-2 sheets of wadding paper.
2-Insert appropriate engine into the bottom of the rocket so that the side of the engine with the propellant is facing away from the rocket.
3-Insert an igniter clip into the small hold in the engine.
4-Bend the clip to a 90 degree angle.
5-Insert an engine plug into the engine to secure the igniter clip.
6-Place the rocket on the launch pad.
7-Attach the launching device to the igniter clip.

Tracking The Flight Angle Of A Rocket

1-Stand at the designated measuring place.
2-Hold down finger on trigger.
3-Follow the rocket up with the altitude finder.
4-Release finger from trigger when you see the ejection charge.

Analyzing Results

1-Calculate the actual rocket altitudes using the angles recorded in the experiment.
2-Calculate the predicted rocket altitudes using the rockets parameters and the model rocket flight simulator program.
3-Simulate the rocket’s flight using Glen Research Center’s RocketModeler 1.2.
4-Compare data from steps 1, 2, and 3.
5-Develop a conclusion.

MATERIALS

-Fatboy Model Rocket Kit
-Monarch Model Rocket Kit
-Mongoose Model Rocket Kit
-Quark Model Rocket Kit
-Menace Model Rocket Kit
-Fireflash Model Rocket Kit
-Estes Repair Kit
-Estes Launch Pad
-Hobby Glue
-Exacto Knife
-Estes B6-2 Engine Pack
-Estes B4-4 Engine Pack
-Estes B6-0 Engine Pack
-Estes B6-6 Engine Pack
-Estes A10-3T Engine Pack
-Estes B6-4 Engine Pack
-Estes C6-5 Engine Pack
-Estes Model Rocket Altitude Finders
-Electronic Ballance
-TI-83+ Graphing Calculator
-Visual Basic 4.0
-Dev C++
-Tape Measure

 

BIBLIOGRAPHY

“Aerotech Single Use Motor Technical Information.” Aerotech Rocket Engine Tech Info. 11/1/03. <http://www.commonwealth.net/rockets/aerotech/su-motor-tech.htm>.

Carr, Jim. “Effect of Aerodynamic Drag Forces.” Effect of Aerodynamic Drag Forces. 11/1/03. <http://www.scri.fsu.edu/~jac/Physics/drag/index.html>.

“Computational Tools.” Rocket Team Vatsaas Computational Tools. 10/31/03. <http://www.vatsaas.org/rtv/tools/computationtools.aspx#transition>.

DeMar, John S. “Model Rocket Drag Analysis Using a Computerized Wind Tunnel.” 11/1/03. <http://web.syr.edu/~smdemar/rocketdrag.html>.

“Estes Rocket Engine Coding: Color Coding.” Northwestern University. 11/3/03. <http://www.goldcoasthobby.com/rocketry/estes/estescod.htm>.

“How do you calculate specific impulse?” Northwestern University. 12/2/03. <http://www.qrg.northwestern.edu/projects/vss/docs/Propulsion/3-how-you-calculate-specific-impulse.html>.

“Model Rocket Drag Analysis.” National Association of Rocketry Research and Development Report. 12/6/03.
<http://web.syr.edu/~smdemar/rocketdrag.html>.

“Model Rocket Engine Information” Model Rocket Engines. 10/31/03. <http://www.rockets-2-go.com/rockets/information/rocketengines.htm>.

“Model Rocketry.” Model Rocketry. 10/31/03. <http://www.stkate.edu/physics/phys111/curric/rocketry.html>.

“NAR Certified Motors”. National Association of Rocketry. 1/15/04. <http://www.nar.org/SandT/NARenglist.shtml>.

“Ogive Nose Cones.” Ogive Nose Cones. 11/1/03. <http://www.geocities.com/rocketguy_101/ogive/OgiveNoseCones.htm>.

Owens, Robert, et al, “Aerodynamics of Spherically-Blunted Cones at Mach numbers from 0.5 to 5.0.” NASA, Marshall Space Flight Center, Huntsville, Alabama. May 1961.

Peraire, J. “The Rocket Equation.” Lecture D4 – Variable Mass Systems. 10/31/03. <http://www.iitk.ac.in/phy/phy102N/Rocket_1.pdf>.

“Rocket Equations.” Rocket Equations. 10/31/03. <http://my.execpc.com/~culp/rockets/rckt_eqn.html>.

“Standard Nose Cone Shapes.” Apogee Rockets. 10/31/03. <www.apogeerockets.com/nose_cones.asp>.

“Thrust Curve Home.” ThrustCurve: Motor Data On-Line. 11/1/03. <http://www.thrustcurve.org/>.

Woodmansee, Paul. “Rocket Equations.” Rocket Science. 10/31/03.
< http://woodmansee.com/science/rocket/r-other/rb-equations.html>.