6个物性参数和干度的公式的更改
This commit is contained in:
@@ -151,12 +151,19 @@ namespace CapMachine.Wpf.Services
|
||||
/// </summary>
|
||||
private readonly LocalCalculationSupport _support;
|
||||
|
||||
private double _h3TempOffset_C = -10.0;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化六个热力结果值计算类。
|
||||
/// </summary>
|
||||
public PPCThermodynamicSixResultsCalculator()
|
||||
public PPCThermodynamicSixResultsCalculator(object refpropLock)
|
||||
{
|
||||
_support = new LocalCalculationSupport();
|
||||
_support = new LocalCalculationSupport(refpropLock);
|
||||
}
|
||||
|
||||
public void SetH3TempOffset_C(double offsetC)
|
||||
{
|
||||
_h3TempOffset_C = offsetC;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -219,7 +226,18 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
|
||||
// 第 5 步:由液路压力/温度求液路比焓 h3。
|
||||
if (!TryGetLiquidPointEnthalpy_ByTP_BarA_C(input.LiquidPressureBarA, input.LiquidTemperatureC, out var h3_kJkg, out var p3Err))
|
||||
double liquidTempForH3_C = input.LiquidTemperatureC;
|
||||
if (_support.TrySATP_SaturationByP_MPa(input.DischargePressureBarA * 0.1, out var tSatK, out _, out _, out var satErr))
|
||||
{
|
||||
liquidTempForH3_C = (tSatK - 273.15) + _h3TempOffset_C;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(satErr))
|
||||
{
|
||||
error = string.IsNullOrWhiteSpace(error)
|
||||
? $"h3温度改用SATP(排气压力)计算Tsat失败,已回退使用LiquidTemperatureC。原因: {satErr}"
|
||||
: $"{error}; h3温度改用SATP(排气压力)计算Tsat失败,已回退使用LiquidTemperatureC。原因: {satErr}";
|
||||
}
|
||||
if (!TryGetLiquidPointEnthalpy_ByTP_BarA_C(input.LiquidPressureBarA, liquidTempForH3_C, out var h3_kJkg, out var p3Err))
|
||||
{
|
||||
error = $"h3 计算失败: {p3Err}";
|
||||
return false;
|
||||
@@ -240,7 +258,7 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
|
||||
// 第 8 步:计算等熵效率。
|
||||
if (!TryComputeIsentropicEfficiencyPct(h1_kJkg, h2_kJkg, h2s_kJkg, out var etaS_pct, out var etaSErr))
|
||||
if (!TryComputeIsentropicEfficiencyPct(mRef_kg_s, h1_kJkg, h2s_kJkg, w_kW, out var etaS_pct, out var etaSErr))
|
||||
{
|
||||
error = etaSErr;
|
||||
return false;
|
||||
@@ -259,7 +277,7 @@ namespace CapMachine.Wpf.Services
|
||||
// 同时把失败原因放到 error 中,供调用方决定是否记录为警告。
|
||||
if (!TryComputeVolumetricEfficiencyPct(mRef_kg_s, v1_m3kg, input.CompressorSpeedRpm, input.CompressorDisplacementCc, out var etaV_pct, out var etaVErr))
|
||||
{
|
||||
error = etaVErr;
|
||||
error = string.IsNullOrWhiteSpace(error) ? etaVErr : $"{error}; {etaVErr}";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -303,9 +321,8 @@ namespace CapMachine.Wpf.Services
|
||||
/// <remarks>
|
||||
/// 当前流程保持与图片/旧代码一致:
|
||||
/// 1. 读取总流量 kg/h
|
||||
/// 2. 读取油流量 kg/h
|
||||
/// 3. 冷媒流量 = 总流量 - 油流量
|
||||
/// 4. 再由 kg/h 换算为 kg/s
|
||||
/// 2. 冷媒流量 = 总流量
|
||||
/// 3. 再由 kg/h 换算为 kg/s
|
||||
/// </remarks>
|
||||
private bool TryGetRefrigerantMassFlow_kg_s(double totalMassFlowKgPerHour, double oilMassFlowKgPerHour, out double mRef_kg_s, out string error)
|
||||
{
|
||||
@@ -319,17 +336,10 @@ namespace CapMachine.Wpf.Services
|
||||
return false;
|
||||
}
|
||||
|
||||
// 再读取油流量。
|
||||
if (!TryGetOilMassFlow_kg_h(oilMassFlowKgPerHour, out var mOil_kg_h, out var oilErr))
|
||||
double mRef_kg_h = mTotal_kg_h;
|
||||
if (mRef_kg_h <= 0)
|
||||
{
|
||||
error = oilErr;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 计算真正参与循环的冷媒质量流量:mRef = mTotal - mOil。
|
||||
if (!TryComputeRefrigerantMassFlow_kg_h(mTotal_kg_h, mOil_kg_h, out var mRef_kg_h, out var refErr))
|
||||
{
|
||||
error = refErr;
|
||||
error = $"冷媒质量流量<=0,总流量={mTotal_kg_h}kg/h";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -814,33 +824,45 @@ namespace CapMachine.Wpf.Services
|
||||
/// <summary>
|
||||
/// 计算等熵效率,单位 %。
|
||||
/// </summary>
|
||||
/// <param name="mRef_kg_s">冷媒质量流量,单位 kg/s。</param>
|
||||
/// <param name="h1_kJkg">吸气比焓 h1,单位 kJ/kg。</param>
|
||||
/// <param name="h2_kJkg">实际排气比焓 h2,单位 kJ/kg。</param>
|
||||
/// <param name="h2s_kJkg">等熵出口比焓 h2s,单位 kJ/kg。</param>
|
||||
/// <param name="w_kW">压缩机功率,单位 kW。</param>
|
||||
/// <param name="etaS_pct">等熵效率输出,单位 %。</param>
|
||||
/// <param name="error">失败原因。</param>
|
||||
/// <returns>是否计算成功。</returns>
|
||||
private bool TryComputeIsentropicEfficiencyPct(double h1_kJkg, double h2_kJkg, double h2s_kJkg, out double etaS_pct, out string error)
|
||||
private bool TryComputeIsentropicEfficiencyPct(double mRef_kg_s, double h1_kJkg, double h2s_kJkg, double w_kW, out double etaS_pct, out string error)
|
||||
{
|
||||
etaS_pct = double.NaN;
|
||||
error = string.Empty;
|
||||
|
||||
// 实际压缩焓升:(h2 - h1)。
|
||||
if (!TryComputeEnthalpyDifference_kJkg(h2_kJkg, h1_kJkg, "实际压缩焓升(h2-h1)", out var actualRise_kJkg, out var actualErr))
|
||||
if (double.IsNaN(mRef_kg_s) || double.IsInfinity(mRef_kg_s) || mRef_kg_s <= 0)
|
||||
{
|
||||
error = actualErr;
|
||||
error = "无效冷媒质量流量";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (double.IsNaN(w_kW) || double.IsInfinity(w_kW) || w_kW <= 0)
|
||||
{
|
||||
error = "无效压缩机功率";
|
||||
return false;
|
||||
}
|
||||
|
||||
// 等熵压缩焓升:(h2s - h1)。
|
||||
if (!TryComputeEnthalpyDifference_kJkg(h2s_kJkg, h1_kJkg, "等熵压缩焓升(h2s-h1)", out var isentropicRise_kJkg, out var isoErr))
|
||||
{
|
||||
error = isoErr;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 等熵效率 = 等熵焓升 / 实际焓升 * 100%。
|
||||
return TryComputeEfficiencyPct(isentropicRise_kJkg, actualRise_kJkg, "等熵效率", out etaS_pct, out error);
|
||||
double eta = (mRef_kg_s * isentropicRise_kJkg) / w_kW;
|
||||
if (double.IsNaN(eta) || double.IsInfinity(eta))
|
||||
{
|
||||
error = "等熵效率结果异常";
|
||||
return false;
|
||||
}
|
||||
|
||||
etaS_pct = eta * 100.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1055,6 +1077,7 @@ namespace CapMachine.Wpf.Services
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 六个热力结果计算类私有的底层物性支持实现。
|
||||
/// </summary>
|
||||
@@ -1064,9 +1087,14 @@ namespace CapMachine.Wpf.Services
|
||||
/// </remarks>
|
||||
private sealed class LocalCalculationSupport : IPPCCalculationSupport
|
||||
{
|
||||
private static readonly object _refpropLock = new object();
|
||||
private readonly object _refpropLock;
|
||||
private static volatile bool _rpInitialized;
|
||||
|
||||
public LocalCalculationSupport(object refpropLock)
|
||||
{
|
||||
_refpropLock = refpropLock ?? throw new ArgumentNullException(nameof(refpropLock));
|
||||
}
|
||||
|
||||
public bool EnsureRefpropInitialized(out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
@@ -1139,7 +1167,47 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
}
|
||||
|
||||
public bool TrySATP_SaturationByP_MPa(double pressureMPa, out double tSatK, out double Dl_molL, out double Dv_molL, out string error) => throw new NotSupportedException();
|
||||
public bool TrySATP_SaturationByP_MPa(double pressureMPa, out double tSatK, out double Dl_molL, out double Dv_molL, out string error)
|
||||
{
|
||||
tSatK = double.NaN;
|
||||
Dl_molL = double.NaN;
|
||||
Dv_molL = double.NaN;
|
||||
error = string.Empty;
|
||||
|
||||
if (!EnsureRefpropInitialized(out var initErr))
|
||||
{
|
||||
error = initErr;
|
||||
return false;
|
||||
}
|
||||
|
||||
double pKPa = pressureMPa * 1000.0;
|
||||
double[] x = new double[20];
|
||||
x[0] = 1.0;
|
||||
|
||||
long kph = 1;
|
||||
double Dl = 0.0;
|
||||
double Dv = 0.0;
|
||||
double[] xliq = new double[20];
|
||||
double[] xvap = new double[20];
|
||||
long ierr = 0;
|
||||
long herrLen = 255;
|
||||
string herr = new string(' ', 255);
|
||||
|
||||
lock (_refpropLock)
|
||||
{
|
||||
IRefProp64.SATPdll(ref pKPa, x, ref kph, ref tSatK, ref Dl, ref Dv, xliq, xvap, ref ierr, ref herr, ref herrLen);
|
||||
}
|
||||
|
||||
if (ierr != 0)
|
||||
{
|
||||
error = $"SATP 错误: {herr.Trim()} (ierr={ierr})";
|
||||
return false;
|
||||
}
|
||||
|
||||
Dl_molL = Dl;
|
||||
Dv_molL = Dv;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryTPRHO_VaporDensity_ByTP_MPa_C(double pressureMPa, double temperatureC, out double densityMolPerL, out string error)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user