public static Capiliary_res CapiliaryCalc(int index, string fluid, double d_cap, double lenth_cap, double tri, double pri, double hri, double mr, double Pwater, int hexType, AbstractState coolprop, double[,] SourceTableData) { //毛细管守恒方程模型 //AbstractState coolprop = AbstractState.factory("HEOS", fluid); Capiliary_res res_cap = new Capiliary_res(); double Ar_cs = Math.PI * Math.Pow(d_cap, 2) / 4; double g = mr / Ar_cs; coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 0); double tsat = coolprop.T(); //double tsat = CoolProp.PropsSI("T", "P", pri * 1000, "Q", 0, fluid); coolprop.update(input_pairs.QT_INPUTS, 0, tsat); double h_l = coolprop.hmass() / 1000; //double h_l = CoolProp.PropsSI("H", "T", tsat, "Q", 0, fluid) / 1000; coolprop.update(input_pairs.QT_INPUTS, 1, tsat); double h_v = coolprop.hmass() / 1000; //double h_v = CoolProp.PropsSI("H", "T", tsat, "Q", 1, fluid) / 1000; double x_i = (hri - h_l) / (h_v - h_l); coolprop.update(input_pairs.PQ_INPUTS, (fluid == "Water" ? Pwater : pri) * 1000, 1); double rho_gi = coolprop.rhomass(); //double rho_gi = CoolProp.PropsSI("D", "Q", 1, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); coolprop.update(input_pairs.PQ_INPUTS, (fluid == "Water" ? Pwater : pri) * 1000, 0); double rho_li = coolprop.rhomass(); //double rho_li = CoolProp.PropsSI("D", "Q", 0, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double mgi = x_i * mr; double mli = (1 - x_i) * mr; double esp_i = 1 / (1 + (1 / x_i - 1) * rho_gi / rho_li); double Vgi = (x_i * mr) / (rho_gi * esp_i * Ar_cs); double Vli = (1 - x_i) * mr / (rho_li * (1 - esp_i) * Ar_cs); //初始化出口参数 double x_o = x_i; double mgo = mgi; double mlo = mli; double rho_go = rho_gi; double rho_lo = rho_li; double esp_o = esp_i; double Vgo_set = Vgi; double Vlo = Vli; double rho_avg = rho_gi * x_i + rho_li * (1 - x_i); coolprop.update(input_pairs.QT_INPUTS, 0, tsat); double ViscosityL = coolprop.viscosity(); //double ViscosityL = CoolProp.PropsSI("V", "T", tsat, "Q", 0, fluid); coolprop.update(input_pairs.QT_INPUTS, 1, tsat); double ViscosityV = coolprop.viscosity(); //double ViscosityV = CoolProp.PropsSI("V", "T", tsat, "Q", 1, fluid); double ViscosityTP = x_i * ViscosityV + (1 - x_i) * ViscosityL; double ReTP = g * d_cap / ViscosityTP; double f_tpi = 0.11 * Math.Pow(0.0014 + 68 / ReTP, 0.25);//0.0014表面粗糙度 double f_tp = f_tpi; double Vgo_cal = 0; int i = 0; double Pro = 0; double hro = 0; double tro = 0; coolprop.update(input_pairs.HmassP_INPUTS, hri * 1000, pri * 1000); double tro1 = coolprop.T() - 273.15; //double tro1 = CoolProp.PropsSI("T", "H", hri * 1000, "P", pri * 1000, fluid) - 273.15; double tro2 = 0; if (hri <= h_v && hri >= h_l) { do { if (i != 0) { Vgo_set = Vgo_cal; } //守恒方程 double a = f_tp / 4 * Math.Pow(mr, 2) / (2 * rho_avg * Math.Pow(Ar_cs, 2)) * Math.PI * d_cap + mr / lenth_cap * (x_o * Vgo_set + (1 - x_o) * Vlo) - mr / lenth_cap * (x_i * Vgi + (1 - x_i) * Vli); Pro = pri - lenth_cap / Ar_cs * (f_tp / 4 * Math.Pow(mr, 2) / (2 * rho_avg * Math.Pow(Ar_cs, 2)) * Math.PI * d_cap + mr / lenth_cap * (x_o * Vgo_set + (1 - x_o) * Vlo) - mr / lenth_cap * (x_i * Vgi + (1 - x_i) * Vli)); hro = 1 / mr * (mr * hri + 1 / 2 * mgi * Math.Pow(Vgi, 2) + 1 / 2 * mli * Math.Pow(Vli, 2) - 1 / 2 * mgo * Math.Pow(Vgo_set, 2) - 1 / 2 * mlo * Math.Pow(Vlo, 2)); //新一轮赋值 coolprop.update(input_pairs.PQ_INPUTS, Pro * 1000, 0); double tsato = coolprop.T(); //double tsato = CoolProp.PropsSI("T", "P", Pro * 1000, "Q", 0, fluid); coolprop.update(input_pairs.QT_INPUTS, 0, tsato); double h_lo = coolprop.hmass(); //double h_lo = CoolProp.PropsSI("H", "T", tsato, "Q", 0, fluid) / 1000; coolprop.update(input_pairs.QT_INPUTS, 1, tsato); double h_vo = coolprop.hmass(); //double h_vo = CoolProp.PropsSI("H", "T", tsato, "Q", 1, fluid) / 1000; coolprop.update(input_pairs.PQ_INPUTS, (fluid == "Water" ? Pwater : Pro) * 1000, 1); rho_go = coolprop.rhomass(); //rho_go = CoolProp.PropsSI("D", "Q", 1, "P", (fluid == "Water" ? Pwater : Pro) * 1000, fluid); coolprop.update(input_pairs.PQ_INPUTS, (fluid == "Water" ? Pwater : Pro) * 1000, 0); rho_lo = coolprop.rhomass(); //rho_lo = CoolProp.PropsSI("D", "Q", 0, "P", (fluid == "Water" ? Pwater : Pro) * 1000, fluid); x_o = (hro - h_lo) / (h_vo - h_lo); esp_o = 1 / (1 + (1 / x_o - 1) * rho_go / rho_lo); Vgo_cal = (x_o * mr) / (rho_go * esp_o * Ar_cs); Vlo = (1 - x_o) * mr / (rho_lo * (1 - esp_o) * Ar_cs); mgo = x_o * mr; mlo = (1 - x_o) * mr; rho_avg = (rho_gi * x_i + rho_li * (1 - x_i) + rho_go * x_o + rho_lo * (1 - x_o)) / 2; coolprop.update(input_pairs.QT_INPUTS, 0, tsato); double ViscosityLo = coolprop.viscosity(); //double ViscosityLo = CoolProp.PropsSI("V", "T", tsato, "Q", 0, fluid); coolprop.update(input_pairs.QT_INPUTS, 1, tsato); double ViscosityVo = coolprop.viscosity(); //double ViscosityVo = CoolProp.PropsSI("V", "T", tsato, "Q", 1, fluid); double ViscosityTPo = x_o * ViscosityVo + (1 - x_o) * ViscosityLo; double ReTPo = g * d_cap / ViscosityTPo; double f_tpo = 0.11 * Math.Pow(0.0014 + 68 / ReTPo, 0.25); f_tp = (f_tpi + f_tpo) / 2; i++; } while (Math.Abs((Vgo_cal - Vgo_set) / Vgo_cal) > 0.02); } else { do { if (i != 0) { tro1 = tro2; } if (i != 0) { Vgo_set = Vgo_cal; } //守恒方程 double a = f_tp / 4 * Math.Pow(mr, 2) / (2 * rho_avg * Math.Pow(Ar_cs, 2)) * Math.PI * d_cap + mr / lenth_cap * (x_o * Vgo_set + (1 - x_o) * Vlo) - mr / lenth_cap * (x_i * Vgi + (1 - x_i) * Vli); Pro = pri - lenth_cap / Ar_cs * (f_tp / 4 * Math.Pow(mr, 2) / (2 * rho_avg * Math.Pow(Ar_cs, 2)) * Math.PI * d_cap + mr / lenth_cap * (x_o * Vgo_set + (1 - x_o) * Vlo) - mr / lenth_cap * (x_i * Vgi + (1 - x_i) * Vli)); hro = 1 / mr * (mr * hri + 1 / 2 * mgi * Math.Pow(Vgi, 2) + 1 / 2 * mli * Math.Pow(Vli, 2) - 1 / 2 * mgo * Math.Pow(Vgo_set, 2) - 1 / 2 * mlo * Math.Pow(Vlo, 2)); //新一轮赋值 coolprop.update(input_pairs.PQ_INPUTS, Pro * 1000, 0); double tsato = coolprop.T(); //double tsato = CoolProp.PropsSI("T", "P", Pro * 1000, "Q", 0, fluid); coolprop.update(input_pairs.QT_INPUTS, 0, tsato); double h_lo = coolprop.hmass(); //double h_lo = CoolProp.PropsSI("H", "T", tsato, "Q", 0, fluid) / 1000; coolprop.update(input_pairs.QT_INPUTS, 1, tsato); double h_vo = coolprop.hmass(); //double h_vo = CoolProp.PropsSI("H", "T", tsato, "Q", 1, fluid) / 1000; coolprop.update(input_pairs.PQ_INPUTS, (fluid == "Water" ? Pwater : Pro) * 1000, 1); rho_go = coolprop.rhomass(); //rho_go = CoolProp.PropsSI("D", "Q", 1, "P", (fluid == "Water" ? Pwater : Pro) * 1000, fluid); coolprop.update(input_pairs.PQ_INPUTS, (fluid == "Water" ? Pwater : Pro) * 1000, 0); rho_lo = coolprop.rhomass(); //rho_lo = CoolProp.PropsSI("D", "Q", 0, "P", (fluid == "Water" ? Pwater : Pro) * 1000, fluid); x_o = (hro - h_lo) / (h_vo - h_lo); esp_o = 1 / (1 + (1 / x_o - 1) * rho_go / rho_lo); Vgo_cal = (x_o * mr) / (rho_go * esp_o * Ar_cs); Vlo = (1 - x_o) * mr / (rho_lo * (1 - esp_o) * Ar_cs); mgo = x_o * mr; mlo = (1 - x_o) * mr; rho_avg = (rho_gi * x_i + rho_li * (1 - x_i) + rho_go * x_o + rho_lo * (1 - x_o)) / 2; coolprop.update(input_pairs.QT_INPUTS, 0, tsato); double ViscosityLo = coolprop.viscosity(); //double ViscosityLo = CoolProp.PropsSI("V", "T", tsato, "Q", 0, fluid); coolprop.update(input_pairs.QT_INPUTS, 1, tsato); double ViscosityVo = coolprop.viscosity(); //double ViscosityVo = CoolProp.PropsSI("V", "T", tsato, "Q", 1, fluid); double ViscosityTPo = x_o * ViscosityVo + (1 - x_o) * ViscosityLo; double ReTPo = g * d_cap / ViscosityTPo; double f_tpo = 0.11 * Math.Pow(0.0014 + 68 / ReTPo, 0.25); f_tp = (f_tpi + f_tpo) / 2; coolprop.update(input_pairs.HmassP_INPUTS, hro * 1000, Pro * 1000); tro2 = coolprop.T() - 273.15; //tro2 = CoolProp.PropsSI("T", "H", hro * 1000, "P", Pro * 1000, fluid) - 273.15; i++; } while (Math.Abs(tro2 - tro1) > 0.02); } double DP_cap = pri - Pro; coolprop.update(input_pairs.HmassP_INPUTS, hro * 1000, Pro * 1000); tro = coolprop.T() - 273.15; //tro = CoolProp.PropsSI("T", "H", hro * 1000, "P", Pro * 1000, fluid) - 273.15; res_cap.pro = Pro; res_cap.hro = hro; res_cap.tro = tro; res_cap.DP_cap = DP_cap; res_cap.x_o = x_o; return(res_cap); }
public static CalcResult CircuitCalc(int index, CirArr[] cirArr, CircuitNumber CircuitInfo, int Nrow, int[] Ntube, int Nelement, string fluid, double l, Geometry geo, double[, ,] ta, double[, ,] RH, double tri, double pri, double hri, double mr, double[,] ma, double[,] ha, double[,] haw, double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity, double Pwater, CapiliaryInput cap_inlet, CapiliaryInput cap_outlet, AbstractState coolprop, double[,] SourceTableData) { #region 算进口毛细管 //调用毛细管守恒方程模型 /// double DP_cap = 0; int N = 1; Capiliary_res[] res_cap_in = new Capiliary_res[N]; if (cap_inlet.d_cap[index] == 0 && cap_inlet.lenth_cap[index] == 0) { pri = pri; hri = hri; tri = tri; } else { for (int i = 0; i < N; i++) { res_cap_in[i] = Capiliary.CapiliaryCalc(index, fluid, cap_inlet.d_cap[index], cap_inlet.lenth_cap[index] / N, tri, pri, hri, mr, Pwater, hexType, coolprop, SourceTableData); pri = res_cap_in[i].pro; hri = res_cap_in[i].hro; tri = res_cap_in[i].tro; DP_cap += res_cap_in[i].DP_cap; } } #endregion #region 算流路 /// //******蒸发器毛细管******// int N_tube = Ntube[0]; //int Ncir = CircuitInfo.number[0]; int Ncir = CircuitInfo.TubeofCir.Length; int[] TubeofCir = CircuitInfo.TubeofCir; CalcResult res_cir = new CalcResult(); CalcResult[] r = new CalcResult[TubeofCir[index]]; int iRow = 0; int iTube = 0; double[] tai = new double[Nelement]; double[] RHi = new double[Nelement]; double[, ,] taout_calc = new double[Nelement, N_tube, Nrow]; double[, ,] RHout_calc = new double[Nelement, N_tube, Nrow]; double[,] Q_detail = new double[N_tube, Nrow];//detail output double[,] DP_detail = new double[N_tube, Nrow]; double[,] Tri_detail = new double[N_tube, Nrow]; double[,] Pri_detail = new double[N_tube, Nrow]; double[,] hri_detail = new double[N_tube, Nrow]; double[,] Tro_detail = new double[N_tube, Nrow]; double[,] Pro_detail = new double[N_tube, Nrow]; double[,] hro_detail = new double[N_tube, Nrow];// double[,] href_detail = new double[N_tube, Nrow]; double[,] mr_detail = new double[N_tube, Nrow]; double[,] charge_detail = new double[N_tube, Nrow]; double Ar = 0; double Aa = 0; double Aa_tube = 0; double Aa_fin = 0; double Ar_cs = 0; double pri_tube = 0; double tri_tube = 0; double hri_tube = 0; double[] ma_tube = new double[Nelement]; double[] ha_tube = new double[Nelement]; double[] haw_tube = new double[Nelement]; int index2 = 0; CheckAir airConverge = new CheckAir(); int iter = 0; //ma = ma / (N_tube*Nelement); //air flow distribution to be considered if (index == 0) { index2 = 0; } else { for (int i = 1; i <= index; i++) { index2 += TubeofCir[i - 1]; } } //do //{ pri_tube = pri; tri_tube = tri; hri_tube = hri; res_cir.DP = 0; // res_cir.Tao += r.Tao; res_cir.Q = 0; res_cir.M = 0; res_cir.Tro = 0; res_cir.Pro = 0; res_cir.hro = 0; res_cir.x_o = 0; res_cir.Vel_r = 0; res_cir.href = 0; res_cir.R_1 = 0; res_cir.R_1a = 0; res_cir.R_1r = 0; res_cir.mr = 0; for (int i = 0; i < TubeofCir[index]; i++) //to be updated //Nrow * N_tube { //index2 = index == 1 ? 0 : (index - 1) * TubeofCir[index - 1 - 1]; iRow = cirArr[i + index2].iRow; iTube = cirArr[i + index2].iTube; Ar = geo.ElementArea[iTube, iRow].A_r; Aa = geo.ElementArea[iTube, iRow].A_a; Aa_tube = geo.ElementArea[iTube, iRow].Aa_tube; Aa_fin = geo.ElementArea[iTube, iRow].Aa_fin; Ar_cs = geo.ElementArea[iTube, iRow].A_r_cs; //tai=ta[,iTube,iRow]; for (int j = 0; j < Nelement; j++) { tai[j] = ta[j, iTube, iRow]; RHi[j] = RH[j, iTube, iRow]; ma_tube[j] = ma[iTube, j]; ha_tube[j] = ha[iTube, j]; haw_tube[j] = haw[iTube, j]; } r[i] = Tube.TubeCalc(Nelement, fluid, l, Aa_fin, Aa_tube, Ar_cs, Ar, geo, tai, RHi, tri_tube, pri_tube, hri_tube, mr, ma_tube, ha_tube, haw_tube, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, coolprop, SourceTableData); if (r[i].Pro < 0) { res_cir.Pro = -10000000; return(res_cir); } /*if (Airdirection == "顺流") * { * for (int j = 0; j < Nelement; j++) * { * taout_calc[j, iTube, iRow] = r[i].Tao; * RHout_calc[j, iTube, iRow] = r[i].RHout; * ta[j, iTube, iRow+1] = r[i].Tao; * RH[j, iTube, iRow+1] = r[i].RHout; * } * } * else//Counter * { * for(int j=0;j<Nelement;j++) * { * taout_calc[j, iTube, iRow] =r[i].Tao_Detail[0, 0, j]; * RHout_calc[j, iTube, iRow] = r[i].RHout; * } * }*/ for (int j = 0; j < Nelement; j++) { taout_calc[j, iTube, iRow] = r[i].Tao_Detail[0, 0, j]; RHout_calc[j, iTube, iRow] = r[i].RHout; } Tri_detail[iTube, iRow] = tri_tube; Pri_detail[iTube, iRow] = pri_tube; hri_detail[iTube, iRow] = hri_tube; tri_tube = r[i].Tro; pri_tube = r[i].Pro; hri_tube = r[i].hro; res_cir.DP += r[i].DP; // res_cir.Tao += r.Tao; res_cir.Q += r[i].Q; Q_detail[iTube, iRow] = r[i].Q; //detail output DP_detail[iTube, iRow] = r[i].DP; Tro_detail[iTube, iRow] = r[i].Tro; Pro_detail[iTube, iRow] = r[i].Pro; hro_detail[iTube, iRow] = r[i].hro; href_detail[iTube, iRow] = r[i].href; mr_detail[iTube, iRow] = mr; charge_detail[iTube, iRow] = r[i].M; res_cir.M += r[i].M; res_cir.Tro = r[i].Tro; res_cir.Pro = r[i].Pro; res_cir.hro = r[i].hro; res_cir.x_o = r[i].x_o; res_cir.Vel_r = r[i].Vel_r; res_cir.href += r[i].href; res_cir.R_1 += r[i].R_1; res_cir.R_1a += r[i].R_1a; res_cir.R_1r += r[i].R_1r; res_cir.Tri = r[i].Tri; res_cir.x_i = r[i].x_i; } /* * if (Airdirection == "顺流") * airConverge.flag = true; * else//Counter * { * airConverge = CheckAirConvergeforCircuits.CheckAirConverge(Nrow, N_tube, Nelement, ta, RH, taout_calc, RHout_calc); * ta = airConverge.ta; * RH = airConverge.RH; * iter++; * } * } while (!airConverge.flag && iter < 100); */ //if (iter >= 100) //{ // throw new Exception("iter for AirConverge > 100."); //} res_cir.mr = mr; res_cir.Tao_Detail = taout_calc; res_cir.RHo_Detail = RHout_calc; //res_cir.Tao = res_cir.Tao / Nelement; res_cir.href = res_cir.href / TubeofCir[index]; res_cir.R_1 = res_cir.R_1 / TubeofCir[index]; res_cir.R_1a = res_cir.R_1a / TubeofCir[index]; res_cir.R_1r = res_cir.R_1r / TubeofCir[index]; res_cir.Q_detail = Q_detail;//detail output res_cir.DP_detail = DP_detail; res_cir.Tri_detail = Tri_detail; res_cir.Pri_detail = Pri_detail; res_cir.hri_detail = hri_detail; res_cir.Tro_detail = Tro_detail; res_cir.Pro_detail = Pro_detail; res_cir.hro_detail = hro_detail; res_cir.href_detail = href_detail; res_cir.mr_detail = mr_detail; #endregion #region 算出口毛细管 //调用毛细管守恒方程模型 ----需要校核,调整---- /// N = 1; Capiliary_res[] res_cap_out = new Capiliary_res[N]; //double DP_cap = 0; if (cap_outlet.d_cap[index] == 0 && cap_outlet.lenth_cap[index] == 0) { pri = pri; hri = hri; tri = tri; } else { for (int i = 0; i < N; i++) { res_cap_out[i] = Capiliary.CapiliaryCalc(index, fluid, cap_outlet.d_cap[index], cap_outlet.lenth_cap[index] / N, res_cir.Tro, res_cir.Pro, res_cir.hro, mr, Pwater, hexType, coolprop, SourceTableData); res_cir.Pro = res_cap_out[i].pro; res_cir.hro = res_cap_out[i].hro; res_cir.Tro = res_cap_out[i].tro; DP_cap += res_cap_out[i].DP_cap; } } #endregion //增加毛细管模型的单流路总压降 res_cir.DP = res_cir.DP + DP_cap; res_cir.DP_cap = DP_cap; res_cir.charge_detail = charge_detail; return(res_cir); }