public void RunTest() { Profile prof = Profile.MakeRandomProfile(new Random(), "myprofi", Profile.ProfileResolution.QuarterHour, -20, 40); HeatingDegreeProfile hdp = new HeatingDegreeProfile(prof, 15, 20); hdp.InitializeDailyAmounts(1000); Info("sum degree days: " + hdp.CalculateHeatingDegreeDaySum()); Info("sum energy: " + hdp.CalculateYearlyConsumptionSum()); foreach (var day in hdp.HeatingDegreeDays) { Info(day.ToString()); } hdp.CalculateYearlyConsumptionSum().Should().BeApproximately(1000, 1); }
public HeatPumpResult Run([NotNull] HeatpumpCalculationParameters hpPar, double yearlyConsumption, [NotNull] Random rnd) { var hpr = new HeatPumpResult(); _hdp.InitializeDailyAmounts(yearlyConsumption); //calculate required power if (hpPar.HouseMinimumEnergyTriggerinPercent > 1) { throw new FlaException("More than 100% trigger is not possible"); } var maxDailyNeed = _hdp.HeatingDegreeDays.Select(x => x.DailyEnergyConsumption).Max(); var power = maxDailyNeed / hpPar.TargetMaximumRuntimePerDay; //only target running for 12h power = Math.Max(power, 5); // minimum 5kw power = ((int)power / 5) * 5; // round to the neared 5kw double houseEnergy = maxDailyNeed * hpPar.StartLevelPercent; int idx = 0; HeatPumpStateEngine hpse = new HeatPumpStateEngine(power, maxDailyNeed, rnd, hpPar); int prepSteps = 1000 + rnd.Next(1000); double dailyEnergyLoss = _hdp.HeatingDegreeDays[0].DailyEnergyConsumption / 96; for (int i = 0; i < prepSteps; i++) { houseEnergy -= dailyEnergyLoss; houseEnergy += hpse.ProvideEnergyForTimestep(houseEnergy, 1); } for (int i = 0; i < 365; i++) { double daily = _hdp.HeatingDegreeDays[i].DailyEnergyConsumption; double energyLostPerTimestep = daily / 96; for (int dayTimeStep = 0; dayTimeStep < 96; dayTimeStep++) { hpr.DailyAvgTemperatures15Min[idx] = _hdp.HeatingDegreeDays[i].DailyAverageTemperature; hpr.HouseEnergyTracker[idx] = houseEnergy; houseEnergy -= energyLostPerTimestep; double heatPumpSuppliedEnergy = hpse.ProvideEnergyForTimestep(houseEnergy, dayTimeStep); // totalEnergy += heatPumpSuppliedEnergy; houseEnergy += heatPumpSuppliedEnergy; hpr.HeatpumpEnergySupply[idx] = heatPumpSuppliedEnergy; idx++; } } CalculateEnergyConsumption(hpr, hpPar.HeatPumpCop); return(hpr); }