public static void CreateData() { Oil Nafta = new Oil((float)0.02, 864, 15); List <int> X_Spots = new List <int>(Enumerable.Range(0, 121)).Where(x => x % 5 == 0).ToList(); List <int> Z_Spots = new List <int>(); for (int i = 0; i < X_Spots.Count; i++) { Z_Spots.Add(new Random().Next(35, 55)); } Pipeline PipeLine = new Pipeline(12, 120, (float)0.82, (float)0.01, (float)0.2, Z_Spots, X_Spots, 120, 40); Pump pump_1 = new Pump(30, (float)279.44688, (float)-0.008687, (float)0.0000011734, (float)-0.000000002225, (float)802.70329, (float)0.18507, (float)0.000183, (float)-0.000000039357); List <Pump> pumpsColl = new List <Pump> { pump_1, pump_1 }; Station station_1 = new Station("Main station", 120, 0, pumpsColl); Station station_2 = new Station("Intermediate station", 110, 60, pumpsColl); SectorFromNPStoNPS FirstSector = new SectorFromNPStoNPS(PipeLine, station_1); SectorFromNPStoNPS SecondSector = new SectorFromNPStoNPS(PipeLine, station_2); LinkedSectorFromNPStoNPS StationNodes = new LinkedSectorFromNPStoNPS(); StationNodes.AppendFirst(FirstSector); StationNodes.AppendFirst(SecondSector); MainAlgorithms.ConvergenceIteration(StationNodes, Nafta, PipeLine); }
public static void ConvergenceIteration(LinkedSectorFromNPStoNPS ArraySectors, Oil oil, Pipeline pipe) { int counter = 0; float Speed; float delta = 10; float HeadCurr = 0; float HeadPrev = 0; float SpeedCurr = 0; float SpeedPrev = 0; while (Math.Abs(delta) > 0.01 && counter < 50) { if (counter == 0) { Speed = (float)2.7; } else if (counter == 1) { Speed = (float)2.5; } else { Speed = SpeedPrev - (HeadPrev * (SpeedCurr - SpeedPrev) / (HeadCurr - HeadPrev)); } counter++; float PressureInEnd = pipe.EndPressure + pipe.EndHighSpot; // Pressure from which payment starts. ???Maybe grab values from form and put it right here??? //float Q = (float)(PI * Speed * Math.Pow(NPS_Pipe.pipe.Diameter, 2) / 4); //var Reyn = NumberReynolds(Q, NPS_Pipe.pipe.Diameter, oil.Viscosity); //var HydroRes = HydroResist(NPS_Pipe.pipe.Roughness, Reyn); //var HydroLoss = HydroLosses(HydroRes, Q, NPS_Pipe.pipe.Diameter) * 1000; // multiplicate to get losses per one km! List <float> headArray = new List <float>(); headArray.Add(PressureInEnd); foreach (var sector in ArraySectors) { //sector.pipe.EndPressure = PressureInEnd; IterationAlgorithm(sector, oil, headArray, (float)Speed, ref PressureInEnd, out string TextMess); // declare "TextMess" } delta = PressureInEnd - ArraySectors.head.Data.station.HighSpot; // How much does ZSpot of station match with last values of pressure (SpeedPrev, HeadPrev, SpeedCurr, HeadCurr) = (SpeedCurr, HeadCurr, Speed, delta); } }