protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices, [NotNull] AnalysisRepository analysisRepo)
        {
            Info("starting to make house results");
            MultiyearTrend myt = new MultiyearTrend();

            foreach (var slice in allSlices)
            {
                var airCons = analysisRepo.GetSlice(slice).Fetch <AirConditioningEntry>();
                myt[slice].AddValue("Klimaanlagen", airCons.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Klimaanlagen Stromverbrauch", airCons.Sum(x => x.EffectiveEnergyDemand), DisplayUnit.GWh);
                var    houses     = analysisRepo.GetSlice(slice).Fetch <House>();
                double percentage = (double)airCons.Count / houses.Count;
                myt[slice].AddValue("Anteil Häuser mit Klimaanlage", percentage, DisplayUnit.Stk);
                var    houseGuidsWithAircon = airCons.ToReferenceGuidHashset(x => x.HouseGuid);
                var    housesWithAirCon     = houses.Where(x => houseGuidsWithAircon.Contains(x.HouseGuid));
                double totalebf             = houses.Sum(x => x.EnergieBezugsFläche);
                double airConEbf            = housesWithAirCon.Sum(x => x.EnergieBezugsFläche);
                myt[slice].AddValue("Anteil EBF mit Klimaanlage", airConEbf / totalebf, DisplayUnit.Stk);
            }
            var filename3 = MakeAndRegisterFullFilename("AirConditioning.xlsx", Constants.PresentSlice);

            Info("Writing results to " + filename3);

            XlsxDumper.DumpMultiyearTrendToExcel(filename3, myt);
            SaveToArchiveDirectory(filename3, RelativeDirectory.Report, Constants.PresentSlice);
        }
        protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices,
                                                 [NotNull] AnalysisRepository analysisRepo)
        {
            Info("starting to make Car results");
            MultiyearTrend myt = new MultiyearTrend();

            foreach (var slice in allSlices)
            {
                var cars = analysisRepo.GetSlice(slice).Fetch <Car>();
                var carDistanceEntries = analysisRepo.GetSlice(slice).Fetch <CarDistanceEntry>();
                if (carDistanceEntries.Count != cars.Count)
                {
                    throw new FlaException("Cars and car distance entries count don't match");
                }

                myt[slice].AddValue("Cars", cars.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Cars Electric", cars.Count(x => x.CarType == CarType.Electric), DisplayUnit.Stk);
                myt[slice].AddValue("Cars Gasoline", cars.Count(x => x.CarType == CarType.Gasoline), DisplayUnit.Stk);
                myt[slice].AddValue("Avg Kilometers Per Car", carDistanceEntries.Average(x => x.DistanceEstimate), DisplayUnit.Stk);
                myt[slice].AddValue("Avg Energy Estimate Per car", carDistanceEntries.Average(x => x.EnergyEstimate), DisplayUnit.Stk);
                var electricCars = cars.Where(x => x.CarType == CarType.Electric).Select(x => x.Guid).ToHashSet();
                var electricCarDistanceEntries = carDistanceEntries.Where(x => electricCars.Contains(x.CarGuid)).ToList();
                myt[slice].AddValue("Summed Electric Energy Estimate Per car",
                                    electricCarDistanceEntries.Sum(x => x.EnergyEstimate),
                                    DisplayUnit.GWh);
                myt[slice].AddValue("Car Distance Entries", carDistanceEntries.Count, DisplayUnit.Stk);
            }

            var filename3 = MakeAndRegisterFullFilename("TotalCarDevelopment.xlsx", Constants.PresentSlice);

            Info("Writing results to " + filename3);
            XlsxDumper.DumpMultiyearTrendToExcel(filename3, myt);
            SaveToArchiveDirectory(filename3, RelativeDirectory.Report, Constants.PresentSlice);
        }
        protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices, [NotNull] AnalysisRepository analysisRepo)
        {
            Info("starting to make trafostation results");
            MultiyearTrend myt = new MultiyearTrend();

            foreach (var slice in allSlices)
            {
                Info("Processing slice " + slice);
                var dbArchiving    = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ProfileAnalysis, slice, DatabaseCode.Smartgrid);
                var saArchiveEntry = SaveableEntry <ArchiveEntry> .GetSaveableEntry(dbArchiving, SaveableEntryTableType.Smartgrid, Services.Logger);

                var sgis = dbArchiving.Fetch <SmartGridInformation>();
                if (sgis.Count != 1)
                {
                    throw new FlaException("invalid count");
                }
                var sgi = sgis[0];
                myt[slice].AddValue("Gesamtspeichergrösse [GWh]", sgi.TotalStorageSize, DisplayUnit.GWh);
                double avgreduction = sgi.SummedReductionFactor / sgi.NumberOfReductionFactors;
                myt[slice].AddValue("Average Reduction Factor", avgreduction, DisplayUnit.Stk);
                myt[slice].AddValue("Number of Prosumers", sgi.NumberOfProsumers, DisplayUnit.Stk);
                var aes = saArchiveEntry.LoadAllOrMatching();
                {
                    var cityload = aes.Single(x => x.Name == SummedLoadType.CityLoad.ToString());
                    myt[slice].AddValue("Energiebedarf Gesamt [GWh]", cityload.Profile.EnergySum(), DisplayUnit.GWh);
                    var cityGen1    = aes.Single(x => x.Name == SummedLoadType.CityGeneration.ToString());
                    var cityGenProf = cityGen1.Profile.MultiplyWith(-1, "Energieerzeugung");
                    if (cityGenProf.EnergySum() > 0)
                    {
                        throw new FlaException("Positive energy sum while generationg");
                    }
                    myt[slice].AddValue("Energieerzeugung Gesamt [GWh]", cityGenProf.EnergySum(), DisplayUnit.GWh);
                    var citySum = cityload.Profile.Add(cityGenProf, "sum");

                    myt[slice].AddValue("Netto-Energiebedarf [GWh]", citySum.EnergySum(), DisplayUnit.GWh);
                    myt[slice].AddValue("Maximale Last am Umspannwerk [MW]", citySum.MaxPower(), DisplayUnit.Mw);
                    myt[slice].AddValue("Minimale Last am Umspannwerk [MW]", citySum.MinPower(), DisplayUnit.Mw);
                }

                var smartcityload = aes.Single(x => x.Name == SummedLoadType.SmartCityLoad.ToString());
                myt[slice].AddValue("Energiebedarf Gesamt (smart) [GWh]", smartcityload.Profile.EnergySum(), DisplayUnit.GWh);
                var smartcityGen = aes.Single(x => x.Name == SummedLoadType.SmartCityGeneration.ToString());
                myt[slice].AddValue("Energieerzeugung Gesamt (smart) [GWh[", smartcityGen.Profile.EnergySum(), DisplayUnit.GWh);
                var smartcitySum = smartcityload.Profile.Add(smartcityGen.Profile, "sum");

                myt[slice].AddValue("Netto-Energiebedarf (smart) [GWh]", smartcitySum.EnergySum(), DisplayUnit.GWh);
                myt[slice].AddValue("Maximale Last am Umspannwerk (smart) [MW]", smartcitySum.MaxPower(), DisplayUnit.Mw);
                myt[slice].AddValue("Minimale Last am Umspannwerk (smart) [MW]", smartcitySum.MinPower(), DisplayUnit.Mw);
            }
            var filename3 = MakeAndRegisterFullFilename("SmartGridOverview.xlsx", Constants.PresentSlice);

            Info("Writing results to " + filename3);
            XlsxDumper.DumpMultiyearTrendToExcel(filename3, myt);
            SaveToPublicationDirectory(filename3, Constants.PresentSlice, "4.5");
        }
        protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices, [NotNull] AnalysisRepository analysisRepo)
        {
            Info("starting to make trafostation results");
            MultiyearTrend myt = new MultiyearTrend();

            foreach (var slice in allSlices)
            {
                HouseComponentRepository hcr = new HouseComponentRepository(analysisRepo, slice);
                var houses = analysisRepo.GetSlice(slice).Fetch <House>();
                Dictionary <string, double> energyUsePerTrafostation = new Dictionary <string, double>();
                var hausanschlusses = analysisRepo.GetSlice(slice).Fetch <Hausanschluss>();
                foreach (var house in houses)
                {
                    var components = house.CollectHouseComponents(hcr);
                    foreach (var component in components)
                    {
                        if (component.HausAnschlussGuid == null)
                        {
                            continue;
                        }
                        var hausanschluss = hausanschlusses.GetByGuid(component.HausAnschlussGuid);
                        var trafo         = hausanschluss.Trafokreis;
                        if (!energyUsePerTrafostation.ContainsKey(trafo))
                        {
                            energyUsePerTrafostation.Add(trafo, 0);
                        }

                        energyUsePerTrafostation[trafo] += component.EffectiveEnergyDemand;
                    }
                }

                double totalEnergy = 0;
                foreach (var energy in energyUsePerTrafostation)
                {
                    myt[slice].AddValue(energy.Key, energy.Value, DisplayUnit.GWh);
                    totalEnergy += energy.Value;
                }
                myt[slice].AddValue("Total", totalEnergy, DisplayUnit.GWh);
            }
            var filename3 = MakeAndRegisterFullFilename("TrafostationEnergyResults.xlsx", Constants.PresentSlice);

            Info("Writing results to " + filename3);
            XlsxDumper.DumpMultiyearTrendToExcel(filename3, myt);
            SaveToArchiveDirectory(filename3, RelativeDirectory.Report, Constants.PresentSlice);
        }
Beispiel #5
0
        private void MakePopulationResults([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices, [NotNull] AnalysisRepository analysisRepo)
        {
            MultiyearTrend myt = new MultiyearTrend();

            foreach (var slice in allSlices)
            {
                var houses     = analysisRepo.GetSlice(slice).Fetch <House>();
                var households = analysisRepo.GetSlice(slice).Fetch <Household>();
                var occupants  = households.SelectMany(x => x.Occupants).ToList();
                myt[slice].AddValue("Anzahl Häuser", houses.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Anzahl Haushalte", households.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Bewohner", occupants.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Durchschnittsalter", occupants.Average(x => x.Age), DisplayUnit.Stk);
                var male = occupants.Count(x => x.Gender == Gender.Male);
                myt[slice].AddValue("Geschlecht", male / (double)occupants.Count, DisplayUnit.Percentage);
                var appartments = houses.Sum(x => x.OfficialNumberOfHouseholds);
                myt[slice].AddValue("Gesamtanzahl Wohnungen Ebbe", appartments, DisplayUnit.Stk);

                var leereWohnungenperHouse = houses.Sum(x =>
                                                        Math.Max(x.OfficialNumberOfHouseholds -
                                                                 households.GetByReferenceGuidWithEmptyReturns(x.HouseGuid, "HouseGuid", y => y.HouseGuid).Count,
                                                                 0));
                myt[slice].AddValue("Leerstand Ebbe", leereWohnungenperHouse, DisplayUnit.Stk);
                myt[slice].AddValue("Leerstand Stadtweit", appartments - households.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Durchschnitt. Haushaltsgrösse", households.Average(x => x.Occupants.Count), DisplayUnit.Stk);
                myt[slice].AddValue("Energiebezugsfläche", houses.Sum(x => x.EnergieBezugsFläche), DisplayUnit.Stk);
                myt[slice].AddValue("Durch. Energiebezugsfläche", houses.Average(x => x.EnergieBezugsFläche), DisplayUnit.Stk);
            }

            var filename3 = MakeAndRegisterFullFilename("PopulationResults.xlsx", Constants.PresentSlice);

            Info("Writing results to " + filename3);
            XlsxDumper.DumpMultiyearTrendToExcel(filename3, myt);
            SaveToArchiveDirectory(filename3, RelativeDirectory.Report, Constants.PresentSlice);
            SaveToPublicationDirectory(filename3, Constants.PresentSlice, "4.4");
        }
        protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices,
                                                 [NotNull] AnalysisRepository analysisRepo)
        {
            Info("starting to make house results");
            MultiyearTrend myt = new MultiyearTrend();

            foreach (var slice in allSlices)
            {
                var households = analysisRepo.GetSlice(slice).Fetch <Household>();
                var occupants  = households.SelectMany(x => x.Occupants).ToList();

                HouseComponentRepository hcr = new HouseComponentRepository(analysisRepo, slice);
                var houses = analysisRepo.GetSlice(slice).Fetch <House>();
                houses[0].CollectHouseComponents(hcr);

                myt[slice].AddValue("Businesses", hcr.Businesses.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Haushalt Energieverbrauch [GWh]", hcr.Households.Sum(x => x.EffectiveEnergyDemand), DisplayUnit.GWh);
                myt[slice].AddValue("Business Energieverbrauch [GWh]", hcr.Businesses.Sum(x => x.EffectiveEnergyDemand), DisplayUnit.GWh);
                myt[slice].AddValue("Gebäudeinfrastruktur Energieverbrauch  [GWh]",
                                    hcr.BuildingInfrastructures.Sum(x => x.EffectiveEnergyDemand),
                                    DisplayUnit.GWh);
                myt[slice].AddValue("Wärmepumpen Energieverbrauch [GWh]",
                                    hcr.HeatingSystemEntries.Where(x => x.SynthesizedHeatingSystemType == HeatingSystemType.Heatpump)
                                    .Sum(x => x.EffectiveEnergyDemand),
                                    DisplayUnit.GWh);
                myt[slice].AddValue("Klimatisierung Energieverbrauch [GWh]",
                                    hcr.AirConditioningEntries.Sum(x => x.EffectiveEnergyDemand),
                                    DisplayUnit.GWh);
                var dhws = analysisRepo.GetSlice(slice).Fetch <DHWHeaterEntry>();
                myt[slice].AddValue("Energiebedarf Warmwasserboiler [GWh]", dhws.Sum(x => x.EffectiveEnergyDemand), DisplayUnit.GWh);

                myt[slice].AddValue("PV Energie [Gwh]", hcr.PVSystems.Sum(x => x.EffectiveEnergyDemand), DisplayUnit.GWh);
                double distance = hcr.CarDistanceEntries.Sum(x => x.CommutingDistance + x.FreizeitDistance) / occupants.Count;
                myt[slice].AddValue("Wegedistanz / Person / Jahr", distance, DisplayUnit.Stk);
                myt[slice].AddValue("Car Distance Entries", hcr.CarDistanceEntries.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Anzahl Gebäudeinfrastruktur", hcr.BuildingInfrastructures.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Wasserkraftwerke", hcr.Wasserkraft.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Wasserkraftwerke Energie", hcr.Wasserkraft.Sum(x => x.EffectiveEnergyDemand), DisplayUnit.Stk);
                myt[slice].AddValue("Heizsysteme Anzahl", hcr.HeatingSystemEntries.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Heizsysteme Gesamtenergiebedarf [GWh]",
                                    hcr.HeatingSystemEntries.Sum(x => x.EffectiveEnergyDemand),
                                    DisplayUnit.GWh);
                myt[slice].AddValue("Heizsysteme Wärmepumpen Anzahl",
                                    hcr.HeatingSystemEntries.Count(x => x.SynthesizedHeatingSystemType == HeatingSystemType.Heatpump),
                                    DisplayUnit.Stk);
                myt[slice].AddValue("Klimatisierung Anzahl", hcr.AirConditioningEntries.Count, DisplayUnit.Stk);
                var cars = analysisRepo.GetSlice(slice).Fetch <Car>();
                myt[slice].AddValue("Autos gesamt", cars.Count, DisplayUnit.Stk);
                myt[slice].AddValue("Elektroautos", cars.Count(x => x.CarType == CarType.Electric), DisplayUnit.Stk);
                myt[slice].AddValue("DHW Elektrisch", dhws.Count(x => x.DhwHeatingSystemType == DhwHeatingSystem.Electricity), DisplayUnit.Stk);
                myt[slice].AddValue("DHW Heatpump", dhws.Count(x => x.DhwHeatingSystemType == DhwHeatingSystem.Heatpump), DisplayUnit.Stk);
            }

            var filename3 = MakeAndRegisterFullFilename("HouseEnergyResults.xlsx", Constants.PresentSlice);

            Info("Writing results to " + filename3);

            XlsxDumper.DumpMultiyearTrendToExcel(filename3, myt);
            SaveToArchiveDirectory(filename3, RelativeDirectory.Report, Constants.PresentSlice);
            SaveToPublicationDirectory(filename3, Constants.PresentSlice, "4.4");
        }