ruoyi-api/ruoyi-ngtools/src/main/java/com/ruoyi/ngCalTools/controller/FlowController.java

1158 lines
43 KiB
Java

package com.ruoyi.ngCalTools.controller;
import com.ruoyi.common.core.domain.AjaxResult;
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.system.controller.UnitConvert;
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.*;
@RestController
@RequestMapping("/flowCalcTools")
public class FlowController {
private final UnitConvert unitConvert;
public ThermService thermService;
public DetailService detailService;
public GBT11062Service gbt11062Service;
public GasController gasController;
public FlowController(UnitConvert unitConvert,GasController gasController) {
this.unitConvert = unitConvert;
this.gasController=gasController;
}
@PostMapping("/flowCalc")
public AjaxResult flowCalc(@RequestBody FlowProps flowProps) {
GasProps gasProps = new GasProps();
thermService = new ThermService();
detailService = new DetailService();
gbt11062Service = new GBT11062Service();
//大气压力转换成Pa
double tempPatm = unitConvert.ConvertUniter("pressure", flowProps.getdPatm(), flowProps.getdPatmUnit(), 0);
//压力转换成Pa
double tempPf = unitConvert.ConvertUniter("pressure", flowProps.getdPf(), flowProps.getdPfUnit(), 0);
//压力转换成Pa
double tempDP = unitConvert.ConvertUniter("pressure", flowProps.getdDp(), flowProps.getdDpUnit(), 0);
//温度转换成K
double tempTf = unitConvert.ConvertUniter("temperature", flowProps.getdTf(), flowProps.getdTfUnit(), 2);
if (flowProps.getdPfType() == 0) //0是表压
{
gasProps.dPf = tempPatm + tempPf;
flowProps.setdPf(tempPatm + tempPf);
} else {
gasProps.dPf = tempPf;
flowProps.setdPf(tempPf);
}
gasProps.dTf = tempTf;
flowProps.setdDp(tempDP);
flowProps.setdTf(tempTf);
gasProps.dCbtj = flowProps.getdCbtj();
String[] stringArray = flowProps.getdngComponents().split("_");
double[] doubleArray = new double[stringArray.length]; // 遍历字符串数组,将每个元素转换为 double 类型
for (int i = 0; i < stringArray.length; i++) {
try {
doubleArray[i] = Double.parseDouble(stringArray[i]) / 100;
} catch (NumberFormatException e) {
// 处理转换异常
System.err.println("无法将字符串 " + stringArray[i] + " 转换为 double 类型: " + e.getMessage());
}
}
gasProps.adMixture = doubleArray;
gasController.ngCalcVoid(flowProps, gasProps); //计算临界流函数所有参数都计算了
//计算流量
switch (flowProps.getdMeterType()) {
case 0: //差压式流量计
OFlowCal(gasProps, flowProps);
break;
case 1:// 速度式流量计
SdFlowCal(gasProps, flowProps);
break;
case 2: //容积式流量计
SdFlowCal(gasProps, flowProps);
break;
case 3:// 临界流函数流量计
NozellFLowCal(gasProps, flowProps);
break;
}
Object[] resultArray = {flowProps, gasProps};
return AjaxResult.success(resultArray);
}
/**
速度式流量计算
*/
public final void SdFlowCal(GasProps gasProps,FlowProps flowProps)
{
//工况体积流量 m³、s
flowProps.setdVFlowf(flowProps.getdPulseNum() / flowProps.getdMeterFactor());
//标况体积流量 m³、s
flowProps.setdVFlowb(FlowConvert_WorkToBase(flowProps, gasProps));
//标况质量流量
flowProps.setdMFlowb(flowProps.getdVFlowb() * gasProps.dRhob);
//标况能量流量
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);
//求渐近速度系数 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(), flowProps.getdTf(), 2, 1));
// 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;
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 = 0;
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()));
}
/**
天然气音速喷嘴流量计算
*/
public final void NozellFLowCal( GasProps gasProps,FlowProps flowProps)
{
double dAnt; // 喷嘴喉部面积
//double dCR;//临界流系数
double dP1Z; //滞止压力
double dT1Z; //滞止温度
//double dPbeta;//上下游压力比
double dDcorrect; // 考虑膨胀系数后的管道直径
double ddcorrect; // 考虑膨胀系数后的喉部直径
double dBeta; //直径比
double dQm;
try
{
ddcorrect = flowProps.getdOrificeD() * (1 + 0.000001 * (flowProps.getdOrificeMaterial()) * (flowProps.getdTf() - 293.15));
dDcorrect = flowProps.getdPipeD() * (1 + 0.000001 * (flowProps.getdOrificeMaterial()) * (flowProps.getdTf() - 293.15));
dBeta = ddcorrect / dDcorrect;
dAnt = 3.1415926 * (ddcorrect / 2) * (ddcorrect / 2);
//ptNGcal.SOS(ref gasProps);
//dCR = gasProps.dCstar * Math.Sqrt(gasProps.dZf);
dP1Z = flowProps.getdPf() * (1 + gasProps.dKappa / 2 * Math.pow((2 / (gasProps.dKappa + 1)), ((gasProps.dKappa + 1) / (gasProps.dKappa - 1))) * Math.pow(dBeta, 4));
dT1Z = flowProps.getdTf() * (1 + (gasProps.dKappa - 1) / 2 * (2 / Math.pow((gasProps.dKappa + 1), ((gasProps.dKappa + 1) / (gasProps.dKappa - 1)))) * Math.pow(dBeta, 4));
// dQm = dAnt * flowProps.dCd * gasProps.dCstar * dP1Z / Math.Sqrt(8314.51 * dT1Z / gasProps.dMrx);
dQm = dAnt * flowProps.getdCd() * gasProps.dCstar * Math.sqrt(gasProps.dZf * dP1Z * gasProps.dRhof);
if (dBeta > 0.25)
{
dQm = dQm * BetaG25(dP1Z, dT1Z, dBeta, gasProps);
}
flowProps.setdMFlowb(dQm);
flowProps.setdVFlowb(flowProps.getdMFlowb() / gasProps.dRhob);
//标况能量流量
flowProps.setdEFlowb(flowProps.getdVFlowb() * gasProps.dHhvm);
flowProps.setdVFlowf(FlowConvert_BaseToWork(flowProps, gasProps));
}
catch (RuntimeException ex)
{
}
}
private double BetaG25(double P0, double T0, double BetaB, GasProps gasProps)
{
double[] nik0 = new double[9];
double[] Sik0 = new double[9];
double[] Tik0 = new double[9];
double[] nik1 = new double[9];
double[] Sik1 = new double[9];
double[] Tik1 = new double[9];
double C0 = 0;
double C1 = 0;
double Pai = 0;
double Tuo = 0;
double b = 0;
double F0 = 0;
double F1 = 0;
double Rf = 0.65;
// 直径比大于0.25的修正因子
nik0[0] = 1.068826e-3;
nik0[1] = 1.199593e-2;
nik0[2] = -1.48292e-3;
nik0[3] = 2.764799e-4;
nik0[4] = 7.920711e-5;
nik0[5] = 1.11278e-3;
nik0[6] = -6.815626e-5;
nik0[7] = 3.86249e-8;
nik1[0] = -3.46148e-3;
nik1[1] = 5.28029e-3;
nik1[2] = 1.195016e-2;
nik1[3] = 1.664232e-3;
nik1[4] = 1.159371e-3;
nik1[5] = 7.260461e-3;
nik1[6] = -7.541933e-4;
nik1[7] = 2.613967e-7;
Sik0[0] = 0;
Sik0[1] = 0;
Sik0[2] = 0.5;
Sik0[3] = 1;
Sik0[4] = 2;
Sik0[5] = 3;
Sik0[6] = 5;
Sik0[7] = 10;
Sik1[0] = 0;
Sik1[1] = 0;
Sik1[2] = 0;
Sik1[3] = 1;
Sik1[4] = 1.5;
Sik1[5] = 3;
Sik1[6] = 5;
Sik1[7] = 10;
Tik0[0] = -1;
Tik0[1] = 0;
Tik0[2] = -6;
Tik0[3] = -1;
Tik0[4] = -2;
Tik0[5] = -8;
Tik0[6] = -10;
Tik0[7] = -18;
Tik1[0] = -3;
Tik1[1] = -1;
Tik1[2] = 0;
Tik1[3] = -2;
Tik1[4] = -4;
Tik1[5] = -10;
Tik1[6] = -12;
Tik1[7] = -15;
Pai = P0 / (gasProps.dPc * 1000000);
Tuo = T0 / gasProps.dTC;
for (int i = 0; i <= 7; i += 1)
{
C0 = C0 + nik0[i] * Math.pow(Pai, Sik0[i]) * Math.pow(Tuo, Tik0[i]);
C1 = C1 + nik1[i] * Math.pow(Pai, Sik1[i]) * Math.pow(Tuo, Tik1[i]);
}
b = 25.879 * Math.pow(BetaB, 6) - 32.693 * Math.pow(BetaB, 5) + 34.276 * Math.pow(BetaB, 4) - 6.0199 * Math.pow(BetaB, 3) - 1.1156 * Math.pow(BetaB, 2) - 0.1122 * BetaB + 0.0047;
F0 = 1 + b * C0;
F1 = 1 + b * C1;
return (1 - Rf) * F0 + Rf * F1;
}
//压力损失计算
public final double YaLiSunShi(double tempLiuChuXiShu, double tempZjb, double tempDp, int JieLiuZhuangZhi)
{
double ylss = 0;
switch (JieLiuZhuangZhi)
{
case 0:
ylss = (tempDp * (Math.sqrt(1 - tempZjb) - tempLiuChuXiShu * Math.pow(tempZjb, 2)) / (Math.sqrt(1 - tempZjb) + tempLiuChuXiShu * Math.pow(tempZjb, 2)));
break;
case 1:
ylss = (tempDp * (Math.sqrt(1 - tempZjb) - tempLiuChuXiShu * Math.pow(tempZjb, 2)) / (Math.sqrt(1 - tempZjb) + tempLiuChuXiShu * Math.pow(tempZjb, 2)));
break;
case 2:
ylss = (tempDp * (Math.sqrt(1 - tempZjb) - tempLiuChuXiShu * Math.pow(tempZjb, 2)) / (Math.sqrt(1 - tempZjb) + tempLiuChuXiShu * Math.pow(tempZjb, 2)));
break;
}
return ylss;
}
//查表计算粘度μ
// VBConversions Note: Former VB static variables moved to class level because they aren't supported in C#.
private final double[][] Dlndjs_Dlnd_Data = new double[8][11];
private final double[] Dlndjs_Dlnd_T = new double[8];
private final double[] Dlndjs_Dlnd_P = new double[11];
public final double Dlndjs(double tempP_jy, double tempT, int PU, int TU)
{
double s1 = 0;
double s2 = 0;
double ky = 0;
double kx = 0;
int i = 0;
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 = 0;
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 = 0;
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 = 0;
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 = 0;
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 = 0;
//粗糙度系数计算
double Jdccd = 0; //绝对粗糙度
double Xdccd = 0; //相对粗糙度
//Dim CcdXs As single
double s1 = 0;
double s2 = 0;
double ky = 0;
double kx = 0;
int i = 0;
int m = 0;
int n = 0;
if (tempPipeType == 0)
{
Jdccd = 0.029F;
Jdccd = 0.075F;
}
else if (tempPipeType == 2)
{
Jdccd = 0.075F;
Jdccd = 0.075F;
}
else if (tempPipeType == 4)
{
Jdccd = 0.1F;
Jdccd = 0.15F;
}
else if (tempPipeType == 6)
{
Jdccd = 1;
Jdccd = 2.1F;
}
else if (tempPipeType == 8)
{
Jdccd = 0.04F;
Jdccd = 0.15F;
}
else if (tempPipeType == 10)
{
Jdccd = 0.13F;
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[8][0] = 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[8][0] = 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[8][0] = 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[8][0] = 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[8][0] = 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;
CcdXsb[8][0] = 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;
}
// #########################################################################
// ######################'流量转换 标况转工况##############################
// ########################################################################
public static double FlowConvert_BaseToWork(FlowProps flowProps, GasProps gasProps)
{
double tempPn = 0;
double tempTn = 0;
try
{
if (gasProps.dZf == 0 || gasProps.dZb == 0)
{
return 0.0;
}
switch (gasProps.dCbtj)
{
case 2:
tempPn = 101325;
tempTn = 273.15;
break;
case 1:
tempPn = 101325;
tempTn = 288.15;
break;
case 0:
tempPn = 101325;
tempTn = 293.15;
break;
case 3:
tempPn = 10155981;
tempTn = 288.7055555;
break;
}
flowProps.setdVFlowf(flowProps.getdVFlowb() * (tempPn * flowProps.getdTf() * gasProps.dZf) / (flowProps.getdPf() * tempTn * gasProps.dZb));
return flowProps.getdVFlowf();
// WARNING: ErrDo: is not supported
}
catch (RuntimeException exc)
{
return 0.0;
}
}
// #########################################################################
// ######################流量转换工况转标况##############################
// ########################################################################
public static double FlowConvert_WorkToBase(FlowProps flowProps, GasProps gasProps)
{
double tempPn = 0;
double tempTn = 0;
// WARNING: On Error GOTO ErrDo is not supported
try
{
switch (gasProps.dCbtj)
{
case 2:
tempPn = 101325;
tempTn = 273.15;
break;
case 1:
tempPn = 101325;
tempTn = 288.15;
break;
case 0:
tempPn = 101325;
tempTn = 293.15;
break;
case 3:
tempPn = 0.10155981;
tempTn = 288.7055555;
break;
}
flowProps.setdVFlowb(flowProps.getdVFlowf() * (flowProps.getdPf() * tempTn * gasProps.dZb) / (tempPn * flowProps.getdTf() * gasProps.dZf));
return flowProps.getdVFlowb();
// WARNING: ErrDo: is not supported
}
catch (RuntimeException exc)
{
return 0.0;
}
}
}