Beispiel #1
0
 public void MakeDegreeDaysTest3Years()
 {
     using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
     {
         var temperaturProfiles = db.LoadTemperatureProfiles();
         var startTime          = new DateTime(2012, 1, 1);
         var endTime            = new DateTime(2014, 12, 31);
         var ldd = DbCalcDegreeHour.GetCalcDegreeHours(temperaturProfiles[0], startTime, endTime, 19,
                                                       10000, false, 0);
         double sumHeating     = 0;
         double sumPercentages = 0;
         var    temperatures   = temperaturProfiles[0].GetTemperatureArray(startTime, endTime, new TimeSpan(1, 0, 0));
         for (var i = 0; i < temperatures.Length; i++)
         {
             Math.Abs(ldd[i].AverageTemperature - temperatures[i]).Should().BeLessThan(0.001);
         }
         foreach (var day in ldd)
         {
             sumHeating     += day.CoolingAmount;
             sumPercentages += day.Percentage;
         }
         Math.Abs(30000 - sumHeating).Should().BeLessThan(0.001);
         Math.Abs(3 - sumPercentages).Should().BeLessThan(0.001);
         db.Cleanup();
     }
 }
        private CoolingParameter MakeCoolingParameters([NotNull] TemperatureProfile temperatureProfile, [NotNull] HouseType houseType)
        {
            if (houseType == null)
            {
                throw new LPGException("Housetype was null");
            }

            if (houseType.CoolingLoadType != null && Math.Abs(houseType.CoolingYearlyTotal) > 0.000001 &&
                !double.IsNaN(houseType.CoolingYearlyTotal))
            {
                var conversionFactor = _ltDict.GetLoadtypeDtoByLoadType(houseType.CoolingLoadType).ConversionFactor;
                var degreeHours      = DbCalcDegreeHour.GetCalcDegreeHours(temperatureProfile,
                                                                           _calcParameters.InternalStartTime,
                                                                           _calcParameters.InternalEndTime,
                                                                           houseType.CoolingTemperature,
                                                                           houseType.CoolingYearlyTotal / conversionFactor,
                                                                           houseType.AdjustYearlyCooling,
                                                                           houseType.ReferenceCoolingHours);
                var isNan = false;
                foreach (var degreeHour in degreeHours)
                {
                    if (double.IsNaN(degreeHour.CoolingAmount))
                    {
                        isNan = true;
                    }
                }

                if (!isNan)
                {
                    return(new CoolingParameter(degreeHours, houseType.CoolingLoadType, houseType.CoolingYearlyTotal));
                }
            }

            return(null);
        }