public static double x_given_ph(double p, double h) //ONLY USE IN VAPOR DOME { double ret_val; try { ret_val = IF97.Q_phmass(p / 1000000.0, h / 1000.0); //UNIT CONVERSION UNTESTED! return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, x_neutral)); got_error = true; return(x_neutral); } //return IF97.Q_phmass(p/1000000.0,h/1000.0); //UNIT CONVERSION UNTESTED! }
public static double s_given_px(double p, double x) { double ret_val; try { ret_val = IF97.smass_pQ(p / 1000000.0, x) * 1000f; //UNIT CONVERSION UNTESTED! return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, s_neutral)); got_error = true; return(s_neutral); } //return IF97.smass_pQ(p/1000000.0,x)*1000f; //UNIT CONVERSION UNTESTED! }
public static double vvap_given_p(double p) { double ret_val; try { ret_val = 1.0 / IF97.rhovap_p(p / 1000000.0); //expects:MPa returns Kg/M^3 return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, v_neutral)); got_error = true; return(v_neutral); } //return 1.0/IF97.rhovap_p(p/1000000.0); //expects:MPa returns Kg/M^3 }
public static double u_given_pt(double p, double t) //DO NOT USE IN VAPOR DOME { double ret_val; try { ret_val = IF97.umass_Tp(t, p / 1000000.0) * 1000f; //UNIT CONVERSION UNTESTED! return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, u_neutral)); got_error = true; return(u_neutral); } //return IF97.umass_Tp(t, p/1000000.0)*1000f; //UNIT CONVERSION UNTESTED! }
public static double tsat_given_p(double p) { double ret_val; try { ret_val = IF97.Tsat97(p / 1000000.0); //UNIT CONVERSION UNTESTED! return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, t_neutral)); got_error = true; return(t_neutral); } //return IF97.Tsat97(p/1000000.0); //UNIT CONVERSION UNTESTED! }
public static double v_given_px(double p, double x) //ONLY USE IN VAPOR DOME { double ret_val; try { ret_val = 1.0 / IF97.rhomass_pQ(p / 1000000.0, x); //UNIT CONVERSION UNTESTED! return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, v_neutral)); got_error = true; return(v_neutral); } //return 1.0/IF97.rhomass_pQ(p/1000000.0,x); //UNIT CONVERSION UNTESTED! }
public static double v_given_pt(double p, double t) //DO NOT USE IN VAPOR DOME { double ret_val; try { ret_val = 1.0 / IF97.rhomass_Tp(t, p / 1000000.0); //expects:K,MPa returns Kg/M^3 return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, v_neutral)); got_error = true; return(v_neutral); } //return 1.0/IF97.rhomass_Tp(t,p/1000000.0); //expects:K,MPa returns Kg/M^3 }
public static int region_given_ps(double p, double s) { int r = IF97.Region_ps(p / 1000000.0, s / 1000.0); switch (r) { case 1: //liquid return(0); //subcooled liquid case 2: //vapor return(2); //superheated vapor case 3: case 4: //two-phase case 5: return(1); //two-phase } return(-1); }
public static double x_given_pv(double p, double v) //ONLY USE IN VAPOR DOME { double ret_val; try { //f means saturated liquid, //g means saturated gas double vf = 1.0 / IF97.rholiq_p(p / 1000000.0); double vg = 1.0 / IF97.rhovap_p(p / 1000000.0); ret_val = (v - vf) / (vg - vf); //UNIT CONVERSION UNTESTED! return(ret_val); } catch (Exception ex) { Debug.Log(String.Format("Got an exception: {0}\nReturning {1}", ex.Message, x_neutral)); got_error = true; return(x_neutral); } //return (v-vf)/(vg-vf); //UNIT CONVERSION UNTESTED! }
//a bunch of options for getting region here- still need to figure out most reliable //region: 0 subcooled liquid, 1 two-phase, 2 superheated vapor public static int region_given_pvt(double p, double v, double t) { int liq = 0; int two = 1; int vapor = 2; //broad check w/ t if (t - t_smallstep > IF97.Tsat97(p / 1000000.0)) { return(vapor); } if (t + t_smallstep < IF97.Tsat97(p / 1000000.0)) { return(liq); } //broad check w/ p - unneeded //if(p-p_smallstep > IF97.psat97(t)) return liq; //if(p+p_smallstep < IF97.psat97(t)) return vapor; //fine check w/ v //f means saturated liquid, //g means saturated gas double vf = 1.0 / IF97.rholiq_p(p / 1000000.0); if (v <= vf) { return(liq); } double vg = 1.0 / IF97.rhovap_p(p / 1000000.0); if (v >= vg) { return(vapor); } return(two); }
public void CalcProps(PropInfo inputProp1, PropInfo inputProp2) { double dbl1; double dbl2; if (string.IsNullOrEmpty(inputProp1.Value) || string.IsNullOrEmpty(inputProp2.Value)) { for (int i = 0; i < n; i++) { string key = Enum.GetName(typeof(AquaProps), i); this.PropDic[key] = ""; } this.RaisePropertyChanged("PropDic"); } else if (double.TryParse(inputProp1.Value, out dbl1) && double.TryParse(inputProp2.Value, out dbl2)) { for (int i = 0; i < n; i++) { string key = Enum.GetName(typeof(AquaProps), i); string strvalue; double dblValue; if (inputProp1.NameEN == "Pressure") { if (inputProp2.NameEN == "VaporFraction") { dblValue = IF97.PX(dbl1, dbl2, i); } else if (inputProp2.NameEN == "Temperature") { dblValue = IF97.PT(dbl1, dbl2, i); } else if (inputProp2.NameEN == "SpecificVolume") { dblValue = IF97.PV(dbl1, dbl2, i); } else if (inputProp2.NameEN == "Enthalpy") { dblValue = IF97.PH(dbl1, dbl2, i); } else if (inputProp2.NameEN == "Entropy") { dblValue = IF97.PS(dbl1, dbl2, i); } else { throw new FormatException(); } } else if (inputProp1.NameEN == "Temperature") { if (inputProp2.NameEN == "VaporFraction") { dblValue = IF97.TX(dbl1, dbl2, i); } else if (inputProp2.NameEN == "SpecificVolume") { dblValue = IF97.TV(dbl1, dbl2, i); } else if (inputProp2.NameEN == "Enthalpy") { dblValue = IF97.TH(dbl1, dbl2, i); } else if (inputProp2.NameEN == "Entropy") { dblValue = IF97.TS(dbl1, dbl2, i); } else { throw new FormatException(); } } else if (inputProp1.NameEN == "Enthalpy") { if (inputProp2.NameEN == "Entropy") { dblValue = IF97.HS(dbl1, dbl2, i); } else { throw new FormatException(); } } else { throw new FormatException(); } if (dblValue == -1) { strvalue = "N/A"; } else { strvalue = dblValue.ToString(); } this.PropDic[key] = strvalue; } this.RaisePropertyChanged("PropDic"); } }
public static void Init() { got_error = false; IF97.initRegions(); //Pa p_min = IF97.get_Pmin() * 1000000.0; // 611.213 p_max = IF97.get_Pmax() * 1000000.0; // 100000000 p_neutral = 101325.0; p_smallstep = 1.0; //Pa psat_min = IF97.get_ptrip() * 1000000.0; //TODO: comment actual value for quick reference psat_max = IF97.get_pcrit() * 1000000.0; //TODO: comment actual value for quick reference //M^3/kg v_min = 1.0 / 3000; // 0.0003 v_max = 1.0 / 0.001; // 1000 v_neutral = 0.001; v_smallstep = 0.00001; //K t_min = IF97.get_Tmin(); // 273.15 t_max = IF97.get_Tmax(); // 1073.15 t_neutral = 293.0; t_smallstep = 0.001; //J/kg u_min = 0.0; //TODO:find actual min u_max = 9999999999; //TODO:find actual max u_neutral = 83.28; u_smallstep = 0.0; //TODO: find //J/kgK //s_min = IF97.Smin; //TODO: comment actual value for quick reference //I don't think this is correct //s_max = IF97.Smax; //11.9210548250511 //I don't think this is correct... s_min = 0.0; //TODO: actually find something coherent s_max = 999999999999.0; //TODO: actually find something coherent s_neutral = 294.322; s_smallstep = 0.0; //TODO: find //J/kg //h_? = ; //experimentally derived- room temp water //h_min = IF97.Hmin(s_min); //TODO: I don't think this is correct... //h_max = IF97.Hmax(s_max); //4171.65498424024 given s_max 11.9... //TODO: I don't think this is correct... h_min = 0.0; //TODO: actually come up with something coherent h_max = 9999999.0; //TODO: actually come up with something coherent h_neutral = 83377.0; h_smallstep = 0.0; //TODO: find //% x_min = 0.0; x_max = 1.0; x_neutral = 0; x_smallstep = 0.00001; //DEBUG INFO: //IF97.print_tables(); //IAPWS95.print_tables(); //compare_impls(); }