예제 #1
0
파일: Wendu.cs 프로젝트: imdmmp/kpgweigher
        public double RValueToTValue(double r, ABCParam param, ConvertMethod method)
        {
            if (method == ConvertMethod.ITS90)
            {
                double ac, bc, cc;
                ac = param.a;
                bc = param.b;
                cc = param.c;

                //set the search range of T between GetT(r) +/- 1 degree
                double tlow = GetT(r) - 1;
                double tup = tlow + 2;

                double rnew;
                double tnew;
                int count = 0;

                while ((tup - tlow > 0.00005) && (count++ < 100))
                {
                    tnew = (tlow + tup) / 2.0;
                    rnew = GetWr(tnew);
                    rnew = rnew + ac * (rnew - 1) + bc * (rnew - 1) * (rnew - 1) + cc * (rnew - 1) * (rnew - 1) * (rnew - 1);
                    if (r < rnew)
                        tup = tnew;
                    else
                        tlow = tnew;
                }
                return (tlow + tup) / 2.0;
            }
            if (method == ConvertMethod.DIN68 || method == ConvertMethod.DIN90|| method == ConvertMethod.ASTM)
            {
                double alpha,A,B,C;
                alpha = A = B = C = 0;
                if (method == ConvertMethod.DIN68)
                {
                    alpha = 0.003850;
                    param.wtp = 100;
                    A = 3.90802e-3;
                    B = -5.8020e-7;
                    C = -4.2735e-12;
                }
                if (method == ConvertMethod.DIN90)
                {
                    alpha = 0;
                    param.wtp = 100;
                    A = 3.90823e-3;
                    B = -5.7750e-7;
                    C = -4.1830e-12;
                }
                if (method == ConvertMethod.ASTM)
                {
                    alpha = 0.003911;
                    param.wtp = 100;
                    A = 3.9692e-3;
                    B = -5.8495e-7;
                    C = -4.2325e-12;
                }
                double tlow = -201;
                double tup = 1000;

                double rnew;
                double tnew;
                int count = 0;

                while ((tup - tlow > 0.00005) && (count++ < 150))
                {
                    tnew = (tlow + tup) / 2.0;
                    if(tnew > 0)
                        rnew = param.wtp * (1 + A * tnew + B * tnew * tnew);
                    else
                        rnew = param.wtp*(1+A*tnew+B*tnew*tnew+C*(tnew-100)*tnew*tnew*tnew);

                    if (r < rnew)
                        tup = tnew;
                    else
                        tlow = tnew;
                }
                return (tlow + tup) / 2.0;
            }
            if (method == ConvertMethod.PT100)
            {
                //todo
            }
            if (method == ConvertMethod.PT25)
            {
                //todo
            }
            return -9999.9999;
        }
예제 #2
0
        public double RValueToTValue(double r, ABCParam param, ConvertMethod method)
        {
            if (method == ConvertMethod.ITS90)
            {
                double ac, bc, cc;
                ac = param.a;
                bc = param.b;
                cc = param.c;

                //set the search range of T between GetT(r) +/- 1 degree
                double tlow = GetT(r) - 1;
                double tup  = tlow + 2;

                double rnew;
                double tnew;
                int    count = 0;

                while ((tup - tlow > 0.00005) && (count++ < 100))
                {
                    tnew = (tlow + tup) / 2.0;
                    rnew = GetWr(tnew);
                    rnew = rnew + ac * (rnew - 1) + bc * (rnew - 1) * (rnew - 1) + cc * (rnew - 1) * (rnew - 1) * (rnew - 1);
                    if (r < rnew)
                    {
                        tup = tnew;
                    }
                    else
                    {
                        tlow = tnew;
                    }
                }
                return((tlow + tup) / 2.0);
            }
            if (method == ConvertMethod.DIN68 || method == ConvertMethod.DIN90 || method == ConvertMethod.ASTM)
            {
                double alpha, A, B, C;
                alpha = A = B = C = 0;
                if (method == ConvertMethod.DIN68)
                {
                    alpha     = 0.003850;
                    param.wtp = 100;
                    A         = 3.90802e-3;
                    B         = -5.8020e-7;
                    C         = -4.2735e-12;
                }
                if (method == ConvertMethod.DIN90)
                {
                    alpha     = 0;
                    param.wtp = 100;
                    A         = 3.90823e-3;
                    B         = -5.7750e-7;
                    C         = -4.1830e-12;
                }
                if (method == ConvertMethod.ASTM)
                {
                    alpha     = 0.003911;
                    param.wtp = 100;
                    A         = 3.9692e-3;
                    B         = -5.8495e-7;
                    C         = -4.2325e-12;
                }
                double tlow = -201;
                double tup  = 1000;

                double rnew;
                double tnew;
                int    count = 0;

                while ((tup - tlow > 0.00005) && (count++ < 150))
                {
                    tnew = (tlow + tup) / 2.0;
                    if (tnew > 0)
                    {
                        rnew = param.wtp * (1 + A * tnew + B * tnew * tnew);
                    }
                    else
                    {
                        rnew = param.wtp * (1 + A * tnew + B * tnew * tnew + C * (tnew - 100) * tnew * tnew * tnew);
                    }

                    if (r < rnew)
                    {
                        tup = tnew;
                    }
                    else
                    {
                        tlow = tnew;
                    }
                }
                return((tlow + tup) / 2.0);
            }
            if (method == ConvertMethod.PT100)
            {
                //todo
            }
            if (method == ConvertMethod.PT25)
            {
                //todo
            }
            return(-9999.9999);
        }