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

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

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

revision 1834 by jpye, Fri Aug 22 07:26:09 2008 UTC revision 1835 by jpye, Mon Aug 25 08:18:23 2008 UTC
# Line 1  Line 1 
1  #include "ammonia.h"  #include "ammonia.h"
2    
3  /* Property data for Ammonia, from Tillner-Roth, Harms-Watzenberg and  
4    /**
5    Ideal gas data for Ammonia, from Tillner-Roth, Harms-Watzenberg and
6  Baehr, 'Eine neue Fundamentalgleichung für Ammoniak', DKV-Tagungsbericht,  Baehr, 'Eine neue Fundamentalgleichung für Ammoniak', DKV-Tagungsbericht,
7  20:167-181, 1993. This is the ammmonia property correlation recommended  20:167-181, 1993. This is the ammmonia property correlation recommended
8  by NIST in its program REFPROP 7.0. */  by NIST in its program REFPROP 7.0.
9    */
10    const IdealData ideal_data_ammonia = {
11        -15.815020 /* const */
12        , 4.255726 /* linear */
13        , 3 /* power terms */
14        , (const IdealPowTerm[]){
15            {11.474340,   1./3 }
16            ,{-1.296211,  -3./2.}
17            ,{0.5706757,  -7./4.}
18        }
19        , 0, (const IdealExpTerm *)0 /* no exponential terms */
20    };
21                
22    
23    /**
24    Residual (non-ideal) property data for Ammonia, from Tillner-Roth,
25    Harms-Watzenberg and Baehr, 'Eine neue Fundamentalgleichung für Ammoniak',
26    DKV-Tagungsbericht, 20:167-181, 1993. This is the ammmonia property correlation
27    recommended by NIST in its program REFPROP 7.0.
28    */
29  const HelmholtzData helmholtz_data_ammonia = {  const HelmholtzData helmholtz_data_ammonia = {
30      /* R */ 488.189 /* J/kg/K */      /* R */ 488.189 /* J/kg/K */
31      , /* M */ 17.03026 /* kg/kmol */      , /* M */ 17.03026 /* kg/kmol */
32      , /* rho_star */225. /* kg/m³ */      , /* rho_star */225. /* kg/m³ */
33      , /* T_star */ 405.40 /* K */      , /* T_star */ 405.40 /* K */
34      , 5 /* ni */      , &ideal_data_ammonia
35      , (const double[]){ /* a0 values 1..5 */      , 21 /* nr */
          -15.815020  
         ,  4.255726  
         , 11.474340  
         , -1.296211  
         ,  0.5706757  
     }, 21 /* nr */  
36      , (const HelmholtzATDL[]){      , (const HelmholtzATDL[]){
37          /* a_i, t_i, d_i, l_i */          /* a_i, t_i, d_i, l_i */
38          {0.4554431E-1,  -0.5  ,  2,  0}/* 1 */          {0.4554431E-1,  -0.5  ,  2,  0}/* 1 */
# Line 87  int main(void){ Line 102  int main(void){
102      d = &helmholtz_data_ammonia;      d = &helmholtz_data_ammonia;
103      double maxerr = 0;      double maxerr = 0;
104    
     fprintf(stderr,"ENTROPY TESTS\n");  
   
     /* offset required to attain agreement with REFPROP */  
     double Y = -471.596704;  
   
     fprintf(stderr,"s(T,rho) at p = 0.1 MPa\n");  
     ASSERT_TOL(helmholtz_s(273.15+-60, 713.65,d), Y+0.36737e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+  0,0.76124,d), Y+6.8900e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+ 50,0.63869,d), Y+7.2544e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+200,0.43370,d), Y+8.1232e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+300,0.35769,d), Y+8.6084e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+420,0.29562,d), Y+9.1365e3, 1);  
   
     fprintf(stderr,"s(T,rho) at p = 1 MPa\n");  
     ASSERT_TOL(helmholtz_s(273.15+-50,702.49,d), Y+0.56381e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+150,4.9817,d), Y+6.7008e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+200,4.4115,d), Y+6.9770e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+350,3.3082,d), Y+7.7012e3, 0.5);  
     ASSERT_TOL(helmholtz_s(273.15+420,2.9670,d), Y+8.0059e3, 0.5);  
   
     fprintf(stderr,"s(T,rho) at p = 10 MPa\n");  
     ASSERT_TOL(helmholtz_s(273.15+-70,728.11,d), Y+0.14196e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+-50,706.21,d), Y+0.54289e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+-20,670.55,d), Y+1.0975e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+  0,645.04,d), Y+1.4403e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+125.17,356.70,d), Y+3.5463e3, 1);  
   
     ASSERT_TOL(helmholtz_s(273.15+125.17,121.58,d), Y+4.5150e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+200,54.389,d), Y+5.5906e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+350,35.072,d), Y+6.4850e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+420,30.731,d), Y+6.8171e3, 1);  
   
     fprintf(stderr,"s(T,rho) at p = 20 MPa\n");  
     ASSERT_TOL(helmholtz_s(273.15+-50,710.19,d), Y+0.52061e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+ 30,612.22,d), Y+1.8844e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+150,359.41,d), Y+3.7164e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+200,152.83,d), Y+4.8376e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+350,74.590,d), Y+6.0407e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+420,63.602,d), Y+6.4066e3, 1);  
   
     fprintf(stderr,"s(T,rho) at p = 100 MPa\n");  
     ASSERT_TOL(helmholtz_s(273.15+  0,690.41,d), Y+1.2158e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+100,591.07,d), Y+2.5499e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+250,437.69,d), Y+4.0264e3, 1);  
     ASSERT_TOL(helmholtz_s(273.15+420,298.79,d), Y+5.2620e3, 1);  
   
     /* successful entropy tests means that helm_ideal_tau, helm_real_tau, helm_ideal and helm_resid are all OK */  
   
105      fprintf(stderr,"PRESSURE TESTS\n");      fprintf(stderr,"PRESSURE TESTS\n");
106    
107      fprintf(stderr,"p(T,rho) = 0.1 MPa\n");      fprintf(stderr,"p(T,rho) = 0.1 MPa\n");
# Line 225  int main(void){ Line 192  int main(void){
192      ASSERT_TOL(helmholtz_h(273.15+250,437.69,d), Z+1506.6e3, 1e3);      ASSERT_TOL(helmholtz_h(273.15+250,437.69,d), Z+1506.6e3, 1e3);
193      ASSERT_TOL(helmholtz_h(273.15+420,298.79,d), Z+2252.3e3, 1e3);      ASSERT_TOL(helmholtz_h(273.15+420,298.79,d), Z+2252.3e3, 1e3);
194    
195    
196    
197        fprintf(stderr,"ENTROPY TESTS\n");
198    
199        /* offset required to attain agreement with REFPROP */
200        double Y = -471.596704;
201    
202        fprintf(stderr,"s(T,rho) at p = 0.1 MPa\n");
203        ASSERT_TOL(helmholtz_s(273.15+-60, 713.65,d), Y+0.36737e3, 0.5);
204        ASSERT_TOL(helmholtz_s(273.15+  0,0.76124,d), Y+6.8900e3, 0.5);
205        ASSERT_TOL(helmholtz_s(273.15+ 50,0.63869,d), Y+7.2544e3, 0.5);
206        ASSERT_TOL(helmholtz_s(273.15+200,0.43370,d), Y+8.1232e3, 0.5);
207        ASSERT_TOL(helmholtz_s(273.15+300,0.35769,d), Y+8.6084e3, 1);
208        ASSERT_TOL(helmholtz_s(273.15+420,0.29562,d), Y+9.1365e3, 1);
209    
210        fprintf(stderr,"s(T,rho) at p = 1 MPa\n");
211        ASSERT_TOL(helmholtz_s(273.15+-50,702.49,d), Y+0.56381e3, 0.5);
212        ASSERT_TOL(helmholtz_s(273.15+150,4.9817,d), Y+6.7008e3, 0.5);
213        ASSERT_TOL(helmholtz_s(273.15+200,4.4115,d), Y+6.9770e3, 0.5);
214        ASSERT_TOL(helmholtz_s(273.15+350,3.3082,d), Y+7.7012e3, 0.5);
215        ASSERT_TOL(helmholtz_s(273.15+420,2.9670,d), Y+8.0059e3, 0.5);
216    
217        fprintf(stderr,"s(T,rho) at p = 10 MPa\n");
218        ASSERT_TOL(helmholtz_s(273.15+-70,728.11,d), Y+0.14196e3, 1);
219        ASSERT_TOL(helmholtz_s(273.15+-50,706.21,d), Y+0.54289e3, 1);
220        ASSERT_TOL(helmholtz_s(273.15+-20,670.55,d), Y+1.0975e3, 1);
221        ASSERT_TOL(helmholtz_s(273.15+  0,645.04,d), Y+1.4403e3, 1);
222        ASSERT_TOL(helmholtz_s(273.15+125.17,356.70,d), Y+3.5463e3, 1);
223    
224        ASSERT_TOL(helmholtz_s(273.15+125.17,121.58,d), Y+4.5150e3, 1);
225        ASSERT_TOL(helmholtz_s(273.15+200,54.389,d), Y+5.5906e3, 1);
226        ASSERT_TOL(helmholtz_s(273.15+350,35.072,d), Y+6.4850e3, 1);
227        ASSERT_TOL(helmholtz_s(273.15+420,30.731,d), Y+6.8171e3, 1);
228    
229        fprintf(stderr,"s(T,rho) at p = 20 MPa\n");
230        ASSERT_TOL(helmholtz_s(273.15+-50,710.19,d), Y+0.52061e3, 1);
231        ASSERT_TOL(helmholtz_s(273.15+ 30,612.22,d), Y+1.8844e3, 1);
232        ASSERT_TOL(helmholtz_s(273.15+150,359.41,d), Y+3.7164e3, 1);
233        ASSERT_TOL(helmholtz_s(273.15+200,152.83,d), Y+4.8376e3, 1);
234        ASSERT_TOL(helmholtz_s(273.15+350,74.590,d), Y+6.0407e3, 1);
235        ASSERT_TOL(helmholtz_s(273.15+420,63.602,d), Y+6.4066e3, 1);
236    
237        fprintf(stderr,"s(T,rho) at p = 100 MPa\n");
238        ASSERT_TOL(helmholtz_s(273.15+  0,690.41,d), Y+1.2158e3, 1);
239        ASSERT_TOL(helmholtz_s(273.15+100,591.07,d), Y+2.5499e3, 1);
240        ASSERT_TOL(helmholtz_s(273.15+250,437.69,d), Y+4.0264e3, 1);
241        ASSERT_TOL(helmholtz_s(273.15+420,298.79,d), Y+5.2620e3, 1);
242    
243        /* successful entropy tests means that helm_ideal_tau, helm_real_tau, helm_ideal and helm_resid are all OK */
244    
245      fprintf(stderr,"Tests completed OK (maximum error = %0.2f%%)\n",maxerr);      fprintf(stderr,"Tests completed OK (maximum error = %0.2f%%)\n",maxerr);
246      exit(0);      exit(0);
247  }  }

Legend:
Removed from v.1834  
changed lines
  Added in v.1835

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