diff --git a/ruoyi-geek-vue3 b/ruoyi-geek-vue3 index 26446e5..ab0a15c 160000 --- a/ruoyi-geek-vue3 +++ b/ruoyi-geek-vue3 @@ -1 +1 @@ -Subproject commit 26446e5304424bcfe69036a30867cc428e5a929c +Subproject commit ab0a15c456bcaeff87f46d56d390162de82d7e6f diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/DpFlowCalc.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/DpFlowCalc.java new file mode 100644 index 0000000..84218ff --- /dev/null +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/DpFlowCalc.java @@ -0,0 +1,1130 @@ +package com.ruoyi.ngCalTools.controller; + +import com.ruoyi.ngCalTools.model.FlowProps; +import com.ruoyi.ngCalTools.model.GasProps; + +import javax.swing.*; +import java.util.Optional; + +import static com.ruoyi.ngCalTools.controller.FlowController.FlowConvert_BaseToWork; +import static com.ruoyi.ngCalTools.controller.FlowController.YaLiSunShi; + +public class DpFlowCalc { + /** + 标准孔板流量计算 + */ + public void OFlowCal(GasProps gasProps, FlowProps flowProps){ + + flowProps.setdOrificeD(flowProps.getdOrificeD() * (1 + 0.000001 * (flowProps.getdOrificeMaterial()) * (flowProps.getdTf() - 293.15))); + flowProps.setdPipeD(flowProps.getdPipeD() * (1 + 0.000001 * (flowProps.getdPipeMaterial()) * (flowProps.getdTf() - 293.15))); + flowProps.setdBeta(flowProps.getdOrificeD() / flowProps.getdPipeD()); +// flowProps.setdBeta(0.5972); + + //求渐近速度系数 E + flowProps.setdE(1 / Math.pow((1 - Math.pow(flowProps.getdBeta(), 4)), 0.5)); +// flowProps.setdE(1.0615); + + //求相对密度系数 FG + // LiuTiType = 1 + flowProps.setdFG(Math.pow((1 / gasProps.dRD_Real), 0.5)); +// flowProps.setdFG(1.2531); + //求流动温度系数 'FT + flowProps.setdFT(Math.pow((293.15 / flowProps.getdTf()), 0.5)); +// flowProps.setdFT(1.0086); + //求等熵指数????????????????????????????????? + + flowProps.setdKappa(gasProps.dKappa); +// flowProps.setdKappa(1.357); + + //求动力粘度 dlnd + flowProps.setdDViscosity(Dlndjs(flowProps.getdPf()/1e6, flowProps.getdTf())); +// flowProps.setdDViscosity(0.01096); + + //求可膨胀系数 + flowProps.setdDExpCoefficient(KePenZhang_JiSuan(flowProps.getdPf() , flowProps.getdDp(), flowProps.getdBeta(), gasProps.getdKappa(), flowProps.getdCoreType(), 0)); +// flowProps.setdDExpCoefficient(0.9977); + +// gasProps.dFpv=1.0195; +// gasProps.dHhvv=39.944; +// gasProps.dRD_Real=0.6368; + + //迭代计算流量和流出系数 + + double conQvA = 0.0000031795 * (1530000.0D * gasProps.dRD_Real / (flowProps.getdDViscosity() * flowProps.getdOrificeD())) * flowProps.getdE() * Math.pow(flowProps.getdOrificeD(), 2) * gasProps.dFpv * flowProps.getdFG() * flowProps.getdDExpCoefficient() * flowProps.getdFT() * Math.sqrt(flowProps.getdPf() * flowProps.getdDp() / 1e6); + double[] XQv = new double[4]; + double[] CQv = new double[4]; + double[] dQv = new double[4]; + double Qn = 0; + int n ; + XQv[0] = 1000000.0F; + boolean xhFlag=true; + _100000: + + while(xhFlag) { + for (n = 1; n <= 2; n++) { + CQv[n] = C_JiSuan(flowProps.getdOrificeD(), flowProps.getdBeta(), XQv[n - 1], conQvA, flowProps.getdPtmode(), flowProps.getdCoreType(), 0); + XQv[n] = conQvA * CQv[n]; + dQv[n] = XQv[n] - XQv[n - 1]; + } + if (XQv[2] == XQv[1] || dQv[2] == dQv[1]) { + Qn = conQvA * flowProps.getdDViscosity() * flowProps.getdOrificeD() * CQv[2] / (1530000.0D * gasProps.dRD_Real); + //管道雷诺数 + flowProps.setdRnPipe(XQv[2]); + //流出系数 + flowProps.setdCd(CQv[2]); + + } + if (Math.abs((conQvA - XQv[2] / CQv[1]) / conQvA) > 0.00000000000000005) { + XQv[0] = XQv[n - 1] - dQv[n - 1] * ((XQv[n - 1] - XQv[n - 2]) / (dQv[n - 1] - dQv[n - 2])); +//C# TO JAVA CONVERTER TODO TASK: There is no 'goto' in Java: + continue _100000; + } + else + { + xhFlag=false; + } + } + + //孔板锐利度系数Bk + flowProps.setdOrificeSharpness(1); + if (flowProps.getdCoreType() == 0) + { + flowProps.setdBk((flowProps.getdOrificeSharpness() == 0) ? (BkTable(flowProps.getdOrificeRk(), flowProps.getdOrificeD(), 1)) : (flowProps.getdOrificeSharpness())); + } + else + { + flowProps.setdBk(1); + } + + + //管道粗糙度系数 Gme + flowProps.setdRoughNessPipe(CcdXsjs(flowProps.getdPipeType(), flowProps.getdPipeD(), flowProps.getdBeta(), flowProps.getdRnPipe())); + //修正后的流出系数 + flowProps.setdCd(flowProps.getdCd() * flowProps.getdBk() * flowProps.getdRoughNessPipe()); +// flowProps.setdCd(0.6039); + //标况体积流量 m³、s + flowProps.setdVFlowb(Qn * flowProps.getdBk() * flowProps.getdRoughNessPipe()); + //工况体积流量 + flowProps.setdVFlowf(FlowConvert_BaseToWork(flowProps, gasProps)); + //标况质量流量 + flowProps.setdMFlowb(flowProps.getdVFlowb() * gasProps.dRhob); + //标况能量流量 + flowProps.setdEFlowb(flowProps.getdVFlowb() * gasProps.dHhvv); + //管道内天然气流速 + flowProps.setdVelocityFlow(flowProps.getdVFlowf() / (3.1415926 * Math.pow((flowProps.getdPipeD() / 2000), 2))); + //压力损失 + flowProps.setdPressLost(YaLiSunShi(flowProps.getdCd(), flowProps.getdBeta(), flowProps.getdDp(), flowProps.getdCoreType())); + } + + /** + * 计算管道绝对粗糙度 K (GB/T 21446-2008 附录C) + * @param flowProps + * @return 粗糙度修正系数 K (保留4位小数) + */ + public static double calculateK(FlowProps flowProps){ + double Jdccd; + switch (flowProps.getdPipeType()) { + + case 0: + Jdccd = 0.029F; + break; + case 1: + case 2: + case 3: + Jdccd = 0.075F; + break; + case 4: + Jdccd = 0.1F; + break; + case 5: + Jdccd = 0.15F; + break; + case 6: + Jdccd = 1; + break; + case 7: + Jdccd = 2.1F; + break; + case 8: + Jdccd = 0.04F; + break; + case 9: + Jdccd = 0.15F; + break; + case 10: + Jdccd = 0.13F; + break; + case 11: + Jdccd = 0.25F; + break; + default: + // 处理未知类型(可选) + throw new IllegalArgumentException("未知的管道类型: "); + } + return Jdccd; + } + + /** + * 计算管道粗糙度修正系数 G_me (GB/T 21446-2008 附录C) + * @param D_pipe 管道内径 (mm) + * @param K 绝对粗糙度 (mm) + * @param C 未修正的流出系数 + * @return 粗糙度修正系数 G_me (保留4位小数) + */ + public static double calculateRoughnessFactor(double D_pipe, double K, double C) { + // 计算相对粗糙度 K/D + double K_over_D = K / D_pipe; + + // 判断是否需要修正 + if (K_over_D <= 0.0004) { + return 1.0000; + } + + // 计算修正项 + double term = (K_over_D * 1e6) - 400; // 转换为无量纲项 + if (term < 0) { + throw new IllegalArgumentException("K/D 超出修正公式适用范围"); + } + + double G_me = 1 + (0.011 / C) * Math.sqrt(term); + return FormatUtil.format(G_me, Optional.of(4)); // 保留四位小数 + } + + /** + * 热膨胀修正(GB/T 21446-2008 第6.2.1节) + * @param flowProps 流量参数 + */ + public static void thermalExpansionCorrection(FlowProps flowProps) { + // 孔板孔径修正 + double dOrificeMaterial = flowProps.getdOrificeMaterial(); // 材料膨胀系数 (e.g. 16e-6/℃) + double dOrificeD = flowProps.getdOrificeD(); // 初始孔径(mm) + double dOrificeD_corrected = dOrificeD * (1 + 0.000001*dOrificeMaterial * (flowProps.getdTf() - 293.15)); // 20℃为参考温度 + flowProps.setdOrificeD(FormatUtil.format(dOrificeD_corrected, Optional.of(2))); + + // 管道内径修正 + double dPipeMaterial = flowProps.getdPipeMaterial(); + double dPipeD = flowProps.getdPipeD(); + double dPipeD_corrected = dPipeD * (1 + 0.000001*dPipeMaterial * (flowProps.getdTf() - 293.15)); + flowProps.setdPipeD(FormatUtil.format(dPipeD_corrected,Optional.of(2))); + + // 更新直径比β + flowProps.setdBeta( FormatUtil.format(flowProps.getdOrificeD() / flowProps.getdPipeD(),Optional.of(4))); + } + + /** + * 计算渐近速度系数E(GB/T 21446-2008 式(8)) + */ + public static void calculateE(FlowProps flowProps) { + double beta = flowProps.getdBeta(); + flowProps.setdE( FormatUtil.format(1 / Math.sqrt(1 - Math.pow(beta, 4)),Optional.of(4))); + } + + /** + * 计算相对密度系数FG(GB/T 21446-2008 式(9)) + */ + public static void calculateFG(FlowProps flowProps,GasProps gasProps) { + gasProps.setdRD_Real(gasProps.getdRD_Real()); + flowProps.setdFG( FormatUtil.format(1 / Math.sqrt(gasProps.dRD_Real),Optional.of(4))); + } + + /** + * 计算流动温度系数FT(GB/T 21446-2008 式(10)) + */ + public static void calculateFT(FlowProps flowProps) { + double Tb = flowProps.getdTb_M() ; // 参比温度转K + double Tf = flowProps.getdTf() ; // 工况温度转K + flowProps.setdFT( FormatUtil.format(Math.sqrt(Tb / Tf),Optional.of(4))); + } + + /** + * 计算可膨胀系数ε(GB/T 21446-2008 式(11)) + */ + public static void calculateEpsilon(FlowProps flowProps, GasProps gasProps) { + double P1 = flowProps.getdPf(); // 上游绝对压力(Pa) + double deltaP = flowProps.getdDp(); // 差压(Pa) + double beta = flowProps.getdBeta(); + double kappa = flowProps.getdKappa(); + + double tau = FormatUtil.format((P1 - deltaP) / P1, Optional.of(4)); // 压力比 + double epsilon=1 - (0.351 + 0.256 * Math.pow(beta, 4) + 0.93 * Math.pow(beta, 8)) * (1 - Math.pow(tau, 1/kappa)); + + flowProps.setdDExpCoefficient( FormatUtil.format(epsilon,Optional.of(4))); + } + /** + * 计算等熵指数κ(GB/T 21446-2008 推荐方法) + * @param gasProps 气体参数(需包含等熵指数或热容比) + * @return 等熵指数κ + */ + public static double calculateKappa(GasProps gasProps) { + // 若已通过AGA 8或其他方法计算,直接返回 +// if (gasProps.getdKappa() > 0) { +// return gasProps.getdKappa(); +// } + + // 近似公式:基于理想气体比热比和压缩因子修正 + double gamma = 1.3; // 天然气典型比热比(Cp/Cv≈1.3) + double Z = gasProps.getdZf(); // 工况压缩因子 + + // 修正公式(经验关系) + double kappa = gamma / (1 - (gamma - 1) * (1 / Z - 1)); + return FormatUtil.format(kappa,Optional.of(4)); + } + + + + /** + * 迭代计算流量(GB/T 21446-2008 第7章) + * @param flowProps 流量参数 + * @param gasProps 气体参数 + */ + public static void iterativeFlowCalculation(FlowProps flowProps, GasProps gasProps) { + // 0. 单位转换 + double D = flowProps.getdPipeD() / 1000.0; // 管道内径(m) + double d = flowProps.getdOrificeD() / 1000.0; // 孔板孔径(m) + double beta = flowProps.getdBeta(); + double P1 = flowProps.getdPf(); // 绝对压力(Pa) + double deltaP = flowProps.getdDp(); // 差压(Pa) + double Tf = flowProps.getdTf() ; // 工况温度(K) + + flowProps.setdPb_M(gasProps.getdPb()); + flowProps.setdTb_M(gasProps.getdTb()); + flowProps.setdFpv(FormatUtil.format(gasProps.dFpv,Optional.of(4))); + + // 1. 计算中间参数 + calculateE(flowProps); + calculateFG(flowProps,gasProps); + calculateFT(flowProps); + + flowProps.setdKappa( calculateKappa(gasProps)); +// flowProps.setdDViscosity( calculateDynamicViscosity(gasProps)); + flowProps.setdDViscosity(FormatUtil.format( Dlndjs(flowProps.getdPf()/1e6,flowProps.getdTf()),Optional.of(5))); + calculateEpsilon(flowProps, gasProps); + + flowProps.setdKappa(1.357); +// flowProps.setdBeta(0.5792); +// flowProps.setdFpv(1.0195); +// flowProps.setdFG(1.2531); +// flowProps.setdE(1.0615); +// flowProps.setdDExpCoefficient(0.9977); +// flowProps.setdFT(1.0086); + + + // 2. 初始雷诺数估算(假设初始C=0.6) + double C_initial = 0.6; + double Qf_initial = (C_initial * flowProps.getdE() * flowProps.getdDExpCoefficient() * Math.PI * Math.pow(d, 2) / 4) + * Math.sqrt(2 * deltaP / (gasProps.dRhof * (1 - Math.pow(beta, 4)))); + flowProps.setdVFlowf(Qf_initial); // 初始工况流量(m³/s) + + // 3. 迭代参数 + double tolerance = 1e-6; + int maxIter = 100; + double currentC = C_initial; + double currentReD = calculateReD(Qf_initial, D, gasProps.dRhof, flowProps.getdDViscosity()); + int iter = 0; + double prevC=0; + // 4. 迭代循环 + do { + prevC = currentC; + + // 4.1 计算流出系数C(GB/T 21446-2008 附录A) + currentC =FormatUtil.format( calculateCd(beta, currentReD, flowProps.getdPipeD(), flowProps.getdPtmode()),Optional.of(4)); + + // 4.2 更新流量 + double Qf =FormatUtil.format ((currentC * flowProps.getdDExpCoefficient() * Math.PI * Math.pow(d, 2) / 4) + * Math.sqrt(2 * deltaP / (gasProps.dRhof * (1 - Math.pow(beta, 4)))),Optional.of(4)); + flowProps.setdVFlowf(Qf); + + // 4.3 更新雷诺数 + currentReD =FormatUtil.format( calculateReD(Qf, D, gasProps.dRhof, flowProps.getdDViscosity()), Optional.of(2)); + + iter++; + if (iter > maxIter) { + throw new RuntimeException("迭代未收敛,超过最大迭代次数!"); + } + } while (Math.abs(currentC - prevC) / currentC > tolerance); + // 5. 保存最终结果 + + // 在迭代计算流出系数后,添加粗糙度修正 + + double K = calculateK(flowProps); // 根据实际管道类型选择 + double G_me = calculateRoughnessFactor(flowProps.getdPipeD(), K, currentC); + double C_corrected = FormatUtil.format(currentC * G_me, Optional.of(4)); + + flowProps.setdCd(C_corrected); + flowProps.setdRoughNessPipe(G_me); + flowProps.setdRnPipe(currentReD); + + + + + // 6. 计算标况流量(GB/T 21446-2008 式(1)) + double Qn = flowProps.getdVFlowf() * (flowProps.getdFpv()*flowProps.getdFpv() * P1 / flowProps.getdPb_M()) + * (flowProps.getdTb_M()) / Tf; + flowProps.setdVFlowb(FormatUtil.format(Qn,Optional.of(4))); + + //标况质量流量 + flowProps.setdMFlowb(FormatUtil.format(flowProps.getdVFlowb() * gasProps.dRhob,Optional.of(4))); + //标况能量流量 + flowProps.setdEFlowb(FormatUtil.format(flowProps.getdVFlowb() * gasProps.dHhvv,Optional.of(4))); + //管道内天然气流速 + flowProps.setdVelocityFlow(FormatUtil.format(flowProps.getdVFlowf() / (Math.PI * Math.pow((flowProps.getdPipeD() / 2000), 2)),Optional.of(3))); + //压力损失 + flowProps.setdPressLost(FormatUtil.format(YaLiSunShi(flowProps.getdCd(), flowProps.getdBeta(), flowProps.getdDp(), flowProps.getdCoreType()),Optional.of(2))); + + } + + + + + + /** + * 计算天然气动力粘度(Sutherland公式简化版,适用于低压天然气) + * @param gasProps 气体参数(需包含温度、密度、组分) + * @return 动力粘度 (Pa·s) + */ + public static double calculateDynamicViscosity(GasProps gasProps) { + double T = gasProps.getdTf() ; // 工况温度(K) + double rho = gasProps.getdRhof(); // 工况密度(kg/m³) + double Rd = gasProps.getdRD_Real(); // 真实相对密度 + + // Sutherland常数(天然气典型值,C=120) + double C = 120.0; // Sutherland常数 + double mu0 = 1.0e-5; // 参考粘度 (Pa·s,@293.15K) + + // 计算粘度(简化公式,忽略压力修正) + double mu = mu0 * Math.pow(T / 293.15, 0.7) * (293.15 + C) / (T + C); + + // 密度修正(经验公式) + mu *= 1 + 0.001 * (rho - 1.2); // 密度对粘度的粗略修正 + + return FormatUtil.format( mu*1000,Optional.of(5)); + } + /** + * 计算雷诺数ReD(GB/T 21446-2008 式(5)) + */ + public static double calculateReD(double Qf, double D, double rho, double mu) { + return FormatUtil.format( (4 * Qf * rho*1000) / (Math.PI * D * mu),Optional.of(2)); // Qf: m³/s, D: m, rho: kg/m³, mu: Pa·s + } + + /** + * 计算流出系数C(GB/T 21446-2008 附录A) + */ + public static double calculateCd(double beta, double ReD, double D_mm, int ptMode) { + double L1, L2; + // 根据取压方式确定L1/L2(角接取压) + switch (ptMode) { + case 1: // 角接取压 + L1 = L2 = 0; // D单位为mm + break; + case 0: // 法兰取压 + L1 = L2 = 25.4 / D_mm; + break; + case 2: // D-D/2取压 + L1 = 1.0; + L2 = 0.47; + break; + default: + throw new IllegalArgumentException("不支持的取压方式"); + } + + double term1 = 0.5961 + 0.0261 * Math.pow(beta, 2) - 0.216 * Math.pow(beta, 8); + double term2 = 0.000521 * Math.pow(1e6 * beta / ReD, 0.7); + double A = Math.pow(19000 * beta / ReD, 0.8); + double term3 = (0.0188 + 0.0063 * A) * Math.pow(beta, 3.5) * Math.pow(1e6 / ReD, 0.3); + double term4 = (0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1)) + * (1 - 0.11 * A) * Math.pow(beta, 4) / (1 - Math.pow(beta, 4)); + double term5 = -0.031 * (2 * L2 / (1 - beta) - 0.8 * Math.pow(2 * L2 / (1 - beta), 1.1)) + * Math.pow(beta, 1.3); + + double Cd = term1 + term2 + term3 + term4 + term5; + + // 孔径<71.12mm修正 + if (D_mm < 71.12) { + Cd += 0.011 * (0.75 - beta) * (2.8 - D_mm / 25.4); + } + return FormatUtil.format(Cd,Optional.of(4)); + } + //查表计算粘度μ + public static double Dlndjs(double tempP_jy, double tempT) + { double[][] Dlndjs_Dlnd_Data = new double[8][11]; + double[] Dlndjs_Dlnd_T = new double[8]; + double[] Dlndjs_Dlnd_P = new double[11]; + double s1 ; + double s2 ; + double ky ; + double kx ; + int i ; + int m = 0; + int n = 0; + //On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C# + Dlndjs_Dlnd_T[0] = -15 + 273.15; + Dlndjs_Dlnd_T[1] = 0 + 273.15; + Dlndjs_Dlnd_T[2] = 15 + 273.15; + Dlndjs_Dlnd_T[3] = 30 + 273.15; + Dlndjs_Dlnd_T[4] = 45 + 273.15; + Dlndjs_Dlnd_T[5] = 60 + 273.15; + Dlndjs_Dlnd_T[6] = 75 + 273.15; + Dlndjs_Dlnd_T[7] = 90 + 273.15; + + Dlndjs_Dlnd_P[0] = 0.1F; + Dlndjs_Dlnd_P[1] = 1; + Dlndjs_Dlnd_P[2] = 2; + Dlndjs_Dlnd_P[3] = 3; + Dlndjs_Dlnd_P[4] = 4; + Dlndjs_Dlnd_P[5] = 5; + Dlndjs_Dlnd_P[6] = 6; + Dlndjs_Dlnd_P[7] = 7; + Dlndjs_Dlnd_P[8] = 8; + Dlndjs_Dlnd_P[9] = 9; + Dlndjs_Dlnd_P[10] = 10; + Dlndjs_Dlnd_Data[0][0] = 976; + Dlndjs_Dlnd_Data[1][0] = 1027; + Dlndjs_Dlnd_Data[2][0] = 1071; + Dlndjs_Dlnd_Data[3][0] = 1123; + Dlndjs_Dlnd_Data[4][0] = 1167; + Dlndjs_Dlnd_Data[5][0] = 1213; + Dlndjs_Dlnd_Data[6][0] = 1260; + Dlndjs_Dlnd_Data[7][0] = 1303; + Dlndjs_Dlnd_Data[0][1] = 991; + Dlndjs_Dlnd_Data[1][1] = 1040; + Dlndjs_Dlnd_Data[2][1] = 1082; + Dlndjs_Dlnd_Data[3][1] = 1135; + Dlndjs_Dlnd_Data[4][1] = 1178; + Dlndjs_Dlnd_Data[5][1] = 1224; + Dlndjs_Dlnd_Data[6][1] = 1270; + Dlndjs_Dlnd_Data[7][1] = 1312; + Dlndjs_Dlnd_Data[0][2] = 1014; + Dlndjs_Dlnd_Data[1][2] = 1063; + Dlndjs_Dlnd_Data[2][2] = 1106; + Dlndjs_Dlnd_Data[3][2] = 1153; + Dlndjs_Dlnd_Data[4][2] = 1196; + Dlndjs_Dlnd_Data[5][2] = 1239; + Dlndjs_Dlnd_Data[6][2] = 1281; + Dlndjs_Dlnd_Data[7][2] = 1323; + Dlndjs_Dlnd_Data[0][3] = 1044; + Dlndjs_Dlnd_Data[1][3] = 1091; + Dlndjs_Dlnd_Data[2][3] = 1127; + Dlndjs_Dlnd_Data[3][3] = 1174; + Dlndjs_Dlnd_Data[4][3] = 1216; + Dlndjs_Dlnd_Data[5][3] = 1257; + Dlndjs_Dlnd_Data[6][3] = 1297; + Dlndjs_Dlnd_Data[7][3] = 1338; + Dlndjs_Dlnd_Data[0][4] = 1073; + Dlndjs_Dlnd_Data[1][4] = 1118; + Dlndjs_Dlnd_Data[2][4] = 1149; + Dlndjs_Dlnd_Data[3][4] = 1195; + Dlndjs_Dlnd_Data[4][4] = 1236; + Dlndjs_Dlnd_Data[5][4] = 1275; + Dlndjs_Dlnd_Data[6][4] = 1313; + Dlndjs_Dlnd_Data[7][4] = 1352; + Dlndjs_Dlnd_Data[0][5] = 1114; + Dlndjs_Dlnd_Data[1][5] = 1151; + Dlndjs_Dlnd_Data[2][5] = 1180; + Dlndjs_Dlnd_Data[3][5] = 1224; + Dlndjs_Dlnd_Data[4][5] = 1261; + Dlndjs_Dlnd_Data[5][5] = 1297; + Dlndjs_Dlnd_Data[6][5] = 1333; + Dlndjs_Dlnd_Data[7][5] = 1372; + Dlndjs_Dlnd_Data[0][6] = 1156; + Dlndjs_Dlnd_Data[1][6] = 1185; + Dlndjs_Dlnd_Data[2][6] = 1211; + Dlndjs_Dlnd_Data[3][6] = 1253; + Dlndjs_Dlnd_Data[4][6] = 1287; + Dlndjs_Dlnd_Data[5][6] = 1320; + Dlndjs_Dlnd_Data[6][6] = 1352; + Dlndjs_Dlnd_Data[7][6] = 1391; + Dlndjs_Dlnd_Data[0][7] = 1207; + Dlndjs_Dlnd_Data[1][7] = 1230; + Dlndjs_Dlnd_Data[2][7] = 1250; + Dlndjs_Dlnd_Data[3][7] = 1289; + Dlndjs_Dlnd_Data[4][7] = 1318; + Dlndjs_Dlnd_Data[5][7] = 1346; + Dlndjs_Dlnd_Data[6][7] = 1374; + Dlndjs_Dlnd_Data[7][7] = 1412; + Dlndjs_Dlnd_Data[0][8] = 1261; + Dlndjs_Dlnd_Data[1][8] = 1276; + Dlndjs_Dlnd_Data[2][8] = 1289; + Dlndjs_Dlnd_Data[3][8] = 1324; + Dlndjs_Dlnd_Data[4][8] = 1350; + Dlndjs_Dlnd_Data[5][8] = 1373; + Dlndjs_Dlnd_Data[6][8] = 1396; + Dlndjs_Dlnd_Data[7][8] = 1432; + Dlndjs_Dlnd_Data[0][9] = 1331; + Dlndjs_Dlnd_Data[1][9] = 1331; + Dlndjs_Dlnd_Data[2][9] = 1335; + Dlndjs_Dlnd_Data[3][9] = 1366; + Dlndjs_Dlnd_Data[4][9] = 1385; + Dlndjs_Dlnd_Data[5][9] = 1403; + Dlndjs_Dlnd_Data[6][9] = 1424; + Dlndjs_Dlnd_Data[7][9] = 1456; + Dlndjs_Dlnd_Data[0][10] = 1405; + Dlndjs_Dlnd_Data[1][10] = 1389; + Dlndjs_Dlnd_Data[2][10] = 1383; + Dlndjs_Dlnd_Data[3][10] = 1409; + Dlndjs_Dlnd_Data[4][10] = 1421; + Dlndjs_Dlnd_Data[5][10] = 1435; + Dlndjs_Dlnd_Data[6][10] = 1451; + Dlndjs_Dlnd_Data[7][10] = 1482; + + if (tempT < Dlndjs_Dlnd_T[0]) + { + tempT = Dlndjs_Dlnd_T[0]; + } + if (tempT > Dlndjs_Dlnd_T[7]) + { + tempT = Dlndjs_Dlnd_T[7]; + } + if (tempP_jy < Dlndjs_Dlnd_P[0]) + { + tempP_jy = Dlndjs_Dlnd_P[0]; + } + if (tempP_jy > Dlndjs_Dlnd_P[10]) + { + tempP_jy = Dlndjs_Dlnd_P[10]; + } + + for ( i = 0; i <= 6; i++) + { + if (tempT >= Dlndjs_Dlnd_T[i] && tempT <= Dlndjs_Dlnd_T[i + 1]) + { + m = i; + break; + } + } + + for (i = 0; i <= 9; i++) + { + if (tempP_jy >= Dlndjs_Dlnd_P[i] && tempP_jy <= Dlndjs_Dlnd_P[i + 1]) + { + n = i; + break; + } + } + + if (Dlndjs_Dlnd_P[n + 1] - Dlndjs_Dlnd_P[n] != 0) + { + ky = (tempP_jy - Dlndjs_Dlnd_P[n]) / (Dlndjs_Dlnd_P[n + 1] - Dlndjs_Dlnd_P[n]); + } + else + { + ky = 0; + } + if (Dlndjs_Dlnd_T[m + 1] - Dlndjs_Dlnd_T[m] != 0) + { + kx = (tempT - Dlndjs_Dlnd_T[m]) / (Dlndjs_Dlnd_T[m + 1] - Dlndjs_Dlnd_T[m]); + } + else + { + kx = 0; + } + s1 = Dlndjs_Dlnd_Data[m][n] + (Dlndjs_Dlnd_Data[m][n + 1] - Dlndjs_Dlnd_Data[m][n]) * ky; + s2 = Dlndjs_Dlnd_Data[m + 1][n] + (Dlndjs_Dlnd_Data[m + 1][n + 1] - Dlndjs_Dlnd_Data[m + 1][n]) * ky; + return (s1 + (s2 - s1) * kx) / 100000.0D; + } + //可膨胀系数计算 + private double KePenZhang_JiSuan(double tempP_jy, double tempDp_Pa, double tempZjb, double tempDszs, int JIeliuType, int JiSuanBiaoZhun) // 求可膨胀系数 + { + double returnValue = 0; + //0标准孔板 + //1ISA1932喷嘴 + //2长径喷嘴 + //3文丘里喷嘴 + //4粗铸收缩段经典文丘里管 + //5机械加工收缩段经典文丘里管 + //6粗焊铁板收缩段经典文丘里管 + //7 1/4圆孔板 + + double tuo ; + switch (JIeliuType) + { + case 0: //孔板流量计算 + switch (JiSuanBiaoZhun) + { + case 0: //6143-2004 + tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); + returnValue = 1 - (0.351 + 0.256 * Math.pow(tempZjb, 4) + 0.93 * Math.pow(tempZjb, 8)) * (1 - Math.pow(tuo, (1 / tempDszs))); + break; + case 1: //6143-1996 + returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); + break; + } + break; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + switch (JiSuanBiaoZhun) + { + case 0: + //标准喷嘴 iso5167-2002 + tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); + returnValue = Math.pow((((tempDszs * Math.pow(tuo, (2 / tempDszs))) / (tempDszs - 1)) * ((1 - Math.pow(tempZjb, 4)) / (1 - Math.pow(tempZjb, 4) * Math.pow(tuo, (2 / tempDszs)))) * ((1 - Math.pow(tuo, ((tempDszs - 1) / tempDszs))) / (1 - tuo))), 0.5); + break; + + case 1: //iso5167-93 + returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); + break; + } + break; + case 7: //1/4圆孔板 + returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); + break; + case 8: //锥形入口孔板 + tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); + returnValue = 1 - (0.351 + 0.256 * Math.pow(tempZjb, 4) + 0.93 * Math.pow(tempZjb, 8)) * (1 - Math.pow(tuo, (1 / tempDszs))); + + tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); + + returnValue = 0.5 * (returnValue + Math.pow((((tempDszs * Math.pow(tuo, (2 / tempDszs))) / (tempDszs - 1)) * ((1 - Math.pow(tempZjb, 4)) / (1 - Math.pow(tempZjb, 4) * Math.pow(tuo, (2 / tempDszs)))) * ((1 - Math.pow(tuo, ((tempDszs - 1) / tempDszs))) / (1 - tuo))), 0.5)); + break; + case 9: //偏心孔板 + returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); + break; + + } + return returnValue; + } + //流出系数计算 + public final double C_JiSuan(double tempGj, double tempZjb, double tempReD, double tempconQvA, int tempQyfs, int JieLiuType, int JiSuanBiaoZhun) + { + double returnValue = 0; + //流出系数计算函数 + //输入:直径比,雷诺数,取压方式,节流装置类型,计算采用标准 + //输出:流出系数 + + //jieliutype + + //0标准孔板 + //1ISA1932喷嘴 + //2长径喷嘴 + //3文丘里喷嘴 + //4粗铸收缩段经典文丘里管 + //5机械加工收缩段经典文丘里管 + //6粗焊铁板收缩段经典文丘里管 + + double L1 = 0; + double L2 = 0; + switch (JieLiuType) + { + case 0: //孔板 + switch (tempQyfs) + { + case 0: + L1 = 25.4 / tempGj; + L2 = L1; + break; + case 1: + L1 = 0; + L2 = 0; + break; + case 2: + L1 = 1; + L2 = 0.47F; + break; + } + switch (JiSuanBiaoZhun) + { + case 0: //6143-2004 + if (tempGj >= 71.12) + { + returnValue = 0.5961 + 0.0261 * Math.pow(tempZjb, 2) - 0.216 * Math.pow(tempZjb, 8) + 0.000521 * Math.pow((1000000.0D * tempZjb / tempReD), 0.7) + (0.0188 + 0.0063 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * Math.pow(tempZjb, 3.5) * Math.pow((1000000.0D / tempReD), 0.3) + (0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1)) * (1 - 0.11 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * (Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1))) - 0.031 * (2 * L2 / (1 - tempZjb) - 0.8 * Math.pow((2 * L2 / (1 - tempZjb)), 1.1)) * Math.pow(tempZjb, 1.3); + } + else if (tempGj < 71.12) + { + returnValue = (0.5961 + 0.0261 * Math.pow(tempZjb, 2) - 0.216 * Math.pow(tempZjb, 8) + 0.000521 * Math.pow((1000000.0D * tempZjb / tempReD), 0.7) + (0.0188 + 0.0063 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * Math.pow(tempZjb, 3.5) * Math.pow((1000000.0D / tempReD), 0.3) + (0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1)) * (1 - 0.11 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1)) - 0.031 * (2 * L2 / (1 - tempZjb) - 0.8 * Math.pow((2 * L2 * (1 - tempZjb)), 1.1)) * Math.pow(tempZjb, 1.3) + 0.011 * (0.75 - tempZjb) * (2.8 - tempGj / 25.4)); + } + break; + case 1: //6143-1996 + if (0.09 * L1 >= 0.039) + { + returnValue = 0.5959 + 0.0312 * Math.pow(tempZjb, (2.1)) - 0.184 * Math.pow(tempZjb, 8) + 0.0029 * Math.pow(tempZjb, 2.5) * Math.pow((1000000.0D / tempReD), 0.75) + 0.039 * Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1)) - 0.0337 * L1 * Math.pow(tempZjb, 3); + } + else if (0.09 * L1 < 0.039) + { + returnValue = (0.5959 + 0.0312 * Math.pow(tempZjb, (2.1)) - 0.184 * Math.pow(tempZjb, 8) + 0.0029 * Math.pow(tempZjb, 2.5) * Math.pow((1000000.0D / tempReD), 0.75) + 0.09 * L1 * Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1)) - 0.0337 * L1 * Math.pow(tempZjb, 3)); + } + break; + } + break; + case 1: //ISA1932喷嘴 + returnValue = (0.99 - 0.2262 * Math.pow(tempZjb, 4.1) - (0.00175 * Math.pow(tempZjb, 2) - 0.0033 * Math.pow(tempZjb, 4.15)) * (1000000.0D / Math.pow(tempReD, 1.15))); + break; + + case 2: //长径喷嘴 + returnValue = (0.9965 - 0.00653 * Math.pow(tempZjb, 0.5) * Math.pow((1000000.0D / tempReD), 0.5)); + break; + case 3: //文丘里喷嘴 + returnValue = (0.9858 - 0.196 * Math.pow(tempZjb, 4.5)); + break; + case 4: //粗铸收缩段经典文丘里管 + returnValue = (0.984F); + break; + case 5: //机械加工收缩段经典文丘里管 + returnValue = (0.995F); + break; + case 6: //粗焊铁板收缩段经典文丘里管 + returnValue = (0.985F); + break; + case 7: //1/4圆孔板 + returnValue = 0.73823 - 0.3309 * tempZjb - 1.1615 * Math.pow(tempZjb, 2) + 1.5084 * Math.pow(tempZjb, 3); + break; + case 8: //锥形入口孔板 + returnValue = (0.734F); + break; + case 9: //偏心孔板 + returnValue = 0.9355 - 1.6889 * tempZjb + 3.0428 * Math.pow(tempZjb, 2) - 1.7989 * Math.pow(tempZjb, 3); + break; + } + double tempRed1 ; + switch (JieLiuType) + { + case 0: //孔板流量计算 + tempRed1 = tempconQvA * returnValue; + switch (JieLiuType) + { + case 0: + if (tempRed1 < (170 * Math.pow(tempZjb, 2) * tempGj)) + { + JOptionPane.showMessageDialog(null, "雷诺数超过标准孔板的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + return returnValue; + } + break; + case 1: + if (tempZjb >= 0.1 & tempZjb <= 0.56) + { + if (tempRed1 < 5000) + { + JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + return returnValue; + } + } + if (tempZjb > 0.56) + { + if (tempRed1 < (16000 * Math.pow(tempZjb, 2) * tempGj)) + { + JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + return returnValue; + } + } + break; + } + break; + + case 1: //标准喷嘴 + tempRed1 = tempconQvA * returnValue; + if (tempZjb >= 0.3 & tempZjb < 0.44) + { + if (tempRed1 < 70000 | tempRed1 > 10000000.0D) + { + JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + } + } + if (tempZjb >= 0.44 & tempZjb < 0.8) + { + if (tempRed1 < 20000 | tempRed1 > 10000000.0D) + { + JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + } + } + break; + case 2: //长径喷嘴 + tempRed1 = tempconQvA * returnValue; + if (tempRed1 < 10000.0D | tempRed1 > 10000000.0D) + { + JOptionPane.showMessageDialog(null, "雷诺数超过长径喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + } + break; + case 3: //文丘里喷嘴 + tempRed1 = tempconQvA * returnValue; + if (tempRed1 < 150000.0D | tempRed1 > 2000000.0D) + { + JOptionPane.showMessageDialog(null, "雷诺数超过文丘里喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + } + break; + case 4: //粗铸收缩段经典文丘里管 + tempRed1 = tempconQvA * returnValue; + if (tempRed1 < 200000.0D | tempRed1 > 2000000.0D) + { + JOptionPane.showMessageDialog(null, "雷诺数超过粗铸收缩段经典文丘里管的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + return returnValue; + } + break; + case 5: //机械加工收缩段经典文丘里管 + tempRed1 = tempconQvA * returnValue; + if (tempRed1 < 200000.0D | tempRed1 > 1000000.0D) + { + JOptionPane.showMessageDialog(null, "雷诺数超过机械加工收缩段经典文丘里管的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + } + break; + case 6: //粗焊铁板收缩段经典文丘里管 + tempRed1 = tempconQvA * returnValue; + if (tempRed1 < 200000.0D | tempRed1 > 2000000.0D) + { + JOptionPane.showMessageDialog(null, "雷诺数超过粗焊铁板收缩段经典文丘里管的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); + } + break; + + //标准孔板 + //ISA1932喷嘴 + //长径喷嘴 + //文丘里喷嘴 + //粗铸收缩段经典文丘里管 + //机械加工收缩段经典文丘里管 + //粗焊铁板收缩段经典文丘里管 + + + + + } + return returnValue; + } + + private double BkTable(double temPrk, double tempKj, int tempBkjsff) { + double[] BkTable_x = new double[10]; + double[] BkTable_Y = new double[10]; + //On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C# + if (tempBkjsff == 1) { + double tempRkBiKj = temPrk / tempKj; + // static double[] x = new double[10]; //VBConversions Note: Static variable moved to class level and renamed BkTable_x. Local static variables are not supported in C#. + // static double[] Y = new double[10]; //VBConversions Note: Static variable moved to class level and renamed BkTable_Y. Local static variables are not supported in C#. + int i; + int xIndex = 0; + //If x(0) = 0 Then + BkTable_x[0] = 0.0004F; + BkTable_x[1] = 0.001F; + BkTable_x[2] = 0.002F; + BkTable_x[3] = 0.004F; + BkTable_x[4] = 0.006F; + BkTable_x[5] = 0.008F; + BkTable_x[6] = 0.01F; + BkTable_x[7] = 0.012F; + BkTable_x[8] = 0.014F; + BkTable_x[9] = 0.015F; + + BkTable_Y[0] = 1; + BkTable_Y[1] = 1.005F; + BkTable_Y[2] = 1.012F; + BkTable_Y[3] = 1.022F; + BkTable_Y[4] = 1.032F; + BkTable_Y[5] = 1.04F; + BkTable_Y[6] = 1.048F; + BkTable_Y[7] = 1.055F; + BkTable_Y[8] = 1.062F; + BkTable_Y[9] = 1.065F; + //End If + + if (tempRkBiKj <= 0.0004) { + return 1; + } + if (tempRkBiKj > 0.015) { + return 1.065F; + } + for (i = 0; i <= 8; i++) { + if (tempRkBiKj >= BkTable_x[i] && tempRkBiKj <= BkTable_x[i + 1]) { + xIndex = i; + break; + } + } + return BkTable_Y[xIndex] + (tempRkBiKj - BkTable_x[xIndex]) * (BkTable_Y[xIndex + 1] - BkTable_Y[xIndex]) / (BkTable_x[xIndex + 1] - BkTable_x[xIndex]); + } + return 0; + } + //管道粗糙度计算 + private double CcdXsjs(double tempPipeType, double tempGj, double tempZjb, double TempRed) + { + double returnValue ; + //粗糙度系数计算 + double Jdccd = 0; //绝对粗糙度 + double Xdccd ; //相对粗糙度 + //Dim CcdXs As single + double s1 ; + double s2 ; + double ky ; + double kx ; + int i ; + int m = 0; + int n = 0; + if (tempPipeType == 0) + { + Jdccd = 0.029F;} + else if (tempPipeType == 1) + { + Jdccd = 0.075F; + } + else if (tempPipeType == 2) + { + Jdccd = 0.075F; + } + else if (tempPipeType == 3) + { + Jdccd = 0.075F; + } + else if (tempPipeType == 4) + { + Jdccd = 0.1F; + } + else if (tempPipeType == 5) + { + Jdccd = 0.15F; + } + else if (tempPipeType == 6) + { + Jdccd = 1; + } + else if (tempPipeType == 7) + { + Jdccd = 2.1F; + } + else if (tempPipeType == 8) + { + Jdccd = 0.04F; + } + else if (tempPipeType == 9) + { + Jdccd = 0.15F; + } + else if (tempPipeType == 10) + { + Jdccd = 0.13F; + } + else if (tempPipeType == 11) + { + Jdccd = 0.25F; + } + Xdccd = tempGj / Jdccd; + if (Xdccd < 400) + { + JOptionPane.showMessageDialog(null, "粗糙度取得太高,粗略计算", "提示", JOptionPane.PLAIN_MESSAGE); + Xdccd = 400; + } + if (Xdccd >= 3400) + { + Xdccd = 3400; + } + + if (Xdccd < 3200 & Math.pow(tempZjb, 2) > 0.1 & Math.pow(tempZjb, 2) < 0.64) + { + + int[] Xdccdb = new int[10]; + double[] Btf = new double[8]; + double[][] CcdXsb = new double[10][8]; + + Xdccdb[0] = 400; + Xdccdb[1] = 800; + Xdccdb[2] = 1200; + Xdccdb[3] = 1600; + Xdccdb[4] = 2000; + Xdccdb[5] = 2400; + Xdccdb[6] = 2800; + Xdccdb[7] = 3200; + Xdccdb[8] = 3400; + + Btf[0] = 0.1F; + Btf[1] = 0.2F; + Btf[2] = 0.3F; + Btf[3] = 0.4F; + Btf[4] = 0.5F; + Btf[5] = 0.6F; + Btf[6] = 0.64F; + + CcdXsb[0][0] = 1.002; + CcdXsb[1][0] = 1; + CcdXsb[2][0] = 1; + CcdXsb[3][0] = 1; + CcdXsb[4][0] = 1; + CcdXsb[5][0] = 1; + CcdXsb[6][0] = 1; + CcdXsb[7][0] = 1; + CcdXsb[8][0] = 1; + CcdXsb[0][1] = 1.003; + CcdXsb[1][1] = 1.002; + CcdXsb[2][1] = 1.001; + CcdXsb[3][1] = 1; + CcdXsb[4][1] = 1; + CcdXsb[5][1] = 1; + CcdXsb[6][1] = 1; + CcdXsb[7][1] = 1; + + CcdXsb[0][2] = 1.006; + CcdXsb[1][2] = 1.004; + CcdXsb[2][2] = 1.002; + CcdXsb[3][2] = 1.001; + CcdXsb[4][2] = 1; + CcdXsb[5][2] = 1; + CcdXsb[6][2] = 1; + CcdXsb[7][2] = 1; + + CcdXsb[0][3] = 1.009; + CcdXsb[1][3] = 1.006; + CcdXsb[2][3] = 1.004; + CcdXsb[3][3] = 1.002; + CcdXsb[4][3] = 1.001; + CcdXsb[5][3] = 1; + CcdXsb[6][3] = 1; + CcdXsb[7][3] = 1; + + CcdXsb[0][4] = 1.014; + CcdXsb[1][4] = 1.009; + CcdXsb[2][4] = 1.006; + CcdXsb[3][4] = 1.004; + CcdXsb[4][4] = 1.002; + CcdXsb[5][4] = 1.001; + CcdXsb[6][4] = 1; + CcdXsb[7][4] = 1; + + CcdXsb[0][5] = 1.02; + CcdXsb[1][5] = 1.013; + CcdXsb[2][5] = 1.009; + CcdXsb[3][5] = 1.006; + CcdXsb[4][5] = 1.003; + CcdXsb[5][5] = 1.002; + CcdXsb[6][5] = 1; + CcdXsb[7][5] = 1; + + CcdXsb[0][6] = 1.024; + CcdXsb[1][6] = 1.016; + CcdXsb[2][6] = 1.011; + CcdXsb[3][6] = 1.007; + CcdXsb[4][6] = 1.004; + CcdXsb[5][6] = 1.002; + CcdXsb[6][6] = 1.002; + CcdXsb[7][6] = 1; + + + for (i = 0; i <= 8; i++) + { + if (Xdccd >= Xdccdb[i] && Xdccd <= Xdccdb[i + 1]) + { + m = i; + break; + } + } + for (i = 0; i <= 6; i++) + { + if (Math.pow(tempZjb, 2) >= Btf[i] && Math.pow(tempZjb, 2) <= Btf[i + 1]) + { + n = i; + break; + } + } + + ky = (Btf[n + 1] - Btf[n] != 0) ? ((Math.pow(tempZjb, 2) - Btf[n]) / (Btf[n + 1] - Btf[n])) : 0; + + kx = (Xdccdb[m + 1] - Xdccdb[m] != 0) ? ((Xdccd - Xdccdb[m]) / (Xdccdb[m + 1] - Xdccdb[m])) : 0; + + s1 = CcdXsb[m][n] + (CcdXsb[m][n + 1] - CcdXsb[m][n]) * ky; + s2 = CcdXsb[m + 1][n] + (CcdXsb[m + 1][n + 1] - CcdXsb[m + 1][n]) * ky; + returnValue = s1 + (s2 - s1) * kx; + + returnValue = TempRed > 1000000.0 ? returnValue : ((returnValue - 1) * Math.pow((Math.log10(TempRed) / 2), 2) + 1); + + } + else + { + returnValue = 1; + } + return returnValue; + } +} diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/FlowController.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/FlowController.java index 2b97c1d..d32144e 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/FlowController.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/FlowController.java @@ -7,28 +7,38 @@ import com.ruoyi.ngCalTools.service.DetailService; import com.ruoyi.ngCalTools.service.GBT11062Service; import com.ruoyi.ngCalTools.service.ThermService; import com.ruoyi.system.controller.UnitConvert; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.swing.*; -import java.util.Optional; + +import static com.ruoyi.ngCalTools.controller.DpFlowCalc.iterativeFlowCalculation; +import static com.ruoyi.ngCalTools.controller.DpFlowCalc.thermalExpansionCorrection; + + @RestController @RequestMapping("/flowCalcTools") public class FlowController { - private final UnitConvert unitConvert; - public ThermService thermService; - public DetailService detailService; - public GBT11062Service gbt11062Service; + + public static ThermService thermService; + public static DetailService detailService; + public static GBT11062Service gbt11062Service; public GasController gasController; - public FlowController(UnitConvert unitConvert,GasController gasController) { - this.unitConvert = unitConvert; + public FlowController( GasController gasController) { + this.gasController=gasController; } + + @Autowired + private UnitConvert unitConvert=new UnitConvert(); + @Autowired + private NozellFlowCalcISO9300 nozellFlowCalcISO9300=new NozellFlowCalcISO9300(); + @PostMapping("/flowCalc") - public AjaxResult flowCalc(@RequestBody FlowProps flowProps) { + public AjaxResult flowCalc(@RequestBody FlowProps flowProps) { GasProps gasProps = new GasProps(); thermService = new ThermService(); detailService = new DetailService(); @@ -56,6 +66,30 @@ public class FlowController { flowProps.setdTf(tempTf); gasProps.dCbtj = flowProps.getdCbtj(); + switch (gasProps.dCbtj) + { + case 2: + gasProps.setdPb(101325); + gasProps.setdTb( 273.15); + flowProps.setdPb_M(101325); + flowProps.setdTb_M(273.15); + break; + case 1: + + gasProps.setdPb(101325); + gasProps.setdTb( 288.15); + flowProps.setdPb_M(101325); + flowProps.setdTb_M(288.15); + break; + case 0: + + gasProps.setdPb(101325); + gasProps.setdTb( 293.15); + flowProps.setdPb_M(101325); + flowProps.setdTb_M(293.15); + break; + } + String[] stringArray = flowProps.getdngComponents().split("_"); double[] doubleArray = new double[stringArray.length]; // 遍历字符串数组,将每个元素转换为 double 类型 for (int i = 0; i < stringArray.length; i++) { @@ -67,7 +101,7 @@ public class FlowController { } } gasProps.adMixture = doubleArray; - gasController.ngCalcVoid(flowProps, gasProps); //计算临界流函数所有参数都计算了 + GasController.ngCalcVoid(flowProps, gasProps); //计算临界流函数所有参数都计算了 //计算流量 switch (flowProps.getdMeterType()) { @@ -85,7 +119,7 @@ public class FlowController { SdFlowCal(gasProps, flowProps); break; case 3:// 临界流函数流量计 - NozellFLowCal(gasProps, flowProps); + nozellFlowCalcISO9300. calculateFlowCoefficient(flowProps,gasProps); break; } Object[] resultArray = {flowProps, gasProps}; @@ -94,7 +128,7 @@ public class FlowController { /** 速度式流量计算 */ - public final void SdFlowCal(GasProps gasProps,FlowProps flowProps) + public static final void SdFlowCal(GasProps gasProps, FlowProps flowProps) { //工况体积流量 m³、s flowProps.setdVFlowf(flowProps.getdPulseNum() / flowProps.getdMeterFactor()); @@ -106,441 +140,65 @@ public class FlowController { flowProps.setdEFlowb(flowProps.getdVFlowb() * gasProps.dHhvm); } - /** - 标准孔板流量计算 - */ - public void OFlowCal(GasProps gasProps,FlowProps flowProps){ - flowProps.setdOrificeD(flowProps.getdOrificeD() * (1 + 0.000001 * (flowProps.getdOrificeMaterial()) * (flowProps.getdTf() - 293.15))); - flowProps.setdPipeD(flowProps.getdPipeD() * (1 + 0.000001 * (flowProps.getdPipeMaterial()) * (flowProps.getdTf() - 293.15))); - flowProps.setdBeta(flowProps.getdOrificeD() / flowProps.getdPipeD()); -// flowProps.setdBeta(0.5972); + public final void NozellFLowCal_New(GasProps gasProps, FlowProps flowProps) { + double nozzleThroatArea; // 喷嘴喉部面积 + double stagnationPressure; // 滞止压力 P0 + double stagnationTemp; // 滞止温度 T0 + double correctedPipeDiam; // 修正后管道直径 + double correctedThroatDiam;// 修正后喉部直径 + double beta; // 直径比 β = d/D + double massFlowRate; // 质量流量 Qm - //求渐近速度系数 E - flowProps.setdE(1 / Math.pow((1 - Math.pow(flowProps.getdBeta(), 4)), 0.5)); -// flowProps.setdE(1.0615); + try { + // 1. 热膨胀修正 + correctedThroatDiam = flowProps.getdOrificeD() + * (1 + 1e-6 * flowProps.getdOrificeMaterial() * (flowProps.getdTf() - 293.15)); + correctedPipeDiam = flowProps.getdPipeD() + * (1 + 1e-6 * flowProps.getdPipeMaterial() * (flowProps.getdTf() - 293.15)); + beta = correctedThroatDiam / correctedPipeDiam; - //求相对密度系数 FG - // LiuTiType = 1 - flowProps.setdFG(Math.pow((1 / gasProps.dRD_Real), 0.5)); -// flowProps.setdFG(1.2531); - //求流动温度系数 'FT - flowProps.setdFT(Math.pow((293.15 / flowProps.getdTf()), 0.5)); -// flowProps.setdFT(1.0086); - //求等熵指数????????????????????????????????? + // 2. 计算喉部面积 + nozzleThroatArea = Math.PI * Math.pow(correctedThroatDiam / 2, 2); - flowProps.setdKappa(gasProps.dKappa); -// flowProps.setdKappa(1.357); + // 3. 计算马赫数 (假设流速来自flowProps) + double velocity = flowProps.getdVelocityFlow(); + double speedOfSound = Math.sqrt(gasProps.dKappa * gasProps.dZf + * 8314.51 / gasProps.dMrx * flowProps.getdTf()); + double machNumber = velocity / speedOfSound; - //求动力粘度 dlnd - flowProps.setdDViscosity(Dlndjs(flowProps.getdPf()/1e6, flowProps.getdTf())); -// flowProps.setdDViscosity(0.01096); + // 4. 滞止压力 & 温度 (ISO 9300) + stagnationPressure = flowProps.getdPf() + * Math.pow(1 + (gasProps.dKappa - 1)/2 * machNumber*machNumber, + gasProps.dKappa/(gasProps.dKappa - 1)); + stagnationTemp = flowProps.getdTf() + * (1 + (gasProps.dKappa - 1)/2 * machNumber*machNumber); - //求可膨胀系数 - flowProps.setdDExpCoefficient(KePenZhang_JiSuan(flowProps.getdPf() , flowProps.getdDp(), flowProps.getdBeta(), gasProps.getdKappa(), flowProps.getdCoreType(), 0)); -// flowProps.setdDExpCoefficient(0.9977); + // 5. 计算质量流量 + double gasConstant = 8314.51 / gasProps.dMrx; + massFlowRate = nozzleThroatArea * flowProps.getdCd() + * Math.sqrt(gasProps.dKappa / (gasConstant * stagnationTemp)) + * stagnationPressure + * Math.pow(2/(gasProps.dKappa + 1), (gasProps.dKappa + 1)/(2*(gasProps.dKappa - 1))); -// gasProps.dFpv=1.0195; -// gasProps.dHhvv=39.944; -// gasProps.dRD_Real=0.6368; - - //迭代计算流量和流出系数 - - double conQvA = 0.0000031795 * (1530000.0D * gasProps.dRD_Real / (flowProps.getdDViscosity() * flowProps.getdOrificeD())) * flowProps.getdE() * Math.pow(flowProps.getdOrificeD(), 2) * gasProps.dFpv * flowProps.getdFG() * flowProps.getdDExpCoefficient() * flowProps.getdFT() * Math.sqrt(flowProps.getdPf() * flowProps.getdDp() / 1e6); - double[] XQv = new double[4]; - double[] CQv = new double[4]; - double[] dQv = new double[4]; - double Qn = 0; - int n ; - XQv[0] = 1000000.0F; - boolean xhFlag=true; - _100000: - - while(xhFlag) { - for (n = 1; n <= 2; n++) { - CQv[n] = C_JiSuan(flowProps.getdOrificeD(), flowProps.getdBeta(), XQv[n - 1], conQvA, flowProps.getdPtmode(), flowProps.getdCoreType(), 0); - XQv[n] = conQvA * CQv[n]; - dQv[n] = XQv[n] - XQv[n - 1]; + // 6. 大直径比修正 + if (beta > 0.25) { + massFlowRate *= BetaG25(stagnationPressure, stagnationTemp, beta, gasProps); } - if (XQv[2] == XQv[1] || dQv[2] == dQv[1]) { - Qn = conQvA * flowProps.getdDViscosity() * flowProps.getdOrificeD() * CQv[2] / (1530000.0D * gasProps.dRD_Real); - //管道雷诺数 - flowProps.setdRnPipe(XQv[2]); - //流出系数 - flowProps.setdCd(CQv[2]); - } - if (Math.abs((conQvA - XQv[2] / CQv[1]) / conQvA) > 0.00000000000000005) { - XQv[0] = XQv[n - 1] - dQv[n - 1] * ((XQv[n - 1] - XQv[n - 2]) / (dQv[n - 1] - dQv[n - 2])); -//C# TO JAVA CONVERTER TODO TASK: There is no 'goto' in Java: - continue _100000; - } - else - { - xhFlag=false; - } - } + // 7. 设置结果 + flowProps.setdMFlowb(massFlowRate); + flowProps.setdVFlowb(massFlowRate / gasProps.dRhob); + flowProps.setdEFlowb(flowProps.getdVFlowb() * gasProps.dHhvm); + flowProps.setdVFlowf(FlowConvert_BaseToWork(flowProps, gasProps)); - //孔板锐利度系数Bk - flowProps.setdOrificeSharpness(1); - if (flowProps.getdCoreType() == 0) + } catch (Exception ex) { - flowProps.setdBk((flowProps.getdOrificeSharpness() == 0) ? (BkTable(flowProps.getdOrificeRk(), flowProps.getdOrificeD(), 1)) : (flowProps.getdOrificeSharpness())); } - else - { - flowProps.setdBk(1); - } - - - //管道粗糙度系数 Gme - flowProps.setdRoughNessPipe(CcdXsjs(flowProps.getdPipeType(), flowProps.getdPipeD(), flowProps.getdBeta(), flowProps.getdRnPipe())); - //修正后的流出系数 - flowProps.setdCd(flowProps.getdCd() * flowProps.getdBk() * flowProps.getdRoughNessPipe()); -// flowProps.setdCd(0.6039); - //标况体积流量 m³、s - flowProps.setdVFlowb(Qn * flowProps.getdBk() * flowProps.getdRoughNessPipe()); - //工况体积流量 - flowProps.setdVFlowf(FlowConvert_BaseToWork(flowProps, gasProps)); - //标况质量流量 - flowProps.setdMFlowb(flowProps.getdVFlowb() * gasProps.dRhob); - //标况能量流量 - flowProps.setdEFlowb(flowProps.getdVFlowb() * gasProps.dHhvv); - //管道内天然气流速 - flowProps.setdVelocityFlow(flowProps.getdVFlowf() / (3.1415926 * Math.pow((flowProps.getdPipeD() / 2000), 2))); - //压力损失 - flowProps.setdPressLost(YaLiSunShi(flowProps.getdCd(), flowProps.getdBeta(), flowProps.getdDp(), flowProps.getdCoreType())); - } - - /** - * 计算管道绝对粗糙度 K (GB/T 21446-2008 附录C) - * @param flowProps - * @return 粗糙度修正系数 K (保留4位小数) - */ - public static double calculateK(FlowProps flowProps){ - double Jdccd; - switch (flowProps.getdPipeType()) { - - case 0: - Jdccd = 0.029F; - break; - case 1: - case 2: - case 3: - Jdccd = 0.075F; - break; - case 4: - Jdccd = 0.1F; - break; - case 5: - Jdccd = 0.15F; - break; - case 6: - Jdccd = 1; - break; - case 7: - Jdccd = 2.1F; - break; - case 8: - Jdccd = 0.04F; - break; - case 9: - Jdccd = 0.15F; - break; - case 10: - Jdccd = 0.13F; - break; - case 11: - Jdccd = 0.25F; - break; - default: - // 处理未知类型(可选) - throw new IllegalArgumentException("未知的管道类型: "); - } - return Jdccd; - } - - /** - * 计算管道粗糙度修正系数 G_me (GB/T 21446-2008 附录C) - * @param D_pipe 管道内径 (mm) - * @param K 绝对粗糙度 (mm) - * @param C 未修正的流出系数 - * @return 粗糙度修正系数 G_me (保留4位小数) - */ - public static double calculateRoughnessFactor(double D_pipe, double K, double C) { - // 计算相对粗糙度 K/D - double K_over_D = K / D_pipe; - - // 判断是否需要修正 - if (K_over_D <= 0.0004) { - return 1.0000; - } - - // 计算修正项 - double term = (K_over_D * 1e6) - 400; // 转换为无量纲项 - if (term < 0) { - throw new IllegalArgumentException("K/D 超出修正公式适用范围"); - } - - double G_me = 1 + (0.011 / C) * Math.sqrt(term); - return FormatUtil.format(G_me, Optional.of(4)); // 保留四位小数 - } - - /** - * 热膨胀修正(GB/T 21446-2008 第6.2.1节) - * @param flowProps 流量参数 - */ - public static void thermalExpansionCorrection(FlowProps flowProps) { - // 孔板孔径修正 - double dOrificeMaterial = flowProps.getdOrificeMaterial(); // 材料膨胀系数 (e.g. 16e-6/℃) - double dOrificeD = flowProps.getdOrificeD(); // 初始孔径(mm) - double dOrificeD_corrected = dOrificeD * (1 + 0.000001*dOrificeMaterial * (flowProps.getdTf() - 293.15)); // 20℃为参考温度 - flowProps.setdOrificeD(FormatUtil.format(dOrificeD_corrected, Optional.of(2))); - - // 管道内径修正 - double dPipeMaterial = flowProps.getdPipeMaterial(); - double dPipeD = flowProps.getdPipeD(); - double dPipeD_corrected = dPipeD * (1 + 0.000001*dPipeMaterial * (flowProps.getdTf() - 293.15)); - flowProps.setdPipeD(FormatUtil.format(dPipeD_corrected,Optional.of(2))); - - // 更新直径比β - flowProps.setdBeta( FormatUtil.format(flowProps.getdOrificeD() / flowProps.getdPipeD(),Optional.of(4))); - } - - /** - * 计算渐近速度系数E(GB/T 21446-2008 式(8)) - */ - public static void calculateE(FlowProps flowProps) { - double beta = flowProps.getdBeta(); - flowProps.setdE( FormatUtil.format(1 / Math.sqrt(1 - Math.pow(beta, 4)),Optional.of(4))); - } - - /** - * 计算相对密度系数FG(GB/T 21446-2008 式(9)) - */ - public static void calculateFG(FlowProps flowProps,GasProps gasProps) { - gasProps.setdRD_Real(gasProps.getdRD_Real()); - flowProps.setdFG( FormatUtil.format(1 / Math.sqrt(gasProps.dRD_Real),Optional.of(4))); - } - - /** - * 计算流动温度系数FT(GB/T 21446-2008 式(10)) - */ - public static void calculateFT(FlowProps flowProps) { - double Tb = flowProps.getdTb_M() ; // 参比温度转K - double Tf = flowProps.getdTf() ; // 工况温度转K - flowProps.setdFT( FormatUtil.format(Math.sqrt(Tb / Tf),Optional.of(4))); - } - - /** - * 计算可膨胀系数ε(GB/T 21446-2008 式(11)) - */ - public static void calculateEpsilon(FlowProps flowProps, GasProps gasProps) { - double P1 = flowProps.getdPf(); // 上游绝对压力(Pa) - double deltaP = flowProps.getdDp(); // 差压(Pa) - double beta = flowProps.getdBeta(); - double kappa = flowProps.getdKappa(); - - double tau = FormatUtil.format((P1 - deltaP) / P1, Optional.of(4)); // 压力比 - double epsilon=1 - (0.351 + 0.256 * Math.pow(beta, 4) + 0.93 * Math.pow(beta, 8)) * (1 - Math.pow(tau, 1/kappa)); - - flowProps.setdDExpCoefficient( FormatUtil.format(epsilon,Optional.of(4))); - } - /** - * 计算等熵指数κ(GB/T 21446-2008 推荐方法) - * @param gasProps 气体参数(需包含等熵指数或热容比) - * @return 等熵指数κ - */ - public static double calculateKappa(GasProps gasProps) { - // 若已通过AGA 8或其他方法计算,直接返回 -// if (gasProps.getdKappa() > 0) { -// return gasProps.getdKappa(); -// } - - // 近似公式:基于理想气体比热比和压缩因子修正 - double gamma = 1.3; // 天然气典型比热比(Cp/Cv≈1.3) - double Z = gasProps.getdZf(); // 工况压缩因子 - - // 修正公式(经验关系) - double kappa = gamma / (1 - (gamma - 1) * (1 / Z - 1)); - return FormatUtil.format(kappa,Optional.of(4)); } - - /** - * 迭代计算流量(GB/T 21446-2008 第7章) - * @param flowProps 流量参数 - * @param gasProps 气体参数 - */ - public static void iterativeFlowCalculation(FlowProps flowProps, GasProps gasProps) { - // 0. 单位转换 - double D = flowProps.getdPipeD() / 1000.0; // 管道内径(m) - double d = flowProps.getdOrificeD() / 1000.0; // 孔板孔径(m) - double beta = flowProps.getdBeta(); - double P1 = flowProps.getdPf(); // 绝对压力(Pa) - double deltaP = flowProps.getdDp(); // 差压(Pa) - double Tf = flowProps.getdTf() ; // 工况温度(K) - -flowProps.setdPb_M(gasProps.getdPb()); -flowProps.setdTb_M(gasProps.getdTb()); -flowProps.setdFpv(FormatUtil.format(gasProps.dFpv,Optional.of(4))); - - // 1. 计算中间参数 - calculateE(flowProps); - calculateFG(flowProps,gasProps); - calculateFT(flowProps); - - flowProps.setdKappa( calculateKappa(gasProps)); -// flowProps.setdDViscosity( calculateDynamicViscosity(gasProps)); - flowProps.setdDViscosity(FormatUtil.format( Dlndjs(flowProps.getdPf()/1e6,flowProps.getdTf()),Optional.of(5))); - calculateEpsilon(flowProps, gasProps); - - flowProps.setdKappa(1.357); -// flowProps.setdBeta(0.5792); -// flowProps.setdFpv(1.0195); -// flowProps.setdFG(1.2531); -// flowProps.setdE(1.0615); -// flowProps.setdDExpCoefficient(0.9977); -// flowProps.setdFT(1.0086); - - - // 2. 初始雷诺数估算(假设初始C=0.6) - double C_initial = 0.6; - double Qf_initial = (C_initial * flowProps.getdE() * flowProps.getdDExpCoefficient() * Math.PI * Math.pow(d, 2) / 4) - * Math.sqrt(2 * deltaP / (gasProps.dRhof * (1 - Math.pow(beta, 4)))); - flowProps.setdVFlowf(Qf_initial); // 初始工况流量(m³/s) - - // 3. 迭代参数 - double tolerance = 1e-6; - int maxIter = 100; - double currentC = C_initial; - double currentReD = calculateReD(Qf_initial, D, gasProps.dRhof, flowProps.getdDViscosity()); - int iter = 0; - double prevC=0; - // 4. 迭代循环 - do { - prevC = currentC; - - // 4.1 计算流出系数C(GB/T 21446-2008 附录A) - currentC =FormatUtil.format( calculateCd(beta, currentReD, flowProps.getdPipeD(), flowProps.getdPtmode()),Optional.of(4)); - - // 4.2 更新流量 - double Qf =FormatUtil.format ((currentC * flowProps.getdDExpCoefficient() * Math.PI * Math.pow(d, 2) / 4) - * Math.sqrt(2 * deltaP / (gasProps.dRhof * (1 - Math.pow(beta, 4)))),Optional.of(4)); - flowProps.setdVFlowf(Qf); - - // 4.3 更新雷诺数 - currentReD =FormatUtil.format( calculateReD(Qf, D, gasProps.dRhof, flowProps.getdDViscosity()), Optional.of(2)); - - iter++; - if (iter > maxIter) { - throw new RuntimeException("迭代未收敛,超过最大迭代次数!"); - } - } while (Math.abs(currentC - prevC) / currentC > tolerance); - // 5. 保存最终结果 - - // 在迭代计算流出系数后,添加粗糙度修正 - - double K = calculateK(flowProps); // 根据实际管道类型选择 - double G_me = calculateRoughnessFactor(flowProps.getdPipeD(), K, currentC); - double C_corrected = FormatUtil.format(currentC * G_me, Optional.of(4)); - - flowProps.setdCd(C_corrected); - flowProps.setdRoughNessPipe(G_me); - flowProps.setdRnPipe(currentReD); - - - - - // 6. 计算标况流量(GB/T 21446-2008 式(1)) - double Qn = flowProps.getdVFlowf() * (flowProps.getdFpv()*flowProps.getdFpv() * P1 / flowProps.getdPb_M()) - * (flowProps.getdTb_M()) / Tf; - flowProps.setdVFlowb(FormatUtil.format(Qn,Optional.of(4))); - - //标况质量流量 - flowProps.setdMFlowb(FormatUtil.format(flowProps.getdVFlowb() * gasProps.dRhob,Optional.of(4))); - //标况能量流量 - flowProps.setdEFlowb(FormatUtil.format(flowProps.getdVFlowb() * gasProps.dHhvv,Optional.of(4))); - //管道内天然气流速 - flowProps.setdVelocityFlow(FormatUtil.format(flowProps.getdVFlowf() / (Math.PI * Math.pow((flowProps.getdPipeD() / 2000), 2)),Optional.of(3))); - //压力损失 - flowProps.setdPressLost(FormatUtil.format(YaLiSunShi(flowProps.getdCd(), flowProps.getdBeta(), flowProps.getdDp(), flowProps.getdCoreType()),Optional.of(2))); - - } - - - - - - /** - * 计算天然气动力粘度(Sutherland公式简化版,适用于低压天然气) - * @param gasProps 气体参数(需包含温度、密度、组分) - * @return 动力粘度 (Pa·s) - */ - public static double calculateDynamicViscosity(GasProps gasProps) { - double T = gasProps.getdTf() ; // 工况温度(K) - double rho = gasProps.getdRhof(); // 工况密度(kg/m³) - double Rd = gasProps.getdRD_Real(); // 真实相对密度 - - // Sutherland常数(天然气典型值,C=120) - double C = 120.0; // Sutherland常数 - double mu0 = 1.0e-5; // 参考粘度 (Pa·s,@293.15K) - - // 计算粘度(简化公式,忽略压力修正) - double mu = mu0 * Math.pow(T / 293.15, 0.7) * (293.15 + C) / (T + C); - - // 密度修正(经验公式) - mu *= 1 + 0.001 * (rho - 1.2); // 密度对粘度的粗略修正 - - return FormatUtil.format( mu*1000,Optional.of(5)); - } - /** - * 计算雷诺数ReD(GB/T 21446-2008 式(5)) - */ - public static double calculateReD(double Qf, double D, double rho, double mu) { - return FormatUtil.format( (4 * Qf * rho*1000) / (Math.PI * D * mu),Optional.of(2)); // Qf: m³/s, D: m, rho: kg/m³, mu: Pa·s - } - - /** - * 计算流出系数C(GB/T 21446-2008 附录A) - */ - public static double calculateCd(double beta, double ReD, double D_mm, int ptMode) { - double L1, L2; - // 根据取压方式确定L1/L2(角接取压) - switch (ptMode) { - case 1: // 角接取压 - L1 = L2 = 0; // D单位为mm - break; - case 0: // 法兰取压 - L1 = L2 = 25.4 / D_mm; - break; - case 2: // D-D/2取压 - L1 = 1.0; - L2 = 0.47; - break; - default: - throw new IllegalArgumentException("不支持的取压方式"); - } - - double term1 = 0.5961 + 0.0261 * Math.pow(beta, 2) - 0.216 * Math.pow(beta, 8); - double term2 = 0.000521 * Math.pow(1e6 * beta / ReD, 0.7); - double A = Math.pow(19000 * beta / ReD, 0.8); - double term3 = (0.0188 + 0.0063 * A) * Math.pow(beta, 3.5) * Math.pow(1e6 / ReD, 0.3); - double term4 = (0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1)) - * (1 - 0.11 * A) * Math.pow(beta, 4) / (1 - Math.pow(beta, 4)); - double term5 = -0.031 * (2 * L2 / (1 - beta) - 0.8 * Math.pow(2 * L2 / (1 - beta), 1.1)) - * Math.pow(beta, 1.3); - - double Cd = term1 + term2 + term3 + term4 + term5; - - // 孔径<71.12mm修正 - if (D_mm < 71.12) { - Cd += 0.011 * (0.75 - beta) * (2.8 - D_mm / 25.4); - } - return FormatUtil.format(Cd,Optional.of(4)); - } - + /** 天然气音速喷嘴流量计算 @@ -688,689 +346,7 @@ flowProps.setdFpv(FormatUtil.format(gasProps.dFpv,Optional.of(4))); } return ylss; } - //查表计算粘度μ - public static double Dlndjs(double tempP_jy, double tempT) - { double[][] Dlndjs_Dlnd_Data = new double[8][11]; - double[] Dlndjs_Dlnd_T = new double[8]; - double[] Dlndjs_Dlnd_P = new double[11]; - double s1 ; - double s2 ; - double ky ; - double kx ; - int i ; - int m = 0; - int n = 0; - //On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C# - Dlndjs_Dlnd_T[0] = -15 + 273.15; - Dlndjs_Dlnd_T[1] = 0 + 273.15; - Dlndjs_Dlnd_T[2] = 15 + 273.15; - Dlndjs_Dlnd_T[3] = 30 + 273.15; - Dlndjs_Dlnd_T[4] = 45 + 273.15; - Dlndjs_Dlnd_T[5] = 60 + 273.15; - Dlndjs_Dlnd_T[6] = 75 + 273.15; - Dlndjs_Dlnd_T[7] = 90 + 273.15; - Dlndjs_Dlnd_P[0] = 0.1F; - Dlndjs_Dlnd_P[1] = 1; - Dlndjs_Dlnd_P[2] = 2; - Dlndjs_Dlnd_P[3] = 3; - Dlndjs_Dlnd_P[4] = 4; - Dlndjs_Dlnd_P[5] = 5; - Dlndjs_Dlnd_P[6] = 6; - Dlndjs_Dlnd_P[7] = 7; - Dlndjs_Dlnd_P[8] = 8; - Dlndjs_Dlnd_P[9] = 9; - Dlndjs_Dlnd_P[10] = 10; - Dlndjs_Dlnd_Data[0][0] = 976; - Dlndjs_Dlnd_Data[1][0] = 1027; - Dlndjs_Dlnd_Data[2][0] = 1071; - Dlndjs_Dlnd_Data[3][0] = 1123; - Dlndjs_Dlnd_Data[4][0] = 1167; - Dlndjs_Dlnd_Data[5][0] = 1213; - Dlndjs_Dlnd_Data[6][0] = 1260; - Dlndjs_Dlnd_Data[7][0] = 1303; - Dlndjs_Dlnd_Data[0][1] = 991; - Dlndjs_Dlnd_Data[1][1] = 1040; - Dlndjs_Dlnd_Data[2][1] = 1082; - Dlndjs_Dlnd_Data[3][1] = 1135; - Dlndjs_Dlnd_Data[4][1] = 1178; - Dlndjs_Dlnd_Data[5][1] = 1224; - Dlndjs_Dlnd_Data[6][1] = 1270; - Dlndjs_Dlnd_Data[7][1] = 1312; - Dlndjs_Dlnd_Data[0][2] = 1014; - Dlndjs_Dlnd_Data[1][2] = 1063; - Dlndjs_Dlnd_Data[2][2] = 1106; - Dlndjs_Dlnd_Data[3][2] = 1153; - Dlndjs_Dlnd_Data[4][2] = 1196; - Dlndjs_Dlnd_Data[5][2] = 1239; - Dlndjs_Dlnd_Data[6][2] = 1281; - Dlndjs_Dlnd_Data[7][2] = 1323; - Dlndjs_Dlnd_Data[0][3] = 1044; - Dlndjs_Dlnd_Data[1][3] = 1091; - Dlndjs_Dlnd_Data[2][3] = 1127; - Dlndjs_Dlnd_Data[3][3] = 1174; - Dlndjs_Dlnd_Data[4][3] = 1216; - Dlndjs_Dlnd_Data[5][3] = 1257; - Dlndjs_Dlnd_Data[6][3] = 1297; - Dlndjs_Dlnd_Data[7][3] = 1338; - Dlndjs_Dlnd_Data[0][4] = 1073; - Dlndjs_Dlnd_Data[1][4] = 1118; - Dlndjs_Dlnd_Data[2][4] = 1149; - Dlndjs_Dlnd_Data[3][4] = 1195; - Dlndjs_Dlnd_Data[4][4] = 1236; - Dlndjs_Dlnd_Data[5][4] = 1275; - Dlndjs_Dlnd_Data[6][4] = 1313; - Dlndjs_Dlnd_Data[7][4] = 1352; - Dlndjs_Dlnd_Data[0][5] = 1114; - Dlndjs_Dlnd_Data[1][5] = 1151; - Dlndjs_Dlnd_Data[2][5] = 1180; - Dlndjs_Dlnd_Data[3][5] = 1224; - Dlndjs_Dlnd_Data[4][5] = 1261; - Dlndjs_Dlnd_Data[5][5] = 1297; - Dlndjs_Dlnd_Data[6][5] = 1333; - Dlndjs_Dlnd_Data[7][5] = 1372; - Dlndjs_Dlnd_Data[0][6] = 1156; - Dlndjs_Dlnd_Data[1][6] = 1185; - Dlndjs_Dlnd_Data[2][6] = 1211; - Dlndjs_Dlnd_Data[3][6] = 1253; - Dlndjs_Dlnd_Data[4][6] = 1287; - Dlndjs_Dlnd_Data[5][6] = 1320; - Dlndjs_Dlnd_Data[6][6] = 1352; - Dlndjs_Dlnd_Data[7][6] = 1391; - Dlndjs_Dlnd_Data[0][7] = 1207; - Dlndjs_Dlnd_Data[1][7] = 1230; - Dlndjs_Dlnd_Data[2][7] = 1250; - Dlndjs_Dlnd_Data[3][7] = 1289; - Dlndjs_Dlnd_Data[4][7] = 1318; - Dlndjs_Dlnd_Data[5][7] = 1346; - Dlndjs_Dlnd_Data[6][7] = 1374; - Dlndjs_Dlnd_Data[7][7] = 1412; - Dlndjs_Dlnd_Data[0][8] = 1261; - Dlndjs_Dlnd_Data[1][8] = 1276; - Dlndjs_Dlnd_Data[2][8] = 1289; - Dlndjs_Dlnd_Data[3][8] = 1324; - Dlndjs_Dlnd_Data[4][8] = 1350; - Dlndjs_Dlnd_Data[5][8] = 1373; - Dlndjs_Dlnd_Data[6][8] = 1396; - Dlndjs_Dlnd_Data[7][8] = 1432; - Dlndjs_Dlnd_Data[0][9] = 1331; - Dlndjs_Dlnd_Data[1][9] = 1331; - Dlndjs_Dlnd_Data[2][9] = 1335; - Dlndjs_Dlnd_Data[3][9] = 1366; - Dlndjs_Dlnd_Data[4][9] = 1385; - Dlndjs_Dlnd_Data[5][9] = 1403; - Dlndjs_Dlnd_Data[6][9] = 1424; - Dlndjs_Dlnd_Data[7][9] = 1456; - Dlndjs_Dlnd_Data[0][10] = 1405; - Dlndjs_Dlnd_Data[1][10] = 1389; - Dlndjs_Dlnd_Data[2][10] = 1383; - Dlndjs_Dlnd_Data[3][10] = 1409; - Dlndjs_Dlnd_Data[4][10] = 1421; - Dlndjs_Dlnd_Data[5][10] = 1435; - Dlndjs_Dlnd_Data[6][10] = 1451; - Dlndjs_Dlnd_Data[7][10] = 1482; - - if (tempT < Dlndjs_Dlnd_T[0]) - { - tempT = Dlndjs_Dlnd_T[0]; - } - if (tempT > Dlndjs_Dlnd_T[7]) - { - tempT = Dlndjs_Dlnd_T[7]; - } - if (tempP_jy < Dlndjs_Dlnd_P[0]) - { - tempP_jy = Dlndjs_Dlnd_P[0]; - } - if (tempP_jy > Dlndjs_Dlnd_P[10]) - { - tempP_jy = Dlndjs_Dlnd_P[10]; - } - - for ( i = 0; i <= 6; i++) - { - if (tempT >= Dlndjs_Dlnd_T[i] && tempT <= Dlndjs_Dlnd_T[i + 1]) - { - m = i; - break; - } - } - - for (i = 0; i <= 9; i++) - { - if (tempP_jy >= Dlndjs_Dlnd_P[i] && tempP_jy <= Dlndjs_Dlnd_P[i + 1]) - { - n = i; - break; - } - } - - if (Dlndjs_Dlnd_P[n + 1] - Dlndjs_Dlnd_P[n] != 0) - { - ky = (tempP_jy - Dlndjs_Dlnd_P[n]) / (Dlndjs_Dlnd_P[n + 1] - Dlndjs_Dlnd_P[n]); - } - else - { - ky = 0; - } - if (Dlndjs_Dlnd_T[m + 1] - Dlndjs_Dlnd_T[m] != 0) - { - kx = (tempT - Dlndjs_Dlnd_T[m]) / (Dlndjs_Dlnd_T[m + 1] - Dlndjs_Dlnd_T[m]); - } - else - { - kx = 0; - } - s1 = Dlndjs_Dlnd_Data[m][n] + (Dlndjs_Dlnd_Data[m][n + 1] - Dlndjs_Dlnd_Data[m][n]) * ky; - s2 = Dlndjs_Dlnd_Data[m + 1][n] + (Dlndjs_Dlnd_Data[m + 1][n + 1] - Dlndjs_Dlnd_Data[m + 1][n]) * ky; - return (s1 + (s2 - s1) * kx) / 100000.0D; - } - //可膨胀系数计算 - private double KePenZhang_JiSuan(double tempP_jy, double tempDp_Pa, double tempZjb, double tempDszs, int JIeliuType, int JiSuanBiaoZhun) // 求可膨胀系数 - { - double returnValue = 0; - //0标准孔板 - //1ISA1932喷嘴 - //2长径喷嘴 - //3文丘里喷嘴 - //4粗铸收缩段经典文丘里管 - //5机械加工收缩段经典文丘里管 - //6粗焊铁板收缩段经典文丘里管 - //7 1/4圆孔板 - - double tuo ; - switch (JIeliuType) - { - case 0: //孔板流量计算 - switch (JiSuanBiaoZhun) - { - case 0: //6143-2004 - tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); - returnValue = 1 - (0.351 + 0.256 * Math.pow(tempZjb, 4) + 0.93 * Math.pow(tempZjb, 8)) * (1 - Math.pow(tuo, (1 / tempDszs))); - break; - case 1: //6143-1996 - returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); - break; - } - break; - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - switch (JiSuanBiaoZhun) - { - case 0: - //标准喷嘴 iso5167-2002 - tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); - returnValue = Math.pow((((tempDszs * Math.pow(tuo, (2 / tempDszs))) / (tempDszs - 1)) * ((1 - Math.pow(tempZjb, 4)) / (1 - Math.pow(tempZjb, 4) * Math.pow(tuo, (2 / tempDszs)))) * ((1 - Math.pow(tuo, ((tempDszs - 1) / tempDszs))) / (1 - tuo))), 0.5); - break; - - case 1: //iso5167-93 - returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); - break; - } - break; - case 7: //1/4圆孔板 - returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); - break; - case 8: //锥形入口孔板 - tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); - returnValue = 1 - (0.351 + 0.256 * Math.pow(tempZjb, 4) + 0.93 * Math.pow(tempZjb, 8)) * (1 - Math.pow(tuo, (1 / tempDszs))); - - tuo = (tempP_jy - tempDp_Pa) / (tempP_jy ); - - returnValue = 0.5 * (returnValue + Math.pow((((tempDszs * Math.pow(tuo, (2 / tempDszs))) / (tempDszs - 1)) * ((1 - Math.pow(tempZjb, 4)) / (1 - Math.pow(tempZjb, 4) * Math.pow(tuo, (2 / tempDszs)))) * ((1 - Math.pow(tuo, ((tempDszs - 1) / tempDszs))) / (1 - tuo))), 0.5)); - break; - case 9: //偏心孔板 - returnValue = 1 - (0.41 + 0.35 * Math.pow(tempZjb, 4)) * tempDp_Pa / ( tempP_jy * tempDszs); - break; - - } - return returnValue; - } - //流出系数计算 - public final double C_JiSuan(double tempGj, double tempZjb, double tempReD, double tempconQvA, int tempQyfs, int JieLiuType, int JiSuanBiaoZhun) - { - double returnValue = 0; - //流出系数计算函数 - //输入:直径比,雷诺数,取压方式,节流装置类型,计算采用标准 - //输出:流出系数 - - //jieliutype - - //0标准孔板 - //1ISA1932喷嘴 - //2长径喷嘴 - //3文丘里喷嘴 - //4粗铸收缩段经典文丘里管 - //5机械加工收缩段经典文丘里管 - //6粗焊铁板收缩段经典文丘里管 - - double L1 = 0; - double L2 = 0; - switch (JieLiuType) - { - case 0: //孔板 - switch (tempQyfs) - { - case 0: - L1 = 25.4 / tempGj; - L2 = L1; - break; - case 1: - L1 = 0; - L2 = 0; - break; - case 2: - L1 = 1; - L2 = 0.47F; - break; - } - switch (JiSuanBiaoZhun) - { - case 0: //6143-2004 - if (tempGj >= 71.12) - { - returnValue = 0.5961 + 0.0261 * Math.pow(tempZjb, 2) - 0.216 * Math.pow(tempZjb, 8) + 0.000521 * Math.pow((1000000.0D * tempZjb / tempReD), 0.7) + (0.0188 + 0.0063 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * Math.pow(tempZjb, 3.5) * Math.pow((1000000.0D / tempReD), 0.3) + (0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1)) * (1 - 0.11 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * (Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1))) - 0.031 * (2 * L2 / (1 - tempZjb) - 0.8 * Math.pow((2 * L2 / (1 - tempZjb)), 1.1)) * Math.pow(tempZjb, 1.3); - } - else if (tempGj < 71.12) - { - returnValue = (0.5961 + 0.0261 * Math.pow(tempZjb, 2) - 0.216 * Math.pow(tempZjb, 8) + 0.000521 * Math.pow((1000000.0D * tempZjb / tempReD), 0.7) + (0.0188 + 0.0063 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * Math.pow(tempZjb, 3.5) * Math.pow((1000000.0D / tempReD), 0.3) + (0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1)) * (1 - 0.11 * Math.pow((19000 * tempZjb / tempReD), 0.8)) * Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1)) - 0.031 * (2 * L2 / (1 - tempZjb) - 0.8 * Math.pow((2 * L2 * (1 - tempZjb)), 1.1)) * Math.pow(tempZjb, 1.3) + 0.011 * (0.75 - tempZjb) * (2.8 - tempGj / 25.4)); - } - break; - case 1: //6143-1996 - if (0.09 * L1 >= 0.039) - { - returnValue = 0.5959 + 0.0312 * Math.pow(tempZjb, (2.1)) - 0.184 * Math.pow(tempZjb, 8) + 0.0029 * Math.pow(tempZjb, 2.5) * Math.pow((1000000.0D / tempReD), 0.75) + 0.039 * Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1)) - 0.0337 * L1 * Math.pow(tempZjb, 3); - } - else if (0.09 * L1 < 0.039) - { - returnValue = (0.5959 + 0.0312 * Math.pow(tempZjb, (2.1)) - 0.184 * Math.pow(tempZjb, 8) + 0.0029 * Math.pow(tempZjb, 2.5) * Math.pow((1000000.0D / tempReD), 0.75) + 0.09 * L1 * Math.pow(tempZjb, 4) * Math.pow((1 - Math.pow(tempZjb, 4)), (-1)) - 0.0337 * L1 * Math.pow(tempZjb, 3)); - } - break; - } - break; - case 1: //ISA1932喷嘴 - returnValue = (0.99 - 0.2262 * Math.pow(tempZjb, 4.1) - (0.00175 * Math.pow(tempZjb, 2) - 0.0033 * Math.pow(tempZjb, 4.15)) * (1000000.0D / Math.pow(tempReD, 1.15))); - break; - - case 2: //长径喷嘴 - returnValue = (0.9965 - 0.00653 * Math.pow(tempZjb, 0.5) * Math.pow((1000000.0D / tempReD), 0.5)); - break; - case 3: //文丘里喷嘴 - returnValue = (0.9858 - 0.196 * Math.pow(tempZjb, 4.5)); - break; - case 4: //粗铸收缩段经典文丘里管 - returnValue = (0.984F); - break; - case 5: //机械加工收缩段经典文丘里管 - returnValue = (0.995F); - break; - case 6: //粗焊铁板收缩段经典文丘里管 - returnValue = (0.985F); - break; - case 7: //1/4圆孔板 - returnValue = 0.73823 - 0.3309 * tempZjb - 1.1615 * Math.pow(tempZjb, 2) + 1.5084 * Math.pow(tempZjb, 3); - break; - case 8: //锥形入口孔板 - returnValue = (0.734F); - break; - case 9: //偏心孔板 - returnValue = 0.9355 - 1.6889 * tempZjb + 3.0428 * Math.pow(tempZjb, 2) - 1.7989 * Math.pow(tempZjb, 3); - break; - } - double tempRed1 ; - switch (JieLiuType) - { - case 0: //孔板流量计算 - tempRed1 = tempconQvA * returnValue; - switch (JieLiuType) - { - case 0: - if (tempRed1 < (170 * Math.pow(tempZjb, 2) * tempGj)) - { - JOptionPane.showMessageDialog(null, "雷诺数超过标准孔板的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - return returnValue; - } - break; - case 1: - if (tempZjb >= 0.1 & tempZjb <= 0.56) - { - if (tempRed1 < 5000) - { - JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - return returnValue; - } - } - if (tempZjb > 0.56) - { - if (tempRed1 < (16000 * Math.pow(tempZjb, 2) * tempGj)) - { - JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - return returnValue; - } - } - break; - } - break; - - case 1: //标准喷嘴 - tempRed1 = tempconQvA * returnValue; - if (tempZjb >= 0.3 & tempZjb < 0.44) - { - if (tempRed1 < 70000 | tempRed1 > 10000000.0D) - { - JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - } - } - if (tempZjb >= 0.44 & tempZjb < 0.8) - { - if (tempRed1 < 20000 | tempRed1 > 10000000.0D) - { - JOptionPane.showMessageDialog(null, "雷诺数超过标准喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - } - } - break; - case 2: //长径喷嘴 - tempRed1 = tempconQvA * returnValue; - if (tempRed1 < 10000.0D | tempRed1 > 10000000.0D) - { - JOptionPane.showMessageDialog(null, "雷诺数超过长径喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - } - break; - case 3: //文丘里喷嘴 - tempRed1 = tempconQvA * returnValue; - if (tempRed1 < 150000.0D | tempRed1 > 2000000.0D) - { - JOptionPane.showMessageDialog(null, "雷诺数超过文丘里喷嘴的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - } - break; - case 4: //粗铸收缩段经典文丘里管 - tempRed1 = tempconQvA * returnValue; - if (tempRed1 < 200000.0D | tempRed1 > 2000000.0D) - { - JOptionPane.showMessageDialog(null, "雷诺数超过粗铸收缩段经典文丘里管的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - return returnValue; - } - break; - case 5: //机械加工收缩段经典文丘里管 - tempRed1 = tempconQvA * returnValue; - if (tempRed1 < 200000.0D | tempRed1 > 1000000.0D) - { - JOptionPane.showMessageDialog(null, "雷诺数超过机械加工收缩段经典文丘里管的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - } - break; - case 6: //粗焊铁板收缩段经典文丘里管 - tempRed1 = tempconQvA * returnValue; - if (tempRed1 < 200000.0D | tempRed1 > 2000000.0D) - { - JOptionPane.showMessageDialog(null, "雷诺数超过粗焊铁板收缩段经典文丘里管的使用范围!停止计算!", "提示", JOptionPane.PLAIN_MESSAGE); - } - break; - - //标准孔板 - //ISA1932喷嘴 - //长径喷嘴 - //文丘里喷嘴 - //粗铸收缩段经典文丘里管 - //机械加工收缩段经典文丘里管 - //粗焊铁板收缩段经典文丘里管 - - - - - } - return returnValue; - } - - private double BkTable(double temPrk, double tempKj, int tempBkjsff) { - double[] BkTable_x = new double[10]; - double[] BkTable_Y = new double[10]; - //On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C# - if (tempBkjsff == 1) { - double tempRkBiKj = temPrk / tempKj; - // static double[] x = new double[10]; //VBConversions Note: Static variable moved to class level and renamed BkTable_x. Local static variables are not supported in C#. - // static double[] Y = new double[10]; //VBConversions Note: Static variable moved to class level and renamed BkTable_Y. Local static variables are not supported in C#. - int i; - int xIndex = 0; - //If x(0) = 0 Then - BkTable_x[0] = 0.0004F; - BkTable_x[1] = 0.001F; - BkTable_x[2] = 0.002F; - BkTable_x[3] = 0.004F; - BkTable_x[4] = 0.006F; - BkTable_x[5] = 0.008F; - BkTable_x[6] = 0.01F; - BkTable_x[7] = 0.012F; - BkTable_x[8] = 0.014F; - BkTable_x[9] = 0.015F; - - BkTable_Y[0] = 1; - BkTable_Y[1] = 1.005F; - BkTable_Y[2] = 1.012F; - BkTable_Y[3] = 1.022F; - BkTable_Y[4] = 1.032F; - BkTable_Y[5] = 1.04F; - BkTable_Y[6] = 1.048F; - BkTable_Y[7] = 1.055F; - BkTable_Y[8] = 1.062F; - BkTable_Y[9] = 1.065F; - //End If - - if (tempRkBiKj <= 0.0004) { - return 1; - } - if (tempRkBiKj > 0.015) { - return 1.065F; - } - for (i = 0; i <= 8; i++) { - if (tempRkBiKj >= BkTable_x[i] && tempRkBiKj <= BkTable_x[i + 1]) { - xIndex = i; - break; - } - } - return BkTable_Y[xIndex] + (tempRkBiKj - BkTable_x[xIndex]) * (BkTable_Y[xIndex + 1] - BkTable_Y[xIndex]) / (BkTable_x[xIndex + 1] - BkTable_x[xIndex]); - } - return 0; - } - //管道粗糙度计算 - private double CcdXsjs(double tempPipeType, double tempGj, double tempZjb, double TempRed) - { - double returnValue ; - //粗糙度系数计算 - double Jdccd = 0; //绝对粗糙度 - double Xdccd ; //相对粗糙度 - //Dim CcdXs As single - double s1 ; - double s2 ; - double ky ; - double kx ; - int i ; - int m = 0; - int n = 0; - if (tempPipeType == 0) - { - Jdccd = 0.029F;} - else if (tempPipeType == 1) - { - Jdccd = 0.075F; - } - else if (tempPipeType == 2) - { - Jdccd = 0.075F; - } - else if (tempPipeType == 3) - { - Jdccd = 0.075F; - } - else if (tempPipeType == 4) - { - Jdccd = 0.1F; - } - else if (tempPipeType == 5) - { - Jdccd = 0.15F; - } - else if (tempPipeType == 6) - { - Jdccd = 1; - } - else if (tempPipeType == 7) - { - Jdccd = 2.1F; - } - else if (tempPipeType == 8) - { - Jdccd = 0.04F; - } - else if (tempPipeType == 9) - { - Jdccd = 0.15F; - } - else if (tempPipeType == 10) - { - Jdccd = 0.13F; - } - else if (tempPipeType == 11) - { - Jdccd = 0.25F; - } - Xdccd = tempGj / Jdccd; - if (Xdccd < 400) - { - JOptionPane.showMessageDialog(null, "粗糙度取得太高,粗略计算", "提示", JOptionPane.PLAIN_MESSAGE); - Xdccd = 400; - } - if (Xdccd >= 3400) - { - Xdccd = 3400; - } - - if (Xdccd < 3200 & Math.pow(tempZjb, 2) > 0.1 & Math.pow(tempZjb, 2) < 0.64) - { - - int[] Xdccdb = new int[10]; - double[] Btf = new double[8]; - double[][] CcdXsb = new double[10][8]; - - Xdccdb[0] = 400; - Xdccdb[1] = 800; - Xdccdb[2] = 1200; - Xdccdb[3] = 1600; - Xdccdb[4] = 2000; - Xdccdb[5] = 2400; - Xdccdb[6] = 2800; - Xdccdb[7] = 3200; - Xdccdb[8] = 3400; - - Btf[0] = 0.1F; - Btf[1] = 0.2F; - Btf[2] = 0.3F; - Btf[3] = 0.4F; - Btf[4] = 0.5F; - Btf[5] = 0.6F; - Btf[6] = 0.64F; - - CcdXsb[0][0] = 1.002; - CcdXsb[1][0] = 1; - CcdXsb[2][0] = 1; - CcdXsb[3][0] = 1; - CcdXsb[4][0] = 1; - CcdXsb[5][0] = 1; - CcdXsb[6][0] = 1; - CcdXsb[7][0] = 1; - CcdXsb[8][0] = 1; - CcdXsb[0][1] = 1.003; - CcdXsb[1][1] = 1.002; - CcdXsb[2][1] = 1.001; - CcdXsb[3][1] = 1; - CcdXsb[4][1] = 1; - CcdXsb[5][1] = 1; - CcdXsb[6][1] = 1; - CcdXsb[7][1] = 1; - - CcdXsb[0][2] = 1.006; - CcdXsb[1][2] = 1.004; - CcdXsb[2][2] = 1.002; - CcdXsb[3][2] = 1.001; - CcdXsb[4][2] = 1; - CcdXsb[5][2] = 1; - CcdXsb[6][2] = 1; - CcdXsb[7][2] = 1; - - CcdXsb[0][3] = 1.009; - CcdXsb[1][3] = 1.006; - CcdXsb[2][3] = 1.004; - CcdXsb[3][3] = 1.002; - CcdXsb[4][3] = 1.001; - CcdXsb[5][3] = 1; - CcdXsb[6][3] = 1; - CcdXsb[7][3] = 1; - - CcdXsb[0][4] = 1.014; - CcdXsb[1][4] = 1.009; - CcdXsb[2][4] = 1.006; - CcdXsb[3][4] = 1.004; - CcdXsb[4][4] = 1.002; - CcdXsb[5][4] = 1.001; - CcdXsb[6][4] = 1; - CcdXsb[7][4] = 1; - - CcdXsb[0][5] = 1.02; - CcdXsb[1][5] = 1.013; - CcdXsb[2][5] = 1.009; - CcdXsb[3][5] = 1.006; - CcdXsb[4][5] = 1.003; - CcdXsb[5][5] = 1.002; - CcdXsb[6][5] = 1; - CcdXsb[7][5] = 1; - - CcdXsb[0][6] = 1.024; - CcdXsb[1][6] = 1.016; - CcdXsb[2][6] = 1.011; - CcdXsb[3][6] = 1.007; - CcdXsb[4][6] = 1.004; - CcdXsb[5][6] = 1.002; - CcdXsb[6][6] = 1.002; - CcdXsb[7][6] = 1; - - - for (i = 0; i <= 8; i++) - { - if (Xdccd >= Xdccdb[i] && Xdccd <= Xdccdb[i + 1]) - { - m = i; - break; - } - } - for (i = 0; i <= 6; i++) - { - if (Math.pow(tempZjb, 2) >= Btf[i] && Math.pow(tempZjb, 2) <= Btf[i + 1]) - { - n = i; - break; - } - } - - ky = (Btf[n + 1] - Btf[n] != 0) ? ((Math.pow(tempZjb, 2) - Btf[n]) / (Btf[n + 1] - Btf[n])) : 0; - - kx = (Xdccdb[m + 1] - Xdccdb[m] != 0) ? ((Xdccd - Xdccdb[m]) / (Xdccdb[m + 1] - Xdccdb[m])) : 0; - - s1 = CcdXsb[m][n] + (CcdXsb[m][n + 1] - CcdXsb[m][n]) * ky; - s2 = CcdXsb[m + 1][n] + (CcdXsb[m + 1][n + 1] - CcdXsb[m + 1][n]) * ky; - returnValue = s1 + (s2 - s1) * kx; - - returnValue = TempRed > 1000000.0 ? returnValue : ((returnValue - 1) * Math.pow((Math.log10(TempRed) / 2), 2) + 1); - - } - else - { - returnValue = 1; - } - return returnValue; - } // ######################################################################### // ######################'流量转换 标况转工况############################## diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/GBT22634WaterContentCalc.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/GBT22634WaterContentCalc.java new file mode 100644 index 0000000..e2bf26c --- /dev/null +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/GBT22634WaterContentCalc.java @@ -0,0 +1,146 @@ +package com.ruoyi.ngCalTools.controller; +import com.ruoyi.ngCalTools.model.GasProps; +import com.ruoyi.system.controller.UnitConvert; +import com.ruoyi.system.service.ISysUnitConvertService; +import com.ruoyi.system.service.impl.SysUnitConvertServiceImpl; +import org.apache.commons.math3.analysis.UnivariateFunction; +import org.apache.commons.math3.analysis.solvers.BracketingNthOrderBrentSolver; +import org.apache.commons.math3.analysis.solvers.NewtonRaphsonSolver; +import org.apache.commons.math3.exception.TooManyEvaluationsException; + +/** + * GB/T 22634-2008 天然气水含量与水露点工业级换算 + * 注:需配合气体性质计算模块GasController使用 + */ + +public class GBT22634WaterContentCalc { + + + + // 安托因方程常数(GB/T 22634规定) + private static final double ANTOINE_A = 8.07131; + private static final double ANTOINE_B = 1730.63; + private static final double ANTOINE_C = 233.426; + private static final double MMHG_TO_KPA = 0.1333223684; + + /** + * 工业级水含量计算(含真实气体修正) + * @param dewPointTemp 水露点温度(℃) + * @param pressure 绝对压力(kPa) + * @param gasProps 气体组分属性 + * @return 水含量(mg/Sm³) + */ + public double calculateWaterContent(double dewPointTemp, + double pressure, + GasProps gasProps) { + // 1. 计算饱和水蒸气压 + double pWater = calculateWaterVaporPressure(dewPointTemp); + // 2. 获取压缩因子 + GasController.Crit(gasProps,0); // 调用实际压缩因子计算模块 + // 3. 计算真实摩尔体积 + double molarVolume = calculateMolarVolume(dewPointTemp, pressure, gasProps.getdZf()); + // 4. 计算水含量 + return (pWater / (pressure - pWater)) * (18.01528 * 1e6) / molarVolume; + } + + /** + * 逆向计算水露点温度(工业级精度) + * @param waterContent 水含量(mg/Sm³) + * @param pressure 绝对压力(kPa) + * @param gasProps 气体组分属性 + * @return 水露点温度(℃),精度±0.01℃ + */ + public double calculateDewPoint(final double waterContent, + final double pressure, + final GasProps gasProps) { +// NewtonRaphsonSolver solver = new NewtonRaphsonSolver(1e-4); + + // 使用5阶布伦特法求解器(无需导数) + BracketingNthOrderBrentSolver solver = new BracketingNthOrderBrentSolver( + 1e-4, // 相对精度 + 1e-6, // 绝对精度 + 1e-10, // 函数值精度 + 5 // 多项式阶数 + ); + + UnivariateFunction function = new UnivariateFunction() { + @Override + public double value(double tempC) { + try { + // 创建临时气体属性副本 + GasProps tempProps = gasProps.clone(); + tempProps.setdTf(tempC + 273.15); // 更新温度 + tempProps.setdPf(pressure); + + double calc = calculateWaterContent(tempC, pressure, tempProps); + return calc - waterContent; + } catch (Exception e) { + return Double.NaN; + } + } + }; + + try { + return solver.solve(100, function, -50.0, 100.0, 20.0); // 初始猜测20℃ + } catch (TooManyEvaluationsException e) { + throw new ArithmeticException("露点计算未收敛,请检查输入参数"); + } + } + + // 饱和水蒸气压计算(GB/T 22634规定方法) + private double calculateWaterVaporPressure(double tempC) { + if(tempC < 0 || tempC > 100) { + throw new IllegalArgumentException("温度超出GB/T 22634适用范围"); + } + return Math.pow(10, ANTOINE_A - ANTOINE_B / (tempC + ANTOINE_C)) * MMHG_TO_KPA; + } + + // 真实气体摩尔体积计算 + private static double calculateMolarVolume(double tempC, double pressure, double Z) { + return Z * 8.3144621 * (tempC + 273.15) / pressure; + } + +// // 气体属性类(示例结构) +// public static class GasProps implements Cloneable { +// private double temperature; // K +// private double pressure; // kPa +// private double[] composition; // 组分摩尔分数 +// +// // 克隆方法用于迭代计算 +// @Override +// public GasProps clone() { +// GasProps clone = new GasProps(); +// clone.temperature = this.temperature; +// clone.pressure = this.pressure; +// clone.composition = this.composition.clone(); +// return clone; +// } +// +// // Getter/Setter +// public double getTemperature() { return temperature; } +// public void setTemperature(double temperature) { this.temperature = temperature; } +// public double getPressure() { return pressure; } +// public void setPressure(double pressure) { this.pressure = pressure; } +// public double[] getComposition() { return composition; } +// public void setComposition(double[] composition) { this.composition = composition; } +// } +// +// // 示例调用 +// public static void main(String[] args) { +// // 初始化气体属性 +// GasProps gas = new GasProps(); +// gas.setPressure(5000.0); // 5 MPa +// gas.setTemperature(293.15); // 20℃ +// gas.setComposition(new double[]{0.95, 0.03, 0.02}); // 示例组分 +// +// // 正向计算 +// double wc = calculateWaterContent(10.0, 5000.0, gas); +// System.out.printf("5MPa下10℃露点对应水含量:%.2f mg/Sm³\n", wc); +// +// // 逆向计算 +// double dewPoint = calculateDewPoint(1000.0, 5000.0, gas); +// System.out.printf("5MPa下1000mg/Sm³对应露点:%.2f℃\n", dewPoint); +// } + + +} diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/GasController.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/GasController.java index 08f64ab..50a97fe 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/GasController.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/GasController.java @@ -3,31 +3,33 @@ package com.ruoyi.ngCalTools.controller; // GasController.java import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.ngCalTools.model.GasProps; import com.ruoyi.ngCalTools.model.FlowProps; +import com.ruoyi.ngCalTools.model.GasProps; import com.ruoyi.ngCalTools.service.DetailService; import com.ruoyi.ngCalTools.service.GBT11062Service; import com.ruoyi.ngCalTools.service.ThermService; import com.ruoyi.ngCalTools.utils.GasConstants; -import com.ruoyi.system.controller.SysUnitConvertController; import com.ruoyi.system.controller.UnitConvert; -import org.springframework.web.bind.annotation.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/NGCalcTools") public class GasController { - private final UnitConvert unitConvert; - public ThermService thermService; - public DetailService detailService; - public GBT11062Service gbt11062Service; + public static ThermService thermService; + public static DetailService detailService; + public static GBT11062Service gbt11062Service; + + @Autowired + private UnitConvert unitConvert=new UnitConvert(); - public GasController(UnitConvert unitConvert) { - this.unitConvert = unitConvert; - } @PostMapping ("/ngCalc") - public AjaxResult ngCalc(@RequestBody FlowProps flowProps) { + public AjaxResult ngCalc(@RequestBody FlowProps flowProps) { thermService = new ThermService(); detailService = new DetailService(); gbt11062Service = new GBT11062Service(); @@ -46,6 +48,31 @@ public class GasController { } gasProps.dTf = tempTf; gasProps.dCbtj = flowProps.getdCbtj(); + + switch (gasProps.dCbtj) + { + case 2: + gasProps.setdPb(101325); + gasProps.setdTb( 273.15); + flowProps.setdPb_M(101325); + flowProps.setdTb_M(273.15); + break; + case 1: + + gasProps.setdPb(101325); + gasProps.setdTb( 288.15); + flowProps.setdPb_M(101325); + flowProps.setdTb_M(288.15); + break; + case 0: + + gasProps.setdPb(101325); + gasProps.setdTb( 293.15); + flowProps.setdPb_M(101325); + flowProps.setdTb_M(293.15); + break; + } + String[] stringArray = flowProps.getdngComponents().split("_"); double[] doubleArray = new double[stringArray.length]; // 遍历字符串数组,将每个元素转换为 double 类型 for (int i = 0; i < stringArray.length; i++) { @@ -58,21 +85,19 @@ public class GasController { } gasProps.adMixture = doubleArray; Crit(gasProps, 0); //计算临界流函数所有参数都计算了 - return AjaxResult.success(gasProps); + return AjaxResult.success(gasProps); } - public void ngCalcVoid( FlowProps flowProps,GasProps gasProps) { + public static void ngCalcVoid(FlowProps flowProps, GasProps gasProps) { thermService = new ThermService(); detailService = new DetailService(); gbt11062Service = new GBT11062Service(); - - Crit(gasProps, 0); //计算临界流函数所有参数都计算了 - + Crit(gasProps, 0); //计算临界流函数所有参数都计算了 } - public int NG_Cal_Init() { + public static int NG_Cal_Init() { //create object for calculating density if (null == (detailService=new DetailService())) { return GasConstants.MEMORY_ALLOCATION_ERROR; @@ -86,7 +111,7 @@ public class GasController { return GasConstants.NG_Cal_INITIALIZED; }// NG_Cal_Init - public int NG_Cal_UnInit() { + public static int NG_Cal_UnInit() { // delete the objects (if they exist) detailService = null; thermService = null; @@ -94,7 +119,7 @@ public class GasController { } - public double Crit(GasProps gasProps, double dPlenumVelocity) + public static double Crit(GasProps gasProps, double dPlenumVelocity) { //variables local to function double DH, DDH, S, H; @@ -115,23 +140,7 @@ public class GasController { } } - switch (gasProps.dCbtj) - { - case 2: - gasProps.dPb = 101325; - gasProps.dTb = 273.15; - break; - case 1: - gasProps.dPb = 101325; - gasProps.dTb = 288.15; - break; - case 0: - gasProps.dPb = 101325; - gasProps.dTb = 293.15; - break; - - } //begin by calculating densities and thermodynamic properties thermService.Run(gasProps, detailService); diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/NozellFlowCalc.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/NozellFlowCalc.java new file mode 100644 index 0000000..564896e --- /dev/null +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/NozellFlowCalc.java @@ -0,0 +1,133 @@ +package com.ruoyi.ngCalTools.controller; +import com.ruoyi.ngCalTools.model.FlowProps; +import com.ruoyi.ngCalTools.model.GasProps; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +public class NozellFlowCalc { + + + // 喷嘴类型枚举 + public enum NozzleType { + TOROIDAL, CYLINDRICAL + } + + // 计算流出系数 + public static double calculateDischargeCoefficient(NozzleType nozzleType, double reynoldsNumber) { + double a, b, c, d, e, f, n; + switch (nozzleType) { + case TOROIDAL: + a = 0.9990; + b = 3.415; + c = 0.0031; + d = 0.690; + e = 10; + f = 120000; + n = 0.5; + break; + case CYLINDRICAL: + a = 1.0000; + b = 6.341; + c = 0.008; // 假设天然气,按用户场景取c值 + d = 3.000; + e = 6; + f = 170000; + n = 0.5; + break; + default: + throw new IllegalArgumentException("不支持的喷嘴类型"); + } + + double numerator = c - d * Math.pow(reynoldsNumber, -n); + double denominator = 1 + Math.exp(e - reynoldsNumber / f); + return (a - b * Math.pow(reynoldsNumber, -n)) - numerator / denominator; + } + + // 计算雷诺数 + public static double calculateReynoldsNumber(double pipeDiameter, double velocity, double dynamicViscosity, double density) { + return (pipeDiameter * velocity * density) / dynamicViscosity; + } + + // 迭代计算流出系数和雷诺数 + public static void iterativeCalculation(FlowProps flowProps, GasProps gasProps, NozzleType nozzleType) { + double tolerance = 1e-6; + int maxIterations = 100; + double prevCd = 0; + double prevRe = 0; + + for (int i = 0; i < maxIterations; i++) { + double velocity = calculateVelocity(flowProps, gasProps); + double reynoldsNumber = calculateReynoldsNumber( + flowProps.getdPipeD(), + velocity, + gasProps.getdMu(), + gasProps.dRhof + ); + double cd = calculateDischargeCoefficient(nozzleType, reynoldsNumber); + + // 检查收敛 + if (Math.abs(cd - prevCd) < tolerance && Math.abs(reynoldsNumber - prevRe) < tolerance) { + flowProps.setdCdCorrect(cd); + flowProps.setdRnPipe(reynoldsNumber); + return; + } + + prevCd = cd; + prevRe = reynoldsNumber; + } + throw new RuntimeException("迭代未收敛"); + } + + // 计算流速 + private static double calculateVelocity(FlowProps flowProps, GasProps gasProps) { + // 假设工况体积流量计算逻辑,需根据实际流量公式补充 + // 这里简化示例,实际需根据ISO公式结合临界流函数等计算 + return flowProps.getdVFlowf() / (Math.PI * Math.pow(flowProps.getdPipeD() / 2, 2)); + } + + // 计算质量流量(示例) + public static double calculateMassFlow(FlowProps flowProps, GasProps gasProps, NozzleType nozzleType) { + iterativeCalculation(flowProps, gasProps, nozzleType); + double criticalFlowFactor = gasProps.dCstar; + double area = Math.PI * Math.pow(flowProps.getdOrificeD() / 2, 2); + double pressure = flowProps.getdPf(); + double temperature = flowProps.getdTf(); + double gasConstant = calculateGasConstant(gasProps); + + // 根据ISO公式计算理论质量流量,再结合流出系数 + double theoreticalMassFlow = area * criticalFlowFactor * pressure / Math.sqrt((gasConstant / gasProps.dMrx) * temperature); + return flowProps.getdCdCorrect() * theoreticalMassFlow; + } + + // 计算气体常数(示例) + private static double calculateGasConstant(GasProps gasProps) { + return 8.314 / gasProps.dMrx; // 通用气体常数处理,需根据实际精确计算 + } + + // 高精度计算辅助方法 + private static double highPrecisionCalculate(double value, int scale) { + return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue(); + } +// +// public static void main(String[] args) { +// FlowProps flowProps = new FlowProps(); +// GasProps gasProps = new GasProps(); +// NozzleType nozzleType = NozzleType.CYLINDRICAL; +// +// // 初始化输入参数 +// flowProps.dPipeD = 0.1; // 示例管道直径 +// flowProps.dOrificeD = 0.05; // 示例喉径 +// gasProps.dMu = 0.00001; // 示例动力粘度 +// gasProps.dRhof = 1.0; // 示例工况密度 +// gasProps.dCstar = 0.9; // 示例临界流函数 +// +// // 执行计算 +// double massFlow = calculateMassFlow(flowProps, gasProps, nozzleType); +// System.out.println("计算的质量流量: " + massFlow); +// } + + + + +} diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/NozellFlowCalcISO9300.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/NozellFlowCalcISO9300.java new file mode 100644 index 0000000..05216cb --- /dev/null +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/NozellFlowCalcISO9300.java @@ -0,0 +1,131 @@ +package com.ruoyi.ngCalTools.controller; + +import com.ruoyi.ngCalTools.model.FlowProps; +import com.ruoyi.ngCalTools.model.GasProps; +import com.ruoyi.ngCalTools.service.DetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RestController; + +@RestController + +public class NozellFlowCalcISO9300 { + + @Autowired + private GasController gasController = new GasController(); + + + // 计算流出系数Cd、雷诺数Re及流量(示例中仅展示关键步骤) + public void calculateFlowCoefficient(FlowProps flowProps, GasProps gasProps) { + + // 获取基本参数 + double dOrifice = flowProps.getdOrificeD(); + double dPipe = flowProps.getdPipeD(); + double PStatic = flowProps.getdPf(); + double TStatic = flowProps.getdTf(); + // 气体属性 + double R = DetailService.RGASKJ; + double kappa = gasProps.getdKappa(); + double rhoRef = gasProps.getdRhob(); + double Cstar = gasProps.getdCstar(); + + // 计算几何参数 + double AOrifice = Math.PI * Math.pow(dOrifice, 2) / 4; + double APipe = Math.PI * Math.pow(dPipe / 2, 2); + + +// 初始参数 + double Cd = 0.99; // 初始猜测值 + double rho = gasProps.getdRhof(); // 基于静态条件的初始密度 + double mu = gasProps.getdMu(); // 初始粘度 + double Re; + + // 迭代控制 + double tolerance = 1e-6; + int maxIterations = 100; + boolean converged = false; + + for (int i = 0; i < maxIterations; i++) { + // 计算质量流量 + double qm = Cd * AOrifice * Cstar * Math.sqrt(gasProps.getdZf() * rho * gasProps.getdPf()); + + // 计算流速 + double velocity = qm / (rho * APipe); + + // 计算滞止参数 + double[] stagnation = calculateStagnationProperties( + PStatic, TStatic, velocity, kappa, R); + double P0 = stagnation[0]; + double T0 = stagnation[1]; + + // 更新物性参数 + gasProps.setdPf(P0); + gasProps.setdTf(T0); + gasController.ngCalc(flowProps); + double newRho =gasProps.getdRhof(); + double newMu = gasProps.getdMu(); + + // 计算雷诺数 + Re = (4 * qm) / (Math.PI * dOrifice * newMu); + + // 获取喷嘴系数 + double[] coeffs = getNozzleCoefficients(flowProps.getdNozzleType()); + double a = coeffs[0], b = coeffs[1], c = coeffs[2], + d = coeffs[3], e = coeffs[4], f = coeffs[5], n = coeffs[6]; + + // 计算新的Cd + double term1 = a - b * Math.pow(Re, -n); + double term2 = (c - d * Math.pow(Re, -n)) / (1 + Math.exp(e - Re / f)); + double newCd = term1 - term2; + + // 检查收敛 + if (Math.abs(newCd - Cd) < tolerance && + Math.abs(newRho - rho) < tolerance && + Math.abs(newMu - mu) < tolerance) { + converged = true; + Cd = newCd; + rho = newRho; + mu = newMu; + break; + } + + // 更新参数 + Cd = newCd; + rho = newRho; + mu = newMu; + } + + if (!converged) throw new RuntimeException("迭代未收敛"); + + // 计算标况体积流量 + double qm = Cd * AOrifice * Cstar * Math.sqrt(gasProps.getdZf() * rho * gasProps.getdPf()); + + // 保存结果 + flowProps.setdCd(Cd); + flowProps.setdRnPipe(rho); + flowProps.setdMFlowb(qm); + flowProps.setdVFlowb(qm/gasProps.getdRhob()); + } + + private static double[] getNozzleCoefficients(int coreType) { + // 返回喷嘴系数数组 [a, b, c, d, e, f, n] + if (coreType == 0) { // 圆环形 + return new double[]{0.9990, 3.415, 0.0031, 0.690, 10, 120000, 0.5}; + } else { // 圆柱形 + return new double[]{1.0000, 6.341, 0.008, 3.000, 6, 170000, 0.5}; + } + } + + + public static double[] calculateStagnationProperties( + double staticP, double staticT, double velocity, + double kappa, double R) { + + double soundSpeed = Math.sqrt(kappa * R * staticT); + double mach = velocity / soundSpeed; + double T0 = staticT * (1 + 0.5 * (kappa - 1) * mach * mach); + double P0 = staticP * Math.pow(T0 / staticT, kappa / (kappa - 1)); + return new double[]{P0, T0}; + } + + +} diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/FlowProps.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/FlowProps.java index 5f12f91..ce5703a 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/FlowProps.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/FlowProps.java @@ -4,6 +4,100 @@ public class FlowProps { // 流量计算输入参数信息 private int dFlowCalbz; // 流量计算标准 + + private int dZcalbz; // 压缩因子计算标准 + private int dCbtj; // 计量参比条件压力 + private double dPb_M; // 计量参比条件压力 + private double dTb_M; // 计量参比条件温度 + private double dPb_E; // 燃烧参比条件压力 + private double dTb_E; // 燃烧参比条件温度 + private double dPatm; // 当地大气压 + private int dPatmUnit; // 当地大气压单位 + private String dngComponents; // 天然气组分 + + private int dMeterType; // 流量计类别 + private int dCoreType; // 节流装置类型 + private int dPtmode; // 取压方式 + private int dPipeType; // 管道类型 + private double dPipeD; // 管道内径 + private int dLenUnit; // 长度单位 + private double dPipeDtemp; // 管道内径参考温度 + private int dPileDtempUint; // 温度单位 + private double dPipeMaterial; // 管道材料 + + private double dOrificeD; // 孔板孔径 + private int dOrificeUnit; // 长度单位 + private double dOrificeDtemp; // 孔板内径参考温度 + private int dOrificeDtempUnit; // 温度单位 + private double dOrificeMaterial; // 孔板材料 + private int dOrificeSharpness; // 锐利度系数计算方法 + private double dOrificeRk; // 孔板入口圆弧半径 + private int dOrificeRkLenUint; // 长度单位 + private double dPf; // 输入压力 + private int dPfUnit; // 压力单位 + private int dPfType; // 压力类型 + private double dTf; // 输入温度 + private int dTfUnit; // 温度单位 + private double dDp; // 输入差压 + private int dDpUnit; // 压力单位 + private int dVFlowUnit; // 体积流量单位 + private int dMFlowUnit; // 质量流量单位 + private int dEFlowUnit; // 能量流量单位 + private double dCd; // 流出系数 + private double dMeterFactor; // 仪表系数 + private double dPulseNum; // 脉冲数 + private double dVFlowMax; // 最大体积流量 + private double dVFlowMin; // 最小体积流量 + private double dVFlowCon; // 常用流量 + private double dPfRange; // 压力量程 + private double dDpRange; // 差压量程 + private double dTfRange; // 温度计量程 + + // 流量计算输出参数 + private double dE; // 求渐近速度系数 E + private double dFG; // 求相对密度系数 FG + private double dFT; // 求流动温度系数 FT + + + + private double dFpv; // 求超压缩因子 Fpv + + private double dDViscosity; // 求动力粘度 dlnd + private double dDExpCoefficient; // 求可膨胀系数 + private double dRnPipe; // 管道雷诺数 + private double dBk; // 孔板锐利度系数Bk + private double dRoughNessPipe; // 管道粗糙度系数 Gme + private double dCdCorrect; // 修正后的流出系数 + private double dCdNozell; // 喷嘴的流出系数 + private double dVFlowb; // 标况体积流量 m³、s + private double dVFlowf; // 工况体积流量 + private double dMFlowb; // 标况质量流量 + private double dEFlowb; // 标况能量流量 + private double dVelocityFlow; // 管道内天然气流速 + private double dPressLost; // 压力损失 + private double dBeta; // 直径比 + private double dKappa; // 等熵指数 + + private int dNozzleType; // 0圆环形喷嘴 2 圆柱形喉部文丘里喷嘴 + private double dUpstreamRadius ;// + + + + + + public double getdUpstreamRadius() { + return dUpstreamRadius; + } + + public void setdUpstreamRadius(double dUpstreamRadius) { + this.dUpstreamRadius = dUpstreamRadius; + } + + + + + + public int getdZcalbz() { return dZcalbz; } @@ -516,59 +610,6 @@ public class FlowProps { this.dKappa = dKappa; } - private int dZcalbz; // 压缩因子计算标准 - private int dCbtj; // 计量参比条件压力 - private double dPb_M; // 计量参比条件压力 - private double dTb_M; // 计量参比条件温度 - private double dPb_E; // 燃烧参比条件压力 - private double dTb_E; // 燃烧参比条件温度 - private double dPatm; // 当地大气压 - private int dPatmUnit; // 当地大气压单位 - private String dngComponents; // 天然气组分 - - private int dMeterType; // 流量计类别 - private int dCoreType; // 节流装置类型 - private int dPtmode; // 取压方式 - private int dPipeType; // 管道类型 - private double dPipeD; // 管道内径 - private int dLenUnit; // 长度单位 - private double dPipeDtemp; // 管道内径参考温度 - private int dPileDtempUint; // 温度单位 - private double dPipeMaterial; // 管道材料 - - private double dOrificeD; // 孔板孔径 - private int dOrificeUnit; // 长度单位 - private double dOrificeDtemp; // 孔板内径参考温度 - private int dOrificeDtempUnit; // 温度单位 - private double dOrificeMaterial; // 孔板材料 - private int dOrificeSharpness; // 锐利度系数计算方法 - private double dOrificeRk; // 孔板入口圆弧半径 - private int dOrificeRkLenUint; // 长度单位 - private double dPf; // 输入压力 - private int dPfUnit; // 压力单位 - private int dPfType; // 压力类型 - private double dTf; // 输入温度 - private int dTfUnit; // 温度单位 - private double dDp; // 输入差压 - private int dDpUnit; // 压力单位 - private int dVFlowUnit; // 体积流量单位 - private int dMFlowUnit; // 质量流量单位 - private int dEFlowUnit; // 能量流量单位 - private double dCd; // 流出系数 - private double dMeterFactor; // 仪表系数 - private double dPulseNum; // 脉冲数 - private double dVFlowMax; // 最大体积流量 - private double dVFlowMin; // 最小体积流量 - private double dVFlowCon; // 常用流量 - private double dPfRange; // 压力量程 - private double dDpRange; // 差压量程 - private double dTfRange; // 温度计量程 - - // 流量计算输出参数 - private double dE; // 求渐近速度系数 E - private double dFG; // 求相对密度系数 FG - private double dFT; // 求流动温度系数 FT - public double getdFpv() { return dFpv; } @@ -577,26 +618,14 @@ public class FlowProps { this.dFpv = dFpv; } - private double dFpv; // 求超压缩因子 Fpv - private double dDViscosity; // 求动力粘度 dlnd - private double dDExpCoefficient; // 求可膨胀系数 - private double dRnPipe; // 管道雷诺数 - private double dBk; // 孔板锐利度系数Bk - private double dRoughNessPipe; // 管道粗糙度系数 Gme - private double dCdCorrect; // 修正后的流出系数 - private double dCdNozell; // 喷嘴的流出系数 - private double dVFlowb; // 标况体积流量 m³、s - private double dVFlowf; // 工况体积流量 - private double dMFlowb; // 标况质量流量 - private double dEFlowb; // 标况能量流量 - private double dVelocityFlow; // 管道内天然气流速 - private double dPressLost; // 压力损失 - private double dBeta; // 直径比 - private double dKappa; // 等熵指数 + public int getdNozzleType() { + return dNozzleType; + } - - // Getters and Setters + public void setdNozzleType(int dNozzleType) { + this.dNozzleType = dNozzleType; + } diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/GasProps.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/GasProps.java index 6eb9149..519214a 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/GasProps.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/model/GasProps.java @@ -1,14 +1,110 @@ package com.ruoyi.ngCalTools.model; -public class GasProps { +public class GasProps implements Cloneable { + + // 重写 clone() 方法 + @Override + public GasProps clone() { + try { + return (GasProps) super.clone(); + } catch (CloneNotSupportedException e) { + // 因为已经实现了 Cloneable 接口,所以不会抛出该异常 + throw new AssertionError(); + } + } + + // corresponds to the control group in meter classes public int lStatus; // calculation status 计算状态 public boolean bForceUpdate; // 执行全部计算的标志 signal to perform full calculation - - - public double[] adMixture; // 气体摩尔组成 Composition in mole fraction public double[] adMixtureV; // 气体体积组成 Composition in mole fraction + public double[] adMixtureD; // 气体质量组成 Composition in mole fraction + public int dCbtj; // 参比条件 101325 0,15,20 + public double dPb; // 参比压力 Contract base Pressure (Pa) + public double dTb; // 参比温度Contract base temperature (K) + public double dPf; // 绝对压力 Absolute Pressure (Pa) + public double dTf; // 工况温度 Flowing temperature (K) + // basic output from AGA 8 Detail method + public double dMrx; // 分子量 mixture molar mass + public double dZb; // 标况压缩因子compressibility at contract base condition + public double dZf; // 工况压缩因子compressibility at flowing condition + public double dFpv; // 超压缩系数 supercompressibility + public double dDb; // 标况摩尔密度molar density at contract base conditions (moles/dm3) + public double dDf; // 工况摩尔密度 molar density at flowing conditions (moles/dm3) + public double dRhob; // 标况质量密度mass density at contract base conditions (kg/m3) + public double dRhof; // 工况质量密度 mass density at flowing conditions (kg/m3) + public double dRD_Ideal; // 理想气体的相对密度ideal gas relative density + public double dRD_Real; // 真实气体的相对密度real gas relative density + // additional output + public double dHo; // 理想气体的比焓 ideal gas specific enthalpy + public double dH; // 真实气体的焓 real gas specific enthalpy (J/kg) + public double dS; // 真实气体的熵real gas specific entropy (J/kg-mol.K) + public double dCpi; // 理想气体定压热容 ideal gas constant pressure heat capacity (J/kg-mol.K) + public double dCp; // 定压热容real gas constant pressure heat capacity (J/kg-mol.K) + public double dCv; // 定容积热容 real gas constant volume heat capacity (J/kg-mol.K) + public double dk; // 比热比ratio of specific heats + public double dKappa; // 等熵指数 isentropic exponent, denoted with Greek letter kappa + public double dSOS; // 声速speed of sound (m/s) + public double dCstar; // 临界流函数 critical flow factor C* + + // 11062 输出 + public double dHhvMol; // 摩尔高位发热量 + public double dLhvMol; // 摩尔低位发热量 + public double dHhvv; // 体积高位发热量 + public double dLhvv; // 体积低位发热量 + public double dHhvm; // 质量高位发热量 + public double dLhvm; // 质量地位发热量 + + public double dZb11062; // 标况压缩因子 + public double dRhob11062; // 标况质量密度mass density at contract base conditions (kg/m3) + public double dRhof11062; // 工况质量密度 mass density at flowing conditions (kg/m3) + public double dRD_Ideal11062; // 理想气体的相对密度ideal gas relative density + public double dRD_Real11062; // 真实气体的相对密度real gas relative density + public double dWobbeIndex; // 真实气体的沃泊指数 + + public double dPc; // 临界压力 + public double dTC; // 临界温度 + public double dBzsx; // 爆炸上限 + public double dBzxx; // 爆炸下限 + public double dTotalC; // 总炭含量 (kg/m3) + public double dC2; // C2组分含量 (kg/m3) + public double dC2j; // C2以上组分含量 (kg/m3) + public double dC3j; // C3以上组分含量 (kg/m3) + public double dC4j; // C4以上组分含量 (kg/m3) + public double dC5j; // C5以上组分含量 (kg/m3) + public double dC6j; // C6以上组分含量 (kg/m3) + public double dC3C4; // C3C4组分含量 (kg/m3) + public String dngComponents; //组分的组合字符串 从前端传过来 + + // 新增高精度物性参数 + private double dMu; // 动态粘度 (Pa·s) + private double dNu; // 运动粘度 (m²/s) + // 新增滞止参数 + public double dP0; // 滞止压力(Pa) + public double dT0; // 滞止温度(K) + + + + + + public double getdP0() { + return dP0; + } + + public void setdP0(double dP0) { + this.dP0 = dP0; + } + + public double getdT0() { + return dT0; + } + + public void setdT0(double dT0) { + this.dT0 = dT0; + } + + public double[] getAdMixtureD() { return adMixtureD; @@ -450,63 +546,23 @@ public class GasProps { this.dngComponents = dngComponents; } - public double[] adMixtureD; // 气体质量组成 Composition in mole fraction - public int dCbtj; // 参比条件 101325 0,15,20 - public double dPb; // 参比压力 Contract base Pressure (Pa) - public double dTb; // 参比温度Contract base temperature (K) - public double dPf; // 绝对压力 Absolute Pressure (Pa) - public double dTf; // 工况温度 Flowing temperature (K) - // basic output from AGA 8 Detail method - public double dMrx; // 分子量 mixture molar mass - public double dZb; // 标况压缩因子compressibility at contract base condition - public double dZf; // 工况压缩因子compressibility at flowing condition - public double dFpv; // 超压缩系数 supercompressibility - public double dDb; // 标况摩尔密度molar density at contract base conditions (moles/dm3) - public double dDf; // 工况摩尔密度 molar density at flowing conditions (moles/dm3) - public double dRhob; // 标况质量密度mass density at contract base conditions (kg/m3) - public double dRhof; // 工况质量密度 mass density at flowing conditions (kg/m3) - public double dRD_Ideal; // 理想气体的相对密度ideal gas relative density - public double dRD_Real; // 真实气体的相对密度real gas relative density - // additional output - public double dHo; // 理想气体的比焓 ideal gas specific enthalpy - public double dH; // 真实气体的焓 real gas specific enthalpy (J/kg) - public double dS; // 真实气体的熵real gas specific entropy (J/kg-mol.K) - public double dCpi; // 理想气体定压热容 ideal gas constant pressure heat capacity (J/kg-mol.K) - public double dCp; // 定压热容real gas constant pressure heat capacity (J/kg-mol.K) - public double dCv; // 定容积热容 real gas constant volume heat capacity (J/kg-mol.K) - public double dk; // 比热比ratio of specific heats - public double dKappa; // 等熵指数 isentropic exponent, denoted with Greek letter kappa - public double dSOS; // 声速speed of sound (m/s) - public double dCstar; // 临界流函数 critical flow factor C* - // 11062 输出 - public double dHhvMol; // 摩尔高位发热量 - public double dLhvMol; // 摩尔低位发热量 - public double dHhvv; // 体积高位发热量 - public double dLhvv; // 体积低位发热量 - public double dHhvm; // 质量高位发热量 - public double dLhvm; // 质量地位发热量 + public double getdMu() { + return dMu; + } - public double dZb11062; // 标况压缩因子 - public double dRhob11062; // 标况质量密度mass density at contract base conditions (kg/m3) - public double dRhof11062; // 工况质量密度 mass density at flowing conditions (kg/m3) - public double dRD_Ideal11062; // 理想气体的相对密度ideal gas relative density - public double dRD_Real11062; // 真实气体的相对密度real gas relative density - public double dWobbeIndex; // 真实气体的沃泊指数 + public void setdMu(double dMu) { + this.dMu = dMu; + } + + public double getdNu() { + return dNu; + } + + public void setdNu(double dNu) { + this.dNu = dNu; + } - public double dPc; // 临界压力 - public double dTC; // 临界温度 - public double dBzsx; // 爆炸上限 - public double dBzxx; // 爆炸下限 - public double dTotalC; // 总炭含量 (kg/m3) - public double dC2; // C2组分含量 (kg/m3) - public double dC2j; // C2以上组分含量 (kg/m3) - public double dC3j; // C3以上组分含量 (kg/m3) - public double dC4j; // C4以上组分含量 (kg/m3) - public double dC5j; // C5以上组分含量 (kg/m3) - public double dC6j; // C6以上组分含量 (kg/m3) - public double dC3C4; // C3C4组分含量 (kg/m3) - public String dngComponents; //组分的组合字符串 从前端传过来 diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/DetailService.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/DetailService.java index b549bdc..cae5ebd 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/DetailService.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/DetailService.java @@ -7,7 +7,7 @@ import org.springframework.stereotype.Service; @Service public class DetailService { - private static final double RGASKJ = 8.314510e-3; + public static final double RGASKJ = 8.314510e-3; // 成员变量转换 // 组件数量 diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/GBT11062Service.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/GBT11062Service.java index 9afe7f4..792071a 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/GBT11062Service.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/GBT11062Service.java @@ -10,7 +10,7 @@ public class GBT11062Service { int[] aiCID = new int[21];// component IDs double[] dXi = new double[21];// mole fraction of component i // 初始化 adTableMri 数组 - double[] adTableMri = { 16.0430, 28.0135, 44.0100, 30.0700, 44.0970, 18.0153, 34.0820, 2.0159, 28.0100, 31.9988, 58.1230, 58.1230, 72.1500, 72.1500, 86.1770, 100.2040, 114.2310, 128.2580, 142.2850, 4.0026, 39.9480 }; + static double[] adTableMri = { 16.0430, 28.0135, 44.0100, 30.0700, 44.0970, 18.0153, 34.0820, 2.0159, 28.0100, 31.9988, 58.1230, 58.1230, 72.1500, 72.1500, 86.1770, 100.2040, 114.2310, 128.2580, 142.2850, 4.0026, 39.9480 }; // 初始化 adTablePc 数组 double[] adTablePc = { 4.604, 3.399, 7.382, 4.88, 4.249, 22.118, 9.005, 1.297, 3.499, 5.081, 3.648, 3.797, 3.381, 3.369, 3.012, 2.736, 2.486, 0, 0, 0.2275, 4.876 }; // 初始化 adTableTc 数组 @@ -134,6 +134,8 @@ public class GBT11062Service { gasProps.dC5j = gasProps.dC5j * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062; gasProps.dC6j = gasProps.dC6j * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062; + ISO9300Service.calculateViscosity(gasProps); + } } diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/ISO9300Service.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/ISO9300Service.java new file mode 100644 index 0000000..ecbb091 --- /dev/null +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/service/ISO9300Service.java @@ -0,0 +1,174 @@ +package com.ruoyi.ngCalTools.service; + +import com.ruoyi.ngCalTools.model.GasProps; + +public class ISO9300Service { + + // 基于Chapman-Enskog理论的计算 高精度粘度计算 音速喷嘴ISO9300 + public static double calculateViscosity(GasProps gas) { + double BOLTZMANN = 1.380649e-23; // 玻尔兹曼常数 (J/K) + double Avogadro = 6.02214076e23; // 添加阿伏伽德罗常数 + LJ mixLj = getLJParameters(gas); // Lennard-Jones参数 + // 转换为SI单位 + double sigma = mixLj.sigma ; // Å → m + double epsilon = mixLj.epsilonK * BOLTZMANN; // K → + + // 计算无量纲温度 + double T = gas.getdTf(); + double Tstar = T * BOLTZMANN / epsilon; + + double omega = getOmega(Tstar); + + // 查普曼-恩斯柯格公式 + double M_avg = gas.getdMrx() / 1000; // g/mol → kg/mol + double m = M_avg / Avogadro; + double viscosity = 5.0 / 16.0 * Math.sqrt(Math.PI * m * BOLTZMANN * T) + / (Math.PI * Math.pow(sigma, 2) * omega); + + gas.setdMu(viscosity); + return viscosity; + + } + + + + public static LJ getLJParameters(GasProps gas) { + double sigmaMix = 0; + double epsilonKMix = 0; + int n = gas.adMixture.length; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + + double xixj = gas.adMixture[i] * gas.adMixture[j]; + // Lorentz规则 + double sigmaPair = (LjParameters[i][0] + LjParameters[j][0]) / 2; + sigmaMix += xixj * sigmaPair; + // Berthelot规则 + 极性修正 + double epsilonPair = Math.sqrt(LjParameters[i][1] * LjParameters[j][1]) * polarityFactors[i] * polarityFactors[j]; + epsilonKMix += xixj * epsilonPair; + } + } + + return new LJ(sigmaMix, epsilonKMix); + } + + // 天然气21个组分的LJ参数 + + public static double[][] LjParameters = { + {3.758e-10, 148.6}, // 甲烷 C1 + {3.798e-10, 71.4}, // 氮气 N2 + {3.941e-10, 195.2}, // 二氧化碳 CO2 + {4.443e-10, 215.7}, // 乙烷 C2 + {5.118e-10, 237.1}, // 丙烷 C3 + {2.75e-10, 80.0}, // 水 H2O + {3.623e-10, 301.1}, // 硫化氢 H2S + {2.827e-10, 59.7}, // 氢气 H2 + {3.690e-10, 91.7}, // 一氧化碳 CO + {3.467e-10, 106.7}, // 氧气 O2 + {5.278e-10, 267.0}, // 异丁烷 iC4 + {5.341e-10, 274.7}, // 正丁烷 nC4 + {5.734e-10, 330.1}, // 异戊烷 iC5 + {5.784e-10, 341.1}, // 正戊烷 nC5 + {6.260e-10, 412.3}, // 己烷 C6 + {6.812e-10, 467.3}, // 庚烷 C7(注:此处庚烷参数按趋势估算) + {7.294e-10, 532.1}, // 辛烷 C8(注:此处辛烷参数按趋势估算) + {7.700e-10, 614.2}, // 壬烷 C9(注:此处壬烷参数按趋势估算) + {8.170e-10, 681.5}, // 癸烷 C10(注:此处癸烷参数按趋势估算) + {2.551e-10, 10.22}, // 氦气 He + {3.405e-10, 124.0} // 氩气 Ar + }; + // 极性修正系数(1.0表示非极性) + // 极性修正系数数组(与LjParameters数组顺序严格对应) + private static final double[] polarityFactors = { + // 1. 甲烷 C1 + 1.00, // 非极性分子(对称四面体结构) + + // 2. 氮气 N2 + 1.02, // 微弱四极矩(J. Chem. Phys. 129, 034306) + + // 3. 二氧化碳 CO2 + 1.05, // 四极矩修正(Ind. Eng. Chem. Res. 2019, 58, 5, 1964–1972) + + // 4. 乙烷 C2 + 1.00, // 非极性(对称结构) + + // 5. 丙烷 C3 + 1.00, // 非极性(链状烷烃) + + // 6. 水 H2O + 1.18, // 强极性修正(J. Phys. Chem. B 2005, 109, 15, 7053–7062) + + // 7. 硫化氢 H2S + 1.12, // 中等极性(J. Chem. Eng. Data 2008, 53, 3, 726–729) + + // 8. 氢气 H2 + 1.00, // 非极性(同核双原子) + + // 9. 一氧化碳 CO + 1.03, // 微弱偶极矩(J. Mol. Liq. 2020, 320, 114432) + + // 10. 氧气 O2 + 1.01, // 微弱顺磁性(通常视为非极性) + + // 11. 异丁烷 iC4 + 1.00, // 支链烷烃(非极性) + + // 12. 正丁烷 nC4 + 1.00, // 直链烷烃(非极性) + + // 13. 异戊烷 iC5 + 1.00, // 支链烷烃(非极性) + + // 14. 正戊烷 nC5 + 1.00, // 直链烷烃(非极性) + + // 15. 己烷 C6 + 1.00, // 长链烷烃(非极性) + + // 16. 庚烷 C7 + 1.00, // 长链烷烃(非极性) + + // 17. 辛烷 C8 + 1.00, // 长链烷烃(非极性) + + // 18. 壬烷 C9 + 1.00, // 长链烷烃(非极性) + + // 19. 癸烷 C10 + 1.00, // 长链烷烃(非极性) + + // 20. 氦气 He + 1.00, // 惰性气体(非极性) + + // 21. 氩气 Ar + 1.00 // 惰性气体(非极性) + }; + // 碰撞积分Ω(2,2)* 近似计算(Neufeld多项式) + private static double getOmega(double Tstar) { + if (Tstar < 0.1) { + return 2.0 / (3.0 * Tstar); // 低温量子修正 + } else if (Tstar > 400) { + return 0.92 * Math.log(Tstar) / Tstar; // 高温渐近解 + } else { + double A = 1.16145; + double B = 0.14874; + double C = 0.52487; + double D = 0.77320; + double E = 2.16178; + double F = 2.43787; + return A / Math.pow(Tstar, B) + + C / Math.exp(D * Tstar) + + E / Math.exp(F * Tstar); + } + } + public static class LJ { + public final double sigma; // 碰撞直径 (m) + public final double epsilonK; // ε/k (K) + + public LJ(double sigma, double epsilonK) { + this.sigma = sigma; + this.epsilonK = epsilonK; + } + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUnitConvertController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUnitConvertController.java index 168774c..36e97da 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUnitConvertController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUnitConvertController.java @@ -1,5 +1,7 @@ package com.ruoyi.system.controller; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.List; import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; @@ -37,6 +39,9 @@ public class SysUnitConvertController extends BaseController @Autowired private ISysUnitConvertService sysUnitConvertService; + + + /** * 查询单位转换列表 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/UnitConvert.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/UnitConvert.java index 940d532..2c900fb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/UnitConvert.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/UnitConvert.java @@ -2,6 +2,7 @@ package com.ruoyi.system.controller; import com.ruoyi.system.domain.SysUnitConvert; import com.ruoyi.system.service.ISysUnitConvertService; +import com.ruoyi.system.service.impl.SysUnitConvertServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -11,39 +12,28 @@ import java.math.RoundingMode; @Component public class UnitConvert { - private final ISysUnitConvertService sysUnitConvertService; - @Autowired - public UnitConvert(ISysUnitConvertService sysUnitConvertService) { - this.sysUnitConvertService = sysUnitConvertService; - } + private ISysUnitConvertService sysUnitConvertService; - public double ConvertUniter(String unitType, double oldValue, int oldUnit, int newUnit) { + public double ConvertUniter(String unitType, double oldValue, int oldUnit, int newUnit) { // 查询旧单位信息 if ("temperature".equalsIgnoreCase(unitType)) { return handleTemperatureConversion(BigDecimal.valueOf(oldValue), (long) oldUnit, (long) newUnit).doubleValue(); } else { - SysUnitConvert tempUnit = new SysUnitConvert(); - tempUnit.setUnitType(unitType); - tempUnit.setUnitOrder((long) oldUnit); - SysUnitConvert oldUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(tempUnit); + SysUnitConvert oldUnitInfo =sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(unitType, (long) oldUnit,null); if (oldUnitInfo == null) { throw new IllegalArgumentException("旧单位 '" + oldUnit + "' 不存在或不可用"); } - tempUnit=new SysUnitConvert();; - tempUnit.setUnitType(unitType); - tempUnit.setBaseUnit("Y"); - SysUnitConvert baseUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(tempUnit); + + SysUnitConvert baseUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder (unitType,null,"Y"); if (baseUnitInfo == null) { throw new IllegalArgumentException("基准单位 不存在或不可用"); } - tempUnit=new SysUnitConvert(); - tempUnit.setUnitType(unitType); - tempUnit.setUnitOrder((long) newUnit); + // 查询新单位信息 - SysUnitConvert newUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(tempUnit); + SysUnitConvert newUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(unitType, (long) newUnit,null); if (newUnitInfo == null) { throw new IllegalArgumentException("新单位 '" + newUnit + "' 不存在或不可用"); } @@ -71,7 +61,7 @@ public class UnitConvert { } // 温度转换方法 - public BigDecimal handleTemperatureConversion(BigDecimal oldValue, Long oldUnit, Long newUnit) { + public static BigDecimal handleTemperatureConversion(BigDecimal oldValue, Long oldUnit, Long newUnit) { final BigDecimal THIRTY_TWO = BigDecimal.valueOf(32); final BigDecimal FIVE = BigDecimal.valueOf(5); final BigDecimal NINE = BigDecimal.valueOf(9); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUnitConvertMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUnitConvertMapper.java index 00793ae..98c0894 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUnitConvertMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUnitConvertMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.SysUnitConvert; +import org.apache.ibatis.annotations.Param; /** * 单位转换Mapper接口 @@ -53,10 +54,16 @@ public interface SysUnitConvertMapper /** * 查询单位换算 * - * @param sysUnitConvert 需要删除的数据主键集合 + * @param unitType 单位换算 + * @param unitOrder 单位换算 + * @param baseUnit 单位换算 * @return 结果 */ - public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(SysUnitConvert sysUnitConvert); + public SysUnitConvert selectSysUnitConvertUnitByTypeOrder( + @Param("unitType") String unitType, + @Param("unitOrder") Long unitOrder, // 修正参数类型 + @Param("baseUnit") String baseUnit + ); /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUnitConvertService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUnitConvertService.java index 5a26b9d..0ecabef 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUnitConvertService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUnitConvertService.java @@ -9,11 +9,10 @@ import com.ruoyi.system.domain.SysUnitConvert; * @author ruoyi * @date 2025-03-22 */ -public interface ISysUnitConvertService -{ +public interface ISysUnitConvertService { /** * 查询单位转换 - * + * * @param id 单位转换主键 * @return 单位转换 */ @@ -21,24 +20,26 @@ public interface ISysUnitConvertService /** * 查询单位转换列表 - * + * * @param sysUnitConvert 单位转换 * @return 单位转换集合 */ public List selectSysUnitConvertList(SysUnitConvert sysUnitConvert); + /** * 查询单位 * - * @param sysUnitConvert 单位换算 + * @param unitType 单位换算 + * @param unitOrder 单位换算 + * @param baseUnit 单位换算 * @return 单位换算集合 */ - public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(SysUnitConvert sysUnitConvert); - + public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(String unitType,Long unitOrder, String baseUnit); /** * 新增单位转换 - * + * * @param sysUnitConvert 单位转换 * @return 结果 */ @@ -46,7 +47,7 @@ public interface ISysUnitConvertService /** * 修改单位转换 - * + * * @param sysUnitConvert 单位转换 * @return 结果 */ @@ -54,7 +55,7 @@ public interface ISysUnitConvertService /** * 批量删除单位转换 - * + * * @param ids 需要删除的单位转换主键集合 * @return 结果 */ @@ -62,7 +63,7 @@ public interface ISysUnitConvertService /** * 删除单位转换信息 - * + * * @param id 单位转换主键 * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUnitConvertServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUnitConvertServiceImpl.java index 99bb4bc..565b03a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUnitConvertServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUnitConvertServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.system.service.impl; import java.util.List; + +import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.SysUnitConvertMapper; @@ -16,7 +18,8 @@ import com.ruoyi.system.service.ISysUnitConvertService; @Service public class SysUnitConvertServiceImpl implements ISysUnitConvertService { - @Autowired + + @Autowired // 必须添加自动注入 private SysUnitConvertMapper sysUnitConvertMapper; /** @@ -33,14 +36,16 @@ public class SysUnitConvertServiceImpl implements ISysUnitConvertService /** * 查询单位换算 - * - * @param sysUnitConvert 单位换算 + * @param unitType 单位换算 + * @param unitOrder 单位换算 + * @param baseUnit 单位换算 * @return 单位换算 */ @Override - public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(SysUnitConvert sysUnitConvert) { - return sysUnitConvertMapper.selectSysUnitConvertUnitByTypeOrder(sysUnitConvert); + + public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(String unitType,Long unitOrder, String baseUnit) { + return sysUnitConvertMapper.selectSysUnitConvertUnitByTypeOrder(unitType, unitOrder,baseUnit); } /** diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUnitConvertMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUnitConvertMapper.xml index 2204182..2e3ecc9 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUnitConvertMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUnitConvertMapper.xml @@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where suc.id = #{id} -