物性更改2
一些已知的更改
This commit is contained in:
@@ -85,9 +85,9 @@ namespace CapMachine.Wpf.Services
|
||||
/// <summary>
|
||||
/// 初始化过热度 / 过冷度计算类。
|
||||
/// </summary>
|
||||
public PPCSuperheatSubcoolCalculator()
|
||||
public PPCSuperheatSubcoolCalculator(object refpropLock)
|
||||
{
|
||||
_support = new LocalCalculationSupport();
|
||||
_support = new LocalCalculationSupport(refpropLock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -149,6 +149,12 @@ namespace CapMachine.Wpf.Services
|
||||
superheatK = double.NaN;
|
||||
error = string.Empty;
|
||||
|
||||
if (double.IsNaN(suctionPressureBarA) || double.IsInfinity(suctionPressureBarA) || suctionPressureBarA <= 0)
|
||||
{
|
||||
error = "吸气压力无效";
|
||||
return false;
|
||||
}
|
||||
|
||||
// REFPROP 相关函数调用前先做幂等初始化。
|
||||
if (!_support.EnsureRefpropInitialized(out var initErr))
|
||||
{
|
||||
@@ -159,6 +165,12 @@ namespace CapMachine.Wpf.Services
|
||||
// 现有物性 helper 约定输入压力为 MPa,因此这里把 BarA 转成 MPa。
|
||||
double pressureMPa = suctionPressureBarA * 0.1;
|
||||
|
||||
if (pressureMPa <= 0)
|
||||
{
|
||||
error = "吸气压力无效";
|
||||
return false;
|
||||
}
|
||||
|
||||
// 按压力求饱和温度。
|
||||
// 本计算只关心 Tsat,因此 Dl/Dv 结果不使用,用 out _ 丢弃。
|
||||
if (!_support.TrySATP_SaturationByP_MPa(pressureMPa, out var tSatK, out _, out _, out var satErr))
|
||||
@@ -178,6 +190,12 @@ namespace CapMachine.Wpf.Services
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Math.Abs(superheatK) > 100.0)
|
||||
{
|
||||
error = $"过热度结果超范围: {superheatK}";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -200,6 +218,12 @@ namespace CapMachine.Wpf.Services
|
||||
subcoolK = double.NaN;
|
||||
error = string.Empty;
|
||||
|
||||
if (double.IsNaN(liquidPressureBarA) || double.IsInfinity(liquidPressureBarA) || liquidPressureBarA <= 0)
|
||||
{
|
||||
error = "液路压力无效";
|
||||
return false;
|
||||
}
|
||||
|
||||
// REFPROP 相关函数调用前先做幂等初始化。
|
||||
if (!_support.EnsureRefpropInitialized(out var initErr))
|
||||
{
|
||||
@@ -210,6 +234,12 @@ namespace CapMachine.Wpf.Services
|
||||
// 现有 SATP helper 约定压力单位为 MPa,因此先由 BarA 转成 MPa。
|
||||
double pressureMPa = liquidPressureBarA * 0.1;
|
||||
|
||||
if (pressureMPa <= 0)
|
||||
{
|
||||
error = "液路压力无效";
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询该液路压力下的饱和温度 Tsat。
|
||||
if (!_support.TrySATP_SaturationByP_MPa(pressureMPa, out var tSatK, out _, out _, out var satErr))
|
||||
{
|
||||
@@ -227,6 +257,12 @@ namespace CapMachine.Wpf.Services
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Math.Abs(subcoolK) > 100.0)
|
||||
{
|
||||
error = $"过冷度结果超范围: {subcoolK}";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -239,9 +275,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;
|
||||
|
||||
Reference in New Issue
Block a user