Пример #1
0
        public ElectricSourceUtilizationAdjustment(Dictionary <string, Statistic> stats, List <Country> countries)
        {
            /*
             *  eutilization_pctcapnuclear:     Electric Utilization    vs Nuclear Capacity     0.294   0.4     0.42883 n%/u%
             *  eutilization_pctcapfossil:      Electric Utilization    vs Fossil Capacity      0.149   0.4     0.44520 f%/u%
             *  eutilization_pctcaphydro:       Electric Utilization    vs Hydro Capacity       0.050   0.4     0.10781 h%/u%
             *  eutilization_pctcaprenew:       Electric Utilization    vs Renewable Capacity  -0.543   0.4    -0.96077 r%/u%
             */

            // Estimate Utilization

            foreach (var item in stats.OrderBy(k => k.Key))
            {
                Console.WriteLine($"{item.Key}:\t{item.Value.Slope():F4}\n{item.Value.ToString()}");
            }

            var target = countries.FirstOrDefault <Country>(c => c.Name.Equals("United States"));

            if (target is null)
            {
                Console.WriteLine("United States NOT found in country set");
                return;
            }

            var source = target.Electric.Electricity.by_source;

            Console.WriteLine(
                $"{target.Name} PowerTWh: {IntelCore.XValue("eprodtwh", target):F3} Utilization%: {IntelCore.XValue("eutilization", target):F3} "
                + $"f: {IntelCore.XValue("pctcapfossil", target)} "
                + $"h: {IntelCore.XValue("pctcaphydro", target)} "
                + $"n: {IntelCore.XValue("pctcapnuclear", target)} "
                + $"r: {IntelCore.XValue("pctcaprenew", target)}"
                );

            // Utiization starts at .25 for nuclear, fossil, hydro, renew
            // sum of utilizations always = 1 (100%) just like sum of capacity's
            // Total utilization % for a country is ePowerGen total / Capacity total ==> c.Electric.ProdTWh / igc.YearCapacityTWhr (see XValue in IntelCore class)

            // Adjust utilization down for renew take that and split it among the other three


            // Search, calculate LR for each, take some capacity from the lowest and add that to each of the other three, repeat until cap's are equal.
            // Keep track of how much was moved around to each one, this is the estimated utilization

            Console.WriteLine();
        }
Пример #2
0
        private StringBuilder BuildReport(List <string> ReportColumns, string reportStats, string dv)
        {
            var reportSb = new StringBuilder();

            #region Report header

            foreach (var col in ReportColumns)
            {
                reportSb.Append($"{IntelCore.ColumnConfigs[col].Short} {IntelCore.ColumnConfigs[col].Unit}{dv}");

                var match = Regex.Match(col, reportStats);
                if (match.Success)
                {
                    switch (match.Groups[1].Value)
                    {
                    case "eprod":
                        reportSb.Append($"Qx {IntelCore.GetXyUnits("eprod_gdp")}{dv}");
                        reportSb.Append($"Qx {IntelCore.GetXyUnits("eprod_emission")}{dv}");
                        break;

                    case "caphydro":
                        reportSb.Append($"Qx {IntelCore.GetXyUnits("capff_gdp")}{dv}");
                        break;

                    case "capff":
                        reportSb.Append($"Qx {IntelCore.GetXyUnits("caphydro_gdp")}{dv}");
                        reportSb.Append($"Qx {IntelCore.GetXyUnits("caphydro_emission")}{dv}");
                        break;

                    case "emission":
                        reportSb.Append($"Qx {IntelCore.GetXyUnits("gdp_emission")}{dv}");
                        break;
                    }
                }
            }

            reportSb.Append("Country\n");

            if (dv.Equals("|"))
            {
                reportSb.Append(IntelCore.WriteDivider(Regex.Matches(reportSb.ToString(), @"\|").Count) + "\n");
            }

            #endregion

            #region report body

            foreach (var c in _countryData.Countries.OrderByDescending(d => d.Electric.ProdTWh))
            {
                var kgEfossil = c.Electric.Electricity.by_source.fossil_fuels.percent / 100 * c.Electric.ProdTWh *
                                IntelCore.TWh2Kg;

                var wrldKgEfossil = _countryData.World.Electric.Electricity.by_source.fossil_fuels.percent / 100 *
                                    _countryData.World.Electric.ProdTWh * IntelCore.TWh2Kg;

                var igc = c.Electric.Electricity.installed_generating_capacity;
                if (igc == null)
                {
                    continue;
                }

                var currentCap   = igc.YearCapacityTWhr;
                var futureCap50Y = igc.YearCapacityTWhr * 2;

                foreach (var col in ReportColumns)
                {
                    switch (IntelCore.ColumnConfigs[col].Format)
                    {
                    case "1":
                        reportSb.Append($"{IntelCore.XValue(col, c):F1}");
                        break;

                    case "2":
                        reportSb.Append($"{IntelCore.XValue(col, c):F2}");
                        break;

                    case "3":
                        reportSb.Append($"{IntelCore.XValue(col, c):F3}");
                        break;

                    case "4":
                        reportSb.Append($"{IntelCore.XValue(col, c):F4}");
                        break;

                    case "5":
                        reportSb.Append($"{IntelCore.XValue(col, c):F5}");
                        break;

                    default:
                        reportSb.Append($"{IntelCore.XValue(col, c)}");
                        break;
                    }

                    reportSb.Append($"{dv}");

                    var match = Regex.Match(col, reportStats);

                    if (match.Success)
                    {
                        switch (match.Groups[1].Value)
                        {
                        case "eprod":
                            reportSb.Append($"{_countryData.Stats.Stand("eprod_gdp", c):F3}{dv}");
                            reportSb.Append($"{_countryData.Stats.Stand("eprod_emission", c):F3}{dv}");
                            break;

                        case "caphydro":
                            reportSb.Append($"{_countryData.Stats.Stand("caphydro_gdp", c):F3}{dv}");
                            break;

                        case "capff":
                            reportSb.Append($"{_countryData.Stats.Stand("capff_gdp", c):F3}{dv}");
                            reportSb.Append($"{_countryData.Stats.Stand("capff_emission", c):F3}{dv}");
                            break;

                        case "emission":
                            reportSb.Append($"{_countryData.Stats.Stand("gdp_emission", c):F3}{dv}");
                            break;
                        }
                    }
                }

                reportSb.Append($"{c.Name}\n");
            }

            #endregion

            return(reportSb);
        }