public static double Shah_Evap_href(string fluid, double d, double g, double p, double x, double q, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double temperature; double DensityL, DensityV, EnthalpyL, EnthalpyV, ViscosityL, KL, CpL; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); temperature = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, temperature); DensityL = coolprop.rhomass(); EnthalpyL = coolprop.hmass() / 1000; ViscosityL = coolprop.viscosity(); CpL = coolprop.cpmass() / 1000; KL = coolprop.conductivity(); coolprop.update(input_pairs.QT_INPUTS, 1, temperature); DensityV = coolprop.rhomass(); EnthalpyV = coolprop.hmass() / 1000; double Pr_l = CpL * ViscosityL / KL * 1000; double h_fg = EnthalpyV - EnthalpyL; //"KJ" double qflux = q / (l * 3.14159 * d); double Bo = qflux / (g * h_fg); double Co = Math.Pow(1 / x - 1, 0.8) * Math.Pow(DensityV / DensityL, 0.5); double Fr_l = Math.Pow(g, 2.0) / (Math.Pow(DensityL, 2.0) * 9.8 * d); double h_LO = 0.023 * Math.Pow(g * (1 - x) * d / ViscosityL, 0.8) * Math.Pow(Pr_l, 0.4) * (KL / d); double h_LT = 0.023 * Math.Pow(g * (1 - 0) * d / ViscosityL, 0.8) * Math.Pow(Pr_l, 0.4) * (KL / d); int N = 0; double f = 0.0; if (Fr_l > 0.04) { N = 0; } else { N = 1; } if (Bo > 0.0011) { f = 14.7; } else { f = 15.43; } double h1 = 230 * Math.Pow(Bo, 0.5) * h_LO; double h2 = 1.8 * Math.Pow(Co * Math.Pow(0.38 * Math.Pow(Fr_l, -0.3), N), -0.8) * h_LO; double h3 = f * Math.Pow(Bo, 0.5) * Math.Exp(2.47 * Math.Pow(Co * Math.Pow(0.38 * Math.Pow(Fr_l, -0.3), N), -0.15)) * h_LO; double h4 = f * Math.Pow(Bo, 0.5) * Math.Exp(2.74 * Math.Pow(Co * Math.Pow(0.38 * Math.Pow(Fr_l, -0.3), N), -0.1)) * h_LO; double h5 = h_LT; double href = Math.Max(Math.Max(Math.Max(Math.Max(h1, h2), h3), h4), h5); return(href); }
public static double deltap_JR(string fluid, double d, double g, double p, double x, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double DensityL, DensityV, ViscosityL, ViscosityV; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); double tsat = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, tsat); DensityL = coolprop.rhomass(); ViscosityL = coolprop.viscosity(); coolprop.update(input_pairs.QT_INPUTS, 1, tsat); DensityV = coolprop.rhomass(); ViscosityV = coolprop.viscosity(); double Re_l = g * d / ViscosityL; double f_sp = RefrigerantSPDP.ff_Friction(Re_l); double DP_L = f_sp / d * Math.Pow(g, 2.0) / DensityL / 2000; double dp = 0; if (x <= 1.0)//0.93 { double X_tt = Math.Pow(1 / x - 1, 0.9) * Math.Pow(DensityV / DensityL, 0.5) * Math.Pow(ViscosityL / ViscosityV, 0.1); double f_tp = 12.82 * Math.Pow(X_tt, -1.47) * Math.Pow(1 - x, 1.8); double f_fo = 0.046 * Math.Pow(Re_l, -0.2); double DP_l = 2 * f_fo * Math.Pow(g, 2.0) / (DensityL * d); double DP_tp = DP_l * f_tp; dp = Math.Max(DP_L, DP_tp) * l; dp = dp * 0.001; } else { double Re_v = g * d / ViscosityV; double f_sp1 = RefrigerantSPDP.ff_Friction(Re_v); double DP_1 = f_sp1 / d * Math.Pow(g, 2.0) / DensityV / 2000; double x_point93 = 0.93; double X_tt = Math.Pow(1 / x_point93 - 1, 0.9) * Math.Pow(DensityV / DensityL, 0.5) * Math.Pow(ViscosityL / ViscosityV, 0.1); double f_tp = 12.82 * Math.Pow(X_tt, -1.47) * Math.Pow(1 - x_point93, 1.8); double f_fo = 0.046 * Math.Pow(Re_l, -0.2); double DP_l = 2 * f_fo * Math.Pow(g, 2.0) / (DensityL * d); double DP_tp_point93 = DP_l * f_tp; double DP_tp = (DP_tp_point93 + (x - 0.8) / (1.0 - 0.93) * (DP_1 - DP_tp_point93)) * l; dp = DP_tp * 0.001; } return(dp); }
public static double Kandlikar_Evap_href(string fluid, double d, double g, double p, double x, double q, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double temperature; double a_g = 9.8; double DensityL, DensityV, EnthalpyL, EnthalpyV, ViscosityL, KL, CpL; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); temperature = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, temperature); DensityL = coolprop.rhomass(); EnthalpyL = coolprop.hmass() / 1000; ViscosityL = coolprop.viscosity(); CpL = coolprop.cpmass() / 1000; KL = coolprop.conductivity(); coolprop.update(input_pairs.QT_INPUTS, 1, temperature); DensityV = coolprop.rhomass(); EnthalpyV = coolprop.hmass() / 1000; //KL = CoolProp.PropsSI("L", "T", temperature, "Q", 0, fluid); double Pr_l = CpL * ViscosityL / KL * 1000; double Re_l = g * d * (1 - x) / ViscosityL; double h_fg = (EnthalpyV - EnthalpyL); double qflux = q / (l * 3.14159 * d); double Fr_l = 0; if (fluid == "Water") { Fr_l = 1; } else if (fluid == "R11") { Fr_l = 1.3; } else if (fluid == "R12") { Fr_l = 1.5; } else if (fluid == "R22") { Fr_l = 2.2; } else if (fluid == "R113") { Fr_l = 1.3; } else if (fluid == "R114") { Fr_l = 1.24; } else if (fluid == "R152a") { Fr_l = 1.1; } else if (fluid == "R13B1") { Fr_l = 1.31; } else if (fluid == "Nitrogen") { Fr_l = 4.7; //液氮 } else if (fluid == "Neon") { Fr_l = 3.5; //液氖 } else { Fr_l = 1; } double c1 = 1.136; double c2 = -0.9; double c3 = 1058; double c4 = 0.7; double c5 = 0.3; if (Fr_l > 0.04) { c5 = 0; } double Fr_lo = Math.Pow(g, 2) / (Math.Pow(DensityL, 2) * a_g * d); double Bo = qflux / (g * h_fg); double Co = Math.Pow(DensityV / DensityL, 0.5) * Math.Pow(1 / x - 1, 0.8); double h_L = 0.023 * Math.Pow(Re_l, 0.8) * Math.Pow(Pr_l, 0.4) * KL / d; double href = (c1 * Math.Pow(Co, c2) * Math.Pow(25 * Fr_lo, c5) + c3 * Math.Pow(Bo, c4) * Fr_l) * h_L; return(href); }
public static double Dobson_Cond_href(string fluid, double d, double g, double p, double x, double Ts, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double temperature; double a_g = 9.80665; double DensityL, DensityV, EnthalpyL, EnthalpyV, ViscosityL, ViscosityV, KL, CpL; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); temperature = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, temperature); DensityL = coolprop.rhomass(); EnthalpyL = coolprop.hmass() / 1000; ViscosityL = coolprop.viscosity(); CpL = coolprop.cpmass() / 1000; KL = coolprop.conductivity(); coolprop.update(input_pairs.QT_INPUTS, 1, temperature); DensityV = coolprop.rhomass(); EnthalpyV = coolprop.hmass() / 1000; ViscosityV = coolprop.viscosity(); double Pr_l = CpL * ViscosityL / KL * 1000; double Re_l = g * (1.0 - x) * d / ViscosityL; double X_tt = Math.Pow(DensityV / DensityL, 0.5) * Math.Pow(ViscosityL / ViscosityV, 0.1) * Math.Pow(1 / x - 1.0, 0.9); double Re_vo = g * d / ViscosityV; double G_a = a_g * DensityL * (DensityL - DensityV) * Math.Pow(d, 3.0) / Math.Pow(ViscosityL, 2.0); //double Tsat = 1; //double Ts = 0; double Ja_l = CpL * (temperature - Ts) / (EnthalpyV - EnthalpyL);//Ts : surface temperature of tube wall double Fr_l = Math.Pow(g, 2.0) / (Math.Pow(DensityL, 2.0) * g * d); double c1 = 0; double c2 = 0; if (Fr_l > 0 && Fr_l <= 0.7) { c1 = 4.172 + 5.48 * Fr_l - 1.564 * Math.Pow(Fr_l, 2.0); c2 = 1.773 - 0.169 * Fr_l; } else { c1 = 7.242; c2 = 1.655; } double alpha = 1.0 / (1.0 + (1.0 - x) / x * Math.Pow(DensityV / DensityL, 2.0 / 3.0)); double thita_l = 3.14159 - Math.Acos(2.0 * alpha - 1); double a = Math.Pow(1.376 + c1 / Math.Pow(X_tt, c2), 0.5); double Nu_forced = 0.0195 * Math.Pow(Re_l, 0.8) * Math.Pow(Pr_l, 0.4) * a; double Nu1 = 0.023 * Math.Pow(Re_l, 0.8) * Math.Pow(Pr_l, 0.4) * (1 + 2.22 / Math.Pow(X_tt, 0.89)); double Nu2 = 0.23 * Math.Pow(Re_vo, 0.12) / (1.0 + 1.11 * Math.Pow(X_tt, 0.58)) * Math.Pow(G_a * Pr_l / Ja_l, 0.25) + (1.0 - thita_l / 3.14159) * Nu_forced; double h_tp; double Fr_so = 0; if (Re_l <= 1250) { Fr_so = 0.025 * Math.Pow(Re_l, 1.59) * Math.Pow((1.0 + 1.09 * Math.Pow(X_tt, 0.039)) / X_tt, 1.5) * Math.Pow(G_a, -0.5); } else { Fr_so = 1.26 * Math.Pow(Re_l, 1.04) * Math.Pow((1.0 + 1.09 * Math.Pow(X_tt, 0.039)) / X_tt, 1.5) * Math.Pow(G_a, -0.5); } if (g >= 500) { h_tp = KL * Nu1 / d; } else { if (Fr_so <= 20) { h_tp = KL * Nu2 / d; } else { h_tp = KL * Nu1 / d; } } return(h_tp); }
public static double Shah_Cond_href(string fluid, double d, double g, double p, double x, double q, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double temperature; double pc; double a_g = 9.8; double DensityL, DensityV, EnthalpyL, EnthalpyV, ViscosityL, ViscosityV, KL, CpL; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); temperature = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, temperature); DensityL = coolprop.rhomass(); EnthalpyL = coolprop.hmass() / 1000; ViscosityL = coolprop.viscosity(); CpL = coolprop.cpmass() / 1000; KL = coolprop.conductivity(); coolprop.update(input_pairs.QT_INPUTS, 1, temperature); DensityV = coolprop.rhomass(); EnthalpyV = coolprop.hmass() / 1000; ViscosityV = coolprop.viscosity(); pc = coolprop.p_critical() / 1000; double pr = p / pc; double Pr_l = CpL * ViscosityL / KL * 1000.0; double Re_l = g * (1.0 - x) * d / ViscosityL; //double h_fg = r.EnthalpyV - r.EnthalpyL; //"KJ" //double qflux = q / (l * 3.14159 * d); //double Bo = qflux / (g * h_fg); //double Co = Math.Pow(1 / x - 1, 0.8) * Math.Pow(r.DensityV / r.DensityL, 0.5); //double Fr_l = Math.Pow(g, 2.0) / (Math.Pow(r.DensityL, 2.0) * 9.8 * d); //double h_LO = 0.023 * Math.Pow(g * (1 - x) * d / r.ViscosityL, 0.8) * Math.Pow(Pr_l, 0.4) * (r.KL / d); //double h_LT = 0.023 * Math.Pow(g * (1 - 0) * d / r.ViscosityL, 0.8) * Math.Pow(Pr_l, 0.4) * (r.KL / d); //int N = 0; //double f = 0.0; //if (Fr_l > 0.04) N = 0; else N = 1; //if (Bo > 0.0011) f = 14.7; else f = 15.43; //double h1 = 230 * Math.Pow(Bo, 0.5) * h_LO; //double h2 = 1.8 * Math.Pow(Co * Math.Pow(0.38 * Math.Pow(Fr_l, -0.3), N), -0.8) * h_LO; //double h3 = f * Math.Pow(Bo, 0.5) * Math.Exp(2.47 * Math.Pow(Co * Math.Pow(0.38 * Math.Pow(Fr_l, -0.3), N), -0.15)) * h_LO; //double h4 = f * Math.Pow(Bo, 0.5) * Math.Exp(2.74 * Math.Pow(Co * Math.Pow(0.38 * Math.Pow(Fr_l, -0.3), N), -0.1)) * h_LO; //double h5 = h_LT; //double href = Math.Max(Math.Max(Math.Max(Math.Max(h1, h2), h3), h4), h5); //return href; double Z = Math.Pow(1.0 / x - 1.0, 0.8) * Math.Pow(pr, 0.4); double J_g = x * g / Math.Pow(a_g * d * DensityV * (DensityL - DensityV), 0.5); double h_LS = 0.023 * Math.Pow(Re_l, 0.8) * Math.Pow(Pr_l, 0.4) * KL / d; double h_I = h_LS * (1 + 3.8 / Math.Pow(Z, 0.95)) * Math.Pow(ViscosityL / (14.0 * ViscosityV), (0.0058 + 0.557 * pr)); double h_Nu = 1.32 * Math.Pow(Re_l, -1.0 / 3.0) * Math.Pow(DensityL * (DensityL - DensityV) * a_g * Math.Pow(KL, 3.0) / Math.Pow(ViscosityL, 2.0), 1.0 / 3.0); double a = 0.95 / (1.254 + 2.27 * Math.Pow(Z, 1.249)); double b = 0.98 * Math.Pow(Z + 0.263, -0.62); double h_tp = 0; if (J_g <= a) { h_tp = h_Nu; } else { if (J_g >= b) { h_tp = h_I; } else { h_tp = h_I + h_Nu; } } return(h_tp); }
public static double JR_Evap_href(string fluid, double d, double g, double p, double x, double q, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double temperature; double a_g = 9.8; double sigma = 1; int phase1 = 1; double DensityL, DensityV, EnthalpyL, EnthalpyV, ViscosityL, ViscosityV, KL, CpL; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); temperature = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, temperature); DensityL = coolprop.rhomass(); EnthalpyL = coolprop.hmass() / 1000; ViscosityL = coolprop.viscosity(); CpL = coolprop.cpmass() / 1000; KL = coolprop.conductivity(); coolprop.update(input_pairs.QT_INPUTS, 1, temperature); DensityV = coolprop.rhomass(); EnthalpyV = coolprop.hmass() / 1000; ViscosityV = coolprop.viscosity(); double Pr_l = CpL * ViscosityL / KL * 1000; double Re_l = g * d * (1 - x) / ViscosityL; double h_fg = (EnthalpyV - EnthalpyL); double qflux = q / (l * 3.14159 * d); //单相流体的经验关联式 double Bo = qflux / (g * h_fg); double X_tt = Math.Pow(DensityV / DensityL, 0.5) * Math.Pow(1 / x - 1, 0.9) * Math.Pow(ViscosityL / ViscosityV, 0.1); double N = 1; if (X_tt < 1) { N = 4048 * Math.Pow(X_tt, 1.22) * Math.Pow(Bo, 1.13); } double F_p = 2.37 * Math.Pow(0.29 + 1 / X_tt, 0.85); //表面张力sigma的Refprop调用方法 double b_d = 0.0146 * (35 / 180 * 3.14159) * Math.Pow(2 * sigma / a_g / (DensityL - DensityV), 0.5); double h_L = 0.023 * Math.Pow(Re_l, 0.8) * Math.Pow(Pr_l, 0.4) * KL / d; double h_SA = 207 * KL / (b_d) * Math.Pow((qflux / KL) * (b_d / temperature), 0.745) * Math.Pow(DensityV / DensityL, 0.581) * Math.Pow(Pr_l, 0.533); double h_nbc = N * h_SA; double h_cec = F_p * h_L; double href = h_nbc + h_cec; return(href); //两相传热关联式 //重点理解混合物换热关联式对纯质换热关联式的修正 //混合工质两组分各自泡核沸腾的计算式不清楚 //double X = 500; //double Y = 30; //double X_1 = 500; //double X_2 = 500; //double b2 = (1 - X) * log((1.01 - X) / (1.01 - Y)) + X * log(X / Y); //double b3 = 0; //if (X < 0.01) //b3 = Math.Pow(Y/X, 0.1) - 1; //double b4 = 152 * Math.Pow(p / p_cmvc, 3.9); //double b5 = 0.92 * Math.Pow(abs(Y - X), 0.001) * Math.Pow(p / p_cmvc, 0.66); //double C_un = (1 + (b2 + b3) * (1 + b4)) * (1 + b5); //double N = 1; //if (X_tt < 1) //N = 4048 * Math.Pow(X_tt, 1.22) * Math.Pow(Bo, 1.13); //double F_p = 2.37 * Math.Pow(0.29 + 1 / X_tt, 0.85); //double C_me = 1 - 0.35 * Math.Pow(abs(Y - X), 1.56); //double h_lo = 0.023 * Math.Pow(Re_l, 0.8) * Math.Pow(Pr_l, 0.4) * r.KL / d; //double h_i = 1 / (X_1 / h_1 + X_2 / h_2); //double h_un = h_i / C_un; //double h_tp = N / C_un * h_un + C_me * F_p * h_lo; //return h_tp; }
static void Main(string[] args) { Console.Write("**************** INFORMATION ***************" + "\n"); Console.Write("This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell" + "\n"); Console.Write("CoolProp version:" + " " + CoolProp.get_global_param_string("version") + "\n"); Console.Write("CoolProp gitrevision:" + " " + CoolProp.get_global_param_string("gitrevision") + "\n"); Console.Write("CoolProp Fluids:" + " " + CoolProp.get_global_param_string("FluidsList") + "\n"); // See http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function for a list of inputs to high-level interface; Console.Write("*********** HIGH LEVEL INTERFACE *****************" + "\n"); Console.Write("Critical temperature of water:" + " " + CoolProp.Props1SI("Water", "Tcrit") + " " + "K" + "\n"); Console.Write("Boiling temperature of water at 101325 Pa:" + " " + CoolProp.PropsSI("T", "P", 101325, "Q", 0, "Water") + " " + "K" + "\n"); Console.Write("Phase of water at 101325 Pa and 300 K:" + " " + CoolProp.PhaseSI("P", 101325, "Q", 0, "Water") + "\n"); Console.Write("c_p of water at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("C", "P", 101325, "T", 300, "Water") + " " + "J/kg/K" + "\n"); Console.Write("c_p of water (using derivatives) at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("d(H)/d(T)|P", "P", 101325, "T", 300, "Water") + " " + "J/kg/K" + "\n"); Console.Write("*********** HUMID AIR PROPERTIES *****************" + "\n"); Console.Write("Humidity ratio of 50% rel. hum. air at 300 K, 101325 Pa:" + " " + CoolProp.HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5) + " " + "kg_w/kg_da" + "\n"); Console.Write("Relative humidity from last calculation:" + " " + CoolProp.HAPropsSI("R", "T", 300, "P", 101325, "W", CoolProp.HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5)) + " " + "(fractional)" + "\n"); Console.Write("*********** INCOMPRESSIBLE FLUID AND BRINES *****************" + "\n"); Console.Write("Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa:" + " " + CoolProp.PropsSI("D", "T", 300, "P", 101325, "INCOMP::MEG-50%") + " " + "kg/m^3" + "\n"); Console.Write("Viscosity of Therminol D12 at 350 K, 101325 Pa:" + " " + CoolProp.PropsSI("V", "T", 350, "P", 101325, "INCOMP::TD12") + " " + "Pa-s" + "\n"); // If you don't have REFPROP installed, disable the following lines; Console.Write("*********** REFPROP *****************" + "\n"); Console.Write("Critical temperature of water:" + " " + CoolProp.Props1SI("REFPROP::Water", "Tcrit") + " " + "K" + "\n"); Console.Write("Boiling temperature of water at 101325 Pa:" + " " + CoolProp.PropsSI("T", "P", 101325, "Q", 0, "REFPROP::Water") + " " + "K" + "\n"); Console.Write("c_p of water at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("C", "P", 101325, "T", 300, "REFPROP::Water") + " " + "J/kg/K" + "\n"); Console.Write("*********** TABULAR BACKENDS *****************" + "\n"); AbstractState TAB = AbstractState.factory("BICUBIC&HEOS", "R245fa"); TAB.update(input_pairs.PT_INPUTS, 101325, 300); Console.Write("Mass density of refrigerant R245fa at 300 K, 101325 Pa:" + " " + TAB.rhomass() + " " + "kg/m^3" + "\n"); Console.Write("*********** SATURATION DERIVATIVES (LOW-LEVEL INTERFACE) ***************" + "\n"); AbstractState AS_SAT = AbstractState.factory("HEOS", "R245fa"); AS_SAT.update(input_pairs.PQ_INPUTS, 101325, 0); Console.Write("First saturation derivative:" + " " + AS_SAT.first_saturation_deriv(parameters.iP, parameters.iT) + " " + "Pa/K" + "\n"); Console.Write("*********** LOW-LEVEL INTERFACE *****************" + "\n"); AbstractState AS = AbstractState.factory("HEOS", "Water&Ethanol"); DoubleVector z = new DoubleVector(new double[] { 0.5, 0.5 }); AS.set_mole_fractions(z); AS.update(input_pairs.PQ_INPUTS, 101325, 1); Console.Write("Normal boiling point temperature of water and ethanol:" + " " + AS.T() + " " + "K" + "\n"); // If you don't have REFPROP installed, disable the following block; Console.Write("*********** LOW-LEVEL INTERFACE (REFPROP) *****************" + "\n"); AbstractState AS2 = AbstractState.factory("REFPROP", "Methane&Ethane"); DoubleVector z2 = new DoubleVector(new double[] { 0.2, 0.8 }); AS2.set_mole_fractions(z2); AS2.update(input_pairs.QT_INPUTS, 1, 120); Console.Write("Vapor molar density:" + " " + AS2.keyed_output(parameters.iDmolar) + " " + "mol/m^3" + "\n"); }
public static CalcResult ElementCalc1(string fluid, double l, double Aa_fin, double Aa_tube, double A_r_cs, double Ar, Geometry geo, double tai, double RHi, double tri, double pri, double hri, double mr, double g, double ma, double ha, double haw, double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity, AbstractState coolprop, double[,] SourceTableData) { Model.HumidAirProp humidairprop = new Model.HumidAirProp(); RHi = RHi > 1 ? 1 : RHi; double dh = geo.Di; double r_metal = thickness / conductivity / Ar; double gg = 9.8; double q_initial = 0.01; double q = q_initial; bool flag = false; double err = 0.01; int iter = 1; CalcResult res = new CalcResult(); double EnthalpyL, EnthalpyV; coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 0); tri = coolprop.T() - 273.15; //tri = CoolProp.PropsSI("T", "P", pri * 1000, "Q", 0, fluid) - 273.15; coolprop.update(input_pairs.QT_INPUTS, 0, tri + 273.15); EnthalpyL = coolprop.hmass() / 1000; //EnthalpyL = CoolProp.PropsSI("H", "T", tri + 273.15, "Q", 0, fluid) / 1000; coolprop.update(input_pairs.QT_INPUTS, 1, tri + 273.15); EnthalpyV = coolprop.hmass() / 1000; //EnthalpyV = CoolProp.PropsSI("H", "T", tri + 273.15, "Q", 1, fluid) / 1000; res.x_i = (hri - EnthalpyL) / (EnthalpyV - EnthalpyL); RefHTCandDPResult htc_dp = new RefHTCandDPResult(); do { flag = false; htc_dp = RefrigerantHTCandDP.HTCandDP_2p(fluid, dh, g, pri, res.x_i, l, q, zh, zdp, hexType, coolprop); res.href = htc_dp.Href; res.DP = htc_dp.DPref; double k_fin = 237; double Fthickness = geo.Fthickness; double Pt = geo.Pt; double Pr = geo.Pr; double Do = geo.Do; double r_eta = Do / 2; double XD = Math.Pow((Pr * Pr + Pt * Pt / 4), 0.5) / 2; double XT = Pt / 2; double rf_r = 1.27 * XT / r_eta * Math.Pow((XD / XT - 0.3), 0.5); double m = Math.Pow((2 * ha / k_fin / Fthickness), 0.5); double fai = (rf_r - 1) * (1 + (0.3 + Math.Pow((m * r_eta * (rf_r - r_eta) / 2.5), (1.5 - 1 / 12 * rf_r)) * (0.26 * Math.Pow(rf_r, 0.3) - 0.3)) * Math.Log(rf_r)); double eta_0 = Math.Tanh(m * r_eta * fai) / m / r_eta / fai * Math.Cos(0.1 * m * r_eta * fai); double eta_a = (eta_0 * Aa_fin + Aa_tube) / (Aa_fin + Aa_tube); //// //double cp_a0 = CoolProp.HAPropsSI("C", "T", tai + 273.15, "P", 101325, "R", RHi); //double cp_a = 1005.1458551 + 0.1541627 * tai + 4.3454442 * RHi - 0.0090904 * Math.Pow(tai, 2) - 0.3409659 * Math.Pow(RHi, 2) - 0.0007819 * tai * RHi + 0.0001851 * Math.Pow(tai, 3) + 0.0049274 * Math.Pow(RHi, 3) + 0.0476513 * tai * Math.Pow(RHi, 2) + 0.020268209 * Math.Pow(tai, 2) * RHi; double cp_a = humidairprop.Cp(tai, RHi, SourceTableData); double UA = 1 / (1 / ha / (Aa_fin * eta_0 + Aa_tube) + 1 / (res.href * Ar) + r_metal); double Ntu_dry = UA / (ma * cp_a); double epsilon_dry = 1 - Math.Exp(-Ntu_dry); double Q_dry = epsilon_dry * ma * cp_a * (tai - tri) * Math.Pow(-1, hexType); double tao = tai - Q_dry / (ma * cp_a) * Math.Pow(-1, hexType); double hro = hri + Q_dry / 1000 / mr * Math.Pow(-1, hexType); double UA_o = ha * (Aa_fin * eta_0 + Aa_tube); double UA_i = res.href * Ar; double NTU_o = UA_o / (cp_a * ma); double T_so_a = (UA_o * tai + UA_i * tri) / (UA_o + UA_i); double T_so_b = (UA_o * tao + UA_i * tri) / (UA_o + UA_i); double Q = Q_dry; double Q_sensible = 0; //double omega_in0 = CoolProp.HAPropsSI("W", "T", tai + 273.15, "P", 101325, "R", RHi); //double omega_in = (-0.0682340 + 0.0292341 * tai + 4.1604535 * RHi - 0.0025985 * Math.Pow(tai, 2) - 0.0769009 * Math.Pow(RHi, 2) + 0.1246489 * tai * RHi + 6.008 * Math.Pow(10, -5) * Math.Pow(tai, 3) - 0.0006775 * Math.Pow(RHi, 3) + 0.0267183 * tai * Math.Pow(RHi, 2) + 0.019904969 * Math.Pow(tai, 2) * RHi) / 1000; double omega_in = humidairprop.O(tai, RHi, SourceTableData); //double hai0 = CoolProp.HAPropsSI("H", "T", tai + 273.15, "P", 101325, "R", RHi); //double hai = -244.2924077 + 1135.8711 * tai + 10101.404 * RHi - 12.968219 * Math.Pow(tai, 2) - 11.356807 * Math.Pow(RHi, 2) + 357.25464 * tai * RHi + 0.3178346 * Math.Pow(tai, 3) - 0.0024329 * Math.Pow(RHi, 3) + 44.100799 * tai * Math.Pow(RHi, 2) + 50.31444812 * Math.Pow(tai, 2) * RHi; double hai = humidairprop.H(tai, "R", RHi, SourceTableData); //double ha2 = ((1.006 + 1.805 * omega_in1) * tai + 2501 * omega_in1) * 1000;//采用湿空气 物性的关系来写 //double omega_out = omega_in; double hout_a = hai - Q / ma * Math.Pow(-1, hexType); ///// //***delete***// //res.RHout = CoolProp.HAPropsSI("R", "T", tao + 273.15, "P", 101325, "W", omega_out); //res.RHout = 0.0215344 - 0.0059467 * tao + 0.2386894 * (omega_out * 1000) + 0.0004378 * Math.Pow(tao, 2) + 0.0004635 * Math.Pow((omega_out * 1000), 2) - 0.0125912 * tao * (omega_out * 1000) - 9.134 * Math.Pow(10, -6) * Math.Pow(tao, 3) + 1.696 * Math.Pow(10, -6) * Math.Pow((omega_out * 1000), 3) - 2.214 * Math.Pow(10, -5) * tao * Math.Pow((omega_out * 1000), 2) + 0.000200865 * Math.Pow(tao, 2) * (omega_out * 1000); //***delete***// //double resRHout0 = CoolProp.HAPropsSI("R", "T", tao + 273.15, "P", 101325, "H", hout_a); //res.RHout = 0.0259124 - 0.0996818 * tao + 0.0934877 * (hout_a / 1000) + 0.0040018 * Math.Pow(tao, 2) - 0.0003662 * Math.Pow((hout_a / 1000), 2) - 0.0034077 * tao * (hout_a / 1000) - 1.76447 * Math.Pow(10, -5) * Math.Pow(tao, 3) - 2.74524 * Math.Pow(10, -6) * Math.Pow((hout_a / 1000), 3) + 2.99291 * Math.Pow(10, -5) * tao * Math.Pow((hout_a / 1000), 2) - 9.56644 * Math.Pow(10, -6) * Math.Pow(tao, 2) * (hout_a / 1000); double Tdp_out = humidairprop.Ts(hout_a, SourceTableData); res.RHout = humidairprop.RHI(tao, Tdp_out, SourceTableData); double f_dry = 0; if (hexType == 0 && tri < tai) { double hao = 0; //double Tdp0 = CoolProp.HAPropsSI("D", "T", tai + 273.15, "P", 101325, "R", RHi) - 273.15; //double Tdp = -273.15 + 241.0212518 + 0.5718833 * tai + 84.99553 * RHi + 0.002691 * Math.Pow(tai, 2) - 95.003186 * Math.Pow(RHi, 2) + 0.7135779 * tai * RHi - 2.691 / Math.Pow(10, 5) * Math.Pow(tai, 3) + 42.58183 * Math.Pow(RHi, 3) - 0.3227474 * tai * Math.Pow(RHi, 2) - 0.000884612 * Math.Pow(tai, 2) * RHi; double Tdp = humidairprop.Tdp(tai, RHi, SourceTableData); /* * double Ps = omega_in * 101325 / (0.622 + omega_in); * double Tdp1 = -39.957 - 1.8762 * Math.Log(Ps) + 1.1689 * Math.Pow(Math.Log(Ps), 2); * double Tdp3 = 8.22 + 12.4 * Math.Log(Ps) + 1.9 * Math.Pow(Math.Log(Ps), 2); * if (Tdp1 <= 0) * { * Tdp1 = -60.45 + 7.0322 * Math.Log(Ps) + 0.37 * Math.Pow(Math.Log(Ps), 2); * } */ if (T_so_b > Tdp) { f_dry = 1.0; Q = Q_dry; Q_sensible = Q; //omega_out = omega_in; } else { double T_ac = 0; double h_ac = 0; if (T_so_a < Tdp) { f_dry = 0.0; Q_dry = 0.0; T_ac = tai; h_ac = hai; } else { T_ac = Tdp + UA_i / UA_o * (Tdp - tri); epsilon_dry = (tai - T_ac) / (tai - tri); f_dry = -1.0 / Ntu_dry * Math.Log(1.0 - epsilon_dry); //double h_ac0 = CoolProp.HAPropsSI("H", "T", T_ac + 273.15, "P", 101325, "W", omega_in); //h_ac = -244.2924077 + 1135.8711 * T_ac + 10101.404 * RHi - 12.968219 * Math.Pow(T_ac, 2) - 11.356807 * Math.Pow(RHi, 2) + 357.25464 * T_ac * RHi + 0.3178346 * Math.Pow(T_ac, 3) - 0.0024329 * Math.Pow(RHi, 3) + 44.100799 * T_ac * Math.Pow(RHi, 2) + 50.31444812 * Math.Pow(T_ac, 2) * RHi; h_ac = humidairprop.H(T_ac, "Omega", omega_in, SourceTableData); Q_dry = ma * cp_a * (tai - T_ac); } //double h1 = 58.732687 * Math.Pow(tri + 273.15 + 0.01, 2) - 30921.970577 * (tri + 273.15 + 0.01) + 4075493.951473; double h1 = humidairprop.H(tri + 0.01, "R", 1, SourceTableData); //double h2 = 58.732687 * Math.Pow(tri + 273.15 - 0.01, 2) - 30921.970577 * (tri + 273.15 - 0.01) + 4075493.951473; double h2 = humidairprop.H(tri - 0.01, "R", 1, SourceTableData); double c_s = (h1 - h2) / 0.02; //double c_s0 = (CoolProp.HAPropsSI("H", "T", tri + 273.15 + 0.01, "P", 101325, "R", 1.0) - CoolProp.HAPropsSI("H", "T", tri + 273.15 - 0.01, "P", 101325, "R", 1.0)) / 0.02; m = Math.Pow((2 * haw / k_fin / Fthickness), 0.5); fai = (rf_r - 1) * (1 + (0.3 + Math.Pow((m * r_eta * (rf_r - r_eta) / 2.5), (1.5 - 1 / 12 * rf_r)) * (0.26 * Math.Pow(rf_r, 0.3) - 0.3)) * Math.Log(rf_r)); double eta_wet = Math.Tanh(m * r_eta * fai) / m / r_eta / fai * Math.Cos(0.1 * m * r_eta * fai); //eta_a = (eta_0 * Aa_fin + Aa_tube) / (Aa_fin + Aa_tube); UA_o = haw * (eta_wet * Aa_fin + Aa_tube); NTU_o = UA_o / (ma * cp_a); double UA_wet = 1 / (c_s / UA_i + cp_a / UA_o); double Ntu_wet = UA_wet / ma; double epsilon_wet = 1 - Math.Exp(-(1 - f_dry) * Ntu_wet); //double h_s_s_o0 = CoolProp.HAPropsSI("H", "T", tri + 273.15, "P", 101325, "R", 1.0); //double h_s_s_o = 58.732687 * Math.Pow(tri + 273.15, 2) - 30921.970577 * (tri + 273.15 - 0.01) + 4075493.951473; double h_s_s_o = humidairprop.H(tri, "R", 1, SourceTableData); double Q_wet = epsilon_wet * ma * (h_ac - h_s_s_o); Q = Q_wet + Q_dry; hao = h_ac - Q_wet / ma; double h_s_s_e = h_ac - (h_ac - hao) / (1 - Math.Exp(-(1 - f_dry) * NTU_o)); //double T_s_e0 = CoolProp.HAPropsSI("T","H",h_s_s_e,"P",101325,"R",1.0)-273.15; //double T_s_e = -273.15 - 1.96 * Math.Pow(10, -3) * Math.Pow(h_s_s_e / 1000, 2) + 0.5357597 * h_s_s_e / 1000 + 268.871551; double T_s_e = humidairprop.Ts(h_s_s_e, SourceTableData); tao = T_s_e + (T_ac - T_s_e) * Math.Exp(-(1 - f_dry) * NTU_o); Q_sensible = ma * cp_a * (tai - tao); hro = hri + Q / 1000 / mr; } hout_a = hai - Q / ma * Math.Pow(-1, hexType); //double resRHout00 = CoolProp.HAPropsSI("R", "T", tao + 273.15, "P", 101325, "H", hout_a); //res.RHout = 0.0259124 - 0.0996818 * tao + 0.0934877 * (hout_a / 1000) + 0.0040018 * Math.Pow(tao, 2) - 0.0003662 * Math.Pow((hout_a / 1000), 2) - 0.0034077 * tao * (hout_a / 1000) - 1.76447 * Math.Pow(10, -5) * Math.Pow(tao, 3) - 2.74524 * Math.Pow(10, -6) * Math.Pow((hout_a / 1000), 3) + 2.99291 * Math.Pow(10, -5) * tao * Math.Pow((hout_a / 1000), 2) - 9.56644 * Math.Pow(10, -6) * Math.Pow(tao, 2) * (hout_a / 1000); Tdp_out = humidairprop.Ts(hout_a, SourceTableData); res.RHout = humidairprop.RHI(tao, Tdp_out, SourceTableData); if (res.RHout > 1) { res.RHout = 1; //double tao0 = CoolProp.HAPropsSI("T", "H", hao, "P", 101325, "R", 1)-273.15; //tao = -273.15 - 1.96 * Math.Pow(10, -3) * Math.Pow(hao / 1000, 2) + 0.5357597 * hao / 1000 + 268.871551; tao = humidairprop.Ts(hao, SourceTableData); Q_sensible = ma * cp_a * (tai - tao); } } res.R_1a = 1 / ((eta_0 * Aa_fin + Aa_tube) * ha); res.R_1r = 1 / (res.href * Ar); res.R_1 = res.R_1a + res.R_1r + r_metal; res.Q = Q / 1000; res.Tao = tao; res.hro = hro; res.Pro = pri - res.DP; if (res.Pro < 0) { res.Pro = -10000000; return(res); } coolprop.update(input_pairs.HmassP_INPUTS, res.hro * 1000, res.Pro * 1000); res.Tro = coolprop.T() - 273.15; //res.Tro = CoolProp.PropsSI("T", "P", res.Pro * 1000, "H", res.hro * 1000, fluid); double rho_o = coolprop.rhomass(); //double rho_o = CoolProp.PropsSI("D", "P", res.Pro * 1000, "H", res.hro * 1000, fluid); res.Vel_r = g / rho_o; res.x_o = (res.hro - EnthalpyL) / (EnthalpyV - EnthalpyL); //+ 139.17 for reference state, to be changed if (Math.Abs(q - res.Q) / res.Q > err) { q = res.Q; flag = true; } iter++; } while (flag && iter < 20); //if (iter >= 20) //{ // throw new Exception("iter for href > 100."); //} return(res); }
public static CalcResult ElementCalc(string fluid, double l, double Aa_fin, double Aa_tube, double A_r_cs, double Ar, Geometry geo, double tai, double RHi, double tri, double pri, double hri, double mr, double g, double ma, double ha, double haw, double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double dh = geo.Di; double r_metal = thickness / conductivity / Ar; double gg = 9.8; 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(); double EnthalpyL, EnthalpyV; //recalc tri to make sure it is 2ph, ruhao, 20180225 coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 0); tri = coolprop.T() - 273.15; //tri = CoolProp.PropsSI("T", "P", pri * 1000, "Q", 0, fluid) - 273.15; coolprop.update(input_pairs.QT_INPUTS, 0, tri + 273.15); EnthalpyL = coolprop.hmass() / 1000; //EnthalpyL = CoolProp.PropsSI("H", "T", tri + 273.15, "Q", 0, fluid) / 1000; coolprop.update(input_pairs.QT_INPUTS, 1, tri + 273.15); EnthalpyV = coolprop.hmass() / 1000; //EnthalpyV = CoolProp.PropsSI("H", "T", tri + 273.15, "Q", 1, fluid) / 1000; res.x_i = (hri - EnthalpyL) / (EnthalpyV - EnthalpyL); RefHTCandDPResult htc_dp = new RefHTCandDPResult(); do { flag = false; htc_dp = RefrigerantHTCandDP.HTCandDP_2p(fluid, dh, g, pri, res.x_i, l, q, zh, zdp, hexType, coolprop); 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 * (tai - tri) * Math.Pow(-1, hexType);//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 - EnthalpyL) / (EnthalpyV - EnthalpyL); //+ 139.17 for reference state, to be changed //res.DP = 0; res.Pro = pri - res.DP; if (res.Pro < 0) { res.Pro = -10000000; return(res); } coolprop.update(input_pairs.HmassP_INPUTS, res.hro * 1000, res.Pro * 1000); res.Tro = coolprop.T(); //res.Tro = CoolProp.PropsSI("T", "P", res.Pro * 1000, "H", res.hro * 1000, fluid); double rho_o = coolprop.rhomass(); //double rho_o = CoolProp.PropsSI("D", "P", res.Pro * 1000, "H", res.hro * 1000, fluid); 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); }
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 ElementCal(string fluid, double l, double Aa_fin, double Aa_tube, double A_r_cs, double Ar, Geometry geo, double tai, double RHi, double tri, double pri, double hri, double mr, double g, double ma, double ha, double haw, double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity, double Pwater, AbstractState coolprop, double[,] SourceTableData) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double tsat; coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 0); tsat = coolprop.T(); //tsat = CoolProp.PropsSI("T", "P", pri * 1000, "Q", 0, fluid); double Vol_tubes = A_r_cs * l; //Tube volume, for charge calculation 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_v1 = CoolProp.PropsSI("H", "T", tsat, "Q", 1, fluid) / 1000 ; double Tri_mod; double alpha; var res_element = new CalcResult(); // **********Superheated state********** if (hri > h_v && fluid != "Water") { if (hri < 1.02 * h_v) //ignore modification for now, ruhao,20180226 { Tri_mod = tri + 0.5 * 0; //"for Tri modification in the transition region" } else { Tri_mod = tri; } res_element = SPElement.ElementCalc3(fluid, l, Aa_fin, Aa_tube, A_r_cs, Ar, geo, tai, RHi, Tri_mod, pri, hri, mr, g, ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, coolprop, SourceTableData); if (res_element.Pro < 0) { return(res_element); } 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} coolprop.update(input_pairs.HmassP_INPUTS, hri * 1000, pri * 1000); double rho = coolprop.rhomass(); res_element.M = Vol_tubes * rho; //"Mass calculated" } // **********Twophase state**********" if (hri <= h_v && hri >= h_l && fluid != "Water") { res_element = TPElement.ElementCalc1(fluid, l, Aa_fin, Aa_tube, A_r_cs, Ar, geo, tai, RHi, tri, pri, hri, mr, g, ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, coolprop, SourceTableData); if (res_element.Pro < 0) { return(res_element); } //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 coolprop.update(input_pairs.PQ_INPUTS, P_avg * 1000, 0); double rho_l = coolprop.rhomass(); //double rho_l = CoolProp.PropsSI("D", "P", P_avg * 1000, "Q", 0, fluid); coolprop.update(input_pairs.PQ_INPUTS, P_avg * 1000, 1); double rho_v = coolprop.rhomass(); //double rho_v = CoolProp.PropsSI("D", "P", P_avg * 1000, "Q", 1, fluid); //{Call VOIDFRACTION_pressure(ref$, x_avg, P_avg : alpha_p) "Baroczy void fraction model" } double alpha_homog = 1 / (1 + (1 - x_avg) / x_avg * (rho_v / rho_l)); // Homogeneous model, Intermittent flow void fraction res_element.M = Vol_tubes * (alpha_homog * rho_v + (1 - alpha_homog) * rho_l); //Mass calculated } //**********Subcooled state********** if (hri < h_l || fluid == "Water") { if (hri > 0.98 * h_l) //ignore modification for now, ruhao,20180226 { Tri_mod = tri - 0.5 * 0; //"for Tri modification in the transition region" } else { Tri_mod = tri; } if (fluid == "Water") { Tri_mod = tri - 0.0001; } res_element = SPElement.ElementCalc3(fluid, l, Aa_fin, Aa_tube, A_r_cs, Ar, geo, tai, RHi, Tri_mod, pri, hri, mr, g, ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, coolprop, SourceTableData); if (res_element.Pro < 0) { return(res_element); } //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} coolprop.update(input_pairs.HmassP_INPUTS, hri * 1000, pri * 1000); double rho = coolprop.rhomass(); res_element.M = Vol_tubes * rho; //Mass calculated } return(res_element); }
public static CalcResult SlabCalc(int[,] CirArrange, CircuitNumber CircuitInfo, int Nrow, int[] Ntube, int Nelement, string fluid, //double Npass, int[] N_tubes_pass, double l, Geometry geo, double[, ,] ta, double[, ,] RH, double te, double pe, 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, string Airdirection, CapiliaryInput cap_inlet, CapiliaryInput cap_outlet, AbstractState coolprop, double[,] SourceTableData) { //-------> // R2 R1 // [11 1] <==== // [12 2] <==== // <==== Air // [13 3] <==== // [14 4] <==== // [15 5] <==== // [16 6] <==== // [17 7] <==== // [18 8] <==== // [19 9] <==== // [20 10] <==== // Ncir=1, 11in, 20->10 1out // [19 - 17 - 15 - 13 11 9 7 5 3 1] <====Air // [20 - 18 - 16 - 14 12 10 8 6 4 2] <====Air // Ncir=1, 20in, 20->19 1out // CirArrange = new int[,] { { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 } }; // Nrow=2 // Ncir=2 //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double[] Q1 = new double[50]; double tri = te; //Refrigerant.SATP(fluid, composition, pri, 1).Temperature - 273.15; double pri = pe; int Nciri = CircuitInfo.number[0]; int Nciro = CircuitInfo.number[1]; int Ncir = (Nciri == Nciro ? Nciri : Nciri + Nciro); int N_tube = Ntube[0]; int N_tube_total = 0; int iRow = 0; int iTube_o = 0; int iTube_n = 0; int index_o = 0; int index_n = 0; double te_calc_org = 0; CirArr[] cirArr = new CirArr[Nrow * N_tube]; CirArrforAir cirArrforAir = new CirArrforAir(); cirArrforAir = CirArrangement.ReadCirArr(CirArrange, CircuitInfo, Nrow, Ntube, 0); cirArr = cirArrforAir.CirArr; CalcResult res_slab = new CalcResult(); double[] pri_cir = new double[Ncir]; //[element, tube, row] double[] hri_cir = new double[Ncir]; double[] tri_cir = new double[Ncir]; double[] mr_ciri = new double[Nciri]; List <double[]> mr_ciri_base = new List <double[]>(); double[] mr_ciro = new double[Nciro]; int[] Ngroupin = new int[Nciro]; int index = 0; int restartDP_index = 0; int N_tube2 = 0; int[] index_cir = new int[Ncir]; int index_mr_ciri_base = 0; CalcResult[] r = new CalcResult[Ncir]; CalcResult[] r1 = new CalcResult[Ncir]; CalcResult[] r2 = new CalcResult[Ncir]; //for NinMout only CalcResult[] res_cir2 = new CalcResult[Nciro + 1]; CalcResult[] res_type = new CalcResult[Nciri + 1]; 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]; int flag_ciro = 0; int Ncir_forDP = 0; double[] mr_forDP = new double[Nciri]; int k; double te_calc = 0; CheckAir airConverge = new CheckAir(); CheckDP dPconverge = new CheckDP(); CheckPri priconverge = new CheckPri(); for (int i = 0; i < Nrow; i++) { N_tube_total += Ntube[i]; } for (int i = 0; i < Nciro; i++) { mr_ciro[i] = mr / Nciro; } bool index_outbig; if (CircuitInfo.UnequalCir == null || CircuitInfo.UnequalCir[0] > 0) { index_outbig = false; } else { index_outbig = true; } if (CircuitInfo.UnequalCir != null) { for (int j = 0; j < Nciro; j++) { for (int i = 0; i < Ncir; i++) { if (CircuitInfo.UnequalCir[i] == Nciri + 1 + j) { Ngroupin[j]++; } } //for (int i = 0; i < Nciri; i++) mr_ciri[i] = mr_ciro[j] / Ngroupin[j]; } } int iterforAir = 0; int iterforDP = 0; int iterforPri = 0; double pri_1 = 0; double pri_2 = 0; double pri_3 = 0; double pri_4 = 0; double tri1 = 0; double te1 = 0; double iterforDP_ciri = 0; double iterforDP_ciro = 0; //Starting properties iterforDP_ciro = 0; double[] mr_forDP_o_4 = new double[Nciri]; double[] mr_forDP_o_3 = new double[Nciri]; double[] mr_forDP_o_2 = new double[Nciri]; double[] mr_forDP_o_1 = new double[Nciri]; do { #region //AirConverge do { //iterforDP = 0; r = new CalcResult[Ncir]; r1 = new CalcResult[Ncir]; res_cir2 = new CalcResult[Nciro + 1]; flag_ciro = (index_outbig ? 1 : 0); //tri = tri; //制冷制热模块计算切换 if (hexType == 0) { coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 0); tri = coolprop.T() - 273.15; tri = CoolProp.PropsSI("T", "P", pri * 1000, "Q", 0, fluid) - 273.15; int a = 1; } else { coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 0); te = coolprop.T() - 273.15; te = CoolProp.PropsSI("T", "P", pri * 1000, "Q", 0, fluid) - 273.15; int a = 1; } for (int j = 0; j < (flag_ciro == 1 ? (index_outbig ? Nciri + 1 : 1) : Nciro + 1); j++) { if (j >= Nciro) { j = j - Nciro; //for Nciro flag_ciro = (index_outbig ? 0 : 1); } if (j == 1 && index_outbig && index == 0) { j = j - 1; flag_ciro = 0; } index = 0; iterforDP_ciri = 0; double[] mr_forDP_4 = new double[Nciri]; double[] mr_forDP_3 = new double[Nciri]; double[] mr_forDP_2 = new double[Nciri]; double[] mr_forDP_1 = new double[Nciri]; double [] mr0_forDP = new double[5]; #region //DPConverge do { res_type = new CalcResult[Nciri + 1]; k = 0; if (!index_outbig) { for (int i = 0; i < (flag_ciro == 1 ? Nciro : (Nciri == Nciro ? Ncir : Ncir - Nciro)); i++) { if (flag_ciro == 1) { pri_cir[i + Ncir - Nciro] = res_cir2[i].Pro; hri_cir[i + Ncir - Nciro] = res_cir2[i].hro; tri_cir[i + Ncir - Nciro] = res_cir2[i].Tro; } else { pri_cir[i] = pri; hri_cir[i] = hri; tri_cir[i] = tri; } } } else { for (int i = 0; i < (flag_ciro == 1 ? Nciro : Ncir); i++) { if (flag_ciro == 1) { pri_cir[i] = pri; hri_cir[i] = hri; tri_cir[i] = tri; } else { if (CircuitInfo.UnequalCir[i] == Nciri + 1 + j) { pri_cir[i] = r2[j].Pro; hri_cir[i] = r2[j].hro; tri_cir[i] = r2[j].Tro; } } } } for (int i = 0; i < Ncir; i++) { if (flag_ciro == 1) { //汇管计算 if (CircuitInfo.UnequalCir[i] <= 0) { //for (int i = 0; i < Ncir; i++) //r[i] = Circuit.CircuitCalc(i, cirArr, CircuitInfo, Nrow, Ntube, Nelement, fluid, dh, l, geo.element, ta, RH, // tri_cir[i], pri_cir[i], hri_cir[i], mr_ciro[k], ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, Airdirection, d_cap, lenth_cap); r[i] = Circuit.CircuitCalc(i, cirArr, CircuitInfo, Nrow, Ntube, Nelement, fluid, l, geo, ta, RH, tri_cir[i], pri_cir[i], hri_cir[i], mr_ciro[k], ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, cap_inlet, cap_outlet, coolprop, SourceTableData); if (r[i].Pro < 0) { res_slab.Pro = -10000000; return(res_slab); } r1[k] = r[i].ShallowCopy(); r2[k] = r[i].ShallowCopy(); if (!index_outbig) { r1[k].DP += res_cir2[k].DP; } index_cir[k] = i; k++; Ncir_forDP = Nciro; mr_forDP = (double[])mr_ciro.Clone(); // mr_forDP = mr_ciro if (k == Nciro) { break; } } } else if (Nciri == Nciro || CircuitInfo.UnequalCir[i] == Nciri + 1 + j) { //均匀流路计算和不均匀流路开始部分(独立管)计算 if (index == 0) { if (Nciri == Nciro && iterforPri == 0) { mr_ciro.CopyTo(mr_ciri, 0); } else if (Nciri != Nciro) { if (restartDP_index == 1 || !priconverge.flag) { var mm = mr_ciri_base[j].Sum(); //foreach (var item in mr_ciri_base[j]) //mm += item; mr_ciri[k] = mr_ciri_base[j][k] * mr_ciro[j] / mm;//(mr / Nciro); } else { mr_ciri[k] = mr_ciro[j] / Ngroupin[j]; } } } //else mr_ciri_base.CopyTo(mr_ciri[k], 0); //for (int i = 0; i < Ncir; i++) //首次流路计算 if (CircuitInfo.CirType != null && CircuitInfo.CirType.flag == true) { bool circuit_cap = false; //if (d_cap[index] == 0 && lenth_cap[index] == 0) circuit_cap = true; if ((CircuitInfo.CirType.flag == true) && (CircuitInfo.CirType.type[i, 0] == 0) && (res_type[CircuitInfo.CirType.type[i, 1]] != null && circuit_cap)) { //r[i] = res_type[CircuitInfo.CirType.type[i, 1]]; r[i] = new CalcResult(); r[i].DP = res_type[CircuitInfo.CirType.type[i, 1]].DP; r[i].DP_cap = res_type[CircuitInfo.CirType.type[i, 1]].DP_cap; r[i].href = res_type[CircuitInfo.CirType.type[i, 1]].href; r[i].hro = res_type[CircuitInfo.CirType.type[i, 1]].hro; r[i].M = res_type[CircuitInfo.CirType.type[i, 1]].M; r[i].Pro = res_type[CircuitInfo.CirType.type[i, 1]].Pro; r[i].Q = res_type[CircuitInfo.CirType.type[i, 1]].Q; r[i].R_1 = res_type[CircuitInfo.CirType.type[i, 1]].R_1; r[i].R_1a = res_type[CircuitInfo.CirType.type[i, 1]].R_1a; r[i].R_1r = res_type[CircuitInfo.CirType.type[i, 1]].R_1r; r[i].Ra_ratio = res_type[CircuitInfo.CirType.type[i, 1]].Ra_ratio; r[i].RHout = res_type[CircuitInfo.CirType.type[i, 1]].RHout; r[i].Tao = res_type[CircuitInfo.CirType.type[i, 1]].Tao; r[i].Tri = res_type[CircuitInfo.CirType.type[i, 1]].Tri; r[i].Tro = res_type[CircuitInfo.CirType.type[i, 1]].Tro; r[i].x_i = res_type[CircuitInfo.CirType.type[i, 1]].x_i; r[i].x_o = res_type[CircuitInfo.CirType.type[i, 1]].x_o; r[i].Vel_r = res_type[CircuitInfo.CirType.type[i, 1]].Vel_r; r[i].mr = res_type[CircuitInfo.CirType.type[i, 1]].mr; r[i].Q_detail = new double[N_tube, Nrow];// r[i].DP_detail = new double[N_tube, Nrow]; r[i].Tri_detail = new double[N_tube, Nrow]; r[i].Pri_detail = new double[N_tube, Nrow]; r[i].hri_detail = new double[N_tube, Nrow]; r[i].Tro_detail = new double[N_tube, Nrow]; r[i].Pro_detail = new double[N_tube, Nrow]; r[i].hro_detail = new double[N_tube, Nrow]; r[i].href_detail = new double[N_tube, Nrow]; r[i].mr_detail = new double[N_tube, Nrow]; r[i].Tao_Detail = new double[Nelement, N_tube, Nrow]; r[i].RHo_Detail = new double[Nelement, N_tube, Nrow]; r[i].charge_detail = new double[N_tube, Nrow]; for (int m = 0; m < CircuitInfo.TubeofCir[i]; m++) { index_o = 0; index_n = 0; if (i == 0) { index_n = 0; } else { for (int n = 1; n <= i; n++) { index_n += CircuitInfo.TubeofCir[n - 1]; } } if (res_type[CircuitInfo.CirType.type[i, 1]].index == 0) { index_o = 0; } else { for (int n = 1; n <= res_type[CircuitInfo.CirType.type[i, 1]].index; n++) { index_o += CircuitInfo.TubeofCir[n - 1]; } } iRow = cirArr[m + index_o].iRow; iTube_o = cirArr[m + index_o].iTube; iTube_n = cirArr[m + index_n].iTube; r[i].Q_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].Q_detail[iTube_o, iRow];// r[i].DP_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].DP_detail[iTube_o, iRow]; r[i].Tri_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].Tri_detail[iTube_o, iRow]; r[i].Pri_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].Pri_detail[iTube_o, iRow]; r[i].hri_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].hri_detail[iTube_o, iRow]; r[i].Tro_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].Tro_detail[iTube_o, iRow]; r[i].Pro_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].Pro_detail[iTube_o, iRow]; r[i].hro_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].hro_detail[iTube_o, iRow]; r[i].href_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].href_detail[iTube_o, iRow]; r[i].mr_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].mr_detail[iTube_o, iRow]; r[i].charge_detail[iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].charge_detail[iTube_o, iRow]; for (int p = 0; p < Nelement; p++) { //ta[p, iTube_n, iRow + 1] = res_type[CircuitInfo.CirType.type[i, 1]].Tao_Detail[p, iTube_o, iRow]; //RH[p, iTube_n, iRow + 1] = res_type[CircuitInfo.CirType.type[i, 1]].RHo_Detail[p, iTube_o, iRow]; r[i].Tao_Detail[p, iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].Tao_Detail[p, iTube_o, iRow]; r[i].RHo_Detail[p, iTube_n, iRow] = res_type[CircuitInfo.CirType.type[i, 1]].RHo_Detail[p, iTube_o, iRow]; } } //r[i].Tao_Detail = ta; //r[i].RHo_Detail = RH; } else { //r[i] = Circuit.CircuitCalc(i, cirArr, CircuitInfo, Nrow, Ntube, Nelement, fluid, dh, l, geo.element, ta, RH, //tri_cir[i], pri_cir[i], hri_cir[i], mr_ciri[k], ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, Airdirection, d_cap, lenth_cap); r[i] = Circuit.CircuitCalc(i, cirArr, CircuitInfo, Nrow, Ntube, Nelement, fluid, l, geo, ta, RH, tri_cir[i], pri_cir[i], hri_cir[i], mr_ciri[k], ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, cap_inlet, cap_outlet, coolprop, SourceTableData); if (r[i].Pro < 0) { res_slab.Pro = -10000000; return(res_slab); } if (CircuitInfo.CirType.type[i, 0] == 0) { res_type[CircuitInfo.CirType.type[i, 1]] = r[i]; res_type[CircuitInfo.CirType.type[i, 1]].index = i; } } } else { //r[i] = Circuit.CircuitCalc(i, cirArr, CircuitInfo, Nrow, Ntube, Nelement, fluid, dh, l, geo.element, ta, RH, //tri_cir[i], pri_cir[i], hri_cir[i], mr_ciri[k], ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, Airdirection, d_cap, lenth_cap); r[i] = Circuit.CircuitCalc(i, cirArr, CircuitInfo, Nrow, Ntube, Nelement, fluid, l, geo, ta, RH, tri_cir[i], pri_cir[i], hri_cir[i], mr_ciri[k], ma, ha, haw, eta_surface, zh, zdp, hexType, thickness, conductivity, Pwater, cap_inlet, cap_outlet, coolprop, SourceTableData); if (r[i].Pro < 0) { res_slab.Pro = -10000000; return(res_slab); } } r1[k] = r[i].ShallowCopy(); index_cir[k] = i;//不均匀流路的输出才会用到 k++; if (k == (Nciri == Nciro ? Ncir : Ngroupin[j])) { Ncir_forDP = (Nciri == Nciro ? Ncir : Ngroupin[j]); mr_forDP = (double[])mr_ciri.Clone(); break; } } } if (index_outbig && flag_ciro == 1) { break; } index++; //dPconverge = CheckDPforCircuits.CheckDPConverge(mr, mr_ciri, r, Ncir); dPconverge = CheckDPforCircuits.CheckDPConverge(hexType, res_cir2, iterforPri, flag_ciro, mr_forDP, r1, Ncir_forDP); if (flag_ciro == 0) { iterforDP_ciri++; if (iterforDP_ciri >= 5) { mr_forDP_4 = mr_forDP_3; mr_forDP_3 = mr_forDP_2; mr_forDP_2 = mr_forDP_1; mr_forDP_1 = mr_forDP; try { if (mr_forDP_1[0] < mr_forDP_2[0] && (Math.Abs(mr_forDP_1[0] - mr_forDP_3[0]) / mr_forDP_1[0] < 0.0001) || Math.Abs(mr_forDP_1[0] - mr_forDP_4[0]) / mr_forDP_1[0] < 0.0001) { dPconverge.flag = true; } } catch (Exception ex) { continue; } } restartDP_index = 0; if (!dPconverge.flag) { dPconverge.mr.CopyTo(mr_ciri, 0); //mr_ciri = dPconverge.mr; } } else //(flag_ciro == 1) { iterforDP_ciro++; if (iterforDP_ciro >= 5) { mr_forDP_o_4 = mr_forDP_o_3; mr_forDP_o_3 = mr_forDP_o_2; mr_forDP_o_2 = mr_forDP_o_1; mr_forDP_o_1 = mr_forDP; try { if (mr_forDP_o_1[0] < mr_forDP_o_2[0] && (Math.Abs(mr_forDP_o_1[0] - mr_forDP_o_3[0]) / mr_forDP_o_1[0] < 0.0001) || Math.Abs(mr_forDP_o_1[0] - mr_forDP_o_4[0]) / mr_forDP_o_1[0] < 0.0001) { dPconverge.flag = true; } } catch (Exception ex) { continue; } } if (dPconverge.flag) { restartDP_index = 0; } else { restartDP_index = 1; dPconverge.mr.CopyTo(mr_ciro, 0); //mr_ciro = dPconverge.mr; break; } } iterforDP++; N_tube2 = 0; #region //Result print out if (dPconverge.flag) { if (Nciri == Nciro) { //te_calc = Refrigerant.SATP(fluid, composition, r[j].Pro, 1).Temperature; coolprop.update(input_pairs.PQ_INPUTS, r[j].Pro * 1000, 0); te_calc = coolprop.T(); te_calc = CoolProp.PropsSI("T", "P", r[j].Pro * 1000, "Q", 0, fluid); int a = 1; } else { if (mr_ciri_base.Count == Nciro && flag_ciro == 0) { mr_ciri_base.RemoveAt(index_mr_ciri_base); mr_ciri_base.Insert(index_mr_ciri_base, mr_forDP); index_mr_ciri_base++; index_mr_ciri_base %= mr_ciri_base.Count; } if (mr_ciri_base.Count < Nciro) { mr_ciri_base.Add(mr_forDP); //keep original mr ratio for fast iter } j = (flag_ciro == 1 ? j + Nciro : j); res_cir2[j] = new CalcResult(); for (int i = 0; i < (flag_ciro == 1 ? Nciro : Ngroupin[j]); i++) { res_cir2[j].Q += r1[i].Q; res_cir2[j].M += r1[i].M; res_cir2[j].hro += (flag_ciro == 1 ? mr_ciro[i] : mr_ciri[i]) * r1[i].hro; if (fluid == "Water") { res_cir2[j].Tro += (flag_ciro == 1 ? mr_ciro[i] : mr_ciri[i]) * r1[i].Tro; } res_cir2[j].Vel_r = r1[i].Vel_r; res_cir2[j].href += r1[i].href * CircuitInfo.TubeofCir[index_cir[i]]; res_cir2[j].R_1 += r1[i].R_1 * CircuitInfo.TubeofCir[index_cir[i]]; res_cir2[j].R_1a += r1[i].R_1a * CircuitInfo.TubeofCir[index_cir[i]]; res_cir2[j].R_1r += r1[i].R_1r * CircuitInfo.TubeofCir[index_cir[i]]; N_tube2 += CircuitInfo.TubeofCir[index_cir[i]]; } res_cir2[j].DP = r1[(flag_ciro == 1 ? Nciro : Ngroupin[j]) - 1].DP; res_cir2[j].Tao_Detail = ta; res_cir2[j].Pro = r1[(flag_ciro == 1 ? Nciro : Ngroupin[j]) - 1].Pro; res_cir2[j].hro = res_cir2[j].hro / (flag_ciro == 1 ? mr : mr_ciro[j]); res_cir2[j].href = res_cir2[j].href / N_tube2; res_cir2[j].R_1 = res_cir2[j].R_1 / N_tube2; res_cir2[j].R_1a = res_cir2[j].R_1a / N_tube2; res_cir2[j].R_1r = res_cir2[j].R_1r / N_tube2; res_cir2[j].Tri = tri; //te_calc = Refrigerant.SATP(fluid, composition, res_cir2[j].Pro, 1).Temperature; coolprop.update(input_pairs.PQ_INPUTS, res_cir2[j].Pro * 1000, 0); te_calc = coolprop.T(); te_calc = CoolProp.PropsSI("T", "P", res_cir2[j].Pro * 1000, "Q", 0, fluid); if (fluid == "Water") { res_cir2[j].Tro = res_cir2[j].Tro / (flag_ciro == 1 ? mr : mr_ciro[j]) - 273.15; } else { res_cir2[j].Tro = CoolProp.PropsSI("T", "P", res_cir2[j].Pro * 1000, "H", res_cir2[j].hro * 1000, fluid) - 273.15; } } } #endregion #endregion } while (!dPconverge.flag && iterforDP < 200); if (Nciri == Nciro) { break; } if (index_outbig && (j == Nciro - 1) && (res_cir2[0] != null)) { for (int i = 0; i < Nciro; i++) { r2[i].DP += res_cir2[i].DP; } flag_ciro = 1; Ncir_forDP = Nciro; mr_forDP = (double[])mr_ciro.Clone(); // mr_forDP = mr_ciro dPconverge = CheckDPforCircuits.CheckDPConverge(hexType, res_cir2, iterforPri, flag_ciro, mr_forDP, r2, Ncir_forDP); iterforDP_ciro++; if (iterforDP_ciro >= 5) { mr_forDP_o_4 = mr_forDP_o_3; mr_forDP_o_3 = mr_forDP_o_2; mr_forDP_o_2 = mr_forDP_o_1; mr_forDP_o_1 = mr_forDP; try { if (mr_forDP_o_1[0] < mr_forDP_o_2[0] && (Math.Abs(mr_forDP_o_1[0] - mr_forDP_o_3[0]) / mr_forDP_o_1[0] < 0.0001) || Math.Abs(mr_forDP_o_1[0] - mr_forDP_o_4[0]) / mr_forDP_o_1[0] < 0.0001) { dPconverge.flag = true; } } catch (Exception ex) { continue; } } if (!dPconverge.flag) { restartDP_index = 1; dPconverge.mr.CopyTo(mr_ciro, 0); //mr_ciro = dPconverge.mr; } break; } } if (Airdirection == "顺流") { airConverge.flag = true; for (int ii = 0; ii < Ncir; ii++) { for (int i = 0; i < Nrow; i++) { for (int j = 0; j < N_tube; j++) { for (int kk = 0; kk < Nelement; kk++) { if (r[ii].Tao_Detail[kk, j, i] != 0) { ta[kk, j, i + 1] = r[ii].Tao_Detail[kk, j, i]; } if (r[ii].RHo_Detail[kk, j, i] != 0) { RH[kk, j, i + 1] = r[ii].RHo_Detail[kk, j, i]; } } } } } } else//Counter { airConverge = CheckAirConvergeforCircuits.CheckAirConverge(cirArrforAir.TotalDirection, Nrow, N_tube, Nelement, ta, RH, r); //taout_calc, RHout_calc ta = airConverge.ta; RH = airConverge.RH; iterforAir++; } //Add Q converge criterion to avoid results oscillation, ruhao 20180426 if (Airdirection != "顺流") //No airConverge iter for Parallel { for (int i = 0; i < Ncir; i++) { Q1[iterforAir - 1] += r[i].Q; } try { if (Q1[iterforAir - 1] < Q1[iterforAir - 2] && (Math.Abs(Q1[iterforAir - 1] - Q1[iterforAir - 3]) / Q1[iterforAir - 1] < 0.0001) || Math.Abs(Q1[iterforAir - 1] - Q1[iterforAir - 4]) / Q1[iterforAir - 1] < 0.0001) { airConverge.flag = true; } } catch (Exception ex) { continue; } } } while (!airConverge.flag && iterforAir < 50); #endregion //using (StreamWriter wr = File.AppendText(@"D:\Work\Simulation\Test\MinNout.txt")) //{ //for (int i = 0; i < Ncir; i++) //{ //wr.WriteLine("Q, {0}, DP, {1}, href, {2}, Ra_ratio, {3}, Tao, {4}, Tro, {5}, mr, {6}", r[i].Q, r[i].DP, r[i].href, r[i].Ra_ratio, r[i].Tao, r[i].Tro, r[i].mr); //} //} if (restartDP_index == 1) { priconverge.flag = false; } else if (hexType == 0 && (fluid != "Water")) { priconverge = CheckPin.CheckPriConverge(te, te_calc - 273.15, te_calc_org - 273.15, pri, pe, r[Ncir - 1].Pro); //res_slab.Pro iterforPri++; if (iterforPri >= 20) { pri_4 = pri_3; pri_3 = pri_2; pri_2 = pri_1; pri_1 = pri; try { if (pri_1 < pri_2 && (Math.Abs(pri_1 - pri_3) / pri_1 < 1e-5) || Math.Abs(pri_1 - pri_4) / pri_1 < 1e-5) { priconverge.flag = true; } } catch (Exception ex) { continue; } } pri = priconverge.pri; te_calc_org = te_calc; if (priconverge.flag && iterforPri == 1 && iterforDP == 1) { priconverge.flag = false; //to avoid not even iterate but converge by chance } } else { priconverge.flag = true; } } while (!priconverge.flag && iterforPri < 100); // if (iterforDP >= 200) //{ // return res_slab; // throw new Exception("iter for DPConverge > 100."); //} //if (iterforPri >= 50) //{ // return res_slab; // throw new Exception("iter for Pri > 50."); //} #region //Result print out for (int i = 0; i < Ncir; i++) { res_slab.Q += r[i].Q; res_slab.M += r[i].M; if (Nciri == Nciro) { res_slab.hro += mr_ciri[i] * r[i].hro; } res_slab.href += r[i].href * CircuitInfo.TubeofCir[i]; res_slab.R_1 += r[i].R_1 * CircuitInfo.TubeofCir[i]; res_slab.R_1a += r[i].R_1a * CircuitInfo.TubeofCir[i]; res_slab.R_1r += r[i].R_1r * CircuitInfo.TubeofCir[i]; for (int j = 0; j < N_tube; j++)//detail output { for (k = 0; k < Nrow; k++) { if (r[i].Q_detail[j, k] != 0) { Q_detail[j, k] = r[i].Q_detail[j, k]; } if (r[i].DP_detail[j, k] != 0) { DP_detail[j, k] = r[i].DP_detail[j, k]; } if (r[i].Tri_detail[j, k] != 0) { Tri_detail[j, k] = r[i].Tri_detail[j, k]; } if (r[i].Pri_detail[j, k] != 0) { Pri_detail[j, k] = r[i].Pri_detail[j, k]; } if (r[i].hri_detail[j, k] != 0) { hri_detail[j, k] = r[i].hri_detail[j, k]; } if (r[i].Tro_detail[j, k] != 0) { Tro_detail[j, k] = r[i].Tro_detail[j, k]; } if (r[i].Pro_detail[j, k] != 0) { Pro_detail[j, k] = r[i].Pro_detail[j, k]; // } if (r[i].hro_detail[j, k] != 0) { hro_detail[j, k] = r[i].hro_detail[j, k]; } if (r[i].href_detail[j, k] != 0) { href_detail[j, k] = r[i].href_detail[j, k]; } if (r[i].mr_detail[j, k] != 0) { mr_detail[j, k] = r[i].mr_detail[j, k]; } if (r[i].charge_detail[j, k] != 0) { charge_detail[j, k] = r[i].charge_detail[j, k]; } } } } if (Nciri == Nciro) { res_slab.hro = res_slab.hro / mr; res_slab.Pro = r[Ncir - 1].Pro; res_slab.DP_cap = r[Ncir - 1].DP_cap; res_slab.Vel_r = r[Ncir - 1].Vel_r; } else if (!index_outbig) { res_slab.hro = res_cir2[Nciro].hro; res_slab.Pro = res_cir2[Nciro].Pro; res_slab.DP_cap = res_cir2[Nciro].DP_cap; res_slab.Vel_r = res_cir2[Nciro].Vel_r; } else { res_slab.hro = res_cir2[Nciro - 1].hro; res_slab.Pro = res_cir2[Nciro - 1].Pro; res_slab.DP_cap = res_cir2[Nciro - 1].DP_cap; res_slab.Vel_r = res_cir2[Nciro - 1].Vel_r; } res_slab.Pri = pri; res_slab.Tri = tri; res_slab.hri = hri; res_slab.mr = mr; res_slab.DP = pri - res_slab.Pro; res_slab.Tao_Detail = ta; res_slab.RHo_Detail = RH; res_slab.href = res_slab.href / N_tube_total; for (int i = 0; i < ha.GetLength(0); i++) { for (int j = 0; j < ha.GetLength(1); j++) { res_slab.ha += ha[i, j]; } } res_slab.ha = res_slab.ha / ha.Length; res_slab.R_1 = res_slab.R_1 / N_tube_total; res_slab.R_1a = res_slab.R_1a / N_tube_total; res_slab.R_1r = res_slab.R_1r / N_tube_total; coolprop.update(input_pairs.PQ_INPUTS, res_slab.Pro * 1000, 0); te_calc = coolprop.T() - 273.15; te_calc = CoolProp.PropsSI("T", "P", res_slab.Pro * 1000, "Q", 0, fluid) - 273.15; coolprop.update(input_pairs.QT_INPUTS, 0, te_calc + 273.15); double densityLo = coolprop.rhomass(); //double densityLo = CoolProp.PropsSI("D", "T", te_calc + 273.15, "Q", 0, fluid); coolprop.update(input_pairs.QT_INPUTS, 1, te_calc + 273.15); double densityVo = coolprop.rhomass(); //double densityVo = CoolProp.PropsSI("D", "T", te_calc + 273.15, "Q", 1, fluid); coolprop.update(input_pairs.DmassT_INPUTS, densityLo, te_calc + 273.15); double hlo = coolprop.hmass() / 1000; //double hlo = CoolProp.PropsSI("H", "T", te_calc + 273.15, "D", densityLo, fluid) / 1000 ; coolprop.update(input_pairs.DmassT_INPUTS, densityVo, te_calc + 273.15); double hvo = coolprop.hmass() / 1000; //double hvo = CoolProp.PropsSI("H", "T", te_calc + 273.15, "D", densityVo, fluid) / 1000 ; res_slab.x_o = (res_slab.hro - hlo) / (hvo - hlo); coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 0); double hli = coolprop.hmass() / 1000; //double hli = CoolProp.PropsSI("H", "P", pri * 1000, "Q", 0, fluid) / 1000 ; coolprop.update(input_pairs.PQ_INPUTS, pri * 1000, 1); double hvi = coolprop.hmass() / 1000; //double hvi = CoolProp.PropsSI("H", "P", pri * 1000, "Q", 1, fluid) / 1000 ; res_slab.x_i = (res_slab.hri - hli) / (hvi - hli); coolprop.update(input_pairs.HmassP_INPUTS, res_slab.hro * 1000, res_slab.Pro * 1000); res_slab.Tro = coolprop.T() - 273.15; //res_slab.Tro = CoolProp.PropsSI("T", "P", res_slab.Pro * 1000, "H", res_slab.hro * 1000, fluid) - 273.15; double h = res_slab.hro; for (int j = 0; j < N_tube; j++) { for (int i = 0; i < Nelement; i++) { res_slab.Tao += res_slab.Tao_Detail[i, j, Nrow]; res_slab.RHout += res_slab.RHo_Detail[i, j, Nrow]; } } res_slab.Tao = res_slab.Tao / (N_tube * Nelement); res_slab.RHout = res_slab.RHout / (N_tube * Nelement); res_slab.Ra_ratio = res_slab.R_1a / res_slab.R_1; for (int i = 0; i < ma.GetLength(0); i++) { for (int j = 0; j < ma.GetLength(1); j++) { res_slab.ma += ma[i, j]; } } res_slab.Va = res_slab.ma / 1.2 * 3600; res_slab.Q_detail = Q_detail;//detail output res_slab.DP_detail = DP_detail; res_slab.Tri_detail = Tri_detail; res_slab.Pri_detail = Pri_detail; res_slab.hri_detail = hri_detail; res_slab.Tro_detail = Tro_detail; res_slab.Pro_detail = Pro_detail; res_slab.hro_detail = hro_detail; res_slab.href_detail = href_detail; res_slab.mr_detail = mr_detail; res_slab.Aa = geo.TotalArea.A_a; res_slab.Ar = geo.TotalArea.A_r; res_slab.AHx = geo.TotalArea.A_hx; res_slab.N_row = Nrow; res_slab.tube_row = N_tube; res_slab.charge_detail = charge_detail; return(res_slab); #endregion }
public static CalcResult ElementCalc3(string fluid, double l, double Aa_fin, double Aa_tube, double A_r_cs, double Ar, Geometry geo, double tai, double RHi, double tri, double pri, double hri, double mr, double g, double ma, double ha, double haw, double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity, double Pwater, AbstractState coolprop, double[,] SourceTableData) { Model.HumidAirProp humidairprop = new Model.HumidAirProp(); RHi = RHi > 1 ? 1 : RHi; double dh = geo.Di; double Q = 0; double Tout_a = 0; double Q_sensible = 0; double r_metal = thickness / conductivity / Ar; CalcResult res = new CalcResult(); coolprop.update(input_pairs.HmassP_INPUTS, hri * 1000, (fluid == "Water" ? Pwater : pri) * 1000); double mu_r = coolprop.viscosity(); //double mu_r = CoolProp.PropsSI("V", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double k_r = coolprop.conductivity(); //double k_r = CoolProp.PropsSI("L", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double rho_r = coolprop.rhomass(); //double rho_r = CoolProp.PropsSI("D", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double cp_r = coolprop.cpmass(); //double cp_r = CoolProp.PropsSI("C", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double Pr_r = cp_r * mu_r / k_r; res.Vel_r = g / rho_r; double Re_r = rho_r * res.Vel_r * dh / mu_r; double fh = RefrigerantSPHTC.ff_CHURCHILL(Re_r); double Nusselt = RefrigerantSPHTC.NU_GNIELINSKI(Re_r, Pr_r, fh); res.href = Nusselt * k_r / dh * zh; double cp_da = 1.0; cp_da = (hexType == 0 ? 1.027 : 1.02) * 1000; double Tin_a = tai; double Tin_r = tri; //double cp_da0 = CoolProp.HAPropsSI("C", "T", Tin_a + 273.15, "P", 101325, "R", RHi); //cp_da = 1005.1458551 + 0.1541627 * Tin_a + 4.3454442 * RHi - 0.0090904 * Math.Pow(Tin_a, 2) - 0.3409659 * Math.Pow(RHi, 2) - 0.0007819 * Tin_a * RHi + 0.0001851 * Math.Pow(Tin_a, 3) + 0.0049274 * Math.Pow(RHi, 3) + 0.0476513 * Tin_a * Math.Pow(RHi, 2) + 0.020268209 * Math.Pow(Tin_a, 2) * RHi; cp_da = humidairprop.Cp(Tin_a, RHi, SourceTableData); double h_r = res.href; double k_fin = 237; double Fthickness = geo.Fthickness; double Pt = geo.Pt; double Pr = geo.Pr; double Do = geo.Do; //double h_fin = (Pt - Do) / 2; //double dc = Do + 2 * Fthickness; //double df = Math.Pow(4 / Math.PI * Pt * Pr, 0.5); //double eta_a = 1 / (1 + ha * Math.Pow(df - dc, 2) * Math.Pow(df, 0.5) / 6 / Fthickness / k_fin / Math.Pow(dc, 0.5)); //double m = Math.Sqrt(2 * ha / (k_fin * Fthickness)); //double eta_a= Math.Tanh(m * h_fin) / (m * h_fin);// may cause error //double eta_dry = eta_surface; double r_eta = Do / 2; double XD = Math.Pow((Pr * Pr + Pt * Pt / 4), 0.5) / 2; double XT = Pt / 2; double rf_r = 1.27 * XT / r_eta * Math.Pow((XD / XT - 0.3), 0.5); double m = Math.Pow((2 * ha / k_fin / Fthickness), 0.5); double fai = (rf_r - 1) * (1 + (0.3 + Math.Pow((m * r_eta * (rf_r - r_eta) / 2.5), (1.5 - 1 / 12 * rf_r)) * (0.26 * Math.Pow(rf_r, 0.3) - 0.3)) * Math.Log(rf_r)); double eta_0 = Math.Tanh(m * r_eta * fai) / m / r_eta / fai * Math.Cos(0.1 * m * r_eta * fai); double eta_a = (eta_0 * Aa_fin + Aa_tube) / (Aa_fin + Aa_tube); double UA_i = h_r * Ar; double UA_o = eta_a * (Aa_fin + Aa_tube) * ha; double Ntu_i = UA_i / (mr * cp_r); double Ntu_o = UA_o / (ma * cp_da); double UA = 1 / (1 / (UA_i) + 1 / (UA_o) + r_metal); double Cmin = Math.Min(cp_r * mr, cp_da * ma); double Cmax = Math.Max(cp_r * mr, cp_da * ma); double C_star = Cmin / Cmax; double Ntu_dry = UA / Cmin; double epsilon_dry = (1 - Math.Exp(-Ntu_dry * (1 - C_star))) / (1 - C_star * Math.Exp(-Ntu_dry * (1 - C_star))); double Q_dry = epsilon_dry * Cmin * (Tin_a - Tin_r) * Math.Pow(-1, hexType);//need to be modified//所以蒸发器算不出Q double Tout_a_dry = Tin_a - Q_dry / (ma * cp_da) * Math.Pow(-1, hexType); double Tout_r = Tin_r + Q_dry / (mr * cp_r) * Math.Pow(-1, hexType); double Tout_s = (UA_o * Tout_a_dry + UA_i * Tin_r) / (UA_o + UA_i); double Tin_s = (UA_o * Tin_a + UA_i * Tout_r) / (UA_o + UA_i); double Tout_r_dry = Tout_r; double f_dry = 1.0; //double omega_in0 = CoolProp.HAPropsSI("W", "T", Tin_a + 273.15, "P", 101325, "R", RHi); //double omega_in = (-0.0682340 + 0.0292341 * Tin_a + 4.1604535 * RHi - 0.0025985 * Math.Pow(Tin_a, 2) - 0.0769009 * Math.Pow(RHi, 2) + 0.1246489 * Tin_a * RHi + 6.008 * Math.Pow(10, -5) * Math.Pow(Tin_a, 3) - 0.0006775 * Math.Pow(RHi, 3) + 0.0267183 * Tin_a * Math.Pow(RHi, 2) + 0.019904969 * Math.Pow(Tin_a, 2) * RHi) / 1000; double omega_in = humidairprop.O(Tin_a, RHi, SourceTableData); //double omega_out = omega_in; double hin_a = 0; if (hexType == 0 && tri < tai) { bool isFullyWet = true; //double hin_a0 = CoolProp.HAPropsSI("H", "T", Tin_a + 273.15, "P", 101325, "R", RHi); //hin_a = -244.2924077 + 1135.8711 * Tin_a + 10101.404 * RHi - 12.968219 * Math.Pow(Tin_a, 2) - 11.356807 * Math.Pow(RHi, 2) + 357.25464 * Tin_a * RHi + 0.3178346 * Math.Pow(Tin_a, 3) - 0.0024329 * Math.Pow(RHi, 3) + 44.100799 * Tin_a * Math.Pow(RHi, 2) + 50.31444812 * Math.Pow(Tin_a, 2) * RHi; hin_a = humidairprop.H(Tin_a, "R", RHi, SourceTableData); double hout_a = hin_a - Q_dry / ma * Math.Pow(-1, hexType); //double Tdp0 = CoolProp.HAPropsSI("D", "T", Tin_a + 273.15, "P", 101325, "R", RHi) - 273.15; //double Tdp = -273.15 + 241.0212518 + 0.5718833 * tai + 84.99553 * RHi + 0.002691 * Math.Pow(tai, 2) - 95.003186 * Math.Pow(RHi, 2) + 0.7135779 * tai * RHi - 2.691 / Math.Pow(10, 5) * Math.Pow(tai, 3) + 42.58183 * Math.Pow(RHi, 3) - 0.3227474 * tai * Math.Pow(RHi, 2) - 0.000884612 * Math.Pow(tai, 2) * RHi; double Tdp = humidairprop.Tdp(Tin_a, RHi, SourceTableData); //***delete***// //res.RHout = CoolProp.HAPropsSI("R", "T", Tout_a_dry + 273.15, "P", 101325, "W", omega_out); //res.RHout = 0.0215344 - 0.0059467 * Tout_a_dry + 0.2386894 * (omega_out * 1000) + 0.0004378 * Math.Pow(Tout_a_dry, 2) + 0.0004635 * Math.Pow((omega_out * 1000), 2) - 0.0125912 * Tout_a_dry * (omega_out * 1000) - 9.134 * Math.Pow(10, -6) * Math.Pow(Tout_a_dry, 3) + 1.696 * Math.Pow(10, -6) * Math.Pow((omega_out * 1000), 3) - 2.214 * Math.Pow(10, -5) * Tout_a_dry * Math.Pow((omega_out * 1000), 2) + 0.000200865 * Math.Pow(Tout_a_dry, 2) * (omega_out * 1000); //***delete***// //res.RHout = CoolProp.HAPropsSI("R", "T", Tout_a_dry + 273.15, "P", 101325, "H", hout_a); //double resRHout0 = CoolProp.HAPropsSI("R", "T", Tout_a_dry + 273.15, "P", 101325, "H", hout_a); //res.RHout = 0.0259124 - 0.0996818 * Tout_a_dry + 0.0934877 * (hout_a / 1000) + 0.0040018 * Math.Pow(Tout_a_dry, 2) - 0.0003662 * Math.Pow((hout_a / 1000), 2) - 0.0034077 * Tout_a_dry * (hout_a / 1000) - 1.76447 * Math.Pow(10, -5) * Math.Pow(Tout_a_dry, 3) - 2.74524 * Math.Pow(10, -6) * Math.Pow((hout_a / 1000), 3) + 2.99291 * Math.Pow(10, -5) * Tout_a_dry * Math.Pow((hout_a / 1000), 2) - 9.56644 * Math.Pow(10, -6) * Math.Pow(Tout_a_dry, 2) * (hout_a / 1000); //double Tdp_out0 = CoolProp.HAPropsSI("T", "H", hout_a, "P", 101325, "R", 1.0) - 273.15;//@@@@@@@@@@@@@@@@@@@@@@@@@@ double Tdp_out = humidairprop.Ts(hout_a / 1000, SourceTableData); res.RHout = humidairprop.RHI(Tout_a_dry, Tdp_out, SourceTableData); Tout_a = Tout_a_dry; Q = Q_dry; if (Tin_s < Tdp) { isFullyWet = true; } else { isFullyWet = false; } if (Tout_s < Tdp | isFullyWet == true) { double x1 = Tin_r + 0.001; double x2 = Tin_a - 0.001; double eps = 1e-8; int iter = 1; double change = 999; double y1 = 0, y2 = 0, x3 = 0; double m_star = 0, epsilon_wet = 0, h_s_w_i = 0, h_s_w_o = 0, h_s_s_e = 0, T_s_e = 0, h_a_x = 0, T_a_x = 0; double Q_wet = 0, Ntu_owet = 0, mdot_min = 0; double Ntu_wet = 0; while ((iter <= 3 | change > eps) && iter < 100) { if (iter == 1) { Tout_r = x1; } if (iter > 1) { Tout_r = x2; } double Tout_r_start = Tout_r; //double h_s_w_i0 = CoolProp.HAPropsSI("H", "T", Tin_r + 273.15, "P", 101325, "R", 1.0); //h_s_w_i = 58.732687 * Math.Pow(Tin_r + 273.15, 2) - 30921.970577 * (Tin_r + 273.15) + 4075493.951473; h_s_w_i = humidairprop.H(Tin_r, "R", 1, SourceTableData); /////// //double h10 = 58.732687 * Math.Pow((Tin_r + Tout_r) / 2 + 273.15 + 0.01, 2) - 30921.970577 * ((Tin_r + Tout_r) / 2 + 273.15 + 0.01) + 4075493.951473; double h1 = humidairprop.H((Tin_r + Tout_r) / 2 + 0.01, "R", 1, SourceTableData); //double h20 = 58.732687 * Math.Pow((Tin_r + Tout_r) / 2 + 273.15, 2) - 30921.970577 * ((Tin_r + Tout_r) / 2 + 273.15 ) + 4075493.951473; double h2 = humidairprop.H((Tin_r + Tout_r) / 2, "R", 1, SourceTableData); double c_s = (h1 - h2) / 0.01; //double c_s = (CoolProp.HAPropsSI("H", "T", (Tin_r + Tout_r) / 2 + 273.15 + 0.01, "P", 101325, "R", 1) - CoolProp.HAPropsSI("H", "T", (Tin_r + Tout_r) / 2 + 273.15, "P", 101325, "R", 1)) / 0.01; //double c_s = 2500; //m = Math.Sqrt(2 * ha*c_s/cp_da / (k_fin * Fthickness)); //eta_a= Math.Tanh(m * h_fin) / (m * h_fin);// may cause error //double m_star=ma/(mr*(cp_r/c_s)); //eta_a = eta_a * c_s / cp_da; m = Math.Pow((2 * haw / k_fin / Fthickness), 0.5); fai = (rf_r - 1) * (1 + (0.3 + Math.Pow((m * r_eta * (rf_r - r_eta) / 2.5), (1.5 - 1 / 12 * rf_r)) * (0.26 * Math.Pow(rf_r, 0.3) - 0.3)) * Math.Log(rf_r)); eta_0 = Math.Tanh(m * r_eta * fai) / m / r_eta / fai * Math.Cos(0.1 * m * r_eta * fai); double eta_wet = (eta_0 * Aa_fin + Aa_tube) / (Aa_fin + Aa_tube); Ntu_owet = (eta_0 * Aa_fin + Aa_tube) * haw / (ma * cp_da);//zzc m_star = Math.Min(cp_r * mr / c_s, ma) / Math.Max(cp_r * mr / c_s, ma); mdot_min = Math.Min(cp_r * mr / c_s, ma); Ntu_wet = Ntu_owet / (1 + m_star * (Ntu_owet / Ntu_i));//zzc if (cp_r * mr > c_s * ma) { Ntu_wet = Ntu_owet / (1 + m_star * (Ntu_owet / Ntu_i));//zzc } else { Ntu_wet = Ntu_i / (1 + m_star * (Ntu_i / Ntu_owet)); } epsilon_wet = ((1 - Math.Exp(-Ntu_wet * (1 - m_star))) / (1 - m_star * Math.Exp(-Ntu_wet * (1 - m_star)))); Q_wet = epsilon_wet * mdot_min * (hin_a - h_s_w_i); hout_a = hin_a - Q_wet / ma; Tout_r = Tin_r + ma / (mr * cp_r) * (hin_a - hout_a); //double h_s_w_o0 = CoolProp.HAPropsSI("H", "T", Tout_r + 273.15, "P", 101325, "R", 1.0); //h_s_w_o = 58.732687 * Math.Pow(Tout_r + 273.15, 2) - 30921.970577 * (Tout_r + 273.15) + 4075493.951473; h_s_w_o = humidairprop.H(Tout_r, "R", 1, SourceTableData); //double UA_star = 1 / (cp_da / (eta_a * Aa_fin + Aa_tube) / haw + CoolProp.HAPropsSI("C", "T", (Tin_a + Tout_r) / 2.0 + 273.15, "P", 101325, "R", 1) / h_r / Ar);//zzc double UA_star = 1 / (cp_da / (eta_a * Aa_fin + Aa_tube) / haw + c_s / h_r / Ar); //zzc Tin_s = Tout_r + UA_star / h_r / Ar * (hin_a - h_s_w_o); h_s_s_e = hin_a + (hout_a - hin_a) / (1 - Math.Exp(-Ntu_owet)); //zzc //double T_s_e0 = CoolProp.HAPropsSI("T", "H", h_s_s_e, "P", 101325, "R", 1.0) - 273.15; //T_s_e = -273.15 - 1.96 * Math.Pow(10, -3) * Math.Pow(h_s_s_e / 1000, 2) + 0.5357597 * h_s_s_e / 1000 + 268.871551; T_s_e = humidairprop.Ts(h_s_s_e, SourceTableData); Tout_a = T_s_e + (Tin_a - T_s_e) * Math.Exp(-Ntu_owet);//zzc Q_sensible = ma * cp_da * (Tin_a - Tout_a); double errorToutr = Tout_r - Tout_r_start; if (iter == 1) { y1 = errorToutr; } if (iter > 1) { y2 = errorToutr; x3 = x2 - y2 / (y2 - y1) * (x2 - x1); change = Math.Abs(y2 / (y2 - y1) * (x2 - x1)); y1 = y2; x1 = x2; x2 = x3; } iter++; } //if (iter > 500) // Q = Q_dry; double Tout_r_wet = Tout_r; f_dry = 0.0; if ((Tin_s > Tdp) && isFullyWet == false) { double iter1 = 1; double error = 1; double Tout_r_guess = 0; x1 = 0.0001; x2 = 0.9999; eps = 1e-8; while ((iter1 <= 3 | change > eps) && iter < 100) { if (iter1 == 1) { f_dry = x1; } if (iter1 > 1) { f_dry = x2; } double K = Ntu_dry * (1.0 - C_star); double expk = Math.Exp(-K * f_dry); if (cp_da * ma < cp_r * mr) { Tout_r_guess = (Tdp + C_star * (Tin_a - Tdp) - expk * (1 - K / Ntu_o) * Tin_a) / (1 - expk * (1 - K / Ntu_o));//zzc } else { Tout_r_guess = (expk * (Tin_a + (C_star - 1) * Tdp) - C_star * (1 + K / Ntu_o) * Tin_a) / (expk * C_star - C_star * (1 + K / Ntu_o));//zzc } epsilon_dry = ((1 - Math.Exp(-f_dry * Ntu_dry * (1 - C_star))) / (1 - C_star * Math.Exp(-f_dry * Ntu_dry * (1 - C_star)))); epsilon_wet = ((1 - Math.Exp(-(1 - f_dry) * Ntu_wet * (1 - m_star))) / (1 - m_star * Math.Exp(-(1 - f_dry) * Ntu_wet * (1 - m_star)))); double T_w_x = (Tin_r + (mdot_min) / (cp_r * mr) * epsilon_wet * (hin_a - h_s_w_i - epsilon_dry * Cmin / ma * Tin_a)) / (1 - (Cmin * mdot_min) / (cp_r * mr * ma) * epsilon_wet * epsilon_dry); T_a_x = Tin_a - epsilon_dry * Cmin * (Tin_a - T_w_x) / (ma * cp_da); h_a_x = hin_a - cp_da * (Tin_a - T_a_x); Tout_r = (Cmin) / (cp_r * mr) * epsilon_dry * Tin_a + (1 - (Cmin) / (cp_r * mr) * epsilon_dry) * T_w_x; error = Tout_r - Tout_r_guess; if (iter1 > 500) { Q = Q_dry; } if (iter1 == 1) { y1 = error; } if (iter1 > 1) { y2 = error; x3 = x2 - y2 / (y2 - y1) * (x2 - x1); change = Math.Abs(y2 / (y2 - y1) * (x2 - x1)); y1 = y2; x1 = x2; x2 = x3; } iter1++; } //if (iter1 > 500) // Q = Q_dry; Q = mr * cp_r * (Tout_r - Tin_r); hout_a = hin_a - Q / ma; h_s_s_e = h_a_x + (hout_a - h_a_x) / (1 - Math.Exp(-(1 - f_dry) * Ntu_owet));//zzc //double T_s_e0 = CoolProp.HAPropsSI("T", "H", h_s_s_e, "P", 101325, "R", 1.0) - 273.15;//////////////// //T_s_e = -273.15 - 1.96 * Math.Pow(10, -3) * Math.Pow(h_s_s_e / 1000, 2) + 0.5357597 * h_s_s_e / 1000 + 268.871551; T_s_e = humidairprop.Ts(h_s_s_e, SourceTableData); Tout_a = T_s_e + (T_a_x - T_s_e) * Math.Exp(-(1 - f_dry) * Ntu_owet);//zzc Q_sensible = ma * cp_da * (Tin_a - Tout_a); } else { Q = Q_wet; } //res.RHout = CoolProp.HAPropsSI("R", "T", Tout_a + 273.15, "P", 101325, "H", hout_a); //double resRHout1 = CoolProp.HAPropsSI("R", "T", Tout_a + 273.15, "P", 101325, "H", hout_a); //res.RHout = 0.0259124 - 0.0996818 * Tout_a + 0.0934877 * (hout_a / 1000) + 0.0040018 * Math.Pow(Tout_a, 2) - 0.0003662 * Math.Pow((hout_a / 1000), 2) - 0.0034077 * Tout_a * (hout_a / 1000) - 1.76447 * Math.Pow(10, -5) * Math.Pow(Tout_a, 3) - 2.74524 * Math.Pow(10, -6) * Math.Pow((hout_a / 1000), 3) + 2.99291 * Math.Pow(10, -5) * Tout_a * Math.Pow((hout_a / 1000), 2) - 9.56644 * Math.Pow(10, -6) * Math.Pow(Tout_a, 2) * (hout_a / 1000); Tdp_out = humidairprop.Ts(hout_a, SourceTableData); res.RHout = humidairprop.RHI(Tout_a, Tdp_out, SourceTableData); if (res.RHout > 1) { //res.RHout = 1; //double Tout_a0 = CoolProp.HAPropsSI("T", "H", hout_a, "P", 101325, "R", 1)-273.15; //Tout_a = -273.15 - 1.96 * Math.Pow(10, -3) * Math.Pow(hout_a / 1000, 2) + 0.5357597 * hout_a / 1000 + 268.871551; //Tdp_out0 = CoolProp.HAPropsSI("T", "H", hout_a, "P", 101325, "R", 1.0) - 273.15;//@@@ Tout_a = humidairprop.Ts(hout_a, SourceTableData); Q_sensible = ma * cp_da * (Tin_a - Tout_a); } } } else { Tout_a = Tout_a_dry; Q = Q_dry; Q_sensible = Q_dry; double hout_a = hin_a - Q / ma * Math.Pow(-1, hexType); //***delete***// //res.RHout = CoolProp.HAPropsSI("R", "T", Tout_a + 273.15, "P", 101325, "W", omega_out); //res.RHout = 0.0215344 - 0.0059467 * Tout_a + 0.2386894 * (omega_out * 1000) + 0.0004378 * Math.Pow(Tout_a, 2) + 0.0004635 * Math.Pow((omega_out * 1000), 2) - 0.0125912 * Tout_a * (omega_out * 1000) - 9.134 * Math.Pow(10, -6) * Math.Pow(Tout_a, 3) + 1.696 * Math.Pow(10, -6) * Math.Pow((omega_out * 1000), 3) - 2.214 * Math.Pow(10, -5) * Tout_a * Math.Pow((omega_out * 1000), 2) + 0.000200865 * Math.Pow(Tout_a, 2) * (omega_out * 1000); //***delete***// //res.RHout = CoolProp.HAPropsSI("R", "T", Tout_a + 273.15, "P", 101325, "H", hout_a); //double resRHout0 = CoolProp.HAPropsSI("R", "T", Tout_a + 273.15, "P", 101325, "H", hout_a); //res.RHout = 0.0259124 - 0.0996818 * Tout_a + 0.0934877 * (hout_a / 1000) + 0.0040018 * Math.Pow(Tout_a, 2) - 0.0003662 * Math.Pow((hout_a / 1000), 2) - 0.0034077 * Tout_a * (hout_a / 1000) - 1.76447 * Math.Pow(10, -5) * Math.Pow(Tout_a, 3) - 2.74524 * Math.Pow(10, -6) * Math.Pow((hout_a / 1000), 3) + 2.99291 * Math.Pow(10, -5) * Tout_a * Math.Pow((hout_a / 1000), 2) - 9.56644 * Math.Pow(10, -6) * Math.Pow(Tout_a, 2) * (hout_a / 1000); //double Tdp_out0 = CoolProp.HAPropsSI("T", "H", hout_a, "P", 101325, "R", 1.0) - 273.15;//@@@ double Tdp_out = humidairprop.Ts(hout_a, SourceTableData); res.RHout = humidairprop.RHI(Tout_a, Tdp_out, SourceTableData); } res.Tao = Tout_a; res.Tro = Tout_r; res.Q = Q / 1000; //res.hro = (hri + Math.Pow(-1, hexType) * res.Q / mr); double f_sp = RefrigerantSPDP.ff_Friction(Re_r); res.DP = zdp * f_sp * l / dh * Math.Pow(g, 2.0) / rho_r / 2000; res.Pro = fluid == "Water" ? pri : pri - res.DP; if (res.Pro < 0) { res.Pro = -10000000; return(res); } res.hro = hri + Math.Pow(-1, hexType) * res.Q / mr; res.R_1a = 1 / ((eta_0 * Aa_fin + Aa_tube) * ha); res.R_1r = 1 / (res.href * Ar); res.R_1 = res.R_1a + res.R_1r + r_metal; if (fluid != "Water") { coolprop.update(input_pairs.HmassP_INPUTS, res.hro * 1000, res.Pro * 1000); res.Tro = coolprop.T() - 273.15; //res.Tro = CoolProp.PropsSI("T", "P", res.Pro * 1000, "H", res.hro * 1000, fluid) - 273.15; } return(res); }
public static CalcResult ElementCalc(string fluid, double l, double Aa_fin, double Aa_tube, double A_r_cs, double Ar, Geometry geo, double tai, double RHi, double tri, double pri, double hri, double mr, double g, double ma, double ha, double haw, double eta_surface, double zh, double zdp, int hexType, double thickness, double conductivity, double Pwater, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double dh = geo.Di; double r_metal = thickness / conductivity / Ar; double gg = 9.8; CalcResult res = new CalcResult(); coolprop.update(input_pairs.HmassP_INPUTS, hri * 1000, (fluid == "Water" ? Pwater : pri) * 1000); double mu_r = coolprop.viscosity(); //double mu_r = CoolProp.PropsSI("V", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double k_r = coolprop.conductivity(); //double k_r = CoolProp.PropsSI("L", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double rho_r = coolprop.rhomass(); //double rho_r = CoolProp.PropsSI("D", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double cp_r = coolprop.cpmass(); //double cp_r = CoolProp.PropsSI("C", "H", hri * 1000, "P", (fluid == "Water" ? Pwater : pri) * 1000, fluid); double Pr_r = cp_r * mu_r / k_r; //for debugging, to check if the 1ph property is in 2ph region but not in 1ph, ruhao20180209 /* * var rr = new Refrigerant.SATTTotalResult(); * rr = Refrigerant.SATTTotal(fluid, composition, Refrigerant.SATP(fluid, composition, pri, 1).Temperature).SATTTotalResult; //satruration temperature * if ( rho_r > rr.DensityV && rho_r < rr.DensityL) * { * throw new Exception("property is not in 1ph region"); * } */ res.Vel_r = g / rho_r; double Re_r = rho_r * res.Vel_r * dh / mu_r; double fh = RefrigerantSPHTC.ff_CHURCHILL(Re_r); double Nusselt = RefrigerantSPHTC.NU_GNIELINSKI(Re_r, Pr_r, fh); res.href = Nusselt * k_r / dh * zh; double cp_a = 1.0; cp_a = (hexType == 0 ? 1.027 : 1.02); double C_r = mr * cp_r / 1000; 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 C_min = Math.Min(C_a, C_r); double C_max = Math.Max(C_a, C_r); double C_ratio = C_min / C_max; double NTU = UA / (C_min * 1000); //流体不混合的一次交叉流 //double epsilon_jc = 1 - Math.Exp(Math.Pow(C_ratio,-1.0)*Math.Pow(NTU,0.22) //*(Math.Exp(-C_ratio*Math.Pow(NTU,0.78))-1)); //顺流计算公式 //double epsilon_downflow = (1 - Math.Exp(-NTU * (1 + C_ratio))) / (1 + C_ratio); //逆流计算公式 double epsilon_counterflow = (1 - Math.Exp(-NTU * (1 - C_ratio))) / (1 - C_ratio * Math.Exp(-NTU * (1 - C_ratio))); double epsilon = epsilon_counterflow; res.Q = epsilon * C_min * (tai - tri) * Math.Pow(-1, hexType); if (C_r < C_a) { // hexType=0 :evap, 1:cond res.Tro = tri + epsilon * (tai - tri); //Math.Abs(tai - tri); res.Tao = tai - C_r * ((res.Tro - tri) / C_a); //Math.Abs(res.Tro - tri) } else { res.Tao = tai - epsilon * (tai - tri); //Math.Abs(tai - tri) res.Tro = tri + C_a * ((tai - res.Tao) / C_r); //(Math.Abs(tai - res.Tao) / C_r) } double f_sp = RefrigerantSPDP.ff_Friction(Re_r); res.DP = zdp * f_sp * l / dh * Math.Pow(g, 2.0) / rho_r / 2000; res.Pro = fluid == "Water" ? pri : pri - res.DP; if (res.Pro < 0) { res.Pro = -10000000; return(res); } res.hro = hri + Math.Pow(-1, hexType) * res.Q / mr; //re-calc tro for refrigerant to avoid Tro < Tsat if (fluid != "Water") { coolprop.update(input_pairs.HmassP_INPUTS, res.hro * 1000, res.Pro * 1000); res.Tro = coolprop.T() - 273.15; //res.Tro = CoolProp.PropsSI("T", "P", res.Pro * 1000, "H", res.hro * 1000, fluid) - 273.15; } res.RHout = 1.1 * RHi; string arr1 = Convert.ToString(res.Q); Console.WriteLine("Q={0}", arr1); return(res); }
public static double deltap_MS(string fluid, double d, double g, double p, double x, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); //double Co=0.01; //double f_oil = 0; //if (x == 1) f_oil = 1.0; else f_oil = 1.15; //double m_to_ft = 1000 / (12 * 25.4); //double dp = 0.0; double DensityL, DensityV, ViscosityL, ViscosityV; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); double tsat = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, tsat); DensityL = coolprop.rhomass(); ViscosityL = coolprop.viscosity(); coolprop.update(input_pairs.QT_INPUTS, 1, tsat); DensityV = coolprop.rhomass(); ViscosityV = coolprop.viscosity(); double Re_l = g * (1 - x) * d / ViscosityL; double Re_v = g * x * d / ViscosityV; double f_l = 0; double f_v = 0; if (Re_l <= 1187) { f_l = 64 / Re_l; } else { f_l = 0.3164 / Math.Pow(Re_l, 0.25); } if (Re_v <= 1187) { f_v = 64 / Re_v; } else { f_v = 0.3164 / Math.Pow(Re_v, 0.25); } double DP_l = 4 * f_l * l * Math.Pow(g * (1 - x), 2.0) / (2 * DensityL * d); //摩擦压降 double a = 2 * f_l * Math.Pow(g * (1 - x), 2.0) / (DensityL * d); double b = 2 * f_v * Math.Pow(g * x, 2.0) / (DensityV * d); double c = a + 2 * (b - a) * x; double dp_dz = c * Math.Pow(1 - x, 1.0 / 3) + b * Math.Pow(x, 3); double f_gd = 1 + dp_dz * ((DensityL / DensityV) / (Math.Pow(ViscosityL / ViscosityV, 0.25)) - 1); double DP_frict = f_gd * DP_l; //加速(动力)压降 double DP_mom = 0; //两相总压降 double dp = (DP_frict + DP_mom) * 0.001; return(dp); //double DP_tp = 0; //if (x <= 0.8) //{ //double f_tp = 0.007397899 / (Math.Pow(x, 0.8) * Math.Pow(d * m_to_ft, 0.5)); //"Sacks & Geary" //DP_tp = f_tp * f_oil * Math.Pow(x * g, 2.0) / (2 * r.DensityV * d); //dp = Math.Max(DP_l, DP_tp) * l; //dp = dp * 0.001; //} //else //{ //double x_point8 = 0.8; //double f_tp_x_point8 = 0.007397899 / (Math.Pow(x_point8, 0.8) * Math.Pow(d * m_to_ft, 0.5)); //0.00566 //double DP_tp_point8 = f_tp_x_point8 * f_oil * Math.Pow(x_point8 * g, 2.0) / (2 * r.DensityV * d); //double x_1 = 1.0; //double f_tp_x_1 = f_v * (1 + 14.73 * Math.Pow(Co, 0.591958)) / Math.Pow(m_to_ft, 0.5); //double DP_tp_1 = f_tp_x_1 * f_oil * Math.Pow(x_1 * g, 2.0) / (2 * r.DensityV * d); //DP_tp = (DP_tp_point8 + (x - 0.8) / (1.0 - 0.8) * (DP_tp_1 - DP_tp_point8)) * l; //dp = DP_tp * 0.001; //} //return dp; }
//For smooth tube for now; public static double deltap_smooth(string fluid, double d, double g, double p, double x, double l, AbstractState coolprop) { //AbstractState coolprop = AbstractState.factory("HEOS", fluid); double Co = 0.01; double f_oil = 0; if (x == 1) { f_oil = 1.0; } else { f_oil = 1.15; } double m_to_ft = 1000 / (12 * 25.4); double dp = 0.0; int phase1 = 1; int phase2 = 2; double DensityL, DensityV, ViscosityL, ViscosityV; coolprop.update(input_pairs.PQ_INPUTS, p * 1000, 0); double tsat = coolprop.T(); coolprop.update(input_pairs.QT_INPUTS, 0, tsat); DensityL = coolprop.rhomass(); ViscosityL = coolprop.viscosity(); coolprop.update(input_pairs.QT_INPUTS, 1, tsat); DensityV = coolprop.rhomass(); ViscosityV = coolprop.viscosity(); double Re_l = g * d / ViscosityL;// r.ViscosityL; double Re_v = g * d / ViscosityV; double f_l = RefrigerantSPDP.ff_Friction(Re_l); double f_v = RefrigerantSPDP.ff_Friction(Re_v); double DP_l = f_l * Math.Pow(g, 2.0) / (2 * DensityL * d); double DP_tp = 0; if (x <= 0.8) { double f_tp = 0.007397899 / (Math.Pow(x, 0.8) * Math.Pow(d * m_to_ft, 0.5)); //"Sacks & Geary" DP_tp = f_tp * f_oil * Math.Pow(x * g, 2.0) / (2 * DensityV * d); dp = Math.Max(DP_l, DP_tp) * l; dp = dp * 0.001; } else { double x_point8 = 0.8; double f_tp_x_point8 = 0.007397899 / (Math.Pow(x_point8, 0.8) * Math.Pow(d * m_to_ft, 0.5)); //0.00566 double DP_tp_point8 = f_tp_x_point8 * f_oil * Math.Pow(x_point8 * g, 2.0) / (2 * DensityV * d); double x_1 = 1.0; double f_tp_x_1 = f_v * (1 + 14.73 * Math.Pow(Co, 0.591958)) / Math.Pow(m_to_ft, 0.5); double DP_tp_1 = f_tp_x_1 * f_oil * Math.Pow(x_1 * g, 2.0) / (2 * DensityV * d); DP_tp = (DP_tp_point8 + (x - 0.8) / (1.0 - 0.8) * (DP_tp_1 - DP_tp_point8)) * l; dp = DP_tp * 0.001; } return(dp); }