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

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

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

revision 1988 by jpye, Tue Feb 3 05:38:33 2009 UTC revision 1989 by jpye, Tue Feb 3 07:29:29 2009 UTC
# Line 194  double helmholtz_a(double T, double rho, Line 194  double helmholtz_a(double T, double rho,
194    
195      @param T temperature in K      @param T temperature in K
196      @param rho mass density in kg/m³      @param rho mass density in kg/m³
197      @param Specific heat capacity in J/kg/K.      @return Isochoric specific heat capacity in J/kg/K.
198  */  */
199  double helmholtz_cv(double T, double rho, const HelmholtzData *data){  double helmholtz_cv(double T, double rho, const HelmholtzData *data){
200      double tau = data->T_star / T;      double tau = data->T_star / T;
# Line 204  double helmholtz_cv(double T, double rho Line 204  double helmholtz_cv(double T, double rho
204  }  }
205    
206  /**  /**
207        Function to calculate isobaric heat capacity from the Helmholtz free energy
208        EOS given temperature and mass density.
209    
210        @param T temperature in K
211        @param rho mass density in kg/m³
212        @return Isobaric specific heat capacity in J/kg/K.
213    */
214    double helmholtz_cp(double T, double rho, const HelmholtzData *data){
215        double tau = data->T_star / T;
216        double delta = rho / data->rho_star;
217    
218        double phir_d = helm_resid_del(tau,delta,data);
219        double phir_dd = helm_resid_deldel(tau,delta,data);
220        double phir_dt = helm_resid_deltau(tau,delta,data);
221        
222        /* note similarities with helmholtz_w */
223        double temp1 = 1 + 2*delta*phir_d + SQ(delta)*phir_dd;
224        double temp2 = 1 + delta*phir_d - delta*tau*phir_dt;
225        double temp3 = SQ(tau)*(helm_ideal_tautau(tau,data->ideal) + helm_resid_tautau(tau,delta,data));
226    
227        return data->R * (-temp3 + SQ(temp2)/temp1);
228    }
229    
230    
231    /**
232        Function to calculate the speed of sound in a fluid from the Helmholtz free
233        energy EOS, given temperature and mass density.
234    
235        @param T temperature in K
236        @param rho mass density in kg/m³
237        @return Speed of sound in m/s.
238    */
239    double helmholtz_w(double T, double rho, const HelmholtzData *data){
240    
241        double tau = data->T_star / T;
242        double delta = rho / data->rho_star;
243    
244        double phir_d = helm_resid_del(tau,delta,data);
245        double phir_dd = helm_resid_deldel(tau,delta,data);
246        double phir_dt = helm_resid_deltau(tau,delta,data);
247        
248        /* note similarities with helmholtz_cp */
249        double temp1 = 1 + 2*delta*phir_d + SQ(delta)*phir_dd;
250        double temp2 = 1 + delta*phir_d - delta*tau*phir_dt;
251        double temp3 = SQ(tau)*(helm_ideal_tautau(tau,data->ideal) + helm_resid_tautau(tau,delta,data));
252    
253        return sqrt(data->R * T *(temp1 - SQ(temp2)/temp3));
254    
255    }
256    
257    /**
258      Calculation zero-pressure specific heat capacity      Calculation zero-pressure specific heat capacity
259  */  */
260  double helmholtz_cp0(double T, const HelmholtzData *data){  double helmholtz_cp0(double T, const HelmholtzData *data){
# Line 616  double helm_resid_tau(double tau,double Line 667  double helm_resid_tau(double tau,double
667          ++ct;          ++ct;
668      }      }
669    
     /* FIXME add critical terms calculation */  
   
670      return res;      return res;
671  }    }  
672    
# Line 701  double helm_resid_deltau(double tau,doub Line 750  double helm_resid_deltau(double tau,doub
750      Second derivative of helmholtz residual function with respect to      Second derivative of helmholtz residual function with respect to
751      delta (twice).      delta (twice).
752    
753      FIXME this function is WRONG.      FIXME this function is WRONG. (UPDATE? is this still true? Think not)
754  */  */
755  double helm_resid_deldel(double tau,double delta,const HelmholtzData *data){  double helm_resid_deldel(double tau,double delta,const HelmholtzData *data){
756      double sum = 0, res = 0;      double sum = 0, res = 0;
# Line 859  double helm_resid_tautau(double tau, dou Line 908  double helm_resid_tautau(double tau, dou
908          ++ct;          ++ct;
909      }      }
910    
     /* FIXME add critical terms calculation */  
   
911  #ifdef RESID_DEBUG  #ifdef RESID_DEBUG
912      fprintf(stderr,"phir_tautau = %f\n",res);      fprintf(stderr,"phir_tautau = %f\n",res);
913  #endif  #endif

Legend:
Removed from v.1988  
changed lines
  Added in v.1989

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