def forceVector(self, flightPitch, AoA, v, altitude = 0, planet = planet.kerbin, includeGravity = False): """ Returns (x, y) forces due to the airfoil. Includes drag, lift, and the parasitic drag due to lift. If includeGravity is set, also includes apparent gravity (taking into account centrifugal effects). flightPitch: angle of velocity vector relative to the surface (degrees) AoA: angle of the airfoil relative to the velocity vector (degrees) """ lift = self.liftForce(AoA, v, altitude, planet) drag = self.dragForce(AoA, v, altitude, planet) liftAngle = math.radians(flightPitch + 90) dragAngle = math.radians(flightPitch + 180) (liftX, liftY) = (lift * math.cos(liftAngle), lift * math.sin(liftAngle)) (dragX, dragY) = (drag * math.cos(dragAngle), drag * math.sin(dragAngle)) if not includeGravity: return (liftX + dragX, liftY + dragY) # now compute apparent gravity vOrbital = planet.orbitalVelocity(altitude) vSrfHorizontal = math.cos(math.radians(flightPitch)) * v vOrbHorizontal = vSrfHorizontal + planet.siderealSpeed(altitude) gravityAccel = planet.gravity(altitude) centrifugeAccel = vOrbHorizontal * vOrbHorizontal / (vOrbital * vOrbital) apparentGravityForce = (centrifugeAccel - gravityAccel) * self.mass return (liftX + dragX, liftY + dragY + apparentGravityForce)
def __init__(self, planet, thrust, Isp, mass, v = None, altitude = 0, deltaT = 0.03): self.t = 0 self.p = vector(0, planet.radius + altitude) if v is None: self.v = vector(planet.siderealSpeed(altitude), 0) else: self.v = vector(*v) self.deltaT = deltaT self.mass = mass self.initialMass = mass self.thrust = thrust self.Ve = Isp * g0 self.planet = planet
def zeroThrustForces(self, flightPitchDegrees, AoADegrees, v, altitude, planet): """ Return the forces other than thrust that this part produces. Returns a tuple (drag, lift, apparentGravity) with quantities in kN. Lift and drag are vectors; gravity is a number (just the y coordinate, positive means up). """ Cd = self._staticCd Clift = 0 if isinstance(self._parttype, lift.wing): Cd = self._parttype.dragCoeff(self._AoA + AoADegrees) Clift = self._parttype.liftCoeff(self._AoA + AoADegrees) elif isinstance(self._parttype, jets.intake): Cd = self._parttype.dragCoeff(self._AoA + AoADegrees) elif isinstance(self._parttype, jets.jetengine): Cd = 0.2 elif isinstance(self._parttype, engine.engine): Cd = 0.2 dragMagnitude = planet.dragForce(altitude, v, self.mass(), Cd) liftMagnitude = v * planet.pressure(altitude) * Clift flightPitchRad = math.radians(flightPitchDegrees) cosPitch = math.cos(flightPitchRad) sinPitch = math.sin(flightPitchRad) horizontalSpeedSrf = v * cosPitch horizontalSpeedOrb = horizontalSpeedSrf + planet.siderealSpeed(altitude) vOrbit = planet.orbitalVelocity(altitude) centrifuge = horizontalSpeedOrb * horizontalSpeedOrb / (vOrbit * vOrbit) gravity = planet.gravity(altitude) downForceMagnitude = self.mass() * (centrifuge - gravity) dragVector = physics.vector(-cosPitch * dragMagnitude, -sinPitch * dragMagnitude) liftVector = physics.vector(-sinPitch * liftMagnitude, cosPitch * liftMagnitude) return (dragVector, liftVector, downForceMagnitude)