Jump to content

"On-The-Rails" Time Warp with Thrust


Recommended Posts

I think it is possible to have a "non-physical" on-the-rails time warp while thrusting using the fact that an analytical solution for this case exists. For a constant thrust (over a frame or time-step), the differential equation for mass is:

Eq. (1): dm(t)/dt = -k

where k is a constant (though its value can change from frame to frame or time-step to time-step).

In space (or the absence of drag), conservation of momentum takes the form:

Eq. (2): m(t)*dv(t)/dt + ISP*dm(t)/dt = 0

where ISP*dm/dt is the thrust term.

Finally, by definition, velocity is related to position by:

Eq. (3): dx(t)/dt = v

Thus, Eqs. (1)-(3) form a system of linear ordinary differential equations, the analytical solutions of which are:

Eq. (4): m(t) = m0 - k*t = m0*c1

Eq. (5): v(t) = v0 + ISP*ln(1/c1)

Eq. (6): x(t) = x0 + v0*t + ISP*(1 + c1/(1-c1)*ln(c1))*t

where c1 is a convenient parameter defined as the ratio of the mass at time t to total mass:

Eq. (7): c1 = (m0-k*t)/m0 = m(t)/m0

It is worth noting that Eq. 6 for position includes an additional term beyond simple Euler integration, namely, ISP*(1 + c1/(1-c1)*ln(c1))*t. This term accounts for the known way that the ship accelerates during a constant burn, and calculates the extra distance the ship has traveled. Similarly, Eq. (5) for velocity includes an analytical acceleration term, and Eq. (4) for mass is linear. Thus, even large time steps will exactly match the correct (analytical) solution, enabling time-warping with thrust.

However, a small correction will have to be added to make sure the craft has enough fuel (and if an ion engine-- enough electricity) to burn for the whole time-step, if the time-step is large enough. There are two options:

(1) Time warp is automatically killed until the time-step is small enough that all the fuel/electricity will not be consumed.

(2) The value of k can be changed such that m(t) = m0 - k*t = 0 i.e. k = m0/t, so that conservation of mass is not violated.

What do you guys think? Can this be implemented in KSP via a plugin or would it have to be hacked into PhysX/Unity?

Edited by arkie87
Link to comment
Share on other sites

The problem isn't really the maths, it's the other stuff. If the craft has the structural integrity or stability of soggy tissue paper, you can't just apply the numbers and move forward. That then leaves you with determining craft which behave close enough to theoretical perfection and can be thrust-warped, and craft that need active physics simulation. In the case of ion engines, you'd need to figure out when any panels would be providing charge, and how much charge they would be providing over the entire burn, and whether there would be any brown/black-out periods to consider.

Link to comment
Share on other sites

I would like to see this implemented in some form for KSP, though it's more helpful for ion engines than anything else.

Two plugins alread implement this using the same approach (changing the orbit): KSP Interstellar for the solar sail and the Orbit Manipulator Series for ion engines. Both add quite a lot of other changes to the game, though.

Link to comment
Share on other sites

The problem isn't really the maths, it's the other stuff. If the craft has the structural integrity or stability of soggy tissue paper, you can't just apply the numbers and move forward. That then leaves you with determining craft which behave close enough to theoretical perfection and can be thrust-warped, and craft that need active physics simulation.

I agree that there are other issues to consider, such as wibble-wobble. However, time warping with thrust would only be allowed if the acceleration is low, such that no wibble-wobble would be encountered, such as usually the case with nuclear engines, and almost always the case with ion engines. Alternatively, time warping with thrust would just assume the body is rigid i.e. infinite struts (which are massless anyway).

In the case of ion engines, you'd need to figure out when any panels would be providing charge, and how much charge they would be providing over the entire burn, and whether there would be any brown/black-out periods to consider.

The game already calculates energy flux on solar panels and battery charging during time warp, so i dont think that will be a problem. Furthermore, since charging/discharging/thrusting is always linear, these effects would not be difficult to incorporate.

Edited by arkie87
Link to comment
Share on other sites

You've completely neglected any sort of gravitational pull. If you aren't in a planetary/moon SOI, you'll still be in the Kerbol SOI.

Yes, but its possible to get around this issue, as Master Tao explained.

- - - Updated - - -

I would like to see this implemented in some form for KSP, though it's more helpful for ion engines than anything else.

Two plugins alread implement this using the same approach (changing the orbit): KSP Interstellar for the solar sail and the Orbit Manipulator Series for ion engines. Both add quite a lot of other changes to the game, though.

Are you saying orbit manipulator series uses the same method/equations i provided?

Link to comment
Share on other sites

I agree that there are other issues to consider, such as wibble-wobble. However, time warping with thrust would only be allowed if the acceleration is low, such that no wibble-wobble would be encountered, such as usually the case with nuclear engines, and almost always the case with ion engines. Alternatively, time warping with thrust would just assume the body is rigid i.e. infinite struts (which are massless anyway).

I disagree that rockets using LV-N power are usually stable. For me, the long LV-N burns (where this could be relevant) are usually for something like a 4*LV-N tug transferring a chunk of station or fuel drop, and it's common to have stability issues with them (not always, just it happens often enough to be an issue, and it happens even with a very low TWR, such as 0.2-ish). That's not me saying that this is a bad idea, or that LV-N should necessarily be excluded. Ultimately it comes down to how accurate or correct you want the warp to be, relative to a standard 1x physics burn.

The game already calculates energy flux on solar panels and battery charging during time warp, so i dont think that will be a problem. Furthermore, since charging/discharging/thrusting is always linear, these effects would not be difficult to incorporate.

It depends what you mean, but I wouldn't regard the solar panel charging as linear. They are instantaneously linear, but highly variable over time, based on the angle to the sun, even for the rotating panel arrays. It's a problem that has a solution, i.e. the energy supply over time is predictable if the path and behaviour of the craft is known, just a complication which should be considered in this context.

Link to comment
Share on other sites

I disagree that rockets using LV-N power are usually stable. For me, the long LV-N burns (where this could be relevant) are usually for something like a 4*LV-N tug transferring a chunk of station or fuel drop, and it's common to have stability issues with them (not always, just it happens often enough to be an issue, and it happens even with a very low TWR, such as 0.2-ish). That's not me saying that this is a bad idea, or that LV-N should necessarily be excluded. Ultimately it comes down to how accurate or correct you want the warp to be, relative to a standard 1x physics burn.

True, for large ships driven by LV-N, there still might be wibble-wobble. Personally, i think wibble-wobble is stupid, since struts will fix the problem, and are massless, so you could just overload on struts. In the end, it makes the most sense to treat the vehicle like a rigid body when thrusting in time warp, and it might just be a necessary sacrifice to make certain burns possible. If you think about it though, most wibble-wobble could be dealt with simply by reducing throttle or turning throttle on, then off, damping wobble and/or correcting aim, then turning back on etc... and so, this feature would just save the player the hassle of doing this. However, the only problem i see is that this would enable engines with CoT misaligned with CoM to fly straight, which would be a problem in my book. To fix this, a simple check could be conducted to determine if too much rotation is being experienced, and if so, refuse time warp (sort of like it already does).

It depends what you mean, but I wouldn't regard the solar panel charging as linear. They are instantaneously linear, but highly variable over time, based on the angle to the sun, even for the rotating panel arrays. It's a problem that has a solution, i.e. the energy supply over time is predictable if the path and behaviour of the craft is known, just a complication which should be considered in this context.

Solar charging is a function of angle, distance from kerbol, and shading etc... but the game already calculates this during time warp (not sure how; its probably inaccurate or uses forward time-stepping allowing you to receive charge for the whole time step if you start the time-step with a view of kerbol). Thus, this problem is already dealt with (somehow).

Link to comment
Share on other sites

Are you saying orbit manipulator series uses the same method/equations i provided?

No, they use the same approach as each other. In non-physical timewarp, both mods edit the orbit rather than using the typical acceleration physics.

However, the only problem i see is that this would enable engines with CoT misaligned with CoM to fly straight, which would be a problem in my book.

Another solution might be to add some very limited physics simulation during non-physical timewarp. Treat the whole craft as a rigid body, but still apply thrust and momentum so it will rotate appropriately, but that also opens the door for SAS input during timewarp to keep the craft steady.

Link to comment
Share on other sites

I think a faster timewarp would useful, anything else would not punish the user for having a poorly built craft that wobbles, or lacks fuel, electricity etc. Someone could do a burn, timewarp, see there wasn't enough fuel, then go back to a quicksave in a much quicker time. And while they do that, they avoid that annoying small wobble and that nervous waiting time, and that fear of having to rebuild and/or relaunch the mission.

It simply isn't the kerbal way of flying.

Edited by treejoe4
Link to comment
Share on other sites

You would probably need numerical integration to account for the non-uniform gravity during the burn. It could easily be integrated into a scheme like the one discussed here.

Thanks for the link. Very interesting. Though i dont support implementation of n-body physics, i do support use of higher-order integration schemes so that 100x physical time warp is possible. In particular, the equations ive provided can be used to obtain higher order accuracy even under numerical integration, though they are not necessary.

Edited by arkie87
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...