Ejemplo n.º 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
Ejemplo n.º 2
0
        } // Region Output backward

        static int BackwardRegion(double p, double X, IF97Parameters inkey)
        {
            // This routine is for testing purposes only.  It returns the
            // Region as an integer based on the backward evaluation of either
            // (p,h) or (p,s)

            // 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.");

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

            switch (region)
            {
                case IF97REGIONS.REGION_1: return 1;
                case IF97REGIONS.REGION_2: return 2;
                case IF97REGIONS.REGION_3: return 3;
                case IF97REGIONS.REGION_4: return 4;
                default: return 0;
            }
        }
Ejemplo n.º 3
0
        public static double RegionOutput(IF97Parameters outkey, double T, double p, SatState State)
        {

            IF97REGIONS region = RegionDetermination_TP(T, p);

            switch (region)
            {
                case IF97REGIONS.REGION_1:
                    if (State == SatState.VAPOR)
                        return R2.output(outkey, T, p);  // On saturation curve and need the Vapor phase
                    else
                        return R1.output(outkey, T, p);  // otherwise, use Liquid Region 1
                case IF97REGIONS.REGION_2:
                    if (State == SatState.LIQUID)
                        return R1.output(outkey, T, p);  // On saturation curve and need the Liquid phase
                    else
                        return R2.output(outkey, T, p);  // otherwise, use Vapor Region 2
                case IF97REGIONS.REGION_3:
                    return Region3.output(outkey, T, p, State);
                case IF97REGIONS.REGION_4:
                    if (State == SatState.VAPOR)
                    {
                        return R2.output(outkey, T, p);
                    }
                    else if (State == SatState.LIQUID)
                    {
                        return R1.output(outkey, T, p);
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException("Cannot use Region 4 with T and p as inputs");
                    }
                case IF97REGIONS.REGION_5: return R5.output(outkey, T, p);
            }
            throw new ArgumentOutOfRangeException("Unable to match region");
        }