Exemplo n.º 1
0
    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!
    }
Exemplo n.º 2
0
    //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);
    }