int mu_Tv_calc(struct BBoxInterp *bbox, int ninputs, int noutputs,
	double *inputs, double *outputs, double *jacobian
){
	(void)bbox; (void)jacobian; // not used
	(void)ninputs; (void)noutputs; // not used currently

	double T = inputs[0];
	double rho = 1./inputs[1];

	/* TODO make checks of two-phase region, act accordingly */
	double mu = freesteam_mu_rhoT(rho,T);

	outputs[0] = mu;
	return 0;
}
示例#2
0
//CL: calculated the properties --> this function is called by the functions above
//CL: does not calulated the internal energy, if this is needed e.g. for sonicFoam
//CL: the function has to be changed a little bit 
void Foam::calculateProperties_h
(
    SteamState S, 
    scalar &p, 
    scalar &h, 
    scalar &T, 
    scalar &rho, 
    scalar &psi, 
    scalar &drhodh, 
    scalar &mu, 
    scalar &alpha, 
    scalar &x
)
{
    label region;
    scalar kappa,lambda,cp,beta; 

    region=freesteam_region(S);

    if (region==1)
    {
        p=S.R1.p;
        T=S.R1.T;
        rho=1/freesteam_region1_v_pT(S.R1.p,S.R1.T);
        h=freesteam_region1_h_pT(S.R1.p,S.R1.T);
        x=0;

        //Cl: note: in FreeStream, beta=1/V*(dV/dP)_P=const is called alphaV (in this region)
        //Cl: note: in FreeStream, kappa=1/V*(dV/dP)_T=const is called kappaT (in this region)
        kappa=freesteam_region1_kappaT_pT(S.R1.p,S.R1.T);
        beta=freesteam_region1_alphav_pT(S.R1.p,S.R1.T);
        cp=freesteam_region1_cp_pT(S.R1.p,S.R1.T);
 
        //CL: getting derivatives using Bridgmans table
        //CL: psi=(drho/dp)_h=const
        //CL: drhodh=(drho/dh)_p=const
        psi=-((T*beta*beta-beta)/cp-kappa*rho);
        drhodh=-rho*beta/cp;

        //CL: getting transport properties
        mu=freesteam_mu_rhoT(rho, T);
        lambda=freesteam_k_rhoT(rho,T);
        alpha=lambda/cp; //Cl: Important info -->alpha= thermal diffusivity time density
    }
    else if (region==2)
    {
        p=S.R2.p;
        T=S.R2.T;
        rho=1/freesteam_region2_v_pT(S.R2.p,S.R2.T);
        h=freesteam_region2_h_pT(S.R2.p,S.R2.T);
        x=1;

        //Cl: note: in FreeStream, beta=1/V*(dV/dP)_P=const is called alphaV (in this region)
        //Cl: note: in FreeStream, kappa=1/V*(dV/dP)_T=const is called kappaT (in this region)
        kappa=freesteam_region2_kappaT_pT(S.R2.p,S.R2.T);
        beta=freesteam_region2_alphav_pT(S.R2.p,S.R2.T);
        cp=freesteam_region2_cp_pT(S.R2.p,S.R2.T);
 
        //CL: getting derivatives using Bridgmans table
        //CL: psi=(drho/dp)_h=const
        //CL: drhodh=(drho/dh)_p=const
        psi=-((T*beta*beta-beta)/cp-kappa*rho);
        drhodh=-rho*beta/cp;

        //CL: getting transport properties
        mu=freesteam_mu_rhoT(rho, T);
        lambda=freesteam_k_rhoT(rho,T);
        alpha=lambda/cp; //Cl: Important info -->alpha= thermal diffusivity time density
    }
    else if (region==3)
    {
        scalar gamma,cv;
 
        rho=S.R3.rho;
        T=S.R3.T;
        p=freesteam_region3_p_rhoT(S.R3.rho,S.R3.T);
        h=freesteam_region3_h_rhoT(S.R3.rho,S.R3.T);
        
        //CL= when h<h @ critical point -->x=0 else x=1
        if (h<2084256.263)
        {
            x=0;
        }
        else
        {
            x=1;
        }
     
        //Cl: note: beta=1/V*(dV/dP)_P=const 
        //Cl: note: kappa=1/V*(dV/dP)_T=const 
        //Cl: note: in FreeStream, gamma=1/p*(dp/dT)_v=const is called alphap (in this region)
        gamma=freesteam_region3_alphap_rhoT(S.R3.rho,S.R3.T);
        cp=freesteam_region3_cp_rhoT(S.R3.rho,S.R3.T);
        cv=freesteam_region3_cv_rhoT(S.R3.rho,S.R3.T);
        beta=(cp-cv)/(S.R3.T/S.R3.rho*p*gamma);
        kappa=(cp-cv)/(S.R3.T/S.R3.rho*p*p*gamma*gamma);

        //CL: getting derivatives using Bridgmans table
        //CL: psi=(drho/dp)_h=const
        //CL: drhodh=(drho/dh)_p=const
        psi=-((T*beta*beta-beta)/cp-kappa*rho);
        drhodh=-rho*beta/cp;


        //CL: getting transport properties
        mu=freesteam_mu_rhoT(rho, T);
        lambda=freesteam_k_rhoT(rho,T);
        alpha=lambda/cp; //Cl: Important info -->alpha= thermal diffusivity time density

    }
    else if (region==4)
    {
        scalar rhov,rhol,betav,betal,kappav,kappal,vv,vl,cpl,cpv,hl,hv,cp;
        scalar dvldp,dvvdp,dhldp,dhvdp;
        scalar dpdT,dvdh,dvdp,dxdp;

        SteamState Sl,Sv;
      
        x=S.R4.x;
        T=S.R4.T;
        rho=1/freesteam_region4_v_Tx(S.R4.T,S.R4.x);
        h=freesteam_region4_h_Tx(S.R4.T,S.R4.x);
        p=freesteam_region4_psat_T(S.R4.T);
        cp=freesteam_region4_cp_Tx(S.R4.T,S.R4.x);

 
        //CL: Getting density on the vapour and liquid lines
        rhov=freesteam_region4_rhog_T(S.R4.T);
        rhol=freesteam_region4_rhof_T(S.R4.T);
        vv=1/rhov;
        vl=1/rhol;

        //CL: getting derivatives --> this is a bit tricky inside the vapor dome

        dpdT=freesteam_region4_dpsatdT_T(S.R4.T);

	// getting the states outside the vapour dome 
        Sl=freesteam_set_pv(p,vl-0.0000001);  //inside region 1
        Sv=freesteam_set_pv(p,vv+0.0000001);  //inside region 2
  
        kappal=freesteam_region1_kappaT_pT(Sl.R1.p,Sl.R1.T);
        kappav=freesteam_region2_kappaT_pT(Sv.R2.p,Sv.R2.T);

        betal=freesteam_region1_alphav_pT(Sl.R1.p,Sl.R1.T);
        betav=freesteam_region2_alphav_pT(Sv.R2.p,Sv.R2.T);

        cpl=freesteam_region1_cp_pT(Sl.R1.p,Sl.R1.T);
        cpv=freesteam_region2_cp_pT(Sv.R2.p,Sv.R2.T);

        hl=freesteam_region1_h_pT(Sl.R1.p,Sl.R1.T);
        hv=freesteam_region2_h_pT(Sv.R2.p,Sv.R2.T);


        //calculation derviatives on liquid and vapour line
        dvldp=betal*vl/dpdT-kappal*vl;
        dvvdp=betav*vv/dpdT-kappav*vv;

        dhldp=vl*(1-betal*Sl.R1.T)+cpl/dpdT;
        dhvdp=vv*(1-betav*Sv.R2.T)+cpl/dpdT;

        dxdp=-dhldp/(hv-hl)
                 +(h-hl)/((hv-hl)*(hv-hl))
                     *(dhvdp-dhldp);
        
        //CL: psi=(drho/dp)_h=const
        dvdp=dvldp+(dvvdp-dvldp)*x+(vv-vl)*dxdp;
        psi=-rho*rho*dvdp;

        //CL: drhodh=(drho/dh)_p=const
        dvdh=(vv-vl)/(hv-hl);
        drhodh=-rho*rho*dvdh;
        
        //CL: getting transport properties
        mu=freesteam_mu_rhoT(rho, T);
        lambda=freesteam_k_rhoT(rho,T);
        alpha=lambda/cp; //Cl: Important info -->alpha= thermal diffusivity time density
    }
    else
    {
        std::cout<<"IAPWS-IF97 error, outside the regions 1-4"<<std::endl;
    }
}