Jump to content

Physics of KSP


mhoram

Recommended Posts

The physics of KSP is a complex story and who doesn't want a guide that explains the details about it?

Information is distributed over many Wiki-Pages and Forum/Reddit-Threads.

I think it is beneficial to have a place where information about all physical aspects of KSP is gathered.

You can get the description of KSP Physics as a PDF here.

Be advised that this contains a lot of Science and is not for the faint of heart. ;)

Edit: This documentation is partially outdated.

Especially the atmosphere, drag and engines have been overhauled on the V1.0 KSP release, so these sections do not apply anymore.

Edited by mhoram
note added about V1.0 changes
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Mhoram, you are a wizard and scholar. I've been looking for months for some of these topics. I designed a program that generates rocket designs that maximize delta-v in space in Excel. There's two parts: One is a one-stage generator, which takes in an engine type (LV-N, LV-909, etc), the number of engines, the desired TWR, and payload mass, and lists out all of the tanks you'll need, and the resulting delta-v. The other is an asparagus generator, which does the same, with extra inputs for the number of side-stacks (an even number) and the ratio of mass between the center stack and the side stacks.

As a mostly separate project, I have a MATLAB program that takes in thrust, total mass, fuel mass, Vac ISP, and Atm ISP to numerically solve a set of three differential equations that describe the height, velocity, and mass through time. It's currently one-dimensional, and only predicts correct results if you thrust straight upward. It includes gravity, drag, and thrust... just like you said in your paper.

I want to transition over to a two-dimensional model, and port my Excel program over so I can start looking at optimal atmospheric craft designs. But a large part of that is optimal ascent paths, which I don't know the math for. I read that you were working on optimal ascent paths now. What are your findings on that front? I believe the optimal ascent path is related to the TWR of the rocket through time, further obfuscating the issue.

Mostly, how do you mathematically model a path, such that you can change the curvature of it numerically? It seems to me that there are more possible paths than there are real numbers. Also, I've always had trouble wrapping my head around why the gravity equation suddenly has a cubic in the denominator when you make it a vector. Do you know why it is?

Link to comment
Share on other sites

Mhoram, you are a wizard and scholar.

There is only one wizard and he is green ;-)

I've been looking for months for some of these topics. I designed a program that generates rocket designs that maximize delta-v in space in Excel. There's two parts: One is a one-stage generator, which takes in an engine type (LV-N, LV-909, etc), the number of engines, the desired TWR, and payload mass, and lists out all of the tanks you'll need, and the resulting delta-v. The other is an asparagus generator, which does the same, with extra inputs for the number of side-stacks (an even number) and the ratio of mass between the center stack and the side stacks.

Sounds nice, have you had a look at http://blizzy.de/asparagus/?

There is also somewhere a website with a javascript program that tries to iteratively find ideal engine and tank configurations, but I can not find it anymore.

As a mostly separate project, I have a MATLAB program that takes in thrust, total mass, fuel mass, Vac ISP, and Atm ISP to numerically solve a set of three differential equations that describe the height, velocity, and mass through time. It's currently one-dimensional, and only predicts correct results if you thrust straight upward. It includes gravity, drag, and thrust... just like you said in your paper.

The problem you describe here is known as the Goddard Problem. In KSP version 0.16 there was a contest about this problem.

I want to transition over to a two-dimensional model, and port my Excel program over so I can start looking at optimal atmospheric craft designs. But a large part of that is optimal ascent paths, which I don't know the math for. I read that you were working on optimal ascent paths now. What are your findings on that front? I believe the optimal ascent path is related to the TWR of the rocket through time, further obfuscating the issue.

You are right, there is no single ascent path that is optimal for all rockets. Each rocket has it's own ideal ascent path for fuel-consumption.

My implementations were in 3D - never tried it in 2D.

If you model it in 2D you have to take care about

- planet rotation (take the surface velocity as the effective velocity for drag)

- centrifugal force

- coriolis effect

- distance to equator (only if you want to model this)

- change of pitch based on horizontal velocity

This thread contains further information about two-dimensional implementations.

This thread might also give you some insight.

Mostly, how do you mathematically model a path, such that you can change the curvature of it numerically? It seems to me that there are more possible paths than there are real numbers.

This depends on how exact you want to model the ascentpaths.

In my implementations I used different approaches.

A simple one was to describe the ascent path by the following parameters:

- Altitude at which the pitchover maneuver happens

- Angle of Pitchover maneuver

- Duration of Pitchover maneuver

- Downrange effective TWR

(This approach required some restrictions on the possible ascent paths)

I picked random numbers for all parameters and simulated the ascent and looked which parametersets resulted in

a) the highest Periapsis (if the periapsis did not reach the target orbit)

B) the amount of fuel spent (if the target orbit was reached)

Using statistical methods I changed the parameters of the best sets by small amounts in order to improve the results.

Also, I've always had trouble wrapping my head around why the gravity equation suddenly has a cubic in the denominator when you make it a vector. Do you know why it is?

The thing is that you have to give the gravity force a vector-direction and a magnitude.

The magnitude is calculated as by the usual formula resulting in distance^2 in the denominator.

Giving the magnitude a direction is done by multiplying it with a vector of length 1 in the intended direction and in this case the direction points from the Ships position to the planets core. And this is the negative Position vector divided by its length.

So you get a distance^3 in the denominator.

^^ Would be very cool to see an optimal trajectory as equation rather than try-error approach. I learned this at university, but it's too big to try for me. Wish you good luck!

Most likely you will not get a single equation that gives you the optimal ascent. Until now the consens of all who tried it on the forum is that it can not be solved analytically. There has been however some effort to solve it numerically.

Good stuff mhoram, stickied :)

Cool, never expected this to happen. :-D

Besides some small corrections and changes I added a few new chapters about contributors, darkness time, differences between KSP and the "Real World", lift, TWR and engine calculations.

Edited by mhoram
Typo
Link to comment
Share on other sites

Your chapter on "differences to the real world" is lacking. Even Wikipedia got more complete description - and that one there still lacks several things.

Other than that you completely omit dozens of things in your descriptions. Looks like you were very picky to make KSP look like a truly realistic game.

Edited by Sky_walker
Link to comment
Share on other sites

Your chapter on "differences to the real world" is lacking.

Please provide more details. I can't give you a meaningful answer to such a general statement.

Even Wikipedia got more complete description - and that one there still lacks several things.

Wikipedia and this documentation have different intentions. And if you have additional knowledge, think about improving the Wikipedia-page.

Other than that you completely omit dozens of things in your descriptions.

Of course I omit things. Mostly for two reasons: focus and time.

Again please provide more details.

Looks like you were very picky to make KSP look like a truly realistic game.

I wrote the comparison chapter, so that readers know where they have to be careful when applying the formula in real-life scenarios, because KSP is far from being a truly realistic game. So I really can not see how you came to this conclusion.

Link to comment
Share on other sites

I checked the document, and see one missing part: what's the formula of intake air?

Good point. Will add a chapter about that.

However I could not find infos about the exact formula yet.

http://wiki.kerbalspaceprogram.com/wiki/Intake_air

http://forum.kerbalspaceprogram.com/threads/73472-Air-intake-model-%28stock-KSP%29

http://www.reddit.com/r/KerbalSpaceProgram/comments/1bx1zd/

But is looks like it increases with increasing intake-area, pressure and surfacevelocity and decreases with increasing AoA.

Link to comment
Share on other sites

I added chapters covering the following topics:

- Delta-V calculation

- Upper bounds for Delta-V

- Geostationary Orbits

- Air Intake description

- Ascent Calculations

- Recommended basic knowledge to understand this document

Link to comment
Share on other sites

  • 2 weeks later...
However I could not find infos about the exact formula yet.

I implemented this in mechjeb a while back, gives the intake air:

https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/VesselState.cs#L1001

The KSP-scripts have a lot of physics implemented:

https://github.com/numerobis/KSP-scripts

- rocket engines, including Isp, combining Isp, deltaV, fuel requirement including tank mass, etc

- jet engines and intakes, including thrust, intake air, and intake drag, and the top speed that an airbreathing plane can achieve

- lift but not yet including the new lifting bodies

- parachutes including calculating how many chutes you need for a given landing speed

- a plane designer that includes computing all the forces including thrust, lift, drag, gravity, and the max throttle you can hold before flaming out

- planets and transfer orbits

- how the curves are computed

Link to comment
Share on other sites

I just added the new lifting surfaces. They're just the same as wings, except that their drag doesn't fall to zero at zero angle of attack.

One funny thing about the new surfaces: the author of the new parts scaled the drag coefficient with the mass. Four wingConnector5 provide essentially the same lift and mass as one wingConnector, but have a quarter of the drag. At 0 angle of attack, two short Mk2 fuselages have essentially the same characteristics as one long Mk2 fuselage, but at 30-degrees angle of attack, the single long fuselage has 1.6x the drag.

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...