# Numerical Approximation of a Rocket's motion

## Main Question or Discussion Point

So, I ve been trying to add orientation to my model of the flight dynamics of a rocket but I ve been running into a lot of problems. I didn't bother actually doing the math for the moments of inertia and everything because I guess it really doesnt have that much of an effect on the general behaviour of the rocket,but rather simple specifics of its movement.

The problem is the following, when the rocket is offset from a perfect 90 degree angle at launch, it gains horizontal velocity faster than vertical (due to gravity) and therefore acquires another offset from the launch angle (say it was 89 degrees). The fins of the rocket should stabilize it by using the lift gained from the small angle of attack and point it back towards the velocity vector, this is what produces the gravity turn we all know and love (I think, I might be wrong though). In my model though, the rocket fails to stabilize properly and starts rotating uncontrollably after a certain amount of time.

At first it oscillates as a pendulum would,but deviating just a bit more with each period and gaining more and more angular velocity. Is this something that naturally arises when using euler's method to analyse this type of motion or would it also happen if I were to use Runge-Kutta's? I was thinking it may be something that naturally happens when using discrete time to analyse something that would be continous. By reducing the time step I was able to increase the time it would take for the deadly rotation to take place, but im running out of memory on excel (Its waay easier than using matlab or anything else, at least for me). Im gonna be trying to use 2nd order RK and see if it works.

Anyways, please tell me what you think, Im attaching the excel spreadsheet and a picture with the equations I am trying to approximate
https://www.mediafire.com/?led0x2ubszo7avv
http://imgur.com/4I3cFUB

Thanks a lot!

#### Attachments

• 2.3 MB Views: 243
• 53.1 KB Views: 509

## Answers and Replies

Related Differential Equations News on Phys.org
Filip Larsen
Gold Member
Without looking at your code, I would say that it is very likely you experience numerical instability. The forward Euler method has a very small region of stability [1] and for suitably stiff problems [2] it can be impossible to find a step size small enough for the solution to be stable, yet large enough that truncation and rounding error do not swamp out the solution. Stiff problems are characterized by having dynamics on different timescales, i.e. orders of magnitude appart. In your problem, the rocket pitch controller would need to "operate" at a much fast timescale than the simple kinematic trajectory of the rocket. In general, vehicle simulations (of all kinds) that includes orientation very often result in stiff problems.

So, what can you do. You can try see if you can to find a sweet-spot for the step size, but you have already tried that you say. You can try switch to a more stable method (that is still doable in Excel) with a larger region of stability, but for a stiff problem the underlying difficulty is still there.

If you are not trying to simulate the pitch controller (that is, you are not doing controller research with an interested in whether on not your rocket is stable in pitch) a better approach would be to remove your pitch controller and simply clamp your pitch to your velocity vector. This means that the trajectory of the rocket is determined from the initial pitch angle (everything else being equal), and it will be very sensitive to the changes in that value, but the numerical integration itself would only operate on a single time scale.

There are of course more advance options you can take, but you would probably first need some clear goals of what you want to achieve with your simulation and you will probably also have code your problem directly as opposed to using a spread-sheet for the numerical integration. Depending on your background you may actually find it easy to add functions to Excel if you like that platform, or you can choose to go for an environment like Matlab [3] or similar [4].

[1] http://en.wikipedia.org/wiki/Euler_method#Numerical_stability
[2] http://en.wikipedia.org/wiki/Stiff_equation
[3] http://en.wikipedia.org/wiki/MATLAB
[4] http://en.wikipedia.org/wiki/List_of_numerical_analysis_software

Filip, I am aware of the limitations of Euler's method, I first chose it because it was the easiest to apply and for something such as the motion of a rocket, it isnt that inaccurate. I managed to get it to be somewhat stable by changing the time scale to 1/100 of a second, when doing that the problem becomes only apparent when the rocket reaches velocities lower than 40m-s, which is bad, but not as bad as it was before. I will try by switching to a high order Runge Kutta method and see how if it gets rid of the problem, Im pretty sure it will help a lot.

The purpose of the model is to determine how stable the rocket is with different fin configurations and to then feed the numbers (along with some random variations) to a program in order to test dead reckoning methods, it would make for a fun experiment and if I can get it to work I could port it into an arduino and try launching it ontop of a rocket. Before adding orientation into the picture I did exactly what you described and got some good results, around 10% accuracy compared to actual data from rocket launches, which is still what I am getting right now because the orientation problems only become apparent at apogee.

Im not really good with MATLAB, but I guess there is a time for everything, what resources would you recommend to a complete newbie with it? Excel on the other hand is a lot more intuitive, I understand exactly what I am doing, and having it in spreadsheet form, only caring about ifs and elses, also makes it a lot easier to spot my mistakes and correct them easily. I will look into numerical methods for stiff equations, I had no idea that was even a thing, Im sure I'll find something relevant to my model.

Anyways, thanks a lot man!

I think you've got a stiff equation, but the other issue is that you're using Euler. You're using a first-order integration method and you've got double derivatives so I think you're compounding your error. Using RK4 might help some, but with stiff equations you might have to use an implicit method with an adaptive step size. Some simple systems I've tried to model for control system design became very unstable in simulation because the equation was stiff, but the values were fine for the system in reality (the simulation worked, but the step sizes were way too small to make the simulation useful for me). Using Simulink and Matlab's ode15 solver might help you out more than Excel. An upshot for using Matlab over Excel is that you don't have to worry that you've implemented your integration scheme wrong. :-)

Hope that helps!