This commit is contained in:
2025-10-13 09:50:51 +08:00
parent 2f7b7cf49e
commit 443894fa9b

View File

@@ -380,8 +380,20 @@ namespace CapMachine.Wpf.Services
double GasMassFlowKgPerH, LiquidMassFlowKgPerH;
LiquidMassFlowKgPerH = LiqRefFlowTag.PVModel.EngValue;
GasMassFlowKgPerH= VRVTag.PVModel.EngValue- LiquidMassFlowKgPerH;
LiquidMassFlowKgPerH = LiqRefFlowTag.PVModel.EngValue; // [kg/h]
// VRV 为体积流量 [L/min],需结合管段相态与 T/P 计算密度后换算为质量流量 [kg/h]
double vrvLmin = VRVTag?.PVModel?.EngValue ?? 0.0;
double totalMassKgPerH;
string flowErr;
if (TryConvertVolumetricFlowLMinToMassKgPerH(vrvLmin, plv, tlv, 1, out totalMassKgPerH, out flowErr)) // 1=液相(若 VRV 在液管)
{
GasMassFlowKgPerH = Math.Max(0.0, totalMassKgPerH - LiquidMassFlowKgPerH);
}
else
{
Logger.Warn($"VRV 体积流量→质量流量换算失败:{flowErr}。已将气体质量流量置 0。输入: VRV={vrvLmin:F3} L/min, Pl={plv:F3} BarA, Tl={tlv:F3} ℃");
GasMassFlowKgPerH = 0.0;
}
//LiquidMassFlowKgPerH = 214.3051;
//GasMassFlowKgPerH = 264.7956- 214.3051;
@@ -684,6 +696,44 @@ namespace CapMachine.Wpf.Services
return x;
}
/// <summary>
/// 将体积流量[L/min]换算为质量流量[kg/h]。
/// 计算公式m_dot = V_dot[L/min] × D[mol/L] × wmm[g/mol] × (60/1000) = V_dot × D × wmm × 0.06。
/// 其中 D 由 TPRHO(T,P,kph) 得到kph=1 液相kph=2 气相,请按传感器所在管段指定。
/// 输入压力为 BarA温度为 ℃。
/// </summary>
private bool TryConvertVolumetricFlowLMinToMassKgPerH(double volFlowLMin, double pressureBarA, double temperatureC, long kphPhase,
out double massFlowKgPerH, out string error)
{
massFlowKgPerH = 0.0; error = string.Empty;
if (volFlowLMin <= 0) { massFlowKgPerH = 0.0; return true; }
if (!EnsureRefpropInitialized(out error)) return false;
double[] x = new double[20]; x[0] = 1.0;
double wmm = 0; // g/mol
double tK = temperatureC + 273.15;
double pKPa = pressureBarA * 100.0; // BarA -> kPa
double D = 0; long kguess = 0; long ierr = 0; string herr = new string(' ', 255); long ln = 255;
lock (_refpropLock)
{
IRefProp64.WMOLdll(x, ref wmm);
if (!(wmm > 0)) { error = "WMOL 返回无效摩尔质量"; return false; }
IRefProp64.TPRHOdll(ref tK, ref pKPa, x, ref kphPhase, ref kguess, ref D, ref ierr, ref herr, ref ln);
}
if (ierr != 0 || D <= 0)
{
error = $"TPRHO 失败或密度无效: {herr.Trim()} (ierr={ierr})";
return false;
}
// 体积流量[L/min] -> 质量流量[kg/h]
massFlowKgPerH = volFlowLMin * D * wmm * 0.06;
if (massFlowKgPerH < 0) massFlowKgPerH = 0; // 保护
return true;
}
/// <summary>
/// 风量数据的计算
/// </summary>