static IF97REGIONS RegionDetermination_pX(double p, double X, IF97Parameters inkey) { // Setup needed Region Equations for region determination // Saturation Region Limit Variables double Tsat = 0; double Xliq = 0; double Xvap = 0; // Check overall boundary limits if ((p < Constants.Pmin) || (p > Constants.Pmax)) throw new ArgumentOutOfRangeException("Pressure out of range"); double Xmin = R1.output(inkey, Constants.Tmin, p); double Xmax = R2.output(inkey, Constants.Tmax, p); if ((X < Xmin) || (X > (Xmax + 1.0E-10))) { if (inkey == IF97Parameters.h) { throw new ArgumentOutOfRangeException("Enthalpy out of range"); } else { throw new ArgumentOutOfRangeException("Entropy out of range"); } } // Check saturation Dome first if (p <= Constants.Pcrit) { Tsat = Region4.Tsat97(p); Xliq = R1.output(inkey, Tsat, p); Xvap = R2.output(inkey, Tsat, p); if ((Xliq <= X) && (X <= Xvap)) { // Within Saturation Dome return IF97REGIONS.REGION_4; // Region 4 } } // End Check saturation Dome // Check values below 16.529 MPa if (p <= Constants.P23min) { // p <= P23min (saturation dome) if (X <= Xliq) return IF97REGIONS.REGION_1; else if (X >= Xvap) return IF97REGIONS.REGION_2; else return IF97REGIONS.REGION_4; } // Check values above 16.529 MPa else if (X <= R1.output(inkey, Constants.T23min, p)) return IF97REGIONS.REGION_1; else if (X >= R2.output(inkey, Region23_p(p), p)) return IF97REGIONS.REGION_2; else return IF97REGIONS.REGION_3; } // Region Output backward
static IF97REGIONS RegionDetermination_TP(double T, double p) { if (T > Constants.Text) { throw new ArgumentOutOfRangeException("Temperature out of range"); } else if (T > Constants.Tmax && T <= Constants.Text) { if (p <= Constants.Pext) { return IF97REGIONS.REGION_5; } else { throw new ArgumentOutOfRangeException("Pressure out of range"); } } else if (T > Constants.T23min && T <= Constants.Tmax) { if (p > Constants.Pmax) { throw new ArgumentOutOfRangeException("Pressure out of range"); } else if (p < 16.5292) { // Check this one first to avoid the call to 2-3 boundary curve (a little bit faster) return IF97REGIONS.REGION_2; } else if (p > Region23_T(T)) { return IF97REGIONS.REGION_3; } else { return IF97REGIONS.REGION_2; } } else if (T >= Constants.Tmin && T <= Constants.T23min) { if (p > Constants.Pmax) throw new ArgumentOutOfRangeException("Pressure out of range"); else if (p > Region4.p_T(T)) return IF97REGIONS.REGION_1; else if (p < Region4.p_T(T)) return IF97REGIONS.REGION_2; else return IF97REGIONS.REGION_4; } else { throw new ArgumentOutOfRangeException("Temperature out of range"); } }
/// Get surface tension [N/m] as a function of T [K] public static double sigma97(double T) { return Region4.sigma_t(T); }
/// Get the saturation pressure [Pa] as a function of T [K] public static double psat97(double T) { return Region4.p_T(T); }
// ******************************************************************************** // // 2-Phase Functions // // ******************************************************************************** // /// Get the saturation temperature [K] as a function of p [Pa] public static double Tsat97(double p) { return Region4.T_p(p); }