Exemplo n.º 1
0
        private int InterfaceAction(Interface3D itf)
        {
            Cell3D liquidCell = itf.LiquidCell;
            Cell3D gasCell    = itf.GasCell;

            double liquidPressure = DropList[liquidCell.Index].Pressure;
            double gasVolume      = BubbleList[gasCell.Index].BubbleVolume;
            double gasAmount      = BubbleList[gasCell.Index].BubbleGasAmount;
            //double gasPressure = BubbleList[gasCell.index].Pressure;

            int action = 0;

            if (gasVolume > 1 && liquidPressure >= gasAmount / (gasVolume - 1))
            {
                action = 1;
            }
            else if (liquidPressure < gasAmount / gasVolume)
            {
                action = -1;
                foreach (Source3D s in SourceList)
                {
                    if (s.SourceCell == liquidCell)
                    {
                        action = 0;
                    }
                }
            }
            else if (gasVolume == 1 && liquidPressure >= gasAmount * 1.5)
            {
                action = 2;//小气泡消失
            }

            return(action);
        }
Exemplo n.º 2
0
        private void TakeAction(Interface3D itf, int action)
        {
            Cell3D gasCell    = itf.GasCell;
            Cell3D liquidCell = itf.LiquidCell;

            if (action == 1)
            {
                List <Cell3D> neighbour    = gasCell.Neighbour;
                List <Cell3D> gasNeighbour = new List <Cell3D>();//gasCell的gas邻域
                foreach (Cell3D nc in neighbour)
                {
                    if (nc.Phase > 0)
                    {
                        gasNeighbour.Add(nc);
                    }
                }
                if (gasNeighbour.Count > 0)
                {
                    double addtion = gasCell.Phase / gasNeighbour.Count;
                    foreach (Cell3D gnc in gasNeighbour)
                    {
                        gnc.Phase += addtion;
                    }
                    gasCell.Phase = 0;//update phase
                }
            }
            else if (action == -1)
            {
                liquidCell.Phase += gasCell.Phase / 2;//update phase
                gasCell.Phase    -= gasCell.Phase / 2;
            }
            else if (action == 2)
            {
                gasCell.Phase = 0;//直接消失
            }
        }
Exemplo n.º 3
0
        private void AnalyzeDrops()
        {
            int numberOfDrops = DropList.Count;

            for (int j = 0; j < numberOfDrops; j++)
            {
                Drop3D currentDrop = DropList[j];
                int    n           = currentDrop.CellList.Count;
                double pressure    = 0;

                for (int i = 0; i < n; i++)
                {
                    Cell3D c = currentDrop.CellList[i];
                    c.Index = j;//update index for every cell

                    List <Cell3D> neighbour = c.Neighbour;

                    foreach (Cell3D nc in neighbour)
                    {
                        if (nc.Phase > 0)
                        {                                                //气液界面
                            Interface3D interf = new Interface3D(c, nc); //(liquid, gas)
                            currentDrop.InterfaceList.Add(interf);
                            if (BubbleList[nc.Index].Pressure > pressure)
                            {//获得与该drop接触的bubble中最大的气压值
                                pressure = BubbleList[nc.Index].Pressure;
                            }
                            //pressure += BubbleList[nc.index].Pressure;
                        }
                    }
                }
                //气液界面按照bubble体积降序排列
                int numberOfInterface = currentDrop.InterfaceList.Count;
                List <Interface3D> orderedInterfaceList = new List <Interface3D>();
                List <bool>        isOrdered            = new List <bool>();
                for (int i = 0; i < numberOfInterface; i++)
                {
                    isOrdered.Add(false);
                }
                for (int i = 0; i < numberOfInterface; i++)
                {
                    double maxV     = 0;
                    int    maxIndex = 0;
                    for (int k = 0; k < numberOfInterface; k++)
                    {
                        Interface3D currentItf = currentDrop.InterfaceList[k];
                        double      v          = BubbleList[currentItf.BubbleIndex].BubbleVolume;
                        if (v > maxV && isOrdered[k] == false)
                        {
                            maxV     = v;
                            maxIndex = k;
                        }
                    }
                    isOrdered[maxIndex] = true;
                    orderedInterfaceList.Add(currentDrop.InterfaceList[maxIndex]);
                }
                currentDrop.InterfaceList = orderedInterfaceList;

                if (!currentDrop.isSource && currentDrop.InterfaceList.Count != 0)
                {
                    //pressure /= currentDrop.InterfaceList.Count;
                    //currentDrop.Pressure = pressure;
                    currentDrop.Pressure = pressure * 0.95;//最大气压的0.95
                }
            }
        }