public void CalcFlowRate(double pressure) { SystemPressure = pressure; if (SystemHead > Pump.MaxTotalHead) { ResetSystem(); return; } var systemFlowRate = LinInterp.LinearInterpolation(Pump.GetPerformanceHeadValues(), Pump.GetPerformanceFlowValues(), SystemHead); if (SuctionPipe == null) { SystemFlowRate = systemFlowRate; } else { double pressureDrop = 0; double systemPressure = 0; //Iterative Berechnung, da Volumenstrom auch vom saugseitigen Druckverlust abhängt double s = -0.01; // Schrittweite für Antastung int i = 7; // Anzahl der Richtungswechsel double error = double.MaxValue; double lastError; while (i > 0) { lastError = error; systemFlowRate += s; pressureDrop = SuctionPipe.CalcPressureDrop(CurrentPresets.Medium, systemFlowRate); var performanceFlowValues = Pump.GetPerformanceFlowValues(); var performanceHeadValues = Pump.GetPerformanceHeadValues(); Array.Reverse(performanceFlowValues); Array.Reverse(performanceHeadValues); systemPressure = LinInterp.LinearInterpolation(performanceFlowValues, performanceHeadValues, systemFlowRate) * 0.0980665; error = systemPressure - pressureDrop - pressure; if (Math.Abs(error) >= Math.Abs(lastError)) { s /= -10; i--; } SuctionPressureDropCalcIterations++; } if (SystemHead > Pump.MaxTotalHead || double.IsInfinity(systemPressure) || double.IsInfinity(systemFlowRate) || double.IsInfinity(pressureDrop)) { ResetSystem(); } else { SystemPressure = systemPressure; SystemFlowRate = systemFlowRate; SuctionPressureDrop = -pressureDrop; } } }
public void CalcFlowRate(double pressure, int?rpm = null) { //for debugging only var sw = new Stopwatch(); SystemPressure = pressure; if (SystemHead > Pump.GetMaxTotalHead(rpm)) { ResetSystem(); return; } var systemFlowRate = LinInterp.LinearInterpolation(Pump.GetPerformanceHeadValues(rpm), Pump.GetPerformanceFlowValues(rpm), SystemHead); if (SuctionPipe == null) { SystemFlowRate = systemFlowRate; } else { double pressureDrop = 0; double systemPressure = 0; //Iterative Berechnung, da Volumenstrom auch vom saugseitigen Druckverlust abhängt double s = -0.01; // Schrittweite für Antastung int i = 7; // Anzahl der Richtungswechsel double error = double.MaxValue; double lastError; sw.Start(); while (i > 0) { lastError = error; systemFlowRate += s; pressureDrop = SuctionPipe.CalcPressureDrop(CurrentPresets.Medium, systemFlowRate); var performanceFlowValues = Pump.GetPerformanceFlowValues(rpm); var performanceHeadValues = Pump.GetPerformanceHeadValues(rpm); Array.Reverse(performanceFlowValues); Array.Reverse(performanceHeadValues); systemPressure = LinInterp.LinearInterpolation(performanceFlowValues, performanceHeadValues, systemFlowRate) * 0.0980665; error = systemPressure - pressureDrop - pressure; if (Math.Abs(error) >= Math.Abs(lastError)) { s /= -10; i--; } SuctionPressureDropCalcIterations++; } sw.Stop(); Debug.WriteLine($"SuctionPressureDropCalc Iterations: {SuctionPressureDropCalcIterations} Time: {sw.ElapsedMilliseconds} ms"); //TODO: Pump.MaxTotalHead für VARIO Pumpe if (SystemHead > Pump.GetMaxTotalHead(rpm) || double.IsInfinity(systemPressure) || double.IsInfinity(systemFlowRate) || double.IsInfinity(pressureDrop)) { ResetSystem(); } else { SystemPressure = systemPressure; SystemFlowRate = systemFlowRate; SuctionPressureDrop = -pressureDrop; } } }