Modeling Time to Cover Distance with variable acceleration

In summary, the conversation is about writing a program to calculate the time it takes for a spaceship to move from Point A to Point B. The program is based on a computer game and the developers have introduced an element of drag to make the flying more user-friendly. The conversation discusses various equations and variables used in the program, including distance traveled, acceleration, thrust, drag, and mass. The conversation also mentions using calculus operations to continuously calculate the changing acceleration due to drag.
  • #1
Istanbul
2
0
Greetings all. I am attempting to write a program that will calculate how long a spaceship will take to move from Point A to Point B. This is actually an attempt to model my favorite computer game, so it isn’t 100% accurate in comparison to the real world. The developers introduced an element of drag to make the flying more user friendly.

I assume that the spacecraft starts out motionless, then applies maximum thrust from it’s engines instantaneously. (In reality it takes perhaps .05 seconds to move the throttle slider on my JS from 0 to 100, so I don’t think that this difference is what is throwing me off). For the very early stages of my program where I am just trying to figure out the proper calculations, I am assuming that Point B is 10000 meters away. The mass of the spaceship is 67620000g and the thrust provided by the engines at max throttle is 6400000 of whatever the applicable units of thrust are.

My understanding of the calculations required is that I need to use the calculations used in jet flight without the lift and gravity aspects. So far my internet research has lead me to the equations:

DistanceTraveled = InitialVel * Time + 1/2 Accel * Time ^ 2

Then:

Accel = ( Thrust - Drag ) / Mass

And:

Drag = DragFactor * Vel ^ 2

The only problem is that the first equation assumes the acceleration is a constant, when in my scenario, acceleration varies due to drag. I attempted to use looping and small time samples to model this, basically assuming that acceleration is constant during a very small moment of time (.01 seconds). (BTW, the DragFactor of the ship in my scenario is 35.5) (Another side note: The numbers given for thrust and the drag coefficient work out perfectly to make the ship stop accelerating at the top speed it has in game, so I don’t think those equations are wrong.)

Unfortunately, the results of this method vary wildly depending on the size of the time sample I use. If I use incredibly small samples (I went down to .00001, that actually took my CPU a few seconds to go through that many loops), it ends up with a result approaching the amount of time it takes to cover that distance if the spacecraft started out at it’s maximum velocity. If I use larger sample sizes, then the result is significantly longer than what it actually takes to perform in game. Using a stop watch, I did time trials that showed the ship taking ~28.5 seconds to cover that distance from a full stop.

I’ve tried to investigate calculus operations that would help me perform these calculations, but have found nothing that seemed to apply. Of course, I’ve forgotten anything I learned in Calculus in High School now, so I may have just not understood something and how it would apply. If anyone knows how to adjust the equations I have to continuously calculate the changing acceleration due to drag, please let me know. If anyone here knows programming and wants to look at my code, let me know and I’ll post a copy of the loop.

*Edit* Thanks to this scenario being in a game, we do not have to address changing mass due to fuel consumption.

Thanks,

Istanbul

P.S. No, I'm not from Turkey, sorry to disappoint.
 
Last edited:
Physics news on Phys.org
  • #2
I've gotten some help (I think) from another forum I visit (a community forum for the game I am attempt to write an application for). I've quoted my comments from that thread, then I have additional commentary below:

T = 1 / x * acosh [ ½ * exp [ 2 * ln ( 2 ) + D * x / q ] – 1 ]

Ok, I’m guessing that this is the appropriate equation, but I’d appreciate a bit of help figuring out what the terms actually are. ‘T’ would be the time obviously, and I’m guessing the ‘D’ is where we would be putting the distance covered. I have no idea what the ‘x’ and the ‘q’ are supposed to be, and I’m guessing that the ‘acosh’ is something to do with cosine. Either that, or when Fido typed this equation, he should have used some spaces. I think I ‘get’ everything else, though I need to investigate how to program in natural logs and natural bases and all that jazz.

Thanks for the link Jonboy, I think you’ve gotten me pointed in the direction I needed. :)

*edit* Further reading of Fido's post, I noticed a couple more equations that define 'x' and 'q'

x = 2 * k * q / M

q = sqrt ( T / k )

‘T’ I’m pretty sure is the thrust, and ‘M’ would probably be the mass, but I am now left just needing to know what the ‘k’ is all about.

acosh: is inverse hyperbolic cosine

k is apparently supposed to be the drag factor.
In the built in functions of vb, ln is apparently log, and log is apparently log10. Kind of an interesting way to do it, but, whatever. They also don’t have acosh (inverse hyperbolic cosine), but it can apparently be derived with what they have. What I found from Microsoft says that

acosh(n)= Log(n+ Sqrt(n*n-1)).

That log would be ln when using a calculator or whatever (unless I misunderstood what they said). In this equation n would be equal to:

[ ½ * exp [ 2 * ln ( 2 ) + D * x / q ] – 1 ]

All the stuff that followed the acosh in the equation up there basically.

To clarify the variables one more time:

T = Time
k = drag factor
M = Mass
T(The other T) = Thrust
D = Distance

x and q are calculated based on the inputs of the variables.
I tried to implant this equation in two ways. One was to substitute everything in as one big equation. The other was to divide each of the parts of the equations into sub functions.

The first method, I started out with the three equations:

T = 1 / x * acosh [ ½ * exp [ 2 * ln ( 2 ) + D * x / q ] – 1 ]

x = 2 * k * q / M

q = sqrt ( T / k )

And did the substitutions.

x = 2 * k * sqrt ( Th / k ) / M

Then into the big equation

Ti = 1 / (2 * k * sqrt ( Th / k ) / M) * acosh [ ½ * exp [ 2 * ln ( 2 ) + D * 2 * k * sqrt ( Th / k ) / M / sqrt ( T / k ) ] – 1 ]

Then, because VB doesn’t have acosh itself as a function, I had to use the method they gave to calculate it.

acosh(n)= Log(n+ Sqrt(n*n-1)).

Then substitute the ‘n’ [ ½ * exp [ 2 * ln ( 2 ) + D * x / q ] – 1 ]

Log([ ½ * exp [ 2 * Log ( 2 ) + D * x / q ] – 1 ]+ Sqrt([ ½ * exp [ 2 * Log ( 2 ) + D * x / q ] – 1 ]* [ ½ * exp [ 2 * ln ( 2 ) + D * x / q ] – 1 ]-1)).

Then add the stuff that’s in front of that part of the equation for the whole kit and caboodle:

Ti = 1 / (2 * k * sqrt ( Th / k ) / M) * Log([ ½ * exp [ 2 * ln ( 2 ) + D * x / q ] – 1 ]+ Sqrt([ ½ * exp [ 2 * log ( 2 ) + D * x / q ] – 1 ]* [ ½ * exp [ 2 * log ( 2 ) + D * x / q ] – 1 ]-1)).

Recall that in vb, log is really ln. This method ended up resulting in the time that it would take to cover the distance flying at top speed the entire time.

The other method, I would’ve thought would yield the same result, but actually gave a time significantly greater than actual. The other method, I set up separate functions to handle each of the subsections of the equation.

First, I had the function that calculated q, then x (which uses q). Then I set up a function to calculate the n for inside the acosh deal. then I set up a function to calculate the acosh, which, again was Log(n+ Sqrt(n*n-1)). Then I simply calculated the 1/x*a (a= the acosh(n)). So, I’m not sure if this equation isn’t actually the right one, or if I’m just making some kinds of algebraic mistakes. Theoretically, both methods should’ve yielded the same answer, but I could have mis-parenthesized and screwed up the order of operations in one, the other or both.

Maybe I should experiment more with my original looping method. I could probably come up with a sample rate that closely approximates what actually happens, but then I’m afraid that that won’t hold up if I change the value of the input variables. It would seem rather stupid of me to set up a program that has to use a different sample rate for every possible scenario that I’d be calculating with the program.

Istanbul
 
  • #3



Dear Istanbul,

Thank you for sharing your project with us. It sounds like you are on the right track with your equations and understanding of the problem. However, there are a few factors that you may want to consider in order to accurately model the time to cover distance with variable acceleration.

Firstly, it is important to note that drag is not the only factor affecting the acceleration of a spacecraft. There are also other forces such as gravity and air resistance that can impact the acceleration. In order to accurately model the acceleration, you may need to take these factors into account as well.

Secondly, the equations you have mentioned are based on the assumption of constant acceleration. In order to account for variable acceleration, you may need to use differential equations or numerical methods to solve for the changing acceleration over time. This may require some additional research and understanding of calculus.

Additionally, it may be helpful to create a more detailed model of your spacecraft, taking into consideration its shape, size, and other physical characteristics. This can help you determine a more accurate drag coefficient and better model the effects of drag on the acceleration.

Lastly, it may be beneficial to collaborate with other scientists or programmers who have experience in this area. They may be able to offer insights or suggestions on how to improve your model and calculations.

I wish you the best of luck with your project and hope that you are able to accurately model the time to cover distance with variable acceleration. Keep up the great work!

Best regards,

 

1. What is the significance of modeling time to cover distance with variable acceleration?

Modeling time to cover distance with variable acceleration is important in understanding the relationship between an object's acceleration and the time it takes to cover a certain distance. This can be useful in predicting the movement of objects in real-world scenarios, such as in transportation or sports.

2. How is variable acceleration taken into account in this model?

This model takes into account variable acceleration by using calculus and differential equations to calculate the change in acceleration over time. This allows for a more accurate representation of how an object's speed changes over time.

3. Can this model be applied to all types of motion?

Yes, this model can be applied to any type of motion where acceleration is variable. This includes both linear and non-linear motion, as well as both positive and negative acceleration.

4. How can this model be used in real-world applications?

This model can be used in various real-world applications, such as predicting the time it takes for a car to reach a certain distance, calculating the acceleration of a rocket during launch, or analyzing the performance of an athlete in a race.

5. What are the limitations of this model?

One limitation of this model is that it assumes constant acceleration between each time interval, which may not always be the case in real-world scenarios. It also does not take into account external factors such as air resistance or friction, which can affect an object's acceleration. Additionally, this model may not be suitable for extremely complex or chaotic systems.

Similar threads

Replies
14
Views
313
  • Mechanics
Replies
4
Views
642
Replies
10
Views
1K
Replies
11
Views
2K
  • Introductory Physics Homework Help
Replies
5
Views
1K
Replies
17
Views
2K
Replies
2
Views
1K
  • Mechanics
Replies
11
Views
2K
Replies
10
Views
304
  • Special and General Relativity
Replies
29
Views
1K
Back
Top