示例#1
0
        // called when the Natural Gas Calc button is pressed
        private void Button_TempPro_Calculate_Click(object sender, EventArgs e)
        {
            long iErr, kph = 1;

            double te = 0.0, p = 0.0, d = 0.0, Dl = 0.0, Dv = 0.0, q = 0.0, ee = 0.0, hh = 0.0, ss = 0.0, cp = 0.0, cv = 0.0, w = 0.0;

            double[] x    = new double[20], xliq = new double[20], xvap = new double[20];
            double[] xlkg = new double[20], xvkg = new double[20];

            double tk = 0.0, wm = 0.0;

            TextBox_TempPro_BubblePoint.Text = "";
            TextBox_TempPro_DewPoint.Text    = "";

            string hpath = @"c:\Program Files (x86)\RefProp\fluids";
            long   size  = hpath.Length;

            hpath += new String(' ', 255 - (int)size);
            IRefProp64.SETPATHdll(hpath, ref size);

            long   numComps = 8;
            string hfld     = "methane|ethane|propane|butane|isobutan|pentane|ipentane|nitrogen";

            size = hfld.Length;

            hfld += new String(' ', 10000 - (int)size);

            string hfmix = "hmx.bnc" + new String(' ', 248);
            string hrf   = "DEF";
            string herr  = new String(' ', 255);

            iErr = 0;
            long hfldLen = hfld.Length, hfmixLen = hfmix.Length, hrfLen = hrf.Length, herrLen = herr.Length;

            numComps = -1;
            IRefProp64.SETUPdll(ref numComps, ref hfld, ref hfmix, ref hrf, ref iErr, ref herr, ref hfldLen, ref hfmixLen, ref hrfLen, ref herrLen);
            double version = iErr / 10000.0;

            TextBox_TempPro_RefPropDLLVersion.Text = Convert.ToString(version);

            numComps = 8;
            IRefProp64.SETUPdll(ref numComps, ref hfld, ref hfmix, ref hrf, ref iErr, ref herr, ref hfldLen, ref hfmixLen, ref hrfLen, ref herrLen);
            if (iErr != 0)
            {
                MessageBox.Show(herr, "RefProp SETUPdll() Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Get the individual components of the composition from the text fields
            x[0] = Convert.ToDouble(TextBox_InputSheet_Methane.Text);
            x[1] = Convert.ToDouble(TextBox_InputSheet_Ethane.Text);
            x[2] = Convert.ToDouble(TextBox_InputSheet_Propane.Text);
            x[3] = Convert.ToDouble(TextBox_InputSheet_Butane.Text);
            x[4] = Convert.ToDouble(TextBox_InputSheet_Isobutane.Text);
            x[5] = Convert.ToDouble(TextBox_InputSheet_Pentane.Text);
            x[6] = Convert.ToDouble(TextBox_InputSheet_Isopentane.Text);
            x[7] = Convert.ToDouble(TextBox_InputSheet_Nitrogen.Text);

            tk = Convert.ToDouble(t_textBox_2ndTab.Text); // temp in Kelvin
            p  = Convert.ToDouble(p_textBox_2ndTab.Text); // pressure in kPa

            IRefProp64.WMOLdll(x, ref wm);                // calculate molecular weight

            IRefProp64.TPFLSHdll(ref tk, ref p, x, ref d, ref Dl, ref Dv, xliq, xvap, ref q, ref ee, ref hh, ref ss, ref cp, ref cv, ref w, ref iErr, ref herr, ref herrLen);

            string[] values = { String.Format("{0,0:0.00}", d), String.Format("{0,0:0.00}", Dl), String.Format("{0,0:0.00}", Dv), String.Format("{0,0:0.00}", q), String.Format("{0,0:0.00}", ee), String.Format("{0,0:0.00}", hh), String.Format("{0,0:0.00}", ss), String.Format("{0,0:0.00}", cp), String.Format("{0,0:0.00}", cv), String.Format("{0,0:0.00}", w), String.Format("{0,0:0}", iErr), herr };

            DataGridView_2ndTab.Rows.Add(values);

            kph = 1;
            IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);

            if (iErr == 0)
            {
                TextBox_TempPro_BubblePoint.Text = String.Format("{0:n1}", te);
            }
            else
            {
                TextBox_TempPro_BubblePoint.Text = "-- ";
            }

            kph = 2;
            IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
            if (iErr == 0)
            {
                TextBox_TempPro_DewPoint.Text = String.Format("{0:n1}", te);
            }
            else
            {
                TextBox_TempPro_DewPoint.Text = "-- ";
            }

            TextBox_TempPro_MolecularWeight.Text = String.Format("{0:n2}", wm);

            double critTemp = 0.0, critPressure = 0.0, critDensity = 0.0;

            IRefProp64.CRITPdll(x, ref critTemp, ref critPressure, ref critDensity, ref iErr, ref herr, ref herrLen);

            if (iErr == 0)
            {
                TextBox_TempPro_CriticalPoint_Temp.Text = String.Format("{0:n1}", critTemp);

                TextBox_TempPro_CriticalPoint_Press.Text = String.Format("{0:n1}", critPressure);

                TextBox_TempPro_CriticalPoint_Density.Text = String.Format("{0:n1}", critDensity);
            }
            else
            {
                TextBox_TempPro_CriticalPoint_Temp.Text = TextBox_TempPro_CriticalPoint_Press.Text = TextBox_TempPro_CriticalPoint_Density.Text = "N/A";
            }
        }
示例#2
0
        // called when the R404A Calc button is pressed
        private void button3_Click(object sender, EventArgs eventArgs)
        {
            long iErr, kph = 1;

            double te = 0.0, p = 0.0, d = 0.0, Dl = 0.0, Dv = 0.0, q = 0.0, h = 0.0, ee = 0.0, hh = 0.0, ss = 0.0, cp = 0.0, cv = 0.0, w = 0.0;

            double[] x    = new double[20], xliq = new double[20], xvap = new double[20];
            double[] xlkg = new double[20], xvkg = new double[20];


            double tk = 0.0, wm = 0.0, prevDeltaH = 0.0;

            TextBox_1stTab_BubblePoint.Text = "";
            TextBox_1stTab_DewPoint.Text    = "";

            string hpath = @"c:\Program Files (x86)\RefProp\fluids";
            long   size  = hpath.Length;

            hpath += new String(' ', 255 - (int)size);
            IRefProp64.SETPATHdll(hpath, ref size);

            long   numComps = 3;
            string hfld     = "R125.FLD|R134A.FLD|R143A.FLD|";

            size = hfld.Length;

            hfld += new String(' ', 10000 - (int)size);

            string hfmix = "hmx.bnc" + new String(' ', 248);
            string hrf   = "DEF";
            string herr  = new String(' ', 255);

            iErr = 0;
            long hfldLen = hfld.Length, hfmixLen = hfmix.Length, hrfLen = hrf.Length, herrLen = herr.Length;

            numComps = -1;
            IRefProp64.SETUPdll(ref numComps, ref hfld, ref hfmix, ref hrf, ref iErr, ref herr, ref hfldLen, ref hfmixLen, ref hrfLen, ref herrLen);
            double version = iErr / 10000.0;

            TextBox_1stRab_RefPropDLLVersion.Text = Convert.ToString(version);

            numComps = 3;
            IRefProp64.SETUPdll(ref numComps, ref hfld, ref hfmix, ref hrf, ref iErr, ref herr, ref hfldLen, ref hfmixLen, ref hrfLen, ref herrLen);
            if (iErr != 0)
            {
                MessageBox.Show(herr, "RefProp SETUPdll() Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Composition
            x[0] = Convert.ToDouble(TextBox_R125_FLD.Text);
            x[1] = Convert.ToDouble(TextBox_R134A_FLD.Text);
            x[2] = Convert.ToDouble(TextBox_R143A_FLD.Text);

            tk = Convert.ToDouble(textBox_t_1stTab.Text);
            p  = Convert.ToDouble(textBox_p_1stTab.Text);

            IRefProp64.SATSPLNdll(x, ref iErr, ref herr, ref herrLen);

            IRefProp64.WMOLdll(x, ref wm);
            TextBox_1stTab_MolecularWeight.Text = String.Format("{0,0:0.0}", wm);

            IRefProp64.TPFLSHdll(ref tk, ref p, x, ref d, ref Dl, ref Dv, xliq, xvap, ref q, ref ee, ref hh, ref ss, ref cp, ref cv, ref w, ref iErr, ref herr, ref herrLen);

            string[] values = { String.Format("{0,0:0.00}", d), String.Format("{0,0:0.00}", Dl), String.Format("{0,0:0.00}", Dv), String.Format("{0,0:0.00}", q), String.Format("{0,0:0.00}", ee), String.Format("{0,0:0.00}", hh), String.Format("{0,0:0.00}", ss), String.Format("{0,0:0.00}", cp), String.Format("{0,0:0.00}", cv), String.Format("{0,0:0.00}", w), String.Format("{0,0:0.00}", iErr), herr };

            DataGridView_1st.Rows.Add(values);

            prevDeltaH = h;

            kph = 1;
            IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);

            if (iErr == 0)
            {
                TextBox_1stTab_BubblePoint.Text = String.Format("{0:n1}", te);
            }
            else
            {
                TextBox_1stTab_BubblePoint.Text = "-- ";
            }

            kph = 2;
            IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
            if (iErr == 0)
            {
                TextBox_1stTab_DewPoint.Text = String.Format("{0:n1}", te);
            }
            else
            {
                TextBox_1stTab_DewPoint.Text = "-- ";
            }

            TextBox_1stTab_MolecularWeight.Text = String.Format("{0:n2}", wm);

            double critTemp = 0.0, critPressure = 0.0, critDensity = 0.0;

            IRefProp64.CRITPdll(x, ref critTemp, ref critPressure, ref critDensity, ref iErr, ref herr, ref herrLen);

            if (iErr == 0)
            {
                TextBox_1stRab_CriticalPoint_Temp.Text = String.Format("{0:n1}", critTemp);

                TextBox_1stRab_CriticalPoint_Press.Text = String.Format("{0:n1}", critPressure);

                TextBox_1stRab_CriticalPoint_Density.Text = String.Format("{0:n1}", critDensity);
            }
            else
            {
                TextBox_1stRab_CriticalPoint_Temp.Text = TextBox_1stRab_CriticalPoint_Press.Text = TextBox_1stRab_CriticalPoint_Density.Text = "N/A";
            }
        }