public static void CalculateShortwaves(PlanetSimulator pSim, Cell cell, WeatherCell[] wCellColumn) { for (int AltLayer = wCellColumn.Length - 1; AltLayer >= 0; AltLayer--) { WeatherCell temp = wCellColumn[AltLayer]; if (AltLayer == pSim.BufferMap.Count - 1) //Is it top layer? { float SunriseFactor = (float)(Mathf.Cos(WeatherFunctions.getLatitude(cell) * Mathf.Deg2Rad) + Mathf.Cos(getSunlightAngle(pSim, AltLayer, cell) * Mathf.Deg2Rad)) / 2f; //Debug.Log("Sunrise Factor: " + SunriseFactor); //checks out //Do check to see if top layer is in sunlight if (WeatherFunctions.isSunlight(pSim, AltLayer, cell)) { float bodyKSun = pSim.bodyKSun * SunriseFactor; //Debug.Log("bodyKSun: " + bodyKSun); temp.SWReflected = bodyKSun * temp.Albedo; temp.SWTransmitted = bodyKSun * temp.Transmissivity; //Debug.Log(temp.SWTransmitted); //top layer gives real values temp.SWAbsorbed = bodyKSun * (1 - temp.Albedo - temp.Transmissivity); } //Else, it's danky dark and this is where the sun don't shine else { temp.SWAbsorbed = 0; temp.SWReflected = 0; temp.SWTransmitted = 0; } } else if (AltLayer == 0) //Is it bottom layer? No transmit { temp.SWReflected = wCellColumn[AltLayer + 1].SWTransmitted * temp.Albedo; temp.SWTransmitted = 0f; temp.SWAbsorbed = wCellColumn[AltLayer + 1].SWTransmitted * (1 - temp.Albedo); //Debug.Log(pSim.BufferMap[AltLayer +1][cell].SWTransmitted); //Gives 0 } else //it's middle layers { temp.SWReflected = wCellColumn[AltLayer + 1].SWTransmitted * temp.Albedo; temp.SWTransmitted = wCellColumn[AltLayer + 1].SWTransmitted * temp.Transmissivity; temp.SWAbsorbed = wCellColumn[AltLayer + 1].SWTransmitted * (1 - temp.Albedo - temp.Transmissivity); //Debug.Log("Layer: "+ AltLayer + ", " + pSim.BufferMap[pSim.LiveMap.Count-1][cell].SWTransmitted); //gives 0 } wCellColumn[AltLayer] = temp; } }
internal static double atmoThermalConductivity = 0.024; //W/m-K public static void InitShortwaves(PlanetSimulator pSim, Cell cell) { //Debug.Log("Init shortwaves"); for (int index = pSim.LiveMap.Count - 1; index > 0; index--) { WeatherCell temp = pSim.BufferMap[index][cell]; if (index == pSim.LiveMap.Count - 1) //Is it top layer? { float SunriseFactor = (float)(Mathf.Cos(WeatherFunctions.getLatitude(cell) * Mathf.Deg2Rad) + Mathf.Cos(getSunlightAngle(pSim, index, cell) * Mathf.Deg2Rad)) / 2f; //check for sunlight if (WeatherFunctions.isSunlight(pSim, index, cell)) { float bodyKSun = pSim.bodyKSun * SunriseFactor; temp.SWReflected = bodyKSun * temp.Albedo; temp.SWTransmitted = bodyKSun * temp.Transmissivity; temp.SWAbsorbed = bodyKSun * (1 - temp.Albedo - temp.Transmissivity); } else { temp.SWAbsorbed = 0f; temp.SWReflected = 0f; temp.SWTransmitted = 0f; } } else if (index == 0) //is it bottom layer? No transmit { temp.SWReflected = pSim.BufferMap[index + 1][cell].SWTransmitted * temp.Albedo; temp.SWTransmitted = 0f; temp.SWAbsorbed = pSim.BufferMap[index + 1][cell].SWTransmitted * (1 - temp.Albedo - temp.Transmissivity); } else { temp.SWReflected = pSim.BufferMap[index + 1][cell].SWTransmitted * temp.Albedo; temp.SWTransmitted = pSim.BufferMap[index + 1][cell].SWTransmitted * temp.Transmissivity; temp.SWAbsorbed = pSim.BufferMap[index + 1][cell].SWTransmitted * (1 - temp.Albedo - temp.Transmissivity); } pSim.BufferMap[index][cell] = temp; } }