コード例 #1
0
        private void CalculateThrustAndISP()
        {
            // Reset all the values
            vecThrust       = Vector3.zero;
            vecActualThrust = Vector3.zero;
            totalVectoredExhaustVelocity       = Vector3.zero;
            totalActualVectoredExhaustVelocity = Vector3.zero;
            totalExhaustVelocity       = 0;
            totalActualExhaustVelocity = 0;
            simpleTotalThrust          = 0d;
            simpleActualTotalThrust    = 0d;
            totalStageThrust           = 0d;
            totalStageActualThrust     = 0d;
            totalStageFlowRate         = 0d;
            totalStageIspFlowRate      = 0d;
            totalStageThrustForce.Reset();

            // Loop through all the active engines totalling the thrust, actual thrust and mass flow rates
            // The thrust is totalled as vectors
            for (int i = 0; i < activeEngines.Count; ++i)
            {
                EngineSim engine = activeEngines[i];

                simpleTotalThrust       += engine.thrust;
                simpleActualTotalThrust += engine.actualThrust;
                vecThrust       += ((float)engine.thrust * engine.thrustVec);
                vecActualThrust += ((float)engine.actualThrust * engine.thrustVec);

                totalVectoredExhaustVelocity += engine.thrustVec * (float)((engine.isp * BasicDeltaV.GRAVITY) / engine.thrust);
                totalExhaustVelocity         += totalVectoredExhaustVelocity.magnitude;

                totalActualVectoredExhaustVelocity += engine.thrustVec * (float)((engine.isp * BasicDeltaV.GRAVITY) / engine.actualThrust);
                totalActualExhaustVelocity         += totalActualVectoredExhaustVelocity.magnitude;

                totalStageFlowRate    += engine.ResourceConsumptions.Mass;
                totalStageIspFlowRate += engine.ResourceConsumptions.Mass * engine.isp;

                for (int j = 0; j < engine.appliedForces.Count; ++j)
                {
                    totalStageThrustForce.AddForce(engine.appliedForces[j]);
                }
            }
            if (log != null)
            {
                log.AppendLine("vecThrust = ", vecThrust.ToString(), "   magnitude = ", vecThrust.magnitude);
            }
            totalStageThrust       = vecThrust.magnitude;
            totalStageActualThrust = vecActualThrust.magnitude;

            // Calculate the effective isp at this point
            if (totalStageFlowRate > 0d && totalStageIspFlowRate > 0d)
            {
                currentisp = totalStageIspFlowRate / totalStageFlowRate;
            }
            else
            {
                currentisp = 0;
            }
        }