Jump to content

Optimal Ascent Path with FAR / KSP Simulation Software


version2_1

Recommended Posts

I recently installed a lot of mods including FAR and Mechjeb2. Mechjeb offers an ascent autopilot and calculates some statistics while ascending from Kerbin: used delta-v, drag losses, gravity losses and steering losses as far as I know.

I was wondering how to get an optimal ascent path. Mechjeb seems to have some problems with FAR (drag losses don't seem to work properly). So I decided to write a program to calculate an optimal ascent path for a given rocket. Since c# is my favorite language I implemented my simulation in c#.net.

The software is pretty beta right now, but here are some screen shots:

szgc5axa.png 7y3qpr39.png ryped9k2.png uut9lgpn.png (yes I'm still using VS 2010)

If someone is interested I will share the source code (and the binary) so you can have a look at it!

I did all the calculation to my best knowledge, but there might be still some bugs, but the required delta-v is relatively close to the values I get in KSP, so the general approach seems correct. Also the parameter study yields useful ascent angles: Using the Kerbal X rocket i get: 20° launch angle, 70° at 20km, 90° at 40km. All the angles are relative to the normal, so on the KSP navball the angle will be 90-x.

I implemented stages (changing vessel mass), air drag, gravity, and thust (value and angle).

Finally here are some code samples showing the formulas I used:


// Init
Vector2D position = new Vector2D(0, equatorialRadius); // We start "on top of Kerbin"
Vector2D velocity = new Vector2D(equatorialRadius * 2 * Math.PI / rotationPeriod, 0); // We get 174,53 m/s for free from the rotation!

// Simulation step:
double pressure = surfacePressure * Math.Exp(-(position.Length - equatorialRadius) / scaleHeight); //position is a vector, measuring the distance from the center of Kerbin.
Vector2D dragForce = -0.5 * area * coefficientDrag * relativeVelocity.Length^2 * relativeVelocity.Normalized * pressure; //relativeVelocity the relative velocity vector in the air flow

Vector2D drag = dragForce / mass;
Vector2D gravitation = position.Normalized * GM / -Square(position.Length);
Vector2D acceleration = thrust + gravitation + drag;
velocity = velocity + acceleration * deltaT;
position = position + velocity * deltaT;

Special thanks to MisterSpock, he helped me implementing the orbital mechanics (calculate AP, Eccentricity) and did some testing!

Link to comment
Share on other sites

Looks promising!

A question--I take it you're assuming a zero-lift ascent (since you can assume a Cd). But--even if that's a safe assumption, about which I'm quite unsure, isn't there a drag spike in the transonic regime, and a different Cd in the supersonic regime?

Link to comment
Share on other sites

Thank you :)

It's quite possible there is a drag spike in the transonic regime, but I simply don't have any formula modeling that - I don't know how FAR calculates stuff really, since i got numbers from the FAR Flight Data Panel that I had problems fitting to my simple drag model: I noticed C_d was changing over time and the referenceArea did dot decrease when I staged radial boosters.

I simply used the first formula I could find on wikipedia for the drag, since i studied electrical engineering and have very limited knowledge about aerodynamics ;) So any help in that direction would be appreciated!

Link to comment
Share on other sites

Your best bet would be posting on the FAR thread and asking Ferram, I'd say?

Reference area is either the surface area of the body if no wings, or the wing area if wings are anywhere present. Since I presume you had fins on the core, ref area wouldn't change on booster separation, but Cd would.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...