Exemple #1
0
def speedForLift(F, liftSurfaces = [], AoAdegrees = 0, altitude = 0, planet = planet.kerbin):
    """
    Return the speed we need to go in order to get a given lift force.
    Useful to figure out the liftoff speed of a plane.
    F is in kN
    liftSurfaces is a list of triples (n, liftType, AoA) with AoA being relative to your craft.
        - you can elide n to mean 1, or elide AoA to mean 0
    """
    coeff = 0
    for item in liftSurfaces:
        if item is wing:
            coeff += item.liftCoeff(AoAdegrees)
        else:
            try:
                (n, x, AoA) = item
                coeff += n * x.liftCoeff(AoA + AoAdegrees)
            except:
                try:
                    (n, x) = item
                    coeff += n * x.liftCoeff(AoAdegrees)
                except:
                    # last-ditch; this may throw
                    (x, AoA) = item
                    coeff += x.liftCoeff(AoA + AoAdegrees)
    # coeff is the lift coefficient of the whole craft
    return F / (coeff * planet.pressure(altitude))
    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)
Exemple #3
0
 def _liftFactor(self, AoAdegrees, altitude = 0, planet = planet.kerbin):
     return self.deflectionLift(AoAdegrees) * planet.pressure(altitude) * self.lift
Exemple #4
0
 def liftForce(self, AoAdegrees, v, altitude = 0, planet = planet.kerbin):
     return v * planet.pressure(altitude) * self.liftCoeff(AoAdegrees)