公式更改版本2603141639

This commit is contained in:
2026-03-14 16:39:49 +08:00
parent add9904134
commit 64fdda325b
3 changed files with 82 additions and 19 deletions

View File

@@ -104,6 +104,34 @@ namespace CapMachine.Wpf.PPCalculation
); );
/***************************************************************************************
* General Flash subroutine taking a pressure and entropy.
* 用于在给定 P、s摩尔熵下求解状态点等熵压缩出口 h2s 等)。
**************************************************************************************/
[DllImport(@".\PPCalculation\REFPROP\REFPRP64.DLL", CharSet = CharSet.Ansi)]
public static extern void PSFLSHdll
(
ref double p, // (INPUT) pressure [kPa]
ref double s, // (INPUT) entropy [J/mol-K]
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] double[] z, // (INPUT) overall (bulk) composition [array of mol frac]
ref double t, // (OUTPUT) temperature [K]
ref double d, // (OUTPUT) overall (bulk) molar density [mol/L]
ref double Dl, // (OUTPUT) molar density of liquid phase [mol/L]
ref double Dv, // (OUTPUT) molar density of the vapor phase [mol/L]
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] double[] xliq, // (OUTPUT) composition of liquid phase [array of mol frac]
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] double[] xvap, // (OUTPUT) composition of vapor phase [array of mol frac]
ref double q, // (OUTPUT) vapor quality on a MOLAR basis
ref double ee, // (OUTPUT) internal energy [J/mol]
ref double h, // (OUTPUT) enthalpy [J/mol]
ref double Cv, // (OUTPUT) Cv [J/mol-K]
ref double Cp, // (OUTPUT) Cp [J/mol-K]
ref double w, // (OUTPUT) speed of sound [m/s]
ref long ierr, // (OUTPUT) error flag
[MarshalAs(UnmanagedType.VBByRefStr)] ref string herr, // (OUTPUT) error string
ref long ln // (INPUT) length of herr
);
/**************************************************************************************** /****************************************************************************************
* Open a mixture file (e.g., R410A.mix) and read constituents and mole fractions * Open a mixture file (e.g., R410A.mix) and read constituents and mole fractions
@@ -254,6 +282,23 @@ namespace CapMachine.Wpf.PPCalculation
ref long herrLen ref long herrLen
); );
/********************************************************************************
* Solve for density given T and P using the most robust iterative routine.
* This mirrors the LabVIEW TPRHO DLL call path to obtain phase-specific density.
********************************************************************************/
[DllImport(@".\PPCalculation\REFPROP\REFPRP64.DLL", CharSet = CharSet.Ansi)]
public static extern void TPRHOdll
(
ref double t, // (INPUT) temperature [K]
ref double p, // (INPUT) pressure [kPa]
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] double[] x, // (INPUT) composition [array of mol frac]
ref long kph, // (INPUT) phase flag: 1=liquid, 2=vapor
ref long kguess, // (INPUT) initial guess: 0=let routine choose
ref double D, // (OUTPUT) molar density [mol/L]
ref long ierr, // (OUTPUT) error flag: 0=success
[MarshalAs(UnmanagedType.VBByRefStr)] ref string herr, // (OUTPUT) error string
ref long herrLen
);
/*************************************************** /***************************************************

View File

@@ -196,6 +196,18 @@ namespace CapMachine.Wpf.Services
TagManger.AddTag(new Tag<short>("通讯PTC膜温", "通讯PTC膜温[℃]", "ComPTCFlmTemp", "程序", "VW14128", 100, 0, 1, "℃", new ShortTagValue(), false) { DecimalPoint = 0 }); TagManger.AddTag(new Tag<short>("通讯PTC膜温", "通讯PTC膜温[℃]", "ComPTCFlmTemp", "程序", "VW14128", 100, 0, 1, "℃", new ShortTagValue(), false) { DecimalPoint = 0 });
TagManger.AddTag(new Tag<short>("通讯PTC模块温度", "通讯PTC模块温度[℃]", "ComPTCMdTemp", "程序", "VW14130", 100, 0, 1, "℃", new ShortTagValue(), false) { DecimalPoint = 0 }); TagManger.AddTag(new Tag<short>("通讯PTC模块温度", "通讯PTC模块温度[℃]", "ComPTCMdTemp", "程序", "VW14130", 100, 0, 1, "℃", new ShortTagValue(), false) { DecimalPoint = 0 });
TagManger.AddTag(new Tag<short>("过热度", "过热度[K]", "Superheat", "程序", "VW14132", 100, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag<short>("过冷度", "过冷度[K]", "Subcooling", "程序", "VW14134", 100, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag<short>("制热量Qh", "制热量Qh[KW]", "HeatingCapacity", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag<short>("压缩机性能系数(制热)", "压缩机性能系数(制热)[K]", "COPHeat", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag<short>("等熵效率ns", "等熵效率ns[%]", "IsentrpEff", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag<short>("制冷量Qc", "制冷量Qc[KW]", "CoolCapacity", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag<short>("压缩机性能系数(制冷)", "压缩机性能系数(制冷)[K]", "COPCool", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag<short>("容积效率nv", "容积效率nv[%]", "VoltricEff", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
#endregion #endregion

View File

@@ -82,15 +82,15 @@ namespace CapMachine.Wpf.Services
TxvFrPressTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前压力[BarA]"); TxvFrPressTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前压力[BarA]");
LiqRefFlowTag = TagManager.DicTags.GetValueOrDefault("液冷媒流量[kg/h]"); //LiqRefFlowTag = TagManager.DicTags.GetValueOrDefault("液冷媒流量[kg/h]");
//kg/h //kg/h
VRVTag = TagManager.DicTags.GetValueOrDefault("冷媒流量[kg/h]"); VRVTag = TagManager.DicTags.GetValueOrDefault("冷媒流量[L/min]");
//润滑油流量 //润滑油流量
LubeFlowTag = TagManager.DicTags.GetValueOrDefault("润滑油流量[kg/h]"); LubeFlowTag = TagManager.DicTags.GetValueOrDefault("润滑油流量[L/min]");
//Cond1TempTag = TagManager.DicTags.GetValueOrDefault("冷凝器出口水温[℃]"); //Cond1TempTag = TagManager.DicTags.GetValueOrDefault("冷凝器出口水温[℃]");
@@ -306,9 +306,13 @@ namespace CapMachine.Wpf.Services
} }
if (iErr == 0) if (iErr == 0)
Superheat.EngPvValue = InhTempTag.EngPvValue - (te - 273.15); {
else double superheatValue = InhTempTag.EngPvValue - (te - 273.15);
Superheat.EngPvValue = 0; if (!double.IsNaN(superheatValue) && !double.IsInfinity(superheatValue))
{
Superheat.EngPvValue = superheatValue;
}
}
herr = new string(' ', 255); herrLen = 255; iErr = 0; herr = new string(' ', 255); herrLen = 255; iErr = 0;
lock (_refpropLock) lock (_refpropLock)
@@ -316,9 +320,13 @@ namespace CapMachine.Wpf.Services
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen); IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
} }
if (iErr == 0) if (iErr == 0)
Subcool.EngPvValue = TxvFrTempTag.EngPvValue - (te1 - 273.15); {
else double subcoolValue = TxvFrTempTag.EngPvValue - (te1 - 273.15);
Subcool.EngPvValue = 0; if (!double.IsNaN(subcoolValue) && !double.IsInfinity(subcoolValue))
{
Subcool.EngPvValue = subcoolValue;
}
}
if (TryUpdateThermodynamicSixResults(out var thermoErr)) if (TryUpdateThermodynamicSixResults(out var thermoErr))
@@ -1090,21 +1098,19 @@ namespace CapMachine.Wpf.Services
COPCooling = copC; COPCooling = copC;
IsentropicEfficiencyPct = etaS_pct; IsentropicEfficiencyPct = etaS_pct;
if (!TryComputeVolumetricEfficiencyPct(mRef_kg_s, v1_m3kg, out var etaV_pct, out var etaVErr))
{
VolumetricEfficiencyPct = double.NaN;
error = etaVErr;
return true;
}
VolumetricEfficiencyPct = etaV_pct;
//赋值
HeatingCapacity.EngPvValue = HeatingCapacityQh_kW; HeatingCapacity.EngPvValue = HeatingCapacityQh_kW;
COPHeat.EngPvValue = COPHeating; COPHeat.EngPvValue = COPHeating;
IsentrpEff.EngPvValue = IsentropicEfficiencyPct; IsentrpEff.EngPvValue = IsentropicEfficiencyPct;
CoolCapacity.EngPvValue = CoolingCapacityQc_kW; CoolCapacity.EngPvValue = CoolingCapacityQc_kW;
COPCool.EngPvValue = COPCooling; COPCool.EngPvValue = COPCooling;
if (!TryComputeVolumetricEfficiencyPct(mRef_kg_s, v1_m3kg, out var etaV_pct, out var etaVErr))
{
error = etaVErr;
return true;
}
VolumetricEfficiencyPct = etaV_pct;
VoltricEff.EngPvValue = VolumetricEfficiencyPct; VoltricEff.EngPvValue = VolumetricEfficiencyPct;
return true; return true;