コード例 #1
0
 public static float GetGasConstant(CelestialBody body)
 {
     if ((object)body == null)
     {
         return(0f);
     }
     if (bodyOrganizedListOfAtmospheres.ContainsKey(body))
     {
         AtmosphereComposition atmosphere = bodyOrganizedListOfAtmospheres[body];
         return(atmosphere.gasConstant);
     }
     return(287.103f);
 }
コード例 #2
0
 public static float GetSpecHeatRatio(CelestialBody body)
 {
     if ((object)body == null)
     {
         return(0f);
     }
     if (bodyOrganizedListOfAtmospheres.ContainsKey(body))
     {
         AtmosphereComposition atmosphere = bodyOrganizedListOfAtmospheres[body];
         return(atmosphere.specHeatRatio);
     }
     return(1.4f);
 }
コード例 #3
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;
 }
コード例 #4
0
        public static void LoadConfigNodes()
        {
            idOrganizedListOfGasSpecies    = new Dictionary <string, AtmosphericGasSpecies>();
            bodyOrganizedListOfAtmospheres = new Dictionary <CelestialBody, AtmosphereComposition>();
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("RH_ATM_GAS_SPECIES"))
            {
                foreach (ConfigNode gasSpeciesNode in node.GetNodes("GAS_SPECIES"))
                {
                    string id = gasSpeciesNode.GetValue("name");
                    AtmosphericGasSpecies newSpecies = new AtmosphericGasSpecies(id);

                    idOrganizedListOfGasSpecies.Add(id, newSpecies);
                }
            }
            foreach (KeyValuePair <string, AtmosphericGasSpecies> pair in idOrganizedListOfGasSpecies)
            {
                pair.Value.Initialize();
            }

            AtmosphereComposition defaultOxygenatedRocky   = new AtmosphereComposition(),
                                  defaultUnoxygenatedRocky = new AtmosphereComposition(),
                                  defaultGasGiant          = new AtmosphereComposition();

            float gasGiantRadius = 3000;

            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("RH_ATM_COMPOSITIONS"))
            {
                foreach (ConfigNode atmNode in node.GetNodes("ATM_COMPOSITION"))
                {
                    AtmosphereComposition newComposition = new AtmosphereComposition();

                    newComposition.gasSpeciesAndMassFractions = new Dictionary <AtmosphericGasSpecies, float>();

                    foreach (ConfigNode gasSpeciesNode in atmNode.GetNodes("GAS_SPECIES"))
                    {
                        AtmosphericGasSpecies decompositionSpecies = AtmDataOrganizer.idOrganizedListOfGasSpecies[gasSpeciesNode.GetValue("name")];

                        float massFraction = float.Parse(gasSpeciesNode.GetValue("massFraction"));
                        newComposition.gasSpeciesAndMassFractions.Add(decompositionSpecies, massFraction);
                    }

                    newComposition.referenceTemperature = float.Parse(atmNode.GetValue("referenceTemperature"));
                    newComposition.maxSimVelocity       = float.Parse(atmNode.GetValue("maxSimVelocity"));

                    string bodyName = atmNode.GetValue("name");

                    for (int idx = 0; idx < FlightGlobals.Bodies.Count; idx++)
                    {
                        CelestialBody body = FlightGlobals.Bodies[idx];
                        if (body.name == bodyName)
                        {
                            newComposition.specHeatRatio = (float)body.atmosphereAdiabaticIndex;
                            newComposition.gasConstant   = (float)((double)(AtmosphericGasSpecies.UniversalGasConstant) / (body.atmosphereMolarMass * 1000d));
                            bodyOrganizedListOfAtmospheres.Add(body, newComposition);
                            break;
                        }
                    }

                    if (bodyName == "defaultOxygenatedRocky")
                    {
                        defaultOxygenatedRocky = newComposition;
                    }
                    else if (bodyName == "defaultUnoxygenatedRocky")
                    {
                        defaultUnoxygenatedRocky = newComposition;
                    }
                    else if (bodyName == "defaultGasGiant")
                    {
                        defaultGasGiant = newComposition;
                    }
                }
                gasGiantRadius = float.Parse(node.GetValue("gasGiantRadius"));
            }

            foreach (CelestialBody body in FlightGlobals.Bodies)
            {
                if (!bodyOrganizedListOfAtmospheres.ContainsKey(body))
                {
                    if (body.Radius > gasGiantRadius)
                    {
                        bodyOrganizedListOfAtmospheres.Add(body, defaultGasGiant);
                    }
                    else if (body.atmosphereContainsOxygen)
                    {
                        bodyOrganizedListOfAtmospheres.Add(body, defaultOxygenatedRocky);
                    }
                    else
                    {
                        bodyOrganizedListOfAtmospheres.Add(body, defaultUnoxygenatedRocky);
                    }
                }
            }
        }
コード例 #5
0
        public static float GetReferenceTemp(CelestialBody body)
        {
            AtmosphereComposition atmosphere = bodyOrganizedListOfAtmospheres[body];

            return(atmosphere.referenceTemperature);
        }
コード例 #6
0
ファイル: AtmData.cs プロジェクト: Kerbas-ad-astra/RealHeat
        public static void LoadConfigNodes()
        {
            idOrganizedListOfGasSpecies = new Dictionary<string, AtmosphericGasSpecies>();
            bodyOrganizedListOfAtmospheres = new Dictionary<CelestialBody, AtmosphereComposition>();
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("RH_ATM_GAS_SPECIES"))
            {
                foreach (ConfigNode gasSpeciesNode in node.GetNodes("GAS_SPECIES"))
                {
                    string id = gasSpeciesNode.GetValue("name");
                    AtmosphericGasSpecies newSpecies = new AtmosphericGasSpecies(id);

                    idOrganizedListOfGasSpecies.Add(id, newSpecies);
                }
            }
            foreach (KeyValuePair<string, AtmosphericGasSpecies> pair in idOrganizedListOfGasSpecies)
                pair.Value.Initialize();

            AtmosphereComposition defaultOxygenatedRocky = new AtmosphereComposition(),
                defaultUnoxygenatedRocky = new AtmosphereComposition(),
                defaultGasGiant = new AtmosphereComposition();

            float gasGiantRadius = 3000;

            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("RH_ATM_COMPOSITIONS"))
            {
                foreach (ConfigNode atmNode in node.GetNodes("ATM_COMPOSITION"))
                {
                    AtmosphereComposition newComposition = new AtmosphereComposition();

                    newComposition.gasSpeciesAndMassFractions = new Dictionary<AtmosphericGasSpecies, float>();

                    foreach (ConfigNode gasSpeciesNode in atmNode.GetNodes("GAS_SPECIES"))
                    {
                        AtmosphericGasSpecies decompositionSpecies = AtmDataOrganizer.idOrganizedListOfGasSpecies[gasSpeciesNode.GetValue("name")];

                        float massFraction = float.Parse(gasSpeciesNode.GetValue("massFraction"));
                        newComposition.gasSpeciesAndMassFractions.Add(decompositionSpecies, massFraction);
                    }

                    newComposition.referenceTemperature = float.Parse(atmNode.GetValue("referenceTemperature"));
                    newComposition.maxSimVelocity = float.Parse(atmNode.GetValue("maxSimVelocity"));

                    string bodyName = atmNode.GetValue("name");

                    for(int idx = 0; idx < FlightGlobals.Bodies.Count; idx++)
                    {
                        CelestialBody body = FlightGlobals.Bodies[idx];
                        if(body.name == bodyName)
                        {
                            newComposition.specHeatRatio = (float)body.atmosphereAdiabaticIndex;
                            newComposition.gasConstant = (float)((double)(AtmosphericGasSpecies.UniversalGasConstant) / (body.atmosphereMolarMass * 1000d));
                            bodyOrganizedListOfAtmospheres.Add(body, newComposition);
                            break;
                        }
                    }

                    if (bodyName == "defaultOxygenatedRocky")
                        defaultOxygenatedRocky = newComposition;
                    else if (bodyName == "defaultUnoxygenatedRocky")
                        defaultUnoxygenatedRocky = newComposition;
                    else if (bodyName == "defaultGasGiant")
                        defaultGasGiant = newComposition;
                }
                gasGiantRadius = float.Parse(node.GetValue("gasGiantRadius"));
            }

            foreach(CelestialBody body in FlightGlobals.Bodies)
            {
                if(!bodyOrganizedListOfAtmospheres.ContainsKey(body))
                {
                    if (body.Radius > gasGiantRadius)
                        bodyOrganizedListOfAtmospheres.Add(body, defaultGasGiant);
                    else if(body.atmosphereContainsOxygen)
                        bodyOrganizedListOfAtmospheres.Add(body, defaultOxygenatedRocky);
                    else
                        bodyOrganizedListOfAtmospheres.Add(body, defaultUnoxygenatedRocky);
                }
            }
        }