using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CapMachine.Wpf.PPCalculation { /// /// 干燥度计算帮助类 /// public static class DrynessCALCHelper { public static void GetValue() { //var dd= DrynessREFPROP.GetDryness(67,0.3); // 获取输入参数 double P_suction = 0.3; // 吸气压力 (bar) double mg = 50 / 3600; // 气体制冷剂流量 (kg/h → kg/s) double ml = 4.5 / 3600; // 液体制冷剂流量 (kg/h → kg/s) double T_gas_valve = 35; // 气体回路阀前温度 (°C) double P_gas_valve = 15; // 气体回路阀前压力 (bar) double T_liq_valve = 67; // 液体制冷剂阀前温度 (°C) double P_liq_valve = 14.5; // 液体制冷剂阀前压力 (bar) double x_target = 14.5; // 目标干度 // 获取焓值 double h_gas = GetEnthalpy(P_gas_valve, T_gas_valve + 273.15); // 转换为 K double h_liq = GetEnthalpy(P_liq_valve, T_liq_valve + 273.15); // 转换为 K // 计算实际干度 double x_actual = CalculateActualDryness(mg, ml, h_gas, h_liq, P_suction); // 计算目标液体流量 double ml_target = CalculateTargetLiquidFlow(mg, h_gas, h_liq, P_suction, x_target); //lblTargetLiquidFlow.Text = $"目标液体流量: {ml_target * 3600:F2} kg/h"; // 转换为 kg/h } /// /// 使用REFPROP64 获取饱和参数 /// /// /// /// /// /// private static void GetSaturationProperties(double P, out double Tsat, out double h_f, out double h_g) { StringBuilder herr = new StringBuilder(255); double Dl, Dv, hl, hv, sl, sv; int ierr; // 调用 REFPROP 的 SATPdll 函数获取饱和参数 DrynessREFPROP.SATPdll(P, 0, "P", "H", out Tsat, out Dl, out Dv, out hl, out hv, out sl, out sv, out ierr, herr, 1, 1); if (ierr != 0) throw new Exception($"饱和状态计算失败: {herr.ToString()}"); h_f = hl; // 饱和液体焓 (J/kg) h_g = hv; // 饱和气体焓 (J/kg) } /// /// 计算实际干度 /// /// /// /// /// /// /// public static double CalculateActualDryness(double mg, double ml, double h_gas, double h_liq, double P_suction) { // 获取吸气压力下的饱和参数 double Tsat, h_f, h_g_sat; GetSaturationProperties(P_suction, out Tsat, out h_f, out h_g_sat); // 计算混合焓 double h_total = (mg * h_gas + ml * h_liq) / (mg + ml); // 计算干度 return (h_total - h_f) / (h_g_sat - h_f); } /// /// 计算目标液体流量 /// /// /// /// /// /// /// public static double CalculateTargetLiquidFlow(double mg, double h_gas, double h_liq, double P_suction, double x_target) { // 获取吸气压力下的饱和参数 double Tsat, h_f, h_g_sat; GetSaturationProperties(P_suction, out Tsat, out h_f, out h_g_sat); // 计算目标焓 double h_target = h_f + x_target * (h_g_sat - h_f); // 解方程求目标液体流量 return mg * (h_gas - h_target) / (h_target - h_liq); } /// /// 获取焓值 /// /// /// /// /// public static double GetEnthalpy(double P, double T) { StringBuilder herr = new StringBuilder(255); double D, Dl, Dv, h, s, u, cv; int ierr; // 调用 REFPROP 的 TPFLSHdll 函数获取焓值 DrynessREFPROP.TPFLSHdll(T, P, "T", "P", out D, out Dl, out Dv, out h, out s, out u, out cv, out ierr, herr, 1, 1); if (ierr != 0) throw new Exception($"焓值计算失败: {herr.ToString()}"); return h; // 返回焓值 (J/kg) } } }