[Physics] How to graph acceleration

accelerationdistanceforcesgravityvelocity

I have written some java code for the calculation of some various acceleration and etc. type data. I am now trying to graph that data so I can pull specific data over a time line. The values I have received via my math program are purely accurate with several different means of error checking. I do not need assistance for the java programming. What I need is a accurate graphing techniques so I can get the appropriate data.

http://physicsforidiots.com/wp/wp-content/ql-cache/quicklatex.com-f80733c4cb4c6cb9bdef0e44fe176cab_l3.svg

acceleration formula

The x axis in that is the time variable. The y axis should be distance, but I'm getting totally bogus numbers. I know I may be off on my understanding of how it would graph.

    double D = Double.parseDouble(txtDistance.getText());
    double T = Double.parseDouble(txtTime.getText());
    double IV = Double.parseDouble(txtIVelocity.getText());
    double M = Double.parseDouble(txtMass.getText());

    double hd = Distance(D);
    double ht = Time(T);

    //2.0*(xt/th-v_i)/th
    //double A = (2 * (hd - ht * IV)) / (ht * ht);
    double A = 2 * (hd/ht - IV)/ht;     
    double PG = (A / 9.8) * 100;

    //IV + A * ht
    //double V = hd / ht;
    double V = IV + A * ht;
    double PL = (V / 299792458) * 100;
    double MPH = V * 2.236936;

    double F = M * A;
    double LBT = F * 0.224809;

    DecimalFormat df = new DecimalFormat("####0.0000");

    txtVelocity.setText(String.valueOf(df.format(V)));
    txtPLight.setText(String.valueOf(df.format(PL)));
    txtMph.setText(String.valueOf(df.format(MPH)));

    txtAcceleration.setText(String.valueOf(df.format(A)));
    txtPGForce.setText(String.valueOf(df.format(PG)));

    txtThrust.setText(String.valueOf(df.format(F)));
    txtLBThrust.setText(String.valueOf(df.format(LBT)));

As you can see by that, I am inputting distance, time, initial velocity, and mass. And in return, it calculates and displays final velocity, percent light speed, miles per hour, acceleration, percent G-force, trust in newton's, and lbs of thrust.

Sample data:

Distance: 160934400 Km (just over an AU)
Time: 40 hrs
Initial velocity: 3070 m/s (geosynchronous earth orbit)
Mass: 54431 Kg

The craft starts in earth orbit and accelerates for 50% of the distance and decelerates for 50% of the distance. This is figured with 72000 seconds, and 80467200000 meters.

Sample response:

Final velocity: 1117600.0000 m/s
Percent light: 0.3728 %
Miles per hour: 2499999.6736 mph (for human understanding of speed for reader)
Acceleration: 30.9592 m/s^2
Percent G-force: 315.9099 %
Thrust: 315.9099 N
Lbs Thrust: 378834.2788 Lbs (again for human understanding)

I know these numbers are as accurate as they can be utilizing the constant acceleration equations posted above. I know these numbers are extreme, but it is a science fiction novel.

The purpose of all this is I am writing a science fiction novel and I have a story line and a time line. I am needing various speeds, based on time and acceleration, etc. I have an additional program that will take this data and graph it so I can click on points to get the appropriate data I need at the given time in the story.

What is the appropriate means of graphing that so I can get accurate numbers that will make sense for my story when you, potential reader read the book?

As an aside for even more accurate numbers, I need to know how to modify my equations to account for gravitational interference in acceleration, etc.

I have spent the last week, upwards to 80 hours working on this so my book can be as accurate as it can be. With that being said, it would be near impossible for me to include all my work on this subject. Any assistance you are willing to offer so I can move forward with this novel would be extremely appreciated.

Best Answer

I am more familiar with graphing in Python than in the language you are using. The following snippet of code produces the graph you are asking for:

import numpy as np
import matplotlib.pyplot as plt

# sci fi velocity graph
D = 160934400000     # m
v_i = 3070           # m/s
total_time = 40*3600 # seconds: 40 hours

# to cover half the distance in half the time, we solve
# x(t) = x(0) + v_0*t + 0.5*a*t*t
# x(0) = 0
# x(t) = D/2
# t = total_time / 2 = th
th = total_time / 2
xt=D/2
a = 2.0*(xt/th-v_i)/th

print 'acceleration needed is %.2f m/s^2'%a
# this prints out 30.96 m/s^2 - encouraging

# calculate position during acceleration phase - every second:
tm = 20*3600 # time at mid point
x=[]
for t in range(0,tm+1):
    x.append(v_i*t + 0.5 * a * t * t)

xm = x[-1] # position at mid point

for t in range(tm+1, 2*tm):
    x.append((v_i + tm*a)*(t-tm) - 0.5 * a * (t - tm) * (t - tm) + xm)

time = np.arange(0,2*tm)/3600.0

plt.close('all')
plt.figure()
plt.plot(time, np.array(x)/1000)
plt.xlabel('time (hr)')
plt.ylabel('position (km)')
plt.show()

v_t = np.diff(x)
plt.figure()
plt.plot(np.array(x[:-1])/1000,v_t/1000)
plt.xlabel('position (km)')
plt.ylabel('velocity (km/s)')
plt.show()

plt.figure()
plt.plot(time[:-1], v_t/1000)
plt.xlabel('time (hr)')
plt.ylabel('velocity (km/s)')
plt.show()

This produces the following graph:

enter image description here

You can also plot velocity as a function of time:

enter image description here

Or as a function of position:

enter image description here