Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        static void IterationAlgorithm(SectorFromNPStoNPS NPS_Pipe, Oil oil, List <float> HeadArray,
                                       float speed, ref float EndPressure, out string TextMessage)
        {
            TextMessage = "";
            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!

            var Head = EndPressure;                                                    // Переменная напора. Изначально равна конечно напору в ТП.

            for (int i = NPS_Pipe.X_SpotsSector.Count - 1; i > 0; i--)
            {
                Head = Head + HydroLoss * (NPS_Pipe.X_SpotsSector[i] - NPS_Pipe.X_SpotsSector[i - 1]);

                // Если начало самотечного участка
                if (Head < NPS_Pipe.Z_SpotsSector[i - 1] + oil.VapourPressure)
                {
                    Head = NPS_Pipe.Z_SpotsSector[i - 1] + oil.VapourPressure;
                }

                // Если напор выше максимального для трубы
                if (Head > NPS_Pipe.pipe.MaxPressure)
                {
                    TextMessage += $"Pressure on {NPS_Pipe.X_SpotsSector[i]} kilometer is exceeded";
                }
                HeadArray.Add(Head);
            }
            if (Head > NPS_Pipe.pipe.MaxPressure)
            {
                TextMessage += $"Outlet pressure on station {NPS_Pipe.station.Name} is exceeded\n";
            }
            Head = Head - NPS_Pipe.station.GetDiffPresure(Q);
            if (Head < NPS_Pipe.station.HighSpot + NPS_Pipe.station.CavitaionPressure)
            {
                TextMessage += $"Inlet pressure on station {NPS_Pipe.station.Name} is too small";
            }
            HeadArray.Append(Head);
            EndPressure = Head;
        }
Exemplo n.º 3
0
        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);
            }
        }