Esempio n. 1
0
        public void MakeDegreeDaysTestMinus3Days()
        {
            using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
            {
                var temperaturProfiles = db.LoadTemperatureProfiles();

                var startTime = new DateTime(2011, 12, 29);
                var endTime   = new DateTime(2012, 1, 3);
                var ldd       = MakeDegreeDaysClass.MakeDegreeDays(temperaturProfiles[0], startTime, endTime, 15, 20,
                                                                   10000, false, 0);
                double sumHeating     = 0;
                double sumPercentages = 0;
                var    temperatures   = temperaturProfiles[0].GetTemperatureArray(startTime, endTime,
                                                                                  new TimeSpan(1, 0, 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.HeatingAmount;
                    sumPercentages += day.Percentage;
                }
                Math.Abs(225 - sumHeating).Should().BeLessThan(200);
                const double val = 225.0 / 10000;
                Math.Abs(val - sumPercentages).Should().BeLessThan(0.1);
                db.Cleanup();
            }
        }
Esempio n. 2
0
        public void MakeDegreeDaysTestWithPrecalcPeriod()
        {
            using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
            {
                var temperaturProfiles = db.LoadTemperatureProfiles();

                var startTime = new DateTime(2011, 12, 27);
                var endTime   = new DateTime(2012, 12, 31);
                var ldd       = MakeDegreeDaysClass.MakeDegreeDays(temperaturProfiles[0], startTime, endTime, 15, 20,
                                                                   10000, false, 0);
                double sumHeating     = 0;
                double sumPercentages = 0;
                var    temperatures   = temperaturProfiles[0].GetTemperatureArray(startTime, endTime,
                                                                                  new TimeSpan(1, 0, 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)
                {
                    if (day.Date.Year != 2012)
                    {
                        continue; //only count values from 2012
                    }
                    sumHeating     += day.HeatingAmount;
                    sumPercentages += day.Percentage;
                }
                Math.Abs(10000 - sumHeating).Should().BeLessThan(0.001);
                Math.Abs(1 - sumPercentages).Should().BeLessThan(0.001);
                db.Cleanup();
            }
        }
        public static CalcSpaceHeatingDto CreateSpaceHeatingObject([NotNull] House house,
                                                                   [NotNull] TemperatureProfile temperatureProfile,
                                                                   [NotNull] HouseholdKey householdKey,
                                                                   [CanBeNull]
                                                                   out CalcLocationDto heatingLocation, DateTime
                                                                   startTime, DateTime endTime,
                                                                   CalcLoadTypeDtoDictionary ltDict) //, List<CalcDeviceTaggingSet> deviceTaggingSets)
        {
            if (house.HouseType == null)
            {
                throw new LPGException("Housetype was null");
            }

            if (house.HouseType.HeatingLoadType != null && Math.Abs(house.HouseType.HeatingYearlyTotal) > 0.0001 &&
                !double.IsNaN(house.HouseType.HeatingYearlyTotal))
            {
                var degreeDays = MakeDegreeDaysClass.MakeDegreeDays(temperatureProfile,
                                                                    startTime, endTime,
                                                                    house.HouseType.HeatingTemperature,
                                                                    house.HouseType.RoomTemperature,
                                                                    house.HouseType.HeatingYearlyTotal,
                                                                    house.HouseType.AdjustYearlyEnergy,
                                                                    house.HouseType.ReferenceDegreeDays);
                foreach (var degreeHour in degreeDays)
                {
                    if (double.IsNaN(degreeHour.HeatingAmount))
                    {
                        throw new LPGException("Heating Amount was NaN");
                    }
                }

                var heatingParameter = new HeatingParameter(degreeDays, house.HouseType.HeatingLoadType, house.HouseType.HeatingYearlyTotal);
                var spaceheating     = MakeSpaceHeatingDto(heatingParameter, ltDict, householdKey, out heatingLocation);
                return(spaceheating); //,deviceTaggingSets
            }

            heatingLocation = null;
            return(null);
        }