Jump to content

Math questions about KSP


fancycat

Recommended Posts

I was wondering how KSP calculates its rotational force applied with ASAS. What is the equation if anyone knows it?

The second thing i wanted to bring up was the ISP. If I reverse calculate the Specific Impulse of the nerve nuclear engine in vacuum i go through this process..

800

800x+C 400x^2+Cx+D ((800x^3)/3)+(Cx^2)/2)+Dx+E where C,D, and E are all constants and x is time in seconds.

the first value of 800 is the engines specific impulse in vacuum, the next equation is the engines acceleration, then speed, and finally position.

you might note that in space the possibilities for acceleration are infinite due to the lack of resistance. As such the acceleration function shown is actually an exponential function.

I have two questions about this.. the first is: did i do the math correctly? and the second: Is there any test i can do or experiment that i could use to find out the value of these constants?

Link to comment
Share on other sites

800x+C 400x^2+Cx+D ((800x^3)/3)+(Cx^2)/2)+Dx+E

this way of writing is pretty hard to read

do it properly in MS Word using the equation editor please

or else... not many ppl bother spending some extra seconds to try comprehending it.

(yes i am that lazy)

Link to comment
Share on other sites

Okay, the only Constant "C" is lightspeed. So I don't know what C, D, and E represent in your equations.

Second, there IS resistance to the Nerva's acceleration... Inertia. Or, more simply, the Mass the Nerva is accelerating. Acceleration will never be infinite due to the Mass of the Nerva itself.

Third, I'm not sure why you're trying to back-calculate the ISP of the engine... or what you hope to do with it. The game simply treats the given ISP number as part of an equation telling it how fast to burn fuel. I *seriously* doubt that the game is truly calculating the exhaust velocity and expansion of spent fuel, and deriving thrust in a "real-world" way.

Link to comment
Share on other sites

I was trying to find acceleration, and velocity at a given point in time. C does not represent the speed of light in this equation. it is just some constant number that i don't have, just like D and E. Mostly I am trying to better understand the math the game for my own satisfaction.

Link to comment
Share on other sites

The acceleration of a rocket varies over time as it burns fuel and its mass decreases. Also it makes little sense to think about the velocity over time of a rocket as it will be moving through a non-constant gravitational field. It is more usual to talk about the delta-v of a rocket, which is it's total ability to change it's velocity.

For most rockets in KSP the time taken to get from body to body is a matter of what route you choose to take. The route also affects the amount of delta-v required. http://alexmoon.github.io/ksp/ can tell you both the delta-v required for a journey and the time it is going to take.

The delta-v of a rocket is found using the /Tsiolkovsky_rocket_equation, for which the ISP is an input.

If you wanted to know how long it will take to do a burn, say of 1000 m/s you would plug the starting mass, ISP and dv into the equation to find the total mass of fuel burnt. time=Isp*mass*g/thrust.

Link to comment
Share on other sites

Delta V is another way to say the directive of velocity or more specifically acceleration, and ISP or specific impulse is the derivative of acceleration or Delta A i suppose.

The rocket equation is a much better way to find the information than i used to be sure.

That leaves me with my first question however. How does KSP calculate the amount of force it uses in pod torque and rcs thrust to adjust it's vector?

Link to comment
Share on other sites

Delta V is another way to say the directive of velocity or more specifically acceleration, and ISP or specific impulse is the derivative of acceleration or Delta A i suppose.

The rocket equation is a much better way to find the information than i used to be sure.

That leaves me with my first question however. How does KSP calculate the amount of force it uses in pod torque and rcs thrust to adjust it's vector?

http://wiki.kerbalspaceprogram.com/wiki/Parts

This wiki page has all the information on the equations used.

To specifically answer your question though the SAS has a limit torque that it can apply to the ship, and using a simple control algorithm it applies that maximum specified torque to counter whatever rotation it is trying to correct. Once it over-corrects the control algorithm applies a reduced torque in the opposite direction and continues to do so until the value is zero (actually very small).

Advanced SAS works differently as it uses RCS and control surfaces to control the force applied. It uses a similar control algorithm, but that is why you get lots of control surface wobble and RCS use. The system does not have fine enough control over movement and does not get to the small value to stop. Especially with complex shapes that can bend or flex.

http://en.wikipedia.org/wiki/Control_loop

This wikipedia page has some really good information on control loops. It should be noted that C7 is implementing a PID controller for 0.21 - which should be a game changer.

Link to comment
Share on other sites

That defiantly explains the wobble. I just caught a video of the asas in .21 and it implements the changes i was thinking about. It looks like they take the distance from target vector and apply that as torque minus the speed of rotation. at a specific point the speed of rotation is higher than the distance so the craft begins to thrust opposite its target vector to slow its rotation to a full stop at the exact vector desired.

I used a similar setup for an auto tracking turret i build for another game. Either way I am glad they have made the change :)

Link to comment
Share on other sites

Okay, the only Constant "C" is lightspeed. So I don't know what C, D, and E represent in your equations.

C, D, and E are just arbitrary constants, they are created when you integrate a function, which is what fancycat was showing. They are unknown constants because he integrated indefinitely, or without constants to the function.

http://www.wolframalpha.com/input/?i=intergrate+800

Link to comment
Share on other sites

Delta V is another way to say the directive of velocity or more specifically acceleration, and ISP or specific impulse is the derivative of acceleration or Delta A i suppose.

I need to clear this up: delta-V is *not* the time-derivative of velocity (which is, as you correctly say, acceleration), nor is Isp the time-derivative of acceleration. Dimensional analysis (looking at the units of the quantities involved) is your friend! :) Delta-V is just the difference between two velocities (its not the derivative, even though it's often written as "dV"), and its in units of m/s, while acceleration (time-derivative of velocity) is in units of m/s^2. Similarly, Isp is measured in seconds, while da/dt would be in m/s^3.

Think of it like this: If a car accelerates from 40 mph to 60 mph, the delta-V is just the difference between the two (20 mph, in this case). But the acceleration tells you how quickly that delta-V occurred. If you go from 40 to 60 in 10 seconds, your average acceleration is 2 mph/s (1/30th mi/s^2), but if you make that same increase in speed over 1 second, your average acceleration is ten times that (1/3rd mi/s^2).

Isp is harder to quantify in this example, but its an efficiency rating, more like your car's miles per gallon. Except instead telling you the distance you can go per mass of fuel, it tells you the maximum delta-V you can reach when a given fraction of your ship's mass is propellant (according the the rocket equation that others have mentioned).

Edited by Kaleb
Link to comment
Share on other sites

Usually, rates of change are represented by a lowercase "d", like in d/dx. Delta (ÃŽâ€) almost always refers to a simple difference (not a difference in change, whatever this means)

Link to comment
Share on other sites

That was a remarkably helpful reply. thank you very much. i had assumed Delta was a rate of change instead of a difference in change. i will do some additional research for some fun planning.

You're welcome! :) (Although, I just noticed I computed those sample acceleration numbers wrong -- they're off by a factor of 60! I can do Calculus, just not simple Arithmetic...) :rolleyes:

Link to comment
Share on other sites

Thats what happens when you learn calc. you forget your basic math. in my class the professor used the delta symbol interchangeably with d/dx, which is why i was so confused.

what is the percentage of fuel you need to have thoes number be accurate by the way? it doesn't seem to say.

Link to comment
Share on other sites

with the new information about what delta means. i was thinking asas should try working like the following....

B = Bearing where left of current position is negative and right is positive where the maximum and minimum values are 1 and -1

D = Delta B and the maximum and minimum possible values if D are 1 and -1

[(Dx10)+(Bx2)]x-1= this equation only applies across one plane so you will need an xy and an xz. the only problem with the equation here is that it doesn't consider the limitations on the thrust power of rcs. Does anyone have any ideas on how to incorporate this.

i may have confused myself...

Edited by fancycat
Link to comment
Share on other sites

You're on the right track here! The ASAS (and many other real-world applications) use what is known as a PID controller (I had to implement one of these in a robotics course, once). PID stands for Proportional, Integral, Derivative. The wikipedia article is somewhat dense, but the basic idea is that you have a variable x that you want to control by creating a response that is proportional to its error at a given time, e(t) = x(t) - x_desired (this is basically a delta, though its not written as such). In addition to just the current error, however, you also look at how quickly the error is changing (d/dt e(t)) and how much error has accumulated over time (Integral e(t) dt). The response of the system (e.g. RCS or flaps) is then determined by a linear combination of these terms. Apparently, the technique of using all three of these terms to determine your response was originally inspired by watching how helmsmen steered ships -- I think that's cool!

Instead of using specific constants like "10" and "2" in your formula, the generic approach uses named constants (Kp, Ki, and Kd) which can be "tuned" to values that work best for a specific application. In KSP, you can actually modify these K values directly in the part cfg files, if you so chose. There's also a mod that lets you dynamically modify them in-game.

So the overall formula then, would look something like:

Response = Kp*e(t) + Kd*(d/dt)e(t) + Ki*(Integral e(t) dt)

You are also correct that this only applies in one dimension, and has to be done for all three. Actually, they work along the three rotational axes (roll, pitch, and yaw). One of the (many) improvements to ASAS that's slated for 0.21 is that the PID will be disabled for an axis that you are trying to steer along. So you pull the nose up your aircraft, the pitch PID will be disabled (while keeping the other ones on). This lets you steer with ASAS on!

One major thing to point out, though, is that the variable being controlled here is the rotational rate (angular velocity), instead of the bearing. Obviously, the desired rotation is 0. So your formula for the ASAS correction has three terms:

Kp * (how fast are you spinning)

Kd * (how fast is your spin accelerating)

Ki * (how much spin has accumulated over time, i.e. how far off the initial angle are you)

It's that last Ki term that tries to put you back to your initial heading, by eliminating the accumulated spin.

There's a lot of advanced control theory focused on applying that equation, which is well beyond what I know, but these are the basics.

Edited by Kaleb
Added link to mod
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...