Пример #1
0
Файл: sim.py Проект: sourtin/SLS
	def analyse(self):
		dat=[[x['distance'], hyp(x['drag']['x'],x['drag']['y'])] for x in self.data]
		dat2=[[x['distance'], hyp(x['thrust']['x'],x['thrust']['y'])] for x in self.data]
		ED = integrate(copy.deepcopy(dat))
		EE = integrate(dat2)
		print "Drag Energy = %f GJ" % (ED/1e9)
		print "Thrust Energy = %f GJ" % (EE/1e9)
		return dat
Пример #2
0
Файл: sim.py Проект: sourtin/SLS
	def step(self,thrust,dt):
		host = self.host; m = self.m; drag = self.drag()
		g = constants['G'] * host.mass / (host.radius + self.pos['alt'])**2
		vx = self.v['x']; vy = self.v['y']; vv = hyp(vx,vy)
		x = self.pos['x']; y = self.pos['y']; r = hyp(x,y)
		ax = (thrust['x'] - drag['x'])/m - g*x/r
		ay = (thrust['y'] - drag['y'])/m - g*y/r
		dsx = vx*dt + .5*ax*dt**2; dsy = vy*dt + .5*ay*dt**2
		x += dsx; y += dsy; alt = hyp(x,y) - host.radius
		#print m, thrust, drag, ax, ay, alt, ",", g, x, y, r
		if alt < 0:
			y = host.radius
			thrust=drag={'x':0, 'y':0}
			alt=x=av=ah=dsx=dsy=vx=vy=v=0
		self.s += hyp(dsx, dsy); self.pos['alt'] = alt
		self.v['x'] = vx+ax*dt; self.v['y'] = vy+ay*dt
		self.pos['x'] = x; self.pos['y'] = y
		return drag
Пример #3
0
Файл: sim.py Проект: sourtin/SLS
	def drag(self):
		atm = self.host.atm; A = self.A; alt = self.pos['alt']
		if self.burning: dr_th = atm.pres(alt) * A['exh']
		else: dr_th = 0
		
		vh = self.v['x']; vv = self.v['y']; v = hyp(vh,vv)
		cc = .5 * self.cd(v) * atm.dens(alt)
		cp = cos(self.pitch); sp = sin(self.pitch)
		dt = cc*A['top']*(vv*cp+vh*sp)**2 + dr_th
		ds = cc*A['side']*(vv*sp-vh*cp)**2
		
		return {'x':(dt*sp + ds*cp)*sign(vh), 'y':(dt*cp - ds*sp)*sign(vv)}
Пример #4
0
Файл: sim.py Проект: sourtin/SLS
def cart2polar(v):
	r = hyp(v['x'], v['y'])
	t = atan2(v['y'], v['x'])
	return {'r':r, 't':t}
Пример #5
0
Файл: sim.py Проект: sourtin/SLS
		def print_cart(v):
			x = v['x']; y = v['y']; r = hyp(x,y)
			return (ni*3).format(x,y,r)
Пример #6
0
Файл: sim.py Проект: sourtin/SLS
		def print_hyp(v):
			x = v['x']; y = v['y']; r = hyp(x,y)
			return ni.format(r)
			return (ni*3).format(x,y,r)