background information is that I have been working on code for a rocket launch to the ISS and I have gotten it close. The problem is when calculating the Force of drag, the problem occurs with it. As entering space, and for this "model" were going to say that temperature is 0 K in space or basically just out of the atmosphere. Obviously absolute 0 isn't possible, but perhaps that would be a simple solution to the problem. When entering space, T= 0 K, and there isn't any air, well not in the "model". So since there isn't any air then there wouldn't be any drag force. I did the calculation for my formula and at y= 44307.69 m, the rocket leaves the atmosphere. the equations I use for temperature is T=Tz - L*y where Tz is the Temperature at time 0, L is temperature lapse rate (assuming linear as y increases) of value 0.0065 K/m, and y is height in m.(adsbygoogle = window.adsbygoogle || []).push({});

Next, is the pressure, and as you know as y increases pressure should also go down. Now as leaving the atmosphere there should not be any pressure. This formula is P= Pnot * (T/Tz)^((g*M)/(R*L)); where Pnot is pressure @ y=0 or 101 kPa, T=current temperature, Tz= Temp @ y=0 (288K), g=gravity (which uses another formula but I have that one working correctly), M= molar mass of air value of 0.02896 kg/Mole, R=8.314 J/K*M, and L is the temperature lapse rate again.

Anyways this is a lot of information obviously, and my question is how to get the force of drag to stop at that y= 44307.69 m, and then keep calculating in the while loop for the computer program. also using the Euler method, in the python language.

Trying to get it to go to the ISS and then come back to earth.

Any help would be appreciated. Thanks.

COPY OF THE CODE ATTACHED BELOW

Code (Text):

from __future__ import division, print_function

from pylab import *

from scipy.interpolate import interp1d

dt= 0.01 #seconds, the timestep

t= 0.0 #seconds, initial time

yfinal= 355000.0 #m, =355km how far up the ISS is traveling

y= 0.0 #m at ground level

v= 0.0 #m/s initial speed

pay= 5000.0 #kg

me= 10000.0 #kg, empty mass with NO fuel or payload

gas= 10000.0 #kg of rocket fuel, 10,000 is max fuel

m= 20000.0 #kg ###+ pay #total mass, empty rocket, fuel, and payload

Em= 10000.0

Ev= 7000.0 #m/s exhaust velocity

Br= 100.0 #kg/s burn rate of the fuel

A= 10.0 #m**2 Reference or cross sectional area

Cd= 0.5 #drag coefficient

gs=9.8 #m/s**2 initial gravity at the earths surface

Vex= 7000.0 #m/s exit velocity of the fuel being ejected out

Ft= Br * Vex #force of thrust, acceleration upward

a=0.0

nogas = gas/Br #the point at which the rocket runs out of gas

Re= 6378100.0 #meters radius of the earth

g= 0.0

rho= 0.0

R= 8.314 #Joules/Kelvin*Mole

M= 0.02896 #kg/mole

T= 288.0

Pz=101000.0 #Pascal Pressure at time 0

Tz= 288.0 #Kelvin Tempature at time 0. Aprox. 14.85 Celsius

L= 0.0065 #Kelvin/meter "Tempature lapse rate"

P= 101000.0 #Pressure in Pascal

Fd= 0.0

Fg= 196000

#initial array values

tArray = array([t])

yArray = array([y])

vArray = array([v])

aArray= array([a])

gArray= array([g])

mArray= array([m])

FtArray= array([Ft])

FdArray = array([Fd])

FgArray= array([Fg])

TArray = array([T])

rhoArray= array([rho])

PArray = array([P])

RArray= array([R])

MArray= array([M])

#calculations for arrays

#if y<=44307.69231:

# break(T)

while (y<=yfinal):# and (T>=0):# and (P>=10100): # and (nogas>=t):

t= t + dt #increments TIME

gas= gas - Br*dt

m = Em + gas

Ft= Br * Vex

T= Tz - (L*y)#*dt

g= (gs/((1+y/Re)**2))

P= Pz*((abs(T/Tz))**((g*M)/(R*L)))

rho= (P*M)/(R*T) #*dt

if(T < 0):

Fd= 0

Fd= .5*rho*A*Cd*v*abs(v)

Fg= (m)*g

a=(-Fg-Fd+Ft)/m

y= y + v*dt #increments HEIGHT

v= v + a*dt #increments VELOCITY

yArray = append(yArray, y) #fills in height array

vArray = append(vArray, v)#fills in velocity array

tArray = append(tArray, t)#fills in time array

aArray = append(aArray, a)

gArray = append(gArray, g)

mArray = append(mArray, m)

FtArray= append(FtArray, Ft)

FgArray= append(FgArray, Fg)

FdArray= append(FdArray, Fd)

TArray = append(TArray, T)

rhoArray= append(rhoArray, rho)

PArray = append(PArray, P)

RArray = append(RArray, R)

MArray= append(MArray, M)

print("time", t, "secs", '\t', "height", y, "m", '\t', 'velocity', v, "m/s")

print(aArray)

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# [Python] Simulating rocket trajectory to ISS

Loading...

Similar Threads - Python Simulating rocket | Date |
---|---|

Python Simulating an infinite well | Jun 1, 2017 |

Python Hydrodynamics simulation | Apr 18, 2016 |

Making a pretty n-body simulation | Feb 23, 2016 |

Help designing an n-body gravity simulator in Python | Nov 29, 2015 |

How much faster is Python than Mathematica? | May 30, 2015 |

**Physics Forums - The Fusion of Science and Community**