public void RunSingleAcTest() { PrepareUnitTest(); // ReSharper disable AssignNullToNotNullAttribute ServiceRepository services = new ServiceRepository(null, null, Logger, Config, new Random()); // ReSharper restore AssignNullToNotNullAttribute 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 var chp = new CoolingProfileGenerator(temperaturProfileHourly, 27, 24, Logger); Random rnd = new Random(); var hpcp = CoolingCalculationParameters.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.CoolingEnergySupply.AsReadOnly(), EnergyOrPower.Energy); Profile temperatureProfile15Min = new Profile("Temperatures", hpr.AvgTemperatures15Min.ToList().AsReadOnly(), EnergyOrPower.Energy); string file = WorkingDirectory.Combine("coolingrofile_Single.xlsx"); List <Profile> profiles = new List <Profile>(); profiles.Add(temperatureProfile15Min); profiles.Add(houseEnergy); profiles.Add(heatPumpEnergysupply); XlsxDumper.DumpProfilesToExcel(file, 2050, 15, new ProfileWorksheetContent("Sheet1", "Last", profiles)); }
protected override void RunChartMaking(ScenarioSliceParameters slice) { var dbProfileExport = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ProfileGeneration, slice, DatabaseCode.HouseProfiles); var sa = SaveableEntry <Prosumer> .GetSaveableEntry(dbProfileExport, SaveableEntryTableType.HouseLoad, Services.Logger); var dbHouses = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, slice); var houses = dbHouses.Fetch <House>(); var house = houses.Single(x => x.ComplexName == "Kornhausgasse 16"); List <Profile> relevantProsumers = new List <Profile>(); foreach (var prosumer in sa.ReadEntireTableDBAsEnumerable()) { if (prosumer.HouseGuid == house.Guid) { if (prosumer.Profile == null) { throw new FlaException("profile was null"); } relevantProsumers.Add(new Profile(prosumer.Name + " " + prosumer.ProfileSourceName, prosumer.Profile.Values, prosumer.Profile.EnergyOrPower)); } } var fn = MakeAndRegisterFullFilename("ExportedProfiles.xlsx", slice); XlsxDumper.DumpProfilesToExcel(fn, slice.DstYear, 15, new ProfileWorksheetContent("kornhausgasse 16", "Last", relevantProsumers)); }
private void ProcessOneSumTypeWithXls([NotNull] ScenarioSliceParameters slice, [NotNull] string fn, SumType sumType) { var dbArchive = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ProfileGeneration, slice, DatabaseCode.SummedLoadForAnalysis); var saHouses = SaveableEntry <ArchiveEntry> .GetSaveableEntry(dbArchive, SaveableEntryTableType.SummedLoadsForAnalysis, Services.Logger); var entries = saHouses.LoadAllOrMatching(); var providerentries = entries.Where(x => x.Key.SumType == sumType).ToList(); var dbRaw = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice); var bkwJ = dbRaw.Fetch <BkwProfile>(); foreach (var ae in providerentries) { if (sumType == SumType.ByProvider) { ae.Profile.Name = ae.Key.ProviderType + " " + ae.GenerationOrLoad; } else if (sumType == SumType.ByProfileSource) { ae.Profile.Name = ae.Key.ProfileSource ?? throw new InvalidOperationException(); } else { throw new FlaException("Unknown sum type"); } } var profiles = providerentries.Select(x => x.Profile).ToList(); var bkw = new Profile(bkwJ[0].Profile); bkw.Name = "Messung 2017"; profiles.Add(bkw); XlsxDumper.DumpProfilesToExcel(fn, 2017, 15, new ProfileWorksheetContent("Profile", "Leistung [MW]", bkw.Name, profiles)); }
private void MakeXlsForCurrentProfile([NotNull] ScenarioSliceParameters slice) { var dbRaw = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice); var bkwArr = dbRaw.Fetch <BkwProfile>(); var bkwJProf = bkwArr[0]; var bkwProf = new Profile(bkwJProf.Profile); var fnProfPresent = MakeAndRegisterFullFilename("PresentProfile.xlsx", slice); XlsxDumper.DumpProfilesToExcel(fnProfPresent, Constants.PresentSlice.DstYear, 15, new ProfileWorksheetContent("bkw", "Last [kW]", 240, bkwProf) ); SaveToPublicationDirectory(fnProfPresent, slice, "4.5"); }
public void Run() { PrepareUnitTest(); // ReSharper disable AssignNullToNotNullAttribute ServiceRepository sp = new ServiceRepository(null, null, Logger, Config, new Random()); // ReSharper restore AssignNullToNotNullAttribute var slice = Constants.PresentSlice; var dbHouse = sp.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, slice); var airconditioningEntries = dbHouse.Fetch <AirConditioningEntry>(); var hausanschlusses = dbHouse.Fetch <Hausanschluss>(); DBDto dbDto = new DBDto(new List <House>(), hausanschlusses, new List <Car>(), new List <Household>(), new List <RlmProfile>()); CoolingProvider hp = new CoolingProvider(sp, slice, dbDto); Info("total hse: " + airconditioningEntries.Count); Profile sumProfile = Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour); foreach (var entry in airconditioningEntries) { (entry.HouseComponentType == HouseComponentType.Cooling).Should().BeTrue(); hp.IsCorrectProvider(entry).Should().BeTrue(); HouseComponentRo hro = new HouseComponentRo(string.Empty, string.Empty, 1, 1, string.Empty, string.Empty, string.Empty, 0); ProviderParameterDto ppd = new ProviderParameterDto(entry, string.Empty, hro); hp.PrepareLoadProfileIfNeeded(ppd); var prof = hp.ProvideProfile(ppd); if (prof != null) { if (prof.Profile == null) { throw new FlaException("Profile was null"); } prof.Profile.EnergySum().Should().BeApproximately(entry.EffectiveEnergyDemand, entry.EffectiveEnergyDemand * 0.1); sumProfile = sumProfile.Add(prof.Profile.Values); } } string fn = WorkingDirectory.Combine("Profiletest_cooling.xlsx"); XlsxDumper.DumpProfilesToExcel(fn, 2050, 15, new ProfileWorksheetContent("Sum", "Last", 240, sumProfile)); Info("Wrote to " + fn); }
public void RunSingleHpTest() { DhwProfileGenerator chp = new DhwProfileGenerator(); Random rnd = new Random(); var dhwcp = DhwCalculationParameters.MakeDefaults(); const double energyuse = 20000; var hpr = chp.Run(dhwcp, energyuse, rnd); var profile = hpr.GetEnergyDemandProfile(); const string file = "dhwProfile_Single.xlsx"; var colnames = new List <string> { "turnoff" }; XlsxDumper.DumpProfilesToExcel(file, 2017, 15, new ProfileWorksheetContent("sheet1", "Last", 240, profile), new EnumWorksheetContent <DhwTurnOffReason>("turnoffs", colnames, hpr.TurnOffReasons.AsReadOnly())); profile.Values.Sum().Should().BeApproximately(energyuse, 100); }
public void Run() { PrepareUnitTest(); // ReSharper disable AssignNullToNotNullAttribute ServiceRepository sp = new ServiceRepository(null, null, Logger, Config, new Random()); // ReSharper restore AssignNullToNotNullAttribute var utopiaSlice = new ScenarioSliceParameters(Scenario.FromEnum(ScenarioEnum.Utopia), 2050, null); var dbHouse = sp.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, utopiaSlice); var heatingSystemEntries = dbHouse.Fetch <HeatingSystemEntry>(); var hausanschlusses = dbHouse.Fetch <Hausanschluss>(); DBDto dbDto = new DBDto(new List <House>(), hausanschlusses, new List <Car>(), new List <Household>(), new List <RlmProfile>()); HeatingProvider hp = new HeatingProvider(sp, utopiaSlice, dbDto); Info("total hse: " + heatingSystemEntries.Count); Profile sumProfile = Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour); foreach (var entry in heatingSystemEntries) { (entry.HouseComponentType == HouseComponentType.Heating).Should().BeTrue(); hp.IsCorrectProvider(entry).Should().BeTrue(); HouseComponentRo hro = new HouseComponentRo("", "", 1, 1, "", "", "", 0); ProviderParameterDto ppd = new ProviderParameterDto(entry, "", hro); hp.PrepareLoadProfileIfNeeded(ppd); var prof = hp.ProvideProfile(ppd); if (prof != null) { if (prof.Profile == null) { throw new FlaException("Profile was null"); } prof.Profile.EnergySum().Should().BeApproximately(entry.EffectiveEnergyDemand / 3, entry.EffectiveEnergyDemand * 0.1); sumProfile = sumProfile.Add(prof.Profile.Values); } } var fn = Path.Combine(WorkingDirectory.Dir, "Profiletest.xlsx"); XlsxDumper.DumpProfilesToExcel(fn, 2050, 15, new ProfileWorksheetContent("Sum", "Last", 240, sumProfile)); }
protected override void RunActualProcess([NotNull] ScenarioSliceParameters slice) { var fn = MakeAndRegisterFullFilename(FilenameHelpers.CleanFileName("SummedLoadProfileExport.xlsx"), slice); var dbArchive = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ProfileGeneration, slice, DatabaseCode.SummedLoadForAnalysis); var saHouses = SaveableEntry <ArchiveEntry> .GetSaveableEntry(dbArchive, SaveableEntryTableType.SummedLoadsForAnalysis, Services.Logger); var dbRaw = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice); var bkwArr = dbRaw.Fetch <BkwProfile>(); var bkwjSonProfile = bkwArr[0]; var entries = saHouses.LoadAllOrMatching(); var providerentries = entries.Where(x => x.Key.SumType == SumType.ByProvider).ToList(); List <Profile> profiles = new List <Profile>(); foreach (var providerentry in providerentries) { providerentry.Profile.Name = (providerentry.Key.ProviderType ?? throw new FlaException()) + " " + providerentry.Key.GenerationOrLoad; if (providerentry.Key.GenerationOrLoad == GenerationOrLoad.Load) { profiles.Add(providerentry.Profile); } else { profiles.Add(providerentry.Profile.MultiplyWith(-1, providerentry.Profile.Name)); } } profiles = MergeProfiles(profiles); var bkwProfile = new Profile(bkwjSonProfile.Profile); bkwProfile.Name = "Messung 2017 [kW]"; profiles.Add(bkwProfile); XlsxDumper.DumpProfilesToExcel(fn, slice.DstYear, 15, new ProfileWorksheetContent("Profiles", "Last [kW]", bkwProfile.Name, profiles)); SaveToArchiveDirectory(fn, RelativeDirectory.Report, slice); SaveToPublicationDirectory(fn, slice, "4.4"); SaveToPublicationDirectory(fn, slice, "5"); Info("saved " + fn); }
private void MakeExampleWsForSmartgrid([NotNull] ScenarioSliceParameters slice, [NotNull] Profile addedProfile, double storageSize, double cappingFactor) { var minimzed3 = ProfileSmoothing.FindBestPowerReductionRatio(addedProfile, storageSize, out var _, out var reductionFactor3, cappingFactor); RowCollection rc = new RowCollection("TotalReduction", "Total Reduction"); var rb = RowBuilder.Start("Reduction", reductionFactor3); rb.Add("BatterySize [GWh]", storageSize / 1000000); rc.Add(rb); var fnProf = MakeAndRegisterFullFilename("SmartGridTestProfiles_centralstorage_" + slice.DstYear + "_capp_" + cappingFactor + ".xlsx", slice); var manualParameters = ProfileSmoothing.UsePeakShaving(addedProfile, storageSize, true, out var storageProfile, reductionFactor3, out var temporaryTargetProfile, out var sum24HProfile, cappingFactor); var adjustedStorageProfile = storageProfile?.MultiplyWith(1 / 4000000.0, "Speicherfüllstand") ?? throw new FlaException(); rb.Add("Energy", manualParameters.EnergySum()); rb.Add("Min Power", manualParameters.MinPower()); rb.Add("Max Power", manualParameters.MaxPower()); XlsxDumper.DumpProfilesToExcel(fnProf, slice.DstYear, 15, new RowWorksheetContent(rc), new ProfileWorksheetContent("raw", "Last [kW]", 240, addedProfile), new ProfileWorksheetContent("manualParameters", "Netto-Last [MW]", 240, manualParameters), new ProfileWorksheetContent("storageprofile", "Speicherfüllstand [GWh]", 240, adjustedStorageProfile), new ProfileWorksheetContent("minimized", "Netto-Last [MW]", 240, minimzed3), new ProfileWorksheetContent("temptarget", "Ziel-Füllstand Speicher [kWh]", 240, temporaryTargetProfile), new ProfileWorksheetContent("sum24h", "Tages-Energiemenge [GWh]", 240, sum24HProfile) ); SaveToPublicationDirectory(fnProf, slice, "4.5"); }
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); }
protected override void RunActualProcess(ScenarioSliceParameters slice) { var dbProfileExport = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ProfileGeneration, slice, DatabaseCode.HouseProfiles); var saLoad = SaveableEntry <Prosumer> .GetSaveableEntry(dbProfileExport, SaveableEntryTableType.HouseLoad, Services.Logger); var saGeneration = SaveableEntry <Prosumer> .GetSaveableEntry(dbProfileExport, SaveableEntryTableType.HouseGeneration, Services.Logger); var dbArchiving = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ProfileAnalysis, slice, DatabaseCode.Smartgrid); dbArchiving.RecreateTable <SmartGridInformation>(); var saArchiveEntry = SaveableEntry <ArchiveEntry> .GetSaveableEntry(dbArchiving, SaveableEntryTableType.Smartgrid, Services.Logger); int count = 0; var smartSlice = slice.CopyThisSlice(); smartSlice.SmartGridEnabled = true; RowCollection prosumerCollection = new RowCollection("Prosumers", "Prosumers"); Stopwatch sw = Stopwatch.StartNew(); const string tkfield = "Trafokreis"; Stopwatch swIdx = Stopwatch.StartNew(); saLoad.CreateIndexIfNotExists(tkfield); saGeneration.CreateIndexIfNotExists(tkfield); Info("Creating the index took " + swIdx.Elapsed); var trafos = saLoad.SelectSingleDistinctField <string>(tkfield); Info("Reading trafokreise took " + sw.Elapsed); Dictionary <string, Profile> trafokreiseLoad = new Dictionary <string, Profile>(); Dictionary <string, Profile> trafokreiseGeneration = new Dictionary <string, Profile>(); ChangableProfile cityload = ChangableProfile.FromProfile(Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour)); ChangableProfile cityGeneration = ChangableProfile.FromProfile(Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour)); ChangableProfile smartCityLoad = ChangableProfile.FromProfile(Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour)); ChangableProfile smartCityGeneration = ChangableProfile.FromProfile(Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour)); RowCollection smartGridPointValues = new RowCollection("SmartGridHASummaries", "SmartGridHASummaries"); SmartGridInformation smartGridInformation = new SmartGridInformation(); foreach (var trafo in trafos) { //if (count > 500) { //continue; //} Dictionary <string, List <Prosumer> > prosumersByHa = new Dictionary <string, List <Prosumer> >(); ChangableProfile trafoLoadSum = ChangableProfile.FromProfile(Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour)); foreach (var prosumer in saLoad.ReadSubsetOfTableDBAsEnumerable(tkfield, trafo)) { RowBuilder rb = RowBuilder.Start("Name", prosumer.Name); rb.Add("Energy", prosumer.Profile?.EnergySum()); rb.Add("HA", prosumer.HausanschlussKey); rb.Add("Trafokreis", prosumer.TrafoKreis); prosumerCollection.Add(rb); count++; if (count % 50 == 0) { Info("Processing Prosumers Load: " + count + " " + sw.Elapsed); } if (!string.IsNullOrWhiteSpace(prosumer.HausanschlussKey)) { if (!prosumersByHa.ContainsKey(prosumer.HausanschlussKey)) { prosumersByHa.Add(prosumer.HausanschlussKey, new List <Prosumer>()); } prosumersByHa[prosumer.HausanschlussKey].Add(prosumer); } trafoLoadSum.Add(prosumer.Profile ?? throw new FlaException("empty profile")); } AnalysisKey keyload = new AnalysisKey(trafo, null, SumType.ByTrafokreis, GenerationOrLoad.Load, null, null, null); ArchiveEntry aeload = new ArchiveEntry("Trafokreis " + trafo, keyload, trafoLoadSum.ToProfile(), GenerationOrLoad.Load, trafo); saArchiveEntry.AddRow(aeload); trafokreiseLoad.Add(trafo, trafoLoadSum.ToProfile()); var trafoGenerationSum = Profile.MakeConstantProfile(0, "Sum", Profile.ProfileResolution.QuarterHour); foreach (var prosumer in saGeneration.ReadSubsetOfTableDBAsEnumerable(tkfield, trafo)) { RowBuilder rb = RowBuilder.Start("Name", prosumer.Name); rb.Add("Energy", prosumer.Profile?.EnergySum()); rb.Add("HA", prosumer.HausanschlussKey); rb.Add("Trafokreis", prosumer.TrafoKreis); prosumerCollection.Add(rb); if (count % 50 == 0) { Info("Processing Prosumers Generation: " + count + " " + sw.Elapsed); } if (!string.IsNullOrWhiteSpace(prosumer.HausanschlussKey)) { if (!prosumersByHa.ContainsKey(prosumer.HausanschlussKey)) { prosumersByHa.Add(prosumer.HausanschlussKey, new List <Prosumer>()); } prosumersByHa[prosumer.HausanschlussKey].Add(prosumer); } //var powerLimited = prosumer.Profile?.LimitToPercentageOfMax(0.5)?? throw new FlaException("blub"); //if(powerLimited.Values.Count ==0) { throw new FlaException("huch?");} trafoGenerationSum = trafoGenerationSum.Add(prosumer.Profile ?? throw new FlaException(), "Sum"); } AnalysisKey key = new AnalysisKey(trafo, null, SumType.ByTrafokreis, GenerationOrLoad.Generation, null, null, null); ArchiveEntry ae = new ArchiveEntry("Trafokreis " + trafo, key, trafoGenerationSum, GenerationOrLoad.Generation, trafo); saArchiveEntry.AddRow(ae); trafokreiseGeneration.Add(trafo, trafoGenerationSum); cityload.Add(trafoLoadSum); cityGeneration.Add(trafoGenerationSum); //if (count > 16000) { ApplySmartGridstuff(prosumersByHa, trafo, smartCityLoad, smartCityGeneration, smartGridPointValues, smartGridInformation, smartSlice); //} } var addedSmart = smartCityLoad.ToProfile().Add(smartCityGeneration.ToProfile(), "Netto-Last (smart)"); var addedSerializeFn = MakeAndRegisterFullFilename("addedProfile.lz4", slice); dbArchiving.BeginTransaction(); dbArchiving.Save(smartGridInformation); dbArchiving.CompleteTransaction(); SaveCityProfile(cityload, saArchiveEntry, SummedLoadType.CityLoad, GenerationOrLoad.Load); SaveCityProfile(cityGeneration, saArchiveEntry, SummedLoadType.CityGeneration, GenerationOrLoad.Generation); SaveCityProfile(smartCityGeneration, saArchiveEntry, SummedLoadType.SmartCityGeneration, GenerationOrLoad.Generation); SaveCityProfile(smartCityLoad, saArchiveEntry, SummedLoadType.SmartCityLoad, GenerationOrLoad.Load); saArchiveEntry.MakeCleanTableForListOfFields(false); saArchiveEntry.SaveDictionaryToDatabase(MyLogger); FileStream fs = new FileStream(addedSerializeFn, FileMode.Create); var added = cityload.ToProfile().Subtract(cityGeneration.ToProfile(), "Netto-Last (konventionell)"); var lz4Arr = LZ4MessagePackSerializer.Serialize(added); fs.Write(lz4Arr, 0, lz4Arr.Length); fs.Close(); MakePlotlyTrafostationBoxPlots("Boxplot_Load_OhneMV.html", trafokreiseLoad, slice, true); MakePlotlyTrafostationBoxPlots("Boxplot_Gen_OhneMV.html", trafokreiseGeneration, slice, true); var fn = MakeAndRegisterFullFilename("ProsumerDump.xlsx", slice); XlsxDumper.DumpProfilesToExcel(fn, slice.DstYear, 15, new RowWorksheetContent(prosumerCollection), new RowWorksheetContent(smartGridPointValues)); var fnProf = MakeAndRegisterFullFilename("SmartGridProfiles_distributedStorage.xlsx", slice); RowCollection rc = new RowCollection("StatusInfo", "Status"); double avgReductionFactor = smartGridInformation.SummedReductionFactor / smartGridInformation.NumberOfReductionFactors; rc.Add(RowBuilder.Start("Total storage size", smartGridInformation.TotalStorageSize) .Add("Number of Prosumers", smartGridInformation.NumberOfProsumers) .Add("Citywide Reduction", avgReductionFactor) .Add("MinimumLoadBefore", added.MinPower()) .Add("MinLoadSmart", addedSmart.MinPower()) .Add("MaxLoadBefore", added.MaxPower()) .Add("MaxLoadSmart", addedSmart.MaxPower()) ); XlsxDumper.DumpProfilesToExcel(fnProf, slice.DstYear, 15, new RowWorksheetContent(rc), new ProfileWorksheetContent("load", "Last [MW]", 240, cityload.ToProfile()), new ProfileWorksheetContent("generation", "Erzeugung [MW]", 240, cityGeneration.ToProfile()), new ProfileWorksheetContent("added", "Netto-Last [kW]", 240, added), new ProfileWorksheetContent("smartload", "Last (smart) [MW]", 240, smartCityLoad.ToProfile()), new ProfileWorksheetContent("smartgeneration", "Erzeugung (smart) [MW]", 240, smartCityGeneration.ToProfile()), new ProfileWorksheetContent("smartadded", "Netto-Last [kW]", 240, added, addedSmart)); SaveToArchiveDirectory(fnProf, RelativeDirectory.Report, smartSlice); SaveToPublicationDirectory(fnProf, slice, "4.5"); SaveToPublicationDirectory(fnProf, slice, "5"); }