Numerical Approximation of a Rocket's motion

In summary, Filip is trying to add orientation to his model of the flight dynamics of a rocket but is running into problems. He doesn't bother doing the math for the moments of inertia and gravity because he says it doesn't have a big effect on the general behavior of the rocket, but rather specific details. The problem is that the rocket fails to stabilize properly and starts rotating uncontrollably after a certain amount of time.
  • #1
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 doesn't 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 I am running out of memory on excel (Its waay easier than using MATLAB or anything else, at least for me). I am going to be trying to use 2nd order RK and see if it works.

Anyways, please tell me what you think, I am attaching the excel spreadsheet and a picture with the equations I am trying to approximate

Thanks a lot!


  • 10740687_10203439585645884_287536767_n.xlsx
    2.3 MB · Views: 374
  • Physics.png
    49.7 KB · Views: 619
Physics news on
  • #2
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].

  • #3
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 isn't 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, I am 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, I am sure I'll find something relevant to my model.

Anyways, thanks a lot man!
  • #4
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!

Suggested for: Numerical Approximation of a Rocket's motion