增加干度计算的数据
This commit is contained in:
135
CapMachine.Wpf/PPCalculation/DrynessCALCHelper.cs
Normal file
135
CapMachine.Wpf/PPCalculation/DrynessCALCHelper.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.PPCalculation
|
||||
{
|
||||
/// <summary>
|
||||
/// 干燥度计算帮助类
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用REFPROP64 获取饱和参数
|
||||
/// </summary>
|
||||
/// <param name="P"></param>
|
||||
/// <param name="Tsat"></param>
|
||||
/// <param name="h_f"></param>
|
||||
/// <param name="h_g"></param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
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)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算实际干度
|
||||
/// </summary>
|
||||
/// <param name="mg"></param>
|
||||
/// <param name="ml"></param>
|
||||
/// <param name="h_gas"></param>
|
||||
/// <param name="h_liq"></param>
|
||||
/// <param name="P_suction"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算目标液体流量
|
||||
/// </summary>
|
||||
/// <param name="mg"></param>
|
||||
/// <param name="h_gas"></param>
|
||||
/// <param name="h_liq"></param>
|
||||
/// <param name="P_suction"></param>
|
||||
/// <param name="x_target"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取焓值
|
||||
/// </summary>
|
||||
/// <param name="P"></param>
|
||||
/// <param name="T"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user