# Simulating a rocket launch

One can make crude estimations of rocket trajectories analytically, usually neglecting the drag force and make assumptions of the gravitation. To do much better estimations of rocket trajectory and other parameters one can do numerical simulation of rocket launches. Let us first see the the equations of the forces on a launching rocket from the last section: These are differential equations that are perfect for numerical integration. We change the equations slightly to be in the horizontal and vertical directions instead: where is the unit vector in the travelling direction, given by while is the unit vector from the center of the Earth to the rocket; is the drag, as defined on the previous page; and is the position vector from the launch site to the rocket. The mass is a function of time, since it decreases as the rocket motor is burning.

Now we have a physical model of the rocket launch. We have not taken roll and other effects into account. Inducing spin takes some energy, and when leaving that out we overestimate the apogee altitude. We want to find the acceleration (which is given by the equation above), velocity and position as a function of time. Hence we need to integrate the equation twice.

So, how can we find the acceleration when it is dependent on the integrated result? The answer is that we solve the equations iteratively. We limit this case to two spatial dimensions. We start first with setting the initial values: and Then we find the acceleration at lift-off at from the acceleration equation above.

We need now to integrate the acceleration. The derivative is given as which can be rewritten as Using this simple method we can do simple integrations. The method is called the Forward Euler integrator, and is an explicit solver (i.e. it only uses information from the previous timestep). This is not an accurate solver, and better approaches do exist, like the Runge–Kutta family.

When we have integrated the acceleration to velocity in the two spatial dimensions, we integrate the velocity to get the position. Then we have the acceleration, velocity and position at time Then we start once again with updating the acceleration based on the velocity and position at the previous timestep and integrate to get the acceleration, velocity and position at time . We do this until the vertical position of the rocket is negative, that is, the rocket has landed or after a given time. We store all acceleration, velocity and position points, and from this we can derive many parameters, e.g. the pitch angle.

The rocket is stable because of the velocity that keeps it pointing forward (small angle of attack). At the start of the launch before the rocket has gained enough velocity to be stable, we need to implement a launch rod to keep it pointing at the launching angle. This is done by fixing the unit vector to the launch angle while (or whatever the length of the rod is).

A few comments before we continue. We have assumed a flat Earth. As most people know, the Earth is indeed spherical (just don’t ask the flat Earth society if this is true), but for a small rocket this can be a good approximation. Also, we have used a constant time step. For numerically heavy simulations it can be smart to implement adaptive time steps to keep the simulation time to a minimum and a more accurate solution. And again, we have only assumed three degrees of freedom, which will overestimate the altitude, range and velocity. Such a simulation can be implemented in for example Python or MATLAB in about 20–30 lines of code.

Another approach is to use software designed to do this. For simple simulations of single stage rockets which are not intended to go into orbit, the open-source 6-DOF OpenRocket software can be recommended. For a professional solution, AGI System Tool Kit is recommended (but it has a steep learning curve).
{"ft_lang_label":"__label__en","ft_lang_prob":0.9200047,"math_prob":0.984065,"size":4003,"snap":"2021-43-2021-49","text_gpt3_token_len":806,"char_repetition_ratio":0.14353588,"word_repetition_ratio":0.011678832,"special_character_ratio":0.19785161,"punctuation_ratio":0.09660574,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99404764,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"im_url_duplicate_count":[null,5,null,5,null,5,null,5,null,5,null,4,null,5,null,10,null,5,null,null,null,5,null,5,null,10,null,5,null,5,null,10,null,5,null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-26T09:35:29Z\",\"WARC-Record-ID\":\"<urn:uuid:c03b8d55-3dfb-4520-bf08-285a299c1ff7>\",\"Content-Length\":\"45670\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3d04cc89-79e1-421c-bb9c-b2e40fb678cc>\",\"WARC-Concurrent-To\":\"<urn:uuid:1c54b8c9-6bb8-4e7b-b0b6-93721d107125>\",\"WARC-IP-Address\":\"128.39.102.146\",\"WARC-Target-URI\":\"https://www.narom.no/undervisningsressurser/sarepta/rocket-theory/rocket-dynamics-2/simulating-a-rocket-launch/\",\"WARC-Payload-Digest\":\"sha1:JFZD2TGGFCHMAYCWW76KDZ6PMCDC6PHU\",\"WARC-Block-Digest\":\"sha1:RCCLXCCYSJP7A4U3F5XTHZYCLGH76XOE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323587854.13_warc_CC-MAIN-20211026072759-20211026102759-00138.warc.gz\"}"}