Example #1
0
        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");
            }
        }