Example #1
0
        private static List <KWSCellMap <WeatherCell> > InitCalcs(PlanetData PD)
        {
            List <KWSCellMap <WeatherCell> > tempMap = new List <KWSCellMap <WeatherCell> >();

            for (int i = 0; i < PD.layers; i++)
            {
                tempMap.Add(new KWSCellMap <WeatherCell>(PD.gridLevel));
            }
            float basePressure = (float)FlightGlobals.getStaticPressure(0, PD.body) * 1000;

            for (int AltLayer = 0; AltLayer < PD.layers; AltLayer++)
            {
                foreach (Cell cell in Cell.AtLevel(PD.gridLevel))
                {
                    WeatherCell wCell = new WeatherCell();

                    wCell.temperature = GetInitTemperature(PD, AltLayer, cell);
                    wCell.TempChange  = 0;

                    if (AltLayer == 0)
                    {
                        wCell.CCN = 1;

                        wCell.pressure         = basePressure;
                        wCell.relativeHumidity = PD.biomeDatas[WeatherFunctions.GetBiome(PD.index, cell)].FLC * 0.85f;  //* wCell.temperature / 288.15f
                    }
                    else
                    {
                        wCell.CCN = 0;

                        wCell.pressure = (float)(tempMap[AltLayer - 1][cell].pressure
                                                 * Math.Exp(-WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell) / (CellUpdater.UGC * PD.SH_correction / PD.atmoData.M / CellUpdater.G(PD.index, AltLayer * WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell)) * tempMap[AltLayer - 1][cell].temperature)));
                        wCell.relativeHumidity = (PD.biomeDatas[WeatherFunctions.GetBiome(PD.index, cell)].FLC * wCell.temperature / 288.15f) * 0.4f;
                    }

                    wCell.windVector        = new Vector3(0f, 0f, 0f);
                    wCell.flowPChange       = 0;
                    tempMap[AltLayer][cell] = wCell;
                }
            }


            return(tempMap);
        }