示例#1
0
 public static void CalculateNewTemperatureCurve(object o)
 {
     try
     {
         tempCurveDataContainer container  = (tempCurveDataContainer)o;
         AtmosphereComposition  atmosphere = bodyOrganizedListOfAtmospheres[container.body];
         //Debug.Log("Beginning Temperature Curve Calculation");
         Curves result = atmosphere.TemperatureAsFunctionOfVelocity(100, 5, atmosphere.maxSimVelocity);
         container.callingCurve.protoTempCurve      = result.temp;
         container.callingCurve.protoVelCpCurve     = result.cp;
         container.callingCurve.referenceTemp       = GetReferenceTemp(container.body);
         container.callingCurve.specificGasConstant = GetGasConstant(container.body);
         if (container.dumpToText)
         {
             container.callingCurve.DumpToText(5, container.body);
         }
     }
     catch (Exception e)
     {
         Debug.LogError("RealHeat: Exception in Temperature Curve Calculation: " + e.StackTrace);
     }
     AtmTempCurve.recalculatingCurve = false;
 }
示例#2
0
        public Curves TemperatureAsFunctionOfVelocity(int stepsBetweenCurvePoints, float dVForIntegration, float maxVel)
        {
            List<CurveData> velTempCurve = new List<CurveData>();
            List<CurveData> velCpCurve = new List<CurveData>();
            List<CurveData> velGammaCurve = new List<CurveData>();

            Dictionary<AtmosphericGasSpecies, float[]> workingGasSpeciesAndMassFractions = CreateWorkingGasSpeciesAndMassFractionDict();

            float temp = referenceTemperature;
            float velocity = 0;

            //StringBuilder debug = new StringBuilder();
            //float oldCp = CalculateCp(workingGasSpeciesAndMassFractions, temp);
            while (velocity < maxVel)
            {
                int i = 0;
                UpdateCompositionDueToDecomposition(workingGasSpeciesAndMassFractions, temp);
                float Cp = CalculateCp(workingGasSpeciesAndMassFractions, temp);
                float dCp_dt = Calculate_dCp_dt(workingGasSpeciesAndMassFractions, temp);
                float Cv = Cp - 0f;
                float energyChange = CalculateEnergyLostThroughDecomposition(workingGasSpeciesAndMassFractions, temp);

                float dT_dV = Cp + dCp_dt * temp + energyChange;
                dT_dV = velocity / dT_dV;

                float dCp_dV = dCp_dt * dT_dV;
                //float dCp_dV = (Cp - oldCp) / dVForIntegration;
                if (i <= stepsBetweenCurvePoints)
                {
                    velTempCurve.Add(new CurveData(velocity, temp - referenceTemperature, dT_dV));
                    velCpCurve.Add(new CurveData(velocity, Cp, dCp_dV));
                }

                i++;
                temp += dT_dV * dVForIntegration;
                velocity += dVForIntegration;
                //oldCp = Cp;
                //debug.AppendLine("Cp: " + Cp + " dCp_dt: " + dCp_dt + " energyChange: " + energyChange + " vel: " + velocity + " temp: " + temp + " dT_dV: " + dT_dV);
            }
            //Debug.Log(debug.ToString());
            Curves retval = new Curves();
            retval.temp = velTempCurve.ToArray();
            retval.cp = velCpCurve.ToArray();
            return retval;
        }