Exemplo n.º 1
0
    def _getFuelInertia(self, timeSinceIgnition):
        if self.initialFuelWeight == 0:
            return Inertia(Vector(0, 0, 0), Vector(0, 0, 0), 0)

        #See comments in _getOxInertia()
        fuelWeight = linInterp(self.times, self.fuelWeights, timeSinceIgnition)

        fuelBurnedFrac = 1 - (fuelWeight / self.initialFuelWeight)

        fuelCG_Z = self.initFuelCG_Z * (
            1 - fuelBurnedFrac) + self.finalFuelCG_Z * fuelBurnedFrac
        fuelCG = Vector(0, 0, fuelCG_Z)

        fuelMOI = linInterp(self.times, self.fuelMOIs, timeSinceIgnition)

        return Inertia(fuelMOI, fuelCG, fuelWeight)
Exemplo n.º 2
0
    def _getOxInertia(self, timeSinceIgnition):
        if self.initialOxidizerWeight == 0:
            return Inertia(Vector(0, 0, 0), Vector(0, 0, 0), 0)

        oxWeight = linInterp(self.times, self.oxWeights, timeSinceIgnition)

        # Find fraction of oxidizer burned
        oxBurnedFrac = 1 - (oxWeight / self.initialOxidizerWeight)

        #Linearly interpolate CG location based on fraction of oxidizer burned
        oxCG_Z = self.initOxCG_Z * (
            1 - oxBurnedFrac) + self.finalOxCG_Z * oxBurnedFrac
        #TODO: Allow motor(s) to be defined off-axis
        oxCG = Vector(0, 0, oxCG_Z)

        # Get MOI
        oxMOI = linInterp(self.times, self.oxMOIs, timeSinceIgnition)

        return Inertia(oxMOI, oxCG, oxWeight)
Exemplo n.º 3
0
    def getAppliedForce(self, state, time, environment, CG):
        #TODO: Model "thrust damping" - where gases moving quickly in the engine act to damp out rotation about the x and y axes
        #TODO: Thrust vs altitude compensation
        timeSinceIgnition = max(0, time - self.ignitionTime)

        # Determine thrust magnitude
        if timeSinceIgnition < 0 or timeSinceIgnition > self.times[-1]:
            thrustMagnitude = 0
        else:
            thrustMagnitude = linInterp(self.times, self.thrustLevels,
                                        timeSinceIgnition)

        # Create Vector
        thrust = Vector(0, 0, thrustMagnitude)
        return ForceMomentSystem(thrust)
Exemplo n.º 4
0
    def _getAeroCoefficients(self, state, environment):
        keys = AeroParameters.getAeroPropertiesList(self.parameterFunctions,
                                                    state, environment)

        if len(keys) > 1:
            # Multi-dimensional linear interpolation
            interpolatedCoefficients = self._interpAeroCoefficients(keys)[0]
        else:
            # 1D linear interpolation
            interpolatedCoefficients = linInterp(self.keys, self.values,
                                                 keys[0])

        aeroCoefficients = [0.0] * 5
        for i in range(len(interpolatedCoefficients)):
            indexInCoeffArray = self.aeroCoeffIndices[i]
            aeroCoefficients[indexInCoeffArray] = interpolatedCoefficients[i]

        return aeroCoefficients
Exemplo n.º 5
0
 def getInertia(self, time, state):
     inertiaData = linInterp(self.times, self.inertiaData, time)
     # MOI is last three columns, CG is the three before that, and mass is column 0
     return Inertia(Vector(*inertiaData[-3:]), Vector(*inertiaData[1:4]),
                    inertiaData[0])
Exemplo n.º 6
0
 def test_linInterp(self):
     self.assertEqual(linInterp([0, 1], [0, 1], 0.5), 0.5)
     self.assertEqual(linInterp([0, 1, 2, 3], [0, 1, 3, 5], 1.5), 2)
     self.assertEqual(linInterp([0, 1, 2, 3], [0, 1, 3, 5], 3), 5)
Exemplo n.º 7
0
 def getAirProperties(self, ASLElevation, _=None):
     return linInterp(self.keys, self.values, ASLElevation)
Exemplo n.º 8
0
 def getMeanWind(self, AGLAltitude):
     return Vector(*linInterp(self.windAltitudes, self.winds, AGLAltitude))