Exemple #1
0
        public static CalcResult ElementCal(string[] fluid, double[] composition, double dh, double l,
                                            double Aa_fin, double Aa_tube, double A_r_cs, double Ar, double tai,
                                            double tri, double pri, double hri, double mr, double g, double ma, double ha,
                                            double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity, double Pwater)
        {
            var    r    = new Refrigerant.SATTTotalResult();
            double href = 0;
            double gg   = 9.8;
            double tsat;
            int    phase1 = 1;
            int    phase2 = 2;

            tsat = Refrigerant.SATP(fluid, composition, pri, phase1).Temperature;
            r    = Refrigerant.SATTTotal(fluid, composition, tsat).SATTTotalResult;

            double Vol_tubes = A_r_cs * l;   //Tube volume, for charge calculation
            double h_l       = r.EnthalpyL;
            double h_v       = r.EnthalpyV;
            double Tri_mod;
            double alpha;
            double M;
            var    res_element = new CalcResult();

            // **********Superheated state**********
            if (hri > h_v && fluid[0] != "Water")
            {
                if (hri < 1.02 * h_v)
                {
                    Tri_mod = tri + 0.5;   //"for Tri modification in the transition region"
                }
                else
                {
                    Tri_mod = tri;
                }

                res_element     = SPElement.ElementCalc(fluid, composition, dh, l, Aa_fin, Aa_tube, A_r_cs, Ar, tai, Tri_mod, pri, hri, mr, g, ma, ha, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater);
                res_element.x_i = (hri - h_l) / (h_v - h_l);
                res_element.x_o = (res_element.hro - h_l) / (h_v - h_l);
                alpha           = 1;                                                                  //set void fraction to 1 to identify a superheated state
                //{Equations are for charge calculation}
                double T_avg = (tri + res_element.Tro) / 2;                                           //Average temperature of the element
                double P_avg = (pri + res_element.Pro) / 2;                                           //Average pressure of the element
                double rho   = Refrigerant.TPFLSH(fluid, composition, T_avg + 273.15, P_avg).D *r.Wm; //density(ref$, T=T_avg, P=P_avg)
                M = Vol_tubes * rho;                                                                  //"Mass calculated"
            }

            // **********Twophase state**********"
            if (hri <= h_v && hri >= h_l && fluid[0] != "Water")
            {
                res_element = TPElement.ElementCalc(fluid, composition, dh, l, Aa_fin, Aa_tube, A_r_cs, Ar, tai, tri, pri, hri, mr, g, ma, ha, eta_surface, zh, zdp, hexType, thickness, conductivity);
                //x=x_o  "outlet quality of the element"
                double x_avg = (res_element.x_i + res_element.x_o) / 2; //Average quality of the element
                if (x_avg < 0)                                          //"If negative, set quality to inlet value"
                {
                    x_avg = res_element.x_i;
                }

                double T_avg = (tri + res_element.Tro) / 2;  //Average temperature of the element
                //Call VOIDFRACTION_charge(ref$,x_avg, T_avg, G_r, Dh: alpha) "Average void fraction of the element"
                alpha = 1;
                //{Equations are for charge calculation}
                double P_avg = (pri + res_element.Pro) / 2; //Average pressure of the element
                double rho_l = Refrigerant.SATP(fluid, composition, P_avg, phase1).DensityL *r.Wm;
                double rho_v = Refrigerant.SATP(fluid, composition, P_avg, phase1).DensityV *r.Wm;
                //{Call VOIDFRACTION_pressure(ref$, x_avg, P_avg : alpha_p)  "Baroczy void fraction model"     }
                M = Vol_tubes * (alpha * rho_v + (1 - alpha) * rho_l);  //Mass calculated
            }

            //**********Subcooled state**********
            if (hri < h_l || fluid[0] == "Water")
            {
                if (hri > 0.98 * h_l)
                {
                    Tri_mod = tri - 0.5;    //"for Tri modification in the transition region"
                }
                else
                {
                    Tri_mod = tri;
                }

                if (fluid[0] == "Water")
                {
                    Tri_mod = tri - 0.0001;
                }

                res_element = SPElement.ElementCalc(fluid, composition, dh, l, Aa_fin, Aa_tube, A_r_cs, Ar, tai, Tri_mod, pri, hri, mr, g, ma, ha, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater);
                //Call SUBCOOLED(ref$, Dh, L, A_a, A_r, Tai, Tri_mod, Pri, hri, m_r, G_r, m_a, h_air, eta_surface: Tro, Pro, hro, Tao, Q, h_ref, R_1, R_1a, R_1r, DELTAP, Vel_r )
                res_element.x_i = (hri - h_l) / (h_v - h_l);
                res_element.x_o = (res_element.hro - h_l) / (h_v - h_l);
                //x=x_o  "outlet quality of the element"
                //{x=-1 "set quality to -100 to identify a subcooled state"}
                alpha = -1;                                                                  //set void fraction to -100 to identify a subcooled state
                //{Equations are for charge calculation}
                double T_avg = (tri + res_element.Tro) / 2;                                  //Average temperature of the element
                double P_avg = (pri + res_element.Pro) / 2;                                  //Average pressure of the element
                double rho   = Refrigerant.TPFLSH(fluid, composition, T_avg, P_avg).D *r.Wm; //density(ref$, T=T_avg, P=P_avg)
                M = Vol_tubes * rho;                                                         //Mass calculated
            }


            return(res_element);
        }
Exemple #2
0
        public static CalcResult ElementCalc(string[] fluid, double[] composition, double dh, double l, double Aa_fin, double Aa_tube, double A_r_cs, double Ar, double tai,
                                             double tri, double pri, double hri, double mr, double g, double ma, double ha,
                                             double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity)
        {
            double r_metal = thickness / conductivity / Ar;
            double gg      = 9.8;
            //double temperature;
            int    phase1    = 1;
            int    phase2    = 2;
            double q_initial = 0.01;
            double q         = q_initial;
            double err       = 0.01;
            bool   flag      = false;
            int    iter      = 1;

            CalcResult res = new CalcResult();
            //res.Tao[0] = new double();
            var r = new Refrigerant.SATTTotalResult();

            //temperature = Refrigerant.SATP(fluid, composition, pri, phase1).Temperature;
            r       = Refrigerant.SATTTotal(fluid, composition, tri + 273.15).SATTTotalResult; //temperature
            res.x_i = (hri - r.EnthalpyL) / (r.EnthalpyV - r.EnthalpyL);                       //+ 140 for reference state, to be changed

            RefHTCandDPResult htc_dp = new RefHTCandDPResult();

            do
            {
                flag   = false;
                htc_dp = RefrigerantHTCandDP.HTCandDP(fluid, composition, dh, g, pri, res.x_i, l, q, zh, zdp);

                res.href = htc_dp.Href;
                res.DP   = htc_dp.DPref;
                double cp_a = 1.0; //keep it for now as a constant
                cp_a = (hexType == 0 ? 1.027 : 1.02);
                double C_a = ma * cp_a;
                res.R_1a = 1 / ((eta_surface * Aa_fin + Aa_tube) * ha);
                res.R_1r = 1 / (res.href * Ar);
                res.R_1  = res.R_1a + res.R_1r + r_metal;
                double UA      = 1 / res.R_1;
                double NTU     = UA / (C_a * 1000);
                double epsilon = 1 - Math.Exp(-NTU);
                res.Q   = epsilon * C_a * Math.Abs(tai - tri);
                res.Tao = tai + Math.Pow(-1, (hexType + 1)) * res.Q / C_a;
                res.hro = hri + Math.Pow(-1, hexType) * res.Q / mr;
                //0:evap, 1:cond

                res.x_o = (res.hro - r.EnthalpyL) / (r.EnthalpyV - r.EnthalpyL); //+ 139.17 for reference state, to be changed
                //res.DP = 0;
                res.Pro = pri - res.DP;
                res.Tro = Refrigerant.PHFLSH(fluid, composition, res.Pro, (res.hro + (fluid[0] == "Water" ? 0 : 140)) * r.Wm).t; //
                double rho_o = Refrigerant.TQFLSH(fluid, composition, res.Tro, res.x_o).D *r.Wm;
                //    .TPFLSH(fluid, composition, res.Tro, res.Pro).D * r.Wm;//wrong value
                //double rho_o = Refrigerant.PHFLSH(fluid, composition, res.Pro, (res.hro + 140) * r.Wm).D * r.Wm;
                //if (res.x_o > 1 || res.x_o < 0)
                //    rho_o = Refrigerant.PHFLSH(fluid, composition, res.Pro, res.hro).D;
                ////rho_o=density(ref$, P=Pri, T=Tro)
                //else
                //    rho_o = 0;
                //    //rho_o=density(ref$, P=Pri, x=x_o)
                res.Tro   = res.Tro - 273.15;
                res.Vel_r = g / rho_o;
                if (Math.Abs(q - res.Q) / res.Q > err)
                {
                    q    = res.Q;
                    flag = true;
                }
                iter++;
            } while (flag && iter < 100);

            if (iter >= 100)
            {
                throw new Exception("iter for href > 100.");
            }
            return(res);
        }