Esempio n. 1
0
        public IList <DTOs.OutputGeneration.Day> GetMaxEmissionsPerDay(Gas gas, Coal coal, EmissionsFactor emissionsFactor)
        {
            MaxEmissionGenerators maxEmissionGenerators = new MaxEmissionGenerators();

            maxEmissionGenerators.Day = new List <DTOs.OutputGeneration.Day>();

            foreach (var gasGenerator in gas.GasGenerator)
            {
                foreach (var inputday in gasGenerator.Generation.Day)
                {
                    DTOs.OutputGeneration.Day outputDay = new DTOs.OutputGeneration.Day();
                    outputDay.Date     = inputday.Date;
                    outputDay.Name     = gasGenerator.Name;
                    outputDay.Emission = inputday.Energy * gasGenerator.EmissionsRating * emissionsFactor.Medium;
                    maxEmissionGenerators.Day.Add(outputDay);
                }
            }

            foreach (var coalGenerator in coal.CoalGenerator)
            {
                foreach (var inputday in coalGenerator.Generation.Day)
                {
                    DTOs.OutputGeneration.Day outputDay = new DTOs.OutputGeneration.Day();
                    outputDay.Date     = inputday.Date;
                    outputDay.Name     = coalGenerator.Name;
                    outputDay.Emission = inputday.Energy * coalGenerator.EmissionsRating * emissionsFactor.High;
                    maxEmissionGenerators.Day.Add(outputDay);
                }
            }
            var result = maxEmissionGenerators.Day.GroupBy(x => x.Date)
                         .SelectMany(group => group.Where(element => element.Emission == group.Max(obj => obj.Emission)));

            return(result.ToList());
        }
        private static GenerationOutput CalculateGenerationData(GenerationReport generationReport, ReferenceData referenceData)
        {
            Totals totals = new Totals();
            List <ActualHeatRates> actualHeatRates       = new List <ActualHeatRates>();
            MaxEmissionGenerators  maxEmissionGenerators = new MaxEmissionGenerators();

            foreach (var windGenerator in generationReport.Wind.WindGenerator)
            {
                var generator = new Generator
                {
                    Name  = windGenerator.Name,
                    Total = CalculateTotalGenerationValue(windGenerator.Generation, windGenerator.Name, referenceData, null)
                };

                totals.Generator.Add(generator);
            }

            foreach (var coalGenerator in generationReport.Coal.CoalGenerator)
            {
                var generator = new Generator
                {
                    Name  = coalGenerator.Name,
                    Total = CalculateTotalGenerationValue(coalGenerator.Generation, coalGenerator.Name, referenceData, coalGenerator.EmissionsRating)
                };

                var actualHeatRate = new ActualHeatRates
                {
                    Name     = coalGenerator.Name,
                    HeatRate = coalGenerator.TotalHeatInput / coalGenerator.ActualNetGeneration
                };

                totals.Generator.Add(generator);
                actualHeatRates.Add(actualHeatRate);
            }

            foreach (var gasGenerator in generationReport.Gas.GasGenerator)
            {
                var generator = new Generator
                {
                    Name  = gasGenerator.Name,
                    Total = CalculateTotalGenerationValue(gasGenerator.Generation, gasGenerator.Name, referenceData, gasGenerator.EmissionsRating)
                };

                totals.Generator.Add(generator);
            }

            maxEmissionGenerators.Day = MaxEmissionsDays.OrderByDescending(x => x.Emission).GroupBy(x => x.Date).Select(b => b.First()).ToList();

            return(new GenerationOutput()
            {
                Totals = totals, ActualHeatRates = actualHeatRates, MaxEmissionGenerators = maxEmissionGenerators
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Method to find out max emission each day and the generator name.
        /// Only Gas and coal generators as per wind generators do not have emission
        /// </summary>
        /// <param name="incomingGeneratedReport"></param>
        /// <returns></returns>
        private MaxEmissionGenerators MaxEmissionGeneratorPerDay(GenerationReport incomingGeneratedReport)
        {
            var maxEmissionGenerator = new MaxEmissionGenerators();

            foreach (var generator in incomingGeneratedReport.coal.coalGenerator)
            {
                foreach (var day in generator.generation.day)
                {
                    var coalDayOutput = new DayOutput
                    {
                        Name     = generator.name,
                        Date     = day.date,
                        Emission = TotalDailyEmissions(day.energy, generator.EmissionsRating,
                                                       GetGeneratorFactorMapping(generator.name).emissionsFactor)
                    };
                    SetMaxEmission(coalDayOutput);
                }
            }

            foreach (var generator in incomingGeneratedReport.gas.gasGenerator)
            {
                foreach (var day in generator.generation.day)
                {
                    var gasdayOutput = new DayOutput
                    {
                        Name     = generator.name,
                        Date     = day.date,
                        Emission = TotalDailyEmissions(day.energy, generator.emissionsRating,
                                                       GetGeneratorFactorMapping(generator.name).emissionsFactor)
                    };
                    SetMaxEmission(gasdayOutput);
                }
            }
            var dayOutput = _lsFinalMaxGenOutput.GroupBy(x => x.Date)
                            .OrderBy(g => g.Key);

            var lsfinalDayOutput = dayOutput.SelectMany(@group => @group.OrderByDescending(c => c.Emission).Take(1)).ToList();

            maxEmissionGenerator.Days = lsfinalDayOutput;

            return(maxEmissionGenerator);
        }