public HeatingProvider([NotNull] ServiceRepository services, [NotNull] ScenarioSliceParameters slice, [NotNull] DBDto dbDto) : base( nameof(HeatingProvider), services, slice) { _dbDto = dbDto; var dbRaw = services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice); var temperatures = dbRaw.Fetch <TemperatureProfileImport>(); var temp = temperatures.Single(x => x.Jahr == slice.DstYear); Profile temperaturProfileHourly = new Profile(temp.Profile ?? throw new FlaException("Missing profile")); _hpg = new HeatpumpProfileGenerator(temperaturProfileHourly, 15, 20, MyLogger); }
public void RunSingleHpTest() { ServiceRepository services = new ServiceRepository(null, null, Logger, Config, new Random()); var dbRaw = services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice); var temperatures = dbRaw.Fetch <TemperatureProfileImport>(); Profile temperaturProfileHourly = new Profile(temperatures[0].Profile ?? throw new FlaException("was null")); //make heatpumpprofile HeatpumpProfileGenerator chp = new HeatpumpProfileGenerator(temperaturProfileHourly, 15, 20, Logger); Random rnd = new Random(); var hpcp = HeatpumpCalculationParameters.MakeDefaults(); const double energyuse = 20000; var hpr = chp.Run(hpcp, energyuse, rnd); hpr.GetEnergyDemandProfile().Values.Sum().Should().BeApproximately(energyuse * 0.333, 100); Profile houseEnergy = new Profile("House Energy", hpr.HouseEnergyTracker.AsReadOnly(), EnergyOrPower.Energy); Profile heatPumpEnergysupply = new Profile("Heat pump Energy supply", hpr.HeatpumpEnergySupply.AsReadOnly(), EnergyOrPower.Energy); Profile temperatureProfile15Min = new Profile("Temperatures", hpr.DailyAvgTemperatures15Min.ToList().AsReadOnly(), EnergyOrPower.Energy); const string file = "heatpumprofile_Single.xlsx"; WriteProfilesToExcel(temperatureProfile15Min, houseEnergy, heatPumpEnergysupply, file); }
public void RunMultiHpTest() { PrepareUnitTest(); // ReSharper disable twice AssignNullToNotNullAttribute ServiceRepository services = new ServiceRepository(null, null, Logger, Config, new Random()); var dbRaw = services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice); var dbHouse = services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, new ScenarioSliceParameters(Scenario.FromEnum(ScenarioEnum.Utopia), 2050, null)); var temperatures = dbRaw.Fetch <TemperatureProfileImport>(); var heatPumpEntries = dbHouse.Fetch <HeatingSystemEntry>(); Profile temperaturProfileHourly = new Profile(temperatures[0].Profile ?? throw new FlaException("was null")); Random rnd = new Random(); //make heatpumpprofile Profile houseEnergy = Profile.MakeConstantProfile(0, "House Energy", Profile.ProfileResolution.QuarterHour); Profile heatPumpEnergysupply = Profile.MakeConstantProfile(0, "Heat pump Energy supply", Profile.ProfileResolution.QuarterHour); Profile heatPumpEnergyDemand = Profile.MakeConstantProfile(0, "Heat pump Energy Demand", Profile.ProfileResolution.QuarterHour); Profile temperatureProfile15Min = null; List <Profile> allHouseDemandProfiles = new List <Profile>(); foreach (var entry in heatPumpEntries) { HeatpumpProfileGenerator chp = new HeatpumpProfileGenerator(temperaturProfileHourly, 15, 20, Logger); var hpcp = HeatpumpCalculationParameters.MakeDefaults(); hpcp.StartingTimeStepEvenings = (21 * 4) + rnd.Next(12); hpcp.StoppingTimeStepMorning = (4 * 4) + rnd.Next(12); hpcp.HouseMinimumEnergyTriggerinPercent = 0.70 - rnd.NextDouble() * 0.2; hpcp.TargetMaximumRuntimePerDay = 16 + rnd.NextDouble() * 4; hpcp.TimingMode = HeatPumpTimingMode.OverTheEntireDay; hpcp.StartLevelPercent = 1 - rnd.NextDouble() * .5; HeatPumpResult hpr = chp.Run(hpcp, entry.EffectiveEnergyDemand, rnd); var result = hpr.GetEnergyDemandProfile(); result.Name += entry.Standort; allHouseDemandProfiles.Add(result); result.Values.Sum().Should().BeApproximately(entry.EffectiveEnergyDemand * .333, entry.EffectiveEnergyDemand * 0.1); heatPumpEnergyDemand = heatPumpEnergyDemand.Add(result, heatPumpEnergyDemand.Name); houseEnergy = houseEnergy.Add(hpr.HouseEnergyTracker.AsReadOnly()); heatPumpEnergysupply = heatPumpEnergysupply.Add(hpr.HeatpumpEnergySupply.AsReadOnly()); if (temperatureProfile15Min == null) { temperatureProfile15Min = new Profile("Temperatures", hpr.DailyAvgTemperatures15Min.ToList().AsReadOnly(), EnergyOrPower.Energy); } } allHouseDemandProfiles.Sort((x, y) => y.EnergySum().CompareTo(x.EnergySum())); var profilesToShow = allHouseDemandProfiles.Take(5).ToList(); var profilesToMerge = allHouseDemandProfiles.Skip(6).ToList(); var mergedProfiles = allHouseDemandProfiles[5].Add(profilesToMerge, "MergedProfiles"); if (temperatureProfile15Min == null) { throw new FlaException("no temperatures"); } ProfileWorksheetContent biggestConsumers = new ProfileWorksheetContent("Biggest Consumers", "Last", profilesToShow); biggestConsumers.Profiles.Add(mergedProfiles); string fullFileName = WorkingDirectory.Combine("heatpump_profiles_multi-WithChart.xlsx"); XlsxDumper.DumpProfilesToExcel(fullFileName, 2017, 15, new ProfileWorksheetContent("Energy Demand", "Last", 240, heatPumpEnergyDemand), new ProfileWorksheetContent("Energy Supply", "Energieversorgung", 240, heatPumpEnergysupply), new ProfileWorksheetContent("Temperatures", "Temperatur", 240, temperatureProfile15Min), new ProfileWorksheetContent("House Energy", "Haus Energiegehalt", 240, houseEnergy), biggestConsumers); //WriteProfilesToExcel(temperatureProfile15Min, houseEnergy, heatPumpEnergysupply,file); }