Skip to content

Commit

Permalink
Added pressure formulas for 86 - 1000 km ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
RimorRes committed Nov 2, 2019
1 parent b8002e0 commit 7ebeea9
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions preflightpy/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,36 @@ def get_temp(self, h: float) -> float:
elif 71000 < h:
return (214.65 + (self.Lm[6]*(h-71000)), 6)

def get_pressure(self, h: float, T: float, b: int)-> float:
if self.Lm[b] != 0:
return self.Pb[b] * ( self.Tb[b]/T )**(self.g*self.M_air/(self.R*self.Lm[b]))
else:
return self.Pb[b] * math.exp( -self.g * self.M_air * (h-self.hb[b]) / (self.R*self.Tb[b]) )
def get_pressure(self, z: float, h: float, T: float, b: int)-> float:

def equ(a, b, c, d, e):
return math.exp( a * z**4 + b * z**3 + c * z**2 + d * z + e)

if b <= 6:
if self.Lm[b] != 0:
return self.Pb[b] * ( self.Tb[b]/T )**(self.g*self.M_air/(self.R*self.Lm[b]))
else:
return self.Pb[b] * math.exp( -self.g * self.M_air * (h-self.hb[b]) / (self.R*self.Tb[b]) )
elif b == 7:
return equ(0.000000, 2.159582*10**(-6), -4.836957*10**(-4), -0.1425192, 13.47530)
elif b == 8:
return equ(0.000000, 3.304895*10**(-5), -0.009062730, 0.6516698, -11.03037)
elif b == 9:
return equ(0.000000, 6.693926*10**(-5), -0.01945388, 1.719080, -47.75030)
elif b == 10:
return equ(0.000000, -6.539316*10**(-5), 0.02485568, -3.223620, 135.9355)
elif b == 11:
return equ(2.283506*10**(-7), -1.343221*10**(-4), 0.02999016, -3.055446, 113.5764)
elif b == 12:
return equ(1.209434*10**(-8), -9.692458*10**(-6), 0.003002041, -0.4523015, 19.19151)
elif b == 13:
return equ(8.113942*10**(-10), -9.822568*10**(-7), 4.687616*10**(-4), -0.1231710, 3.067409)
elif b == 14:
return equ(9.814674*10**(-11), -1.654439*10**(-7), 1.148115*10**(-4), -0.05431334, -2.011365)
elif b == 15:
return equ(-7.835161*10**(-11), 1.964589*10**(-7), -1.657213*10**(-4), 0.04305869, -14.77132)
elif b == 16:
return equ(2.813255*10**(-11), -1.120689*10**(-7), 1.695568*10**(-4), -0.1188941, 14.56718)

def get_density(self, P: float, T: float) -> float:
V = 1
Expand All @@ -67,10 +91,7 @@ def get_c(self, T: float):

def get_status(self, z: float):
h = round(self.get_geopotential_altitude(6378137, z),0)
print(h)
self.T, b = self.get_temp(h)
print(self.T, b)
self.P = self.get_pressure(h, self.T, b)
print(self.P)
self.P = self.get_pressure(z, h, self.T, b)
self.Rho = self.get_density(self.P, self.T)
self.c = self.get_c(self.T)

0 comments on commit 7ebeea9

Please sign in to comment.