public DhwStateEngine(double yearlyEnergy, [NotNull] DhwCalculationParameters dhwPars, [NotNull] Random rnd)
 {
     _dhwPars       = dhwPars;
     _rnd           = rnd;
     _targetRuntime = dhwPars.TurnOffTimeStep - dhwPars.TurnOnTimestep;
     _targetPower   = yearlyEnergy / 365 / (_targetRuntime - 2);
     _dailyEnergy   = yearlyEnergy / 365 * 1.1;
 }
        public DhwResult Run([NotNull] DhwCalculationParameters hpPar, double yearlyConsumption, [NotNull] Random rnd)
        {
            var            hpr            = new DhwResult(yearlyConsumption);
            DhwStateEngine dhwStateEngine = new DhwStateEngine(yearlyConsumption, hpPar, rnd);
            int            idx            = 0;

            for (int i = 0; i < 365; i++)
            {
                for (int dayTimeStep = 0; dayTimeStep < 96; dayTimeStep++)
                {
                    double dhwEnergy = dhwStateEngine.ProvideEnergyForTimestep(dayTimeStep, out var reason);
                    hpr.DhwEnergyDemand[idx] = dhwEnergy;
                    hpr.TurnOffReasons[idx]  = reason;
                    idx++;
                }
            }

            return(hpr);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        protected override Prosumer ProvidePrivateProfile([NotNull] ProviderParameterDto ppdto)
        {
            DHWHeaterEntry dhw = (DHWHeaterEntry)ppdto.HouseComponent;

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

            ppdto.HouseComponentResultObject.DhwSystemType = dhw.DhwHeatingSystemType.ToString();
            if (dhw.DhwHeatingSystemType != DhwHeatingSystem.Electricity && dhw.DhwHeatingSystemType != DhwHeatingSystem.Heatpump)
            {
                ppdto.HouseComponentResultObject.HeatingSystemMessage = "Not electric heating";
                return(null);
            }

            Hausanschluss ha = _dbDto.Hausanschlusse.Single(x => x.Guid == dhw.HausAnschlussGuid);
            var           pa = new Prosumer(dhw.HouseGuid,
                                            dhw.Name,
                                            dhw.HouseComponentType,
                                            dhw.SourceGuid,
                                            dhw.FinalIsn,
                                            dhw.HausAnschlussGuid,
                                            ha.ObjectID,
                                            GenerationOrLoad.Load,
                                            ha.Trafokreis,
                                            Name,
                                            "DHW Profile Generator");
            //todo: randomize this with buckets and/or simulate a central control
            int startTime = 2 * 4 + Services.Rnd.Next(12);
            int stopTime  = startTime + 3 * 4 + Services.Rnd.Next(12);
            //double targetRuntimePerDay = 3*4 + Services.Rnd.NextDouble() * 4;
            double trigger = 1 - 0.05 * Services.Rnd.NextDouble();
            DhwCalculationParameters dhwCalculationParameters = new DhwCalculationParameters(startTime, stopTime, trigger);
            var dhwResult = _dhw.Run(dhwCalculationParameters, dhw.EffectiveEnergyDemand, Services.Rnd);

            pa.Profile = dhwResult.GetEnergyDemandProfile();
            return(pa);
        }
Exemplo n.º 5
0
        public static DhwCalculationParameters MakeDefaults()
        {
            DhwCalculationParameters h = new DhwCalculationParameters(2 * 4, 6 * 4, 0.85);

            return(h);
        }