public static CoolingCalculationParameters MakeDefaults()
        {
            CoolingCalculationParameters h = new CoolingCalculationParameters(3,
                                                                              0.95);

            return(h);
        }
        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));
        }
Ejemplo n.º 3
0
        public CoolingResult Run([NotNull] CoolingCalculationParameters hpPar, double yearlyConsumption, [NotNull] Random rnd)
        {
            var hpr = new CoolingResult();

            _hdp.InitializeDailyAmounts(yearlyConsumption);
            //calculate required power
            if (hpPar.HouseMinimumEnergyTriggerinPercent > 1)
            {
                throw new FlaException("More than 100% trigger is not possible");
            }

            var maxDailyNeed = _hdp.CoolingDegreeHours.Select(x => x.HourlyEnergyConsumption).Max();
            var power        = maxDailyNeed / hpPar.TargetMaximumRuntimePerDay; //only target running for 12h

            power = Math.Max(power, 2);                                         // minimum 2kw
            power = ((int)power / 2) * 2;                                       // round to the neared 2kw
            double             houseEnergy = maxDailyNeed;
            int                idx         = 0;
            double             totalEnergy = 0;
            CoolingStateEngine hpse        = new CoolingStateEngine(power, maxDailyNeed, rnd, hpPar);

            for (int i = 0; i < 8760; i++)
            {
                double daily = _hdp.CoolingDegreeHours[i].HourlyEnergyConsumption;
                double energyLostPerTimestep = daily / 4;
                for (int quarterhourStep = 0; quarterhourStep < 4; quarterhourStep++)
                {
                    hpr.AvgTemperatures15Min[idx] = _hdp.CoolingDegreeHours[i].HourlyAverageTemperature;
                    hpr.HouseEnergyTracker[idx]   = houseEnergy;
                    houseEnergy -= energyLostPerTimestep;
                    double heatPumpSuppliedEnergy = hpse.ProvideEnergyForTimestep(houseEnergy);
                    totalEnergy += heatPumpSuppliedEnergy;
                    houseEnergy += heatPumpSuppliedEnergy;
                    hpr.CoolingEnergySupply[idx] = heatPumpSuppliedEnergy;
                    idx++;
                }
            }

            CalculateEnergyConsumption(hpr);
            _logger.Debug("Calculated air conditioning profile for " + yearlyConsumption + " Energy consumption in profile: " +
                          hpr.CoolingEnergySupply.Sum() + " energy demand: " + hpr.CoolingEnergySupply.Sum() + " Degree days: " +
                          _hdp.CoolingDegreeHours.Sum(x => x.DegreeHours) + " total need in degree days: " +
                          _hdp.CoolingDegreeHours.Sum(x => x.HourlyEnergyConsumption) + " Total energy: " + totalEnergy,
                          Stage.ProfileGeneration,
                          "Profile");
            return(hpr);
        }
        protected override Prosumer ProvidePrivateProfile([NotNull] ProviderParameterDto ppdto)
        {
            AirConditioningEntry hse = (AirConditioningEntry)ppdto.HouseComponent;

            if (hse.HouseComponentType != HouseComponentType.Cooling)
            {
                throw new FlaException("Wrong type");
            }

            Hausanschluss ha = _dbDto.Hausanschlusse.Single(x => x.Guid == hse.HausAnschlussGuid);
            var           pa = new Prosumer(hse.HouseGuid,
                                            hse.Standort,
                                            hse.HouseComponentType,
                                            hse.SourceGuid,
                                            hse.FinalIsn,
                                            hse.HausAnschlussGuid,
                                            ha.ObjectID,
                                            GenerationOrLoad.Load,
                                            ha.Trafokreis,
                                            Name,
                                            "Cooling State Engine");

            // todo: randomize this with buckets and/or simulate a central control
            double targetRuntimePerDay       = 2 + Services.Rnd.NextDouble() * 2;
            double trigger                   = 1 - Services.Rnd.NextDouble() * 0.1;
            CoolingCalculationParameters hpc = new CoolingCalculationParameters(targetRuntimePerDay, trigger);
            var hpr = _coolingProfileGeneratorsByType[hse.AirConditioningType].Run(hpc, hse.EffectiveEnergyDemand, Services.Rnd);

            ppdto.HouseComponentResultObject.CoolingType = hse.AirConditioningType.ToString();
            pa.Profile = hpr.GetEnergyDemandProfile().ScaleToTargetSum(hse.EffectiveEnergyDemand, "Air Conditioning Profile", out var _);
            if (Math.Abs(pa.Profile.EnergySum() - hse.EffectiveEnergyDemand) > 1)
            {
                throw new FlaException("Energy sum from the cooling is all wrong. Should be " + hse.EffectiveEnergyDemand + " but was " +
                                       pa.Profile.EnergySum());
            }

            return(pa);
        }
Ejemplo n.º 5
0
 public CoolingStateEngine(double maxPower, double maxHouseEnergy, [NotNull] Random rnd, [NotNull] CoolingCalculationParameters coolPars)
 {
     _maxPower           = maxPower / 4.0; //for 15 minutes
     _maxHouseEnergy     = maxHouseEnergy;
     _rnd                = rnd;
     _triggerHouseEnergy = maxHouseEnergy * coolPars.HouseMinimumEnergyTriggerinPercent;
 }