如何用double方法返回两个列表?

时间:2019-05-21 06:29:12

标签: c#

我正在研究一个C#程序,该程序从文本框中获取一些值并将它们设置为2类的一些变量,这些变量的名称分别为:"Tfluid""Twell"

然后我通过另一个名称为"fluidcal"的方法在另一个类中使用它们的名称为“ Tcalc”并对其进行一些计算,

我有2个交叉的while,这意味着它以"ql"开头,然后将最终的P与每个"ql"相匹配。现在我想使用这些(ql, P)以另一种形式绘制图形,

那么保存它们的最佳方法是什么 (我不知道该用流体方法返回什么)

以及如何将它们添加到图表中?

这是我的计算过程

public double Fluidcal(TWell well, TFluid fluid)
    {
        double froudnumber, noslipholdup, vm, vsl, vsg, liquidvelocitynumber, l1, l2, l3, l4, fluidregim, hozhold, C, psy, liqhold, liqholdseg, liqholdinter, fn, nren, densityn, viscosityn, y, S, ftp, dpdzel, dpdzf, dpperdzt, rhos, Ek,ql;
        ql = 1;

        while (ql<=fluid.maxoilflowrate)
        {
            vsl = (ql) / Math.PI * Math.Pow(well.tubingdiameter / 2, 2); //superficial velocities
            vsg = (ql * fluid.gor) / Math.PI * Math.Pow(well.tubingdiameter / 2, 2);
            vm = vsl + vsg;
            double nowlength = 0;
            double P = well.wellheadpressure;
            while (nowlength <= well.welldepth)
            {

                froudnumber = Math.Pow(vm, 2) / well.tubingdiameter * 32.174;  //froud number
                noslipholdup = vsl / vm;   //no slip holdup
                double newoildensity = fluid.oildensity / (1 + 0.00056 * (0.01515 * nowlength));
                liquidvelocitynumber = vsl * Math.Pow((newoildensity / 32.174 * fluid.gasliquidsurfacetension), 0.25); //liquid velocity number
                                                                                                      //correlating parametrs
                l1 = 316 * Math.Pow(noslipholdup, 0.302);
                l2 = 0.0009252 * Math.Pow(noslipholdup, -2.4684);
                l3 = 0.1 * Math.Pow(noslipholdup, -1.4516);
                l4 = 0.5 * Math.Pow(noslipholdup, -6.738);
                fluidregim = 0;
                C = 0;
                liqhold = 0;
                if ((noslipholdup < 0.01 && froudnumber < l1) || (noslipholdup >= 0.01 && froudnumber < l2))
                {
                    segregated(froudnumber, noslipholdup, liquidvelocitynumber, out fluidregim, out hozhold, out C, out psy, out liqhold);
                }
                else if ((noslipholdup >= 0.01 && l2 < froudnumber && froudnumber <= l3))
                {
                    transition(froudnumber, noslipholdup, liquidvelocitynumber, l2, l3, out fluidregim, out hozhold, out C, out psy, out liqhold, out liqholdseg, out liqholdinter);

                }
                else if ((noslipholdup >= 0.01 && noslipholdup < 0.4 && froudnumber > l3 && froudnumber <= l1)
               || (noslipholdup >= 0.4 && l3 < froudnumber && froudnumber <= 4))
                {
                    intermittent(froudnumber, noslipholdup, liquidvelocitynumber, out fluidregim, out hozhold, out C, out psy, out liqhold);
                }
                else if ((noslipholdup < 0.4 && froudnumber >= l1) || (noslipholdup >= 0.4 && froudnumber > l4))
                {
                    disturbuted(froudnumber, noslipholdup, out fluidregim, out hozhold, out C, out psy, out liqhold);

                }
               // else
               // {
                //    System.Windows.Forms.MessageBox.Show("Undefined Flow Regim");
                //}
                y = noslipholdup / Math.Pow(liqhold, 2);
                if (y > 1 && y < 1.2)
                {
                    S = Math.Log(2.2 * y - 1.2);


                }
                else
                {
                    S = (Math.Log(y)) / (-0.0523 + 3.182 * Math.Log(y) - 0.8725 * Math.Pow(Math.Log(y), 2) + 0.01853 * Math.Pow(Math.Log(y), 4));
                }

                    viscosityn = fluid.oilviscosity * noslipholdup + fluid.gasviscosity * (1 - noslipholdup);
                    densityn = fluid.oildensity * noslipholdup + (1 - noslipholdup) * fluid.gasdensity;
                    nren = densityn * vm * (well.tubingdiameter) / viscosityn;
                    fn = 1 / Math.Pow((2 * Math.Log(nren / (4.5223 * Math.Log(nren) - 3.8215))), 2);
                    ftp = fn * Math.Exp(S);
                    rhos = fluid.oildensity * liqhold + fluid.gasdensity * (1 - liqhold);
                    Ek = rhos * vm * vsg / 32.2 * P;
                    dpdzel = (1) * rhos;
                    dpdzf = ftp * densityn * Math.Pow(vm, 2) / 2 * 32.174 * well.tubingdiameter;
                    dpperdzt = (dpdzel + dpdzf) / 1 - Ek;
                    P = P + 5 * dpperdzt;




                yax.Add(P);

                nowlength = +5;
                vsl = vm * liqhold;
                vsg = vsl * fluid.gor;
            }

            ql = +20;



        }return; //what should I write here?I want pairs of(ql,P)

1 个答案:

答案 0 :(得分:0)

有几种方法可以做到这一点。我建议将列表封装在一个对象中,然后从您的方法中返回该对象。例如:

public class MyLists
{
    public List<double> ListOne { get; set; }
    public List<double> ListTwo { get; set; }
}

当然,您可以使用元组。如果我正确理解您的问题...