コード例 #1
0
        public double DailyIncomingRadiationIntensity(double lat, double lng, DateTime day, double cloudcover = 0.1)
        {
            mSunEarth.Latitude  = lat;
            mSunEarth.Longitude = lng;
            int hours = 24;

            double[] radis = new double[hours];

            for (int i = 0; i < hours; i++)
            {
                DateTime       dt = day.AddHours(i);
                SunCoordinates sc = mSunEarth.SunPostion(dt);
                if (sc.Azimuth > 0)
                {
                    radis[i] = 1366.2 * Math.Sin(sc.Azimuth * SunEarth.D2R) * (1 - 0.71 * cloudcover) * SkyAttenuation * 3600;
                }
            }
            return(radis.Sum());
        }
コード例 #2
0
        public double[] HourlyIncomingRadiationIntensity(DateTime start, DateTime end, double cloudcover)
        {
            SunEarth se    = new SunEarth(Latitude, Longitude);
            TimeSpan ts    = end - start;
            int      hours = (int)ts.TotalHours;

            double[] radis = new double[hours];

            for (int i = 0; i < hours; i++)
            {
                DateTime       dt = start.AddHours(i);
                SunCoordinates sc = se.SunPostion(dt);
                if (sc.Azimuth > 0)
                {
                    radis[i] = 1366.2 * Math.Sin(sc.Azimuth * SunEarth.D2R) * (1 - 0.71 * cloudcover) * SkyAttenuation;
                }
            }
            return(radis);
        }
コード例 #3
0
        /// <summary>
        ///  the Altitude angular height of the sun in the sky measured from the horizontal.
        /// </summary>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="time"></param>
        /// <returns>Solar atitude in degree</returns>
        public SunCoordinates SunPostion(DateTime time)
        {
            SunCoordinates sc          = new SunCoordinates();
            double         latR        = Latitude * D2R;
            double         lngR        = Longitude * D2R;
            double         declination = DeclinationAngle(time.DayOfYear);
            double         lst         = LST(Longitude, time);
            double         hra         = HRA(lst);
            double         ele         = Math.Sin(latR) * Math.Sin(declination) + Math.Cos(latR) * Math.Cos(declination) * Math.Cos(hra * D2R);
            double         eleR        = Math.Asin(ele);

            sc.Azimuth = eleR * R2D;

            double azi = (Math.Sin(declination) * Math.Cos(latR) - Math.Cos(declination) * Math.Sin(latR) * Math.Cos(hra * D2R)) / Math.Cos(eleR);

            sc.ZenithAngle = Math.Acos(azi) * R2D;
            //if (hra > 0 || lst > 0)
            //   sc.ZenithAngle = 360 - sc.ZenithAngle;
            return(sc);
        }
コード例 #4
0
        public double[] HourlyIncomingRadiationIntensity(DateTime start, DateTime end, double[] cloudcovers)
        {
            SunEarth se    = new SunEarth(Latitude, Longitude);
            TimeSpan ts    = end - start;
            int      hours = (int)ts.TotalHours;

            double[] radis = new double[hours];

            if (cloudcovers.Length != hours)
            {
                throw new Exception("The number of cloud-cover values does not match with the hours");
            }

            for (int i = 0; i < hours; i++)
            {
                DateTime       dt = start.AddHours(i);
                SunCoordinates sc = se.SunPostion(dt);
                if (sc.Azimuth > 0)
                {
                    radis[i] = 1366.2 * Math.Sin(sc.Azimuth * SunEarth.D2R) * (1 - 0.71 * cloudcovers[i]) * SkyAttenuation;
                }
            }
            return(radis);
        }
コード例 #5
0
        public SunCoordinates SunPostion(SolarTime udtTime, Location udtLocation)
        {
            SunCoordinates udtSunCoordinates = new SunCoordinates();
            // Main variables
            double dElapsedJulianDays;
            double dDecimalHours;
            double dEclipticLongitude;
            double dEclipticObliquity;
            double dRightAscension;
            double dDeclination;

            // Auxiliary variables
            double dY;
            double dX;

            // Calculate difference in days between the current Julian Day
            // and JD 2451545.0, which is noon 1 January 2000 Universal Time

            double dJulianDate;
            long   liAux1;
            long   liAux2;

            // Calculate time of the day in UT decimal hours
            dDecimalHours = udtTime.dHours + (udtTime.dMinutes
                                              + udtTime.dSeconds / 60.0) / 60.0;
            // Calculate current Julian Day
            liAux1 = (udtTime.iMonth - 14) / 12;
            liAux2 = (1461 * (udtTime.iYear + 4800 + liAux1)) / 4 + (367 * (udtTime.iMonth
                                                                            - 2 - 12 * liAux1)) / 12 - (3 * ((udtTime.iYear + 4900
                                                                                                              + liAux1) / 100)) / 4 + udtTime.iDay - 32075;
            dJulianDate = (double)(liAux2) - 0.5 + dDecimalHours / 24.0;
            // Calculate difference between current Julian Day and JD 2451545.0
            dElapsedJulianDays = dJulianDate - 2451545.0;


            // Calculate ecliptic coordinates (ecliptic longitude and obliquity of the
            // ecliptic in radians but without limiting the angle to be less than 2*Pi
            // (i.e., the result may be greater than 2*Pi)

            double dMeanLongitude;
            double dMeanAnomaly;
            double dOmega;

            dOmega             = 2.1429 - 0.0010394594 * dElapsedJulianDays;
            dMeanLongitude     = 4.8950630 + 0.017202791698 * dElapsedJulianDays; // Radians
            dMeanAnomaly       = 6.2400600 + 0.0172019699 * dElapsedJulianDays;
            dEclipticLongitude = dMeanLongitude + 0.03341607 * Math.Sin(dMeanAnomaly)
                                 + 0.00034894 * Math.Sin(2 * dMeanAnomaly) - 0.0001134
                                 - 0.0000203 * Math.Sin(dOmega);
            dEclipticObliquity = 0.4090928 - 6.2140e-9 * dElapsedJulianDays
                                 + 0.0000396 * Math.Cos(dOmega);


            // Calculate celestial coordinates ( right ascension and declination ) in radians
            // but without limiting the angle to be less than 2*Pi (i.e., the result may be
            // greater than 2*Pi)

            double dSin_EclipticLongitude;

            dSin_EclipticLongitude = Math.Sin(dEclipticLongitude);
            dY = Math.Cos(dEclipticObliquity) * dSin_EclipticLongitude;
            dX = Math.Cos(dEclipticLongitude);
            dRightAscension = Math.Atan2(dY, dX);
            if (dRightAscension < 0.0)
            {
                dRightAscension = dRightAscension + twopi;
            }
            dDeclination = Math.Asin(Math.Sin(dEclipticObliquity) * dSin_EclipticLongitude);


            // Calculate local coordinates ( azimuth and zenith angle ) in degrees

            double dGreenwichMeanSiderealTime;
            double dLocalMeanSiderealTime;
            double dLatitudeInRadians;
            double dHourAngle;
            double dCos_Latitude;
            double dSin_Latitude;
            double dCos_HourAngle;
            double dParallax;

            dGreenwichMeanSiderealTime = 6.6974243242 +
                                         0.0657098283 * dElapsedJulianDays
                                         + dDecimalHours;
            dLocalMeanSiderealTime = (dGreenwichMeanSiderealTime * 15
                                      + udtLocation.dLongitude) * rad;
            dHourAngle                    = dLocalMeanSiderealTime - dRightAscension;
            dLatitudeInRadians            = udtLocation.dLatitude * rad;
            dCos_Latitude                 = Math.Cos(dLatitudeInRadians);
            dSin_Latitude                 = Math.Sin(dLatitudeInRadians);
            dCos_HourAngle                = Math.Cos(dHourAngle);
            udtSunCoordinates.ZenithAngle = (Math.Acos(dCos_Latitude * dCos_HourAngle
                                                       * Math.Cos(dDeclination) + Math.Sin(dDeclination) * dSin_Latitude));
            dY = -Math.Sin(dHourAngle);
            dX = Math.Tan(dDeclination) * dCos_Latitude - dSin_Latitude * dCos_HourAngle;
            udtSunCoordinates.Azimuth = Math.Atan2(dY, dX);
            if (udtSunCoordinates.Azimuth < 0.0)
            {
                udtSunCoordinates.Azimuth = udtSunCoordinates.Azimuth + twopi;
            }
            udtSunCoordinates.Azimuth = udtSunCoordinates.Azimuth / rad;
            // Parallax Correction
            dParallax = (dEarthMeanRadius / dAstronomicalUnit)
                        * Math.Sin(udtSunCoordinates.ZenithAngle);
            udtSunCoordinates.ZenithAngle = (udtSunCoordinates.ZenithAngle + dParallax) / rad;

            return(udtSunCoordinates);
        }