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

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

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

revision 2259 by jpye, Wed Aug 4 00:14:19 2010 UTC revision 2260 by jpye, Thu Aug 5 06:28:01 2010 UTC
# Line 5  Line 5 
5  #include <math.h>  #include <math.h>
6  #include <stdio.h>  #include <stdio.h>
7    
8  //#define PHASE_DEBUG  #define PHASE_DEBUG
9  #define PHASE_ERRORS  #define PHASE_ERRORS
10    
11  #ifndef PHASE_DEBUG  #ifndef PHASE_DEBUG
12  # define MSG(...)  # define MSG(...)
13  #else  #else
14  # define MSG(ARGS...) fprintf(stderr,"%s: ",__func__);fprintf(stderr,ARGS)  # define MSG(ARGS...) fprintf(stderr,"%s:%d: ",__func__,__LINE__);fprintf(stderr,ARGS)
15  #endif  #endif
16    
17  #ifndef PHASE_DEBUG  #ifndef PHASE_DEBUG
# Line 32  Line 32 
32  int fprops_sat_T(double T, double *p_out, double *rhof_out, double *rhog_out, const HelmholtzData *d){  int fprops_sat_T(double T, double *p_out, double *rhof_out, double *rhog_out, const HelmholtzData *d){
33      double p, p_new, delta_p, delta_p_old;      double p, p_new, delta_p, delta_p_old;
34    
35        if(T < d->T_t){
36            ERR("Temperature T = %e K is below triple point, unable to calculate saturation properties.\n",T);
37            return 5;
38        }
39    
40      /*      /*
41      Estimate of saturation temperature using definition of acentric factor and      Estimate of saturation temperature using definition of acentric factor and
42      the assumed p(T) relationship:      the assumed p(T) relationship:
# Line 293  int fprops_sat_p(double p, double *T_out Line 298  int fprops_sat_p(double p, double *T_out
298              }              }
299              MSG(" delta_T was too large, has been shortened\n");              MSG(" delta_T was too large, has been shortened\n");
300          }          }
301            assert(T > 0);
302            if(T + delta_T < 0)delta_T = -0.2 * T;
303            while(T + delta_T > 10000)delta_T *= 0.5;
304    
305          T = T + delta_T;          T = T + delta_T;
306      }      }
# Line 330  int fprops_sat_p(double p, double *T_out Line 338  int fprops_sat_p(double p, double *T_out
338    
339      MSG("Failed to converge using sat_T approach\n");      MSG("Failed to converge using sat_T approach\n");
340    
341      *rhof_out = -1;      *rhof_out = d->rho_c;
342      *rhog_out = -1;      *rhog_out = d->rho_c;
343      *T_out = -1;      *T_out = d->T_c;
   
344      return 99;      return 99;
345  }  }
346    

Legend:
Removed from v.2259  
changed lines
  Added in v.2260

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