diff --git a/CapMachine.Wpf/PPCalculation/IRefProp64.cs b/CapMachine.Wpf/PPCalculation/IRefProp64.cs index 495e2b3..8830bd3 100644 --- a/CapMachine.Wpf/PPCalculation/IRefProp64.cs +++ b/CapMachine.Wpf/PPCalculation/IRefProp64.cs @@ -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 @@ -254,6 +282,23 @@ namespace CapMachine.Wpf.PPCalculation 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 + ); /*************************************************** diff --git a/CapMachine.Wpf/Services/MachineRtDataService.cs b/CapMachine.Wpf/Services/MachineRtDataService.cs index b42c97b..a39a9a0 100644 --- a/CapMachine.Wpf/Services/MachineRtDataService.cs +++ b/CapMachine.Wpf/Services/MachineRtDataService.cs @@ -196,6 +196,18 @@ namespace CapMachine.Wpf.Services TagManger.AddTag(new Tag("通讯PTC膜温", "通讯PTC膜温[℃]", "ComPTCFlmTemp", "程序", "VW14128", 100, 0, 1, "℃", new ShortTagValue(), false) { DecimalPoint = 0 }); TagManger.AddTag(new Tag("通讯PTC模块温度", "通讯PTC模块温度[℃]", "ComPTCMdTemp", "程序", "VW14130", 100, 0, 1, "℃", new ShortTagValue(), false) { DecimalPoint = 0 }); + + TagManger.AddTag(new Tag("过热度", "过热度[K]", "Superheat", "程序", "VW14132", 100, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + TagManger.AddTag(new Tag("过冷度", "过冷度[K]", "Subcooling", "程序", "VW14134", 100, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + + TagManger.AddTag(new Tag("制热量Qh", "制热量Qh[KW]", "HeatingCapacity", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + TagManger.AddTag(new Tag("压缩机性能系数(制热)", "压缩机性能系数(制热)[K]", "COPHeat", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + TagManger.AddTag(new Tag("等熵效率ns", "等熵效率ns[%]", "IsentrpEff", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + TagManger.AddTag(new Tag("制冷量Qc", "制冷量Qc[KW]", "CoolCapacity", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + TagManger.AddTag(new Tag("压缩机性能系数(制冷)", "压缩机性能系数(制冷)[K]", "COPCool", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + TagManger.AddTag(new Tag("容积效率nv", "容积效率nv[%]", "VoltricEff", "程序", "VW14134", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 }); + + #endregion diff --git a/CapMachine.Wpf/Services/PPCService.cs b/CapMachine.Wpf/Services/PPCService.cs index 94b5adb..0b7f11e 100644 --- a/CapMachine.Wpf/Services/PPCService.cs +++ b/CapMachine.Wpf/Services/PPCService.cs @@ -82,15 +82,15 @@ namespace CapMachine.Wpf.Services TxvFrPressTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前压力[BarA]"); - LiqRefFlowTag = TagManager.DicTags.GetValueOrDefault("液冷媒流量[kg/h]"); + //LiqRefFlowTag = TagManager.DicTags.GetValueOrDefault("液冷媒流量[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("冷凝器出口水温[℃]"); @@ -306,9 +306,13 @@ namespace CapMachine.Wpf.Services } if (iErr == 0) - Superheat.EngPvValue = InhTempTag.EngPvValue - (te - 273.15); - else - Superheat.EngPvValue = 0; + { + double superheatValue = InhTempTag.EngPvValue - (te - 273.15); + if (!double.IsNaN(superheatValue) && !double.IsInfinity(superheatValue)) + { + Superheat.EngPvValue = superheatValue; + } + } herr = new string(' ', 255); herrLen = 255; iErr = 0; 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); } if (iErr == 0) - Subcool.EngPvValue = TxvFrTempTag.EngPvValue - (te1 - 273.15); - else - Subcool.EngPvValue = 0; + { + double subcoolValue = TxvFrTempTag.EngPvValue - (te1 - 273.15); + if (!double.IsNaN(subcoolValue) && !double.IsInfinity(subcoolValue)) + { + Subcool.EngPvValue = subcoolValue; + } + } if (TryUpdateThermodynamicSixResults(out var thermoErr)) @@ -1090,21 +1098,19 @@ namespace CapMachine.Wpf.Services COPCooling = copC; 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; COPHeat.EngPvValue = COPHeating; IsentrpEff.EngPvValue = IsentropicEfficiencyPct; CoolCapacity.EngPvValue = CoolingCapacityQc_kW; 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; return true;