/[ascend]/trunk/models/johnpye/fprops/sat.c
ViewVC logotype

Diff of /trunk/models/johnpye/fprops/sat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2263 by jpye, Thu Aug 5 08:34:43 2010 UTC revision 2264 by jpye, Thu Aug 5 09:25:55 2010 UTC
# Line 196  int fprops_sat_T(double T, double *psat_ Line 196  int fprops_sat_T(double T, double *psat_
196  }  }
197    
198  int fprops_sat_p(double p, double *Tsat_out, double *rhof_out, double * rhog_out, const HelmholtzData *d){  int fprops_sat_p(double p, double *Tsat_out, double *rhof_out, double * rhog_out, const HelmholtzData *d){
199      fprintf(stderr,"%s: NOT YET IMPLEMENTED\n",__func__);      /*
200        Estimate of saturation temperature using definition of acentric factor and
201        the assumed p(T) relationship:
202            log10(p)=A + B/T
203        See Reid, Prausnitz and Poling, 4th Ed., section 2.3.
204        */
205        double T1 = d->T_c / (1. - 3./7. / (1.+d->omega) * log10(p / d->p_c));
206        double p1, rhof, rhog;
207        int i = 0;
208        while(i++ < 20){
209            int res = fprops_sat_T(T1, &p1, &rhof, &rhog, d);
210            if(res)return 1;
211            //fprintf(stderr,"%s: T1 = %f ——> p = %f bar\trhof = %f\trhog = %f\n",__func__, T1, p1/1e5, rhof, rhog);
212            if(fabs(p1 - p) < 1e-5){
213                *Tsat_out = T1;
214                *rhof_out = rhof;
215                *rhog_out = rhog;
216                return 0;
217            }
218            double hf = helmholtz_h_raw(T1, rhof, d);
219            double hg = helmholtz_h_raw(T1, rhog, d);
220            double dpdT_sat = (hg - hf) / T1 / (1./rhog - 1./rhof);
221            //fprintf(stderr,"\t\tdpdT_sat = %f bar/K\n",dpdT_sat/1e5);
222            double delta_T = -(p1 - p)/dpdT_sat;
223            if(T1 + delta_T < d->T_t)T1 = 0.5 * (d->T_t + T1);
224            else T1 += delta_T;
225        }
226        *Tsat_out = T1;
227        *rhof_out = rhof;
228        *rhog_out = rhog;
229      return 1;      return 1;
230  }  }
231    

Legend:
Removed from v.2263  
changed lines
  Added in v.2264

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22