コード例 #1
0
        static double RegionOutputBackward(double p, double X, IF97Parameters inkey)
        {
            // Note that this routine returns only temperature (IF97_T).  All other values should be
            // calculated from this temperature and the known pressure using forward equations.
            // Setup Backward Regions for output

            // Make sure input and output keys are valid for Backward formulas
            if ((inkey != IF97Parameters.h) && (inkey != IF97Parameters.s))
                throw new ArgumentException("Backward Formulas take variable inputs of Enthalpy or Entropy only.");

            // Get Saturation Parameters

            IF97REGIONS region = RegionDetermination_pX(p, X, inkey);

            switch (region)
            {
                case IF97REGIONS.REGION_1:
                    if (inkey == IF97Parameters.h)
                        return B1H.T_pX(p, X);
                    else
                        return B1S.T_pX(p, X);
                case IF97REGIONS.REGION_2:
                    if (inkey == IF97Parameters.h)
                    {
                        if (p <= 4.0)
                            return B2aH.T_pX(p, X);
                        else if (X >= BackwardsRegion.H2b2c_p(p))
                            return B2bH.T_pX(p, X);
                        else
                            return B2cH.T_pX(p, X);
                    }
                    else
                    {
                        if (p <= 4.0)
                            return B2aS.T_pX(p, X);
                        else if (X >= Constants.S2bc)
                            return B2bS.T_pX(p, X);
                        else
                            return B2cS.T_pX(p, X);
                    };
                case IF97REGIONS.REGION_3:
                    if (inkey == IF97Parameters.h)
                    {
                        if (X <= BackwardsRegion.H3ab_p(p))
                            return B3aH.T_pX(p, X);
                        else
                            return B3bH.T_pX(p, X);
                    }
                    else
                    {
                        if (X <= Constants.Scrit)
                            return B3aS.T_pX(p, X);
                        else
                            return B3bS.T_pX(p, X);
                    };
                case IF97REGIONS.REGION_4: return Tsat97(p);
                default: throw new ArgumentOutOfRangeException("Unable to match region");
            }
        }  // Region Output backward
コード例 #2
0
        static IF97BACKREGIONS RegionDetermination_HS(double h, double s)
        {

            // Check Overall Boundaries
            if ((s < Constants.Smin) || (s > Constants.Smax))
                throw new ArgumentOutOfRangeException("Entropy out of range");
            if ((h > Hmax(s)) || (h < Hmin(s)))
                throw new ArgumentOutOfRangeException("Enthalpy out of range");

            // ============================================================================
            // Start at the low entropy curves and work our way up.
            // =================================== Region 1 Check =========================
            if (s <= Constants.SfT23)
            {
                if (h < BackwardsRegion.Hsat_s(s))     //   If below Saturated Liquid Curve
                    return IF97BACKREGIONS.BACK_4;                //       REGION 4
                else if (s < Constants.S13min)              //   If below H13 Curve
                    return IF97BACKREGIONS.BACK_1;                //       REGION 1
                else
                {                            //   IF within H13 Curve (S13min < s < SfT23)
                    if (h < b13.h_s(s))           //       below curve
                        return IF97BACKREGIONS.BACK_1;            //           REGION 1
                    else                          //       above curve
                        return IF97BACKREGIONS.BACK_3A;           //           REGION 3 
                }                            //
            }
            else if (s <= Constants.Scrit)
            {  //========== Region 3a Check (S < Scrit) ==============
                if (h < BackwardsRegion.Hsat_s(s))     //  If below Saturated Liquid Curve
                    return IF97BACKREGIONS.BACK_4;                //      REGION 4
                else                              //  If above curve
                    return IF97BACKREGIONS.BACK_3A;               //      REGION 3(a)
            }
            else if (s <= Constants.S23min)
            {  //========== Region 3b Check            ==============
                if (h < BackwardsRegion.Hsat_s(s))     //  If below Saturated Liquid Curve
                    return IF97BACKREGIONS.BACK_4;                //      REGION 4
                else                              //  If above curve
                    return IF97BACKREGIONS.BACK_3B;               //      REGION 3(a)
            }
            else if (s <= Constants.S23max)
            {  //========== Region 3b/2c Check Along B23 Curve ======
                if (h < BackwardsRegion.Hsat_s(s))     //  if below Saturated Vapor Curve
                    return IF97BACKREGIONS.BACK_4;                //      REGION 4
                else if (h < Constants.H23min)              //  if below bounding box
                    return IF97BACKREGIONS.BACK_3B;               //      REGION 3(b)
                else if (h > Constants.H23max)              //  if above bounding box
                    return IF97BACKREGIONS.BACK_2C;               //      REGION 2(c)
                else
                {                            //  Need to check TB23 Curve
                    double TB23 = b23hs.t_hs(h, s);       //  Calc TB23(h,s)
                    double PB23 = Region23_T(TB23);      //  Calc Corresponding PB23
                    double P = R2c.p_hs(h, s);         //  Calc P(h,s) using Region 2c
                    if (P > PB23)                        //  Above B23 Curve
                        return IF97BACKREGIONS.BACK_3B;                  //      REGION 3(b)
                    else                                 //  Below B23 Curve
                        return IF97BACKREGIONS.BACK_2C;                  //      REGION 2(c)
                }
            }
            else if (s <= Constants.S2bc)
            {   //========== Region 3b Check            ==============
                if (h < BackwardsRegion.Hsat_s(s))     //  If below Saturated Liquid Curve
                    return IF97BACKREGIONS.BACK_4;                //      REGION 4
                else                              //  If above curve
                    return IF97BACKREGIONS.BACK_2C;               //      REGION 2(c)
            }
            else if (s < Constants.Sgtrip)
            { //========== Region 2a/2b (s > S2bc) above Sat. Curve ==
                if (h < BackwardsRegion.Hsat_s(s))     //  If below Saturated Vapor Curve
                    return IF97BACKREGIONS.BACK_4;                //      REGION_4
                else
                {                            //  If above Curve then
                    if (h > BackwardsRegion.H2ab_s(s))   //      if h > h2ab(s) Curve (P=4 MPa)
                        return IF97BACKREGIONS.BACK_2B;             //          REGION 2(b)
                    else                            //      if h < h2ab(s) Curve (P=4 MPa)
                        return IF97BACKREGIONS.BACK_2A;             //          REGION 2(a)
                }
            }
            else
                return IF97BACKREGIONS.BACK_2A;      //========== Region 2a fall thru ========================
        }// Region Determination HS