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

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

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

revision 1840 by jpye, Thu Aug 28 09:20:11 2008 UTC revision 1841 by jpye, Fri Aug 29 07:27:59 2008 UTC
# Line 24  const IdealData ideal_data_nitrogen = { Line 24  const IdealData ideal_data_nitrogen = {
24      }      }
25  };  };
26    
27    /*
28        this correlation is given in molar terms. we convert to mass
29        basis by changing the scaling density rho_star, and the ideal gas constant.
30    */
31    #define M_NITROGEN 28.01348
32  const HelmholtzData helmholtz_data_nitrogen = {  const HelmholtzData helmholtz_data_nitrogen = {
33      /* R */ 8.31451e3 / 28.01348 /* kJ/kmolK / kg/kmol = kJ/kgK */      /* R */ 1e3 * 8.31451 / M_NITROGEN /* 1000 * kJ/kmolK / kg/kmol = J/kgK */
34      , /* M */ 28.01348 /* kg/kmol */      , /* M */ M_NITROGEN /* kg/kmol */
35      , /* rho_star */ 11.1839 * 28.01348 /* kmol/m3 * kg/kmol = kg/m³ (= rho_c for this model) */      , /* rho_star */ 11.1839 * M_NITROGEN /* kmol/m3 * kg/kmol = kg/m³ (= rho_c for this model) */
36      , /* T_star */ 126.192 /* K (= T_c for this model) */      , /* T_star */ 126.192 /* K (= T_c for this model) */
37      , &ideal_data_nitrogen      , &ideal_data_nitrogen
38      , 21 /* np */      , 32 /* np */
39      , (const HelmholtzPowTerm[]){      , (const HelmholtzPowTerm[]){
40          /* a_i, t_i, d_i, l_i */          /* a_i, t_i, d_i, l_i */
41          { 0.924803575275,      0.25,    1,  0}          { 0.924803575275,      0.25,    1,  0}/* 1 */
42          ,{-0.492448489428,     0.875,   1,  0}          ,{-0.492448489428,     0.875,   1,  0}
43          ,{ 0.661883336938,     0.5,     2,  0}          ,{ 0.661883336938,     0.5,     2,  0}
44          ,{-0.192902649201E1,   0.875,   2,  0}          ,{-0.192902649201E1,   0.875,   2,  0}
# Line 42  const HelmholtzData helmholtz_data_nitro Line 47  const HelmholtzData helmholtz_data_nitro
47          ,{ 0.564857472498,     0.5,     1,  1}          ,{ 0.564857472498,     0.5,     1,  1}
48          ,{-0.161720005987E1,   0.75,    1,  1}          ,{-0.161720005987E1,   0.75,    1,  1}
49          ,{-0.481395031883,     2.,      1,  1}          ,{-0.481395031883,     2.,      1,  1}
50          ,{ 0.421150636384,     1.25,    3,  1}          ,{ 0.421150636384,     1.25,    3,  1}/* 10 */
51          ,{-0.161962230825E-1,  3.5,     3,  1}          ,{-0.161962230825E-1,  3.5,     3,  1}
52          ,{ 0.172100994165,     1.,      4,  1}          ,{ 0.172100994165,     1.,      4,  1}
53          ,{ 0.735448924933E-2,  0.5,     6,  1}          ,{ 0.735448924933E-2,  0.5,     6,  1}
# Line 52  const HelmholtzData helmholtz_data_nitro Line 57  const HelmholtzData helmholtz_data_nitro
57          ,{ 0.635466899859E-3,  0.75,    8,  1}          ,{ 0.635466899859E-3,  0.75,    8,  1}
58          ,{ 0.304432279419E-2,  2.5,     8,  1}          ,{ 0.304432279419E-2,  2.5,     8,  1}
59          ,{-0.435762336045E-1,  4.,      1,  2}          ,{-0.435762336045E-1,  4.,      1,  2}
60          ,{-0.723174889316E-1,  6. ,     2,  2}          ,{-0.723174889316E-1,  6. ,     2,  2}/* 20 */
61          ,{ 0.389644315272E-1,  6.,      3,  2}          ,{ 0.389644315272E-1,  6.,      3,  2}
62          ,{-0.212201363910E-1,  3.,      4,  2}          ,{-0.212201363910E-1,  3.,      4,  2}
63          ,{ 0.408822981509E-2,  3.,      5,  2}          ,{ 0.408822981509E-2,  3.,      5,  2}
# Line 65  const HelmholtzData helmholtz_data_nitro Line 70  const HelmholtzData helmholtz_data_nitro
70          ,{-0.441513370350E-2,  7.,      5,  4}          ,{-0.441513370350E-2,  7.,      5,  4}
71          ,{ 0.133722924858E-2,  4.,      6,  4}          ,{ 0.133722924858E-2,  4.,      6,  4}
72          ,{ 0.264832491957E-3, 16.,      9,  4}          ,{ 0.264832491957E-3, 16.,      9,  4}
         /* more terms here still to come */  
73      }      }
74      , 4 /* ne */      , 4 /* ne */
75      , (const HelmholtzExpTerm[]){      , (const HelmholtzExpTerm[]){
# Line 130  int main(void){ Line 134  int main(void){
134      unsigned i;      unsigned i;
135      const unsigned n = ntd;      const unsigned n = ntd;
136    
137    #if 0
138      fprintf(stderr,"Testing sample values from the Span paper...\n");      fprintf(stderr,"Testing sample values from the Span paper...\n");
139    
140      rho = 11.0 * d->M; T = 270;      rho = 10.993 * d->M; T = 270.;
141      p = helmholtz_p(T, rho, d);      p = helmholtz_p(T, rho, d);
142      fprintf(stderr,"p = %f\n", p);      fprintf(stderr,"p = %f\n", p);
143      assert(fabs(p - 27.0621e6) < 50e3);      assert(fabs(p - 27.0621e6) < 5e3);
144        fprintf(stderr,"OK 1\n");
145    
146      rho = 11.2 * d->M; T = 126.2;      rho = 11.2 * d->M; T = 126.2;
147      p = helmholtz_p(T, rho, d);      p = helmholtz_p(T, rho, d);
148      fprintf(stderr,"p = %f\n", p);      fprintf(stderr,"p = %f\n", p);
149      assert(fabs(p - 3.39712e6) < 50e3);      assert(fabs(p - 3.39712e6) < 50e3);
150        fprintf(stderr,"OK 2\n");
151    #endif
152    
153      fprintf(stderr,"Running through %d test points...\n",n);      fprintf(stderr,"Running through %d test points...\n",n);
154    
155      fprintf(stderr,"PRESSURE TESTS\n");      fprintf(stderr,"PRESSURE TESTS\n");
156      for(i=0; i<n;++i){      for(i=0; i<n;++i){
157          ASSERT_TOL(helmholtz_p, td[i].T+273.15, td[i].rho, d, td[i].p*1e6, 1E3);          T = td[i].T+273.15;
158            p = td[i].p*1e6;
159            rho = td[i].rho;
160            ASSERT_TOL(helmholtz_p, T, rho, d, p, p*0.001);
161      }      }
162    
163      /* offset required to attain agreement with REFPROP */      /* offset required to attain agreement with REFPROP */
# Line 169  int main(void){ Line 180  int main(void){
180      exit(0);      exit(0);
181  }  }
182    
   
   
183  const TestData td[] = {  const TestData td[] = {
184  /*  /*
185        samples point from Span et al, as calculated by REFPROP 7.0
186    */
187    #if 1
188        {-3.15E+0, 2.706209546E+1, 3.0814828E+2, 1.448502895E+2, 2.326719559E+2}
189        , {-1.4695E+2, 3.397116495E+0, 3.13750976E+2, 1.832925675E+1, 2.9156686E+1}
190    /*
191      A small set of data points calculated using REFPROP 7.0, for validation      A small set of data points calculated using REFPROP 7.0, for validation
192  */  */
193      {-200.00000, 0.10000000, 824.94146, -130.56454, 2.7206049}      ,
194      , {-195.90650, 0.10000000, 806.59036, -122.24684, 2.8312405}  #endif
195      , {-195.90650, 0.10000000, 4.5564811, 77.072848, 5.4116477}      {-2.00E+2, 1.E-1, 8.249414592E+2, -1.305645426E+2, 2.720604877E+0}
196      , {-150.00000, 0.10000000, 2.7651079, 126.49637, 5.9149401}      , {-1.959064992E+2, 1.E-1, 8.065903588E+2, -1.22246837E+2, 2.83124055E+0}
197      , {-100.00000, 0.10000000, 1.9528859, 178.96289, 6.2726011}      , {-1.959064992E+2, 1.E-1, 4.556481103E+0, 7.7072848E+1, 5.41164774E+0}
198      , {-50.000000, 0.10000000, 1.5119231, 231.14631, 6.5373809}      , {-1.50E+2, 1.E-1, 2.765107908E+0, 1.264963652E+2, 5.914940099E+0}
199      , {0.00000000, 0.10000000, 1.2340278, 283.23654, 6.7480133}      , {-1.00E+2, 1.E-1, 1.952885853E+0, 1.789628879E+2, 6.272601137E+0}
200      , {50.000000, 0.10000000, 1.0426377, 335.30559, 6.9230643}      , {-5.0E+1, 1.E-1, 1.511923126E+0, 2.31146308E+2, 6.537380868E+0}
201      , {100.00000, 0.10000000, 0.90273132, 387.42000, 7.0730090}      , {0.E+0, 1.E-1, 1.234027837E+0, 2.832365424E+2, 6.74801325E+0}
202      , {150.00000, 0.10000000, 0.79597134, 439.66508, 7.2043968}      , {5.0E+1, 1.E-1, 1.042637745E+0, 3.353055943E+2, 6.923064311E+0}
203      , {200.00000, 0.10000000, 0.71181434, 492.14150, 7.3216082}      , {1.00E+2, 1.E-1, 9.027313243E-1, 3.874200009E+2, 7.073009026E+0}
204      , {250.00000, 0.10000000, 0.64376369, 544.95214, 7.4277045}      , {1.50E+2, 1.E-1, 7.959713424E-1, 4.396650845E+2, 7.204396773E+0}
205      , {300.00000, 0.10000000, 0.58759653, 598.18966, 7.5248876}      , {2.00E+2, 1.E-1, 7.118143393E-1, 4.921414969E+2, 7.321608221E+0}
206      , {350.00000, 0.10000000, 0.54044842, 651.92860, 7.6147756}      , {2.50E+2, 1.E-1, 6.437636895E-1, 5.44952141E+2, 7.427704455E+0}
207      , {400.00000, 0.10000000, 0.50030750, 706.22257, 7.6985791}      , {3.00E+2, 1.E-1, 5.875965268E-1, 5.98189656E+2, 7.524887552E+0}
208      , {450.00000, 0.10000000, 0.46571913, 761.10483, 7.7772186}      , {3.50E+2, 1.E-1, 5.404484175E-1, 6.519286035E+2, 7.614775644E+0}
209      , {500.00000, 0.10000000, 0.43560536, 816.59095, 7.8514061}      , {4.00E+2, 1.E-1, 5.003075032E-1, 7.062225739E+2, 7.698579114E+0}
210      , {550.00000, 0.10000000, 0.40915040, 872.68219, 7.9217018}      , {-2.00E+2, 1.E+0, 8.269722658E+2, -1.298970049E+2, 2.714834497E+0}
211      , {600.00000, 0.10000000, 0.38572547, 929.36893, 7.9885535}      , {-1.694030878E+2, 1.E+0, 6.658282477E+2, -6.432677729E+1, 3.460052635E+0}
212      , {650.00000, 0.10000000, 0.36483807, 986.63370, 8.0523256}      , {-1.694030878E+2, 1.E+0, 4.133110398E+1, 8.773400698E+1, 4.92574237E+0}
213      , {700.00000, 0.10000000, 0.34609700, 1044.4538, 8.1133192}      , {-1.50E+2, 1.E+0, 3.089966568E+1, 1.149820382E+2, 5.167381911E+0}
214      , {750.00000, 0.10000000, 0.32918753, 1102.8031, 8.1717867}      , {-1.00E+2, 1.E+0, 2.018992668E+1, 1.731651404E+2, 5.565357304E+0}
215      , {800.00000, 0.10000000, 0.31385363, 1161.6539, 8.2279428}      , {-5.0E+1, 1.E+0, 1.530392626E+1, 2.275480773E+2, 5.841465649E+0}
216      , {850.00000, 0.10000000, 0.29988486, 1220.9778, 8.2819723}      , {0.E+0, 1.E+0, 1.238752228E+1, 2.808281272E+2, 6.056951203E+0}
217      , {900.00000, 0.10000000, 0.28710667, 1280.7465, 8.3340357}      , {5.0E+1, 1.E+0, 1.042615666E+1, 3.336448972E+2, 6.23453053E+0}
218      , {950.00000, 0.10000000, 0.27537304, 1340.9326, 8.3842743}      , {1.00E+2, 1.E+0, 9.009743348E+0, 3.862721678E+2, 6.385956969E+0}
219      , {1000.0000, 0.10000000, 0.26456092, 1401.5096, 8.4328132}      , {1.50E+2, 1.E+0, 7.936266563E+0, 4.38890073E+2, 6.518285235E+0}
220      , {-200.00000, 1.0000000, 826.97227, -129.89700, 2.7148345}      , {2.00E+2, 1.E+0, 7.093503539E+0, 4.916490203E+2, 6.636129311E+0}
221      , {-169.40309, 1.0000000, 665.82825, -64.326777, 3.4600526}      , {2.50E+2, 1.E+0, 6.413750916E+0, 5.44680595E+2, 6.742670284E+0}
222      , {-169.40309, 1.0000000, 41.331104, 87.734007, 4.9257424}      , {3.00E+2, 1.E+0, 5.853600946E+0, 5.980951517E+2, 6.840177103E+0}
223      , {-150.00000, 1.0000000, 30.899666, 114.98204, 5.1673819}      , {3.50E+2, 1.E+0, 5.383882193E+0, 6.519787885E+2, 6.930307557E+0}
224      , {-100.00000, 1.0000000, 20.189927, 173.16514, 5.5653573}      , {4.00E+2, 1.E+0, 4.984238815E+0, 7.063929319E+2, 7.014296741E+0}
225      , {-50.000000, 1.0000000, 15.303926, 227.54808, 5.8414656}      , {-2.00E+2, 1.E+1, 8.452673172E+2, -1.229850766E+2, 2.662217387E+0}
226      , {0.00000000, 1.0000000, 12.387522, 280.82813, 6.0569512}      , {-1.50E+2, 1.E+1, 6.146317008E+2, -2.075504269E+1, 3.721059545E+0}
227      , {50.000000, 1.0000000, 10.426157, 333.64490, 6.2345305}      , {-1.00E+2, 1.0E+1, 2.740868419E+2, 1.083371836E+2, 4.599930836E+0}
228      , {100.00000, 1.0000000, 9.0097433, 386.27217, 6.3859570}      , {-5.0E+1, 1.0E+1, 1.656973184E+2, 1.934337283E+2, 5.035617646E+0}
229      , {150.00000, 1.0000000, 7.9362666, 438.89007, 6.5182852}      , {0.E+0, 1.0E+1, 1.252477529E+2, 2.592718885E+2, 5.302448665E+0}
230      , {200.00000, 1.0000000, 7.0935035, 491.64902, 6.6361293}      , {5.0E+1, 1.E+1, 1.024973378E+2, 3.19262156E+2, 5.504302349E+0}
231      , {250.00000, 1.0000000, 6.4137509, 544.68060, 6.7426703}      , {1.00E+2, 1.E+1, 8.742785901E+1, 3.766273279E+2, 5.66942089E+0}
232      , {300.00000, 1.0000000, 5.8536009, 598.09515, 6.8401771}      , {1.50E+2, 1.0E+1, 7.653447744E+1, 4.326358439E+2, 5.8103035E+0}
233      , {350.00000, 1.0000000, 5.3838822, 651.97879, 6.9303076}      , {2.00E+2, 1.0E+1, 6.821629197E+1, 4.879492416E+2, 5.933867436E+0}
234      , {400.00000, 1.0000000, 4.9842388, 706.39293, 7.0142967}      , {2.50E+2, 1.0E+1, 6.16196599E+1, 5.429759984E+2, 6.044424746E+0}
235      , {450.00000, 1.0000000, 4.6400213, 761.37636, 7.0930813}      , {3.00E+2, 1.0E+1, 5.624066686E+1, 5.979913509E+2, 6.144858594E+0}
236      , {500.00000, 1.0000000, 4.3404109, 816.94862, 7.1673842}      , {3.50E+2, 1.0E+1, 5.175958526E+1, 6.531864458E+2, 6.237185757E+0}
237      , {550.00000, 1.0000000, 4.0772408, 873.11393, 7.2377727}      , {4.00E+2, 1.0E+1, 4.796230162E+1, 7.086931308E+2, 6.32286331E+0}
238      , {600.00000, 1.0000000, 3.8442281, 929.86491, 7.3047002}      , {-1.50E+2, 1.00E+2, 8.420363237E+2, 3.92374019E+1, 3.242503691E+0}
239      , {650.00000, 1.0000000, 3.6364590, 987.18580, 7.3685349}      , {-1.00E+2, 1.00E+2, 7.480840694E+2, 1.189018852E+2, 3.7864991E+0}
240      , {700.00000, 1.0000000, 3.4500344, 1045.0552, 7.4295806}      , {-5.0E+1, 1.00E+2, 6.686218021E+2, 1.936838079E+2, 4.166379675E+0}
241      , {750.00000, 1.0000000, 3.2818204, 1103.4482, 7.4880919}      , {0.E+0, 1.00E+2, 6.020019153E+2, 2.646716357E+2, 4.453651157E+0}
242      , {800.00000, 1.0000000, 3.1292688, 1162.3378, 7.5442851}      , {5.0E+1, 1.00E+2, 5.463770513E+2, 3.326365504E+2, 4.682270323E+0}
243      , {850.00000, 1.0000000, 2.9902865, 1221.6964, 7.5983461}      , {1.00E+2, 1.00E+2, 4.998628485E+2, 3.981897474E+2, 4.870958715E+0}
244      , {900.00000, 1.0000000, 2.8631379, 1281.4962, 7.6504366}      , {1.50E+2, 1.00E+2, 4.607196175E+2, 4.618644601E+2, 5.031138876E+0}
245      , {950.00000, 1.0000000, 2.7463717, 1341.7103, 7.7006986}      , {2.00E+2, 1.00E+2, 4.274764375E+2, 5.241299871E+2, 5.170247187E+0}
246      , {1000.0000, 1.0000000, 2.6387646, 1402.3126, 7.7492578}      , {2.50E+2, 1.00E+2, 3.989550654E+2, 5.853873016E+2, 5.293334174E+0}
247      , {-200.00000, 10.000000, 845.26732, -122.98508, 2.6622174}      , {3.00E+2, 1.00E+2, 3.742353905E+2, 6.459672171E+2, 5.40393536E+0}
248      , {-150.00000, 10.000000, 614.63170, -20.755043, 3.7210595}      , {3.50E+2, 1.00E+2, 3.526046985E+2, 7.061338065E+2, 5.504585302E+0}
249      , {-100.00000, 10.000000, 274.08684, 108.33718, 4.5999308}      , {4.00E+2, 1.00E+2, 3.335102049E+2, 7.660915686E+2, 5.597138445E+0}
     , {-50.000000, 10.000000, 165.69732, 193.43373, 5.0356176}  
     , {0.00000000, 10.000000, 125.24775, 259.27189, 5.3024487}  
     , {50.000000, 10.000000, 102.49734, 319.26216, 5.5043023}  
     , {100.00000, 10.000000, 87.427859, 376.62733, 5.6694209}  
     , {150.00000, 10.000000, 76.534477, 432.63584, 5.8103035}  
     , {200.00000, 10.000000, 68.216292, 487.94924, 5.9338674}  
     , {250.00000, 10.000000, 61.619660, 542.97600, 6.0444247}  
     , {300.00000, 10.000000, 56.240667, 597.99135, 6.1448586}  
     , {350.00000, 10.000000, 51.759585, 653.18645, 6.2371858}  
     , {400.00000, 10.000000, 47.962302, 708.69313, 6.3228633}  
     , {450.00000, 10.000000, 44.699287, 764.59931, 6.4029715}  
     , {500.00000, 10.000000, 41.862548, 820.95992, 6.4783293}  
     , {550.00000, 10.000000, 39.371915, 877.80536, 6.5495709}  
     , {600.00000, 10.000000, 37.166488, 935.14803, 6.6171967}  
     , {650.00000, 10.000000, 35.199092, 992.98747, 6.6816092}  
     , {700.00000, 10.000000, 33.432569, 1051.3142, 6.7431376}  
     , {750.00000, 10.000000, 31.837217, 1110.1129, 6.8020556}  
     , {800.00000, 10.000000, 30.388987, 1169.3641, 6.8585940}  
     , {850.00000, 10.000000, 29.068188, 1229.0464, 6.9129500}  
     , {900.00000, 10.000000, 27.858530, 1289.1373, 6.9652942}  
     , {950.00000, 10.000000, 26.746414, 1349.6141, 7.0157755}  
     , {1000.0000, 10.000000, 25.720391, 1410.4542, 7.0645253}  
     , {-150.00000, 100.00000, 842.03632, 39.237402, 3.2425037}  
     , {-100.00000, 100.00000, 748.08407, 118.90189, 3.7864991}  
     , {-50.000000, 100.00000, 668.62180, 193.68381, 4.1663797}  
     , {0.00000000, 100.00000, 602.00192, 264.67164, 4.4536512}  
     , {50.000000, 100.00000, 546.37705, 332.63655, 4.6822703}  
     , {100.00000, 100.00000, 499.86285, 398.18975, 4.8709587}  
     , {150.00000, 100.00000, 460.71962, 461.86446, 5.0311389}  
     , {200.00000, 100.00000, 427.47644, 524.12999, 5.1702472}  
     , {250.00000, 100.00000, 398.95507, 585.38730, 5.2933342}  
     , {300.00000, 100.00000, 374.23539, 645.96722, 5.4039354}  
     , {350.00000, 100.00000, 352.60470, 706.13381, 5.5045853}  
     , {400.00000, 100.00000, 333.51020, 766.09157, 5.5971384}  
     , {450.00000, 100.00000, 316.52039, 825.99447, 5.6829774}  
     , {500.00000, 100.00000, 301.29531, 885.95525, 5.7631519}  
     , {550.00000, 100.00000, 287.56440, 946.05406, 5.8384731}  
     , {600.00000, 100.00000, 275.11003, 1006.3459, 5.9095787}  
     , {650.00000, 100.00000, 263.75533, 1066.8665, 5.9769785}  
     , {700.00000, 100.00000, 253.35515, 1127.6376, 6.0410866}  
     , {750.00000, 100.00000, 243.78927, 1188.6704, 6.1022442}  
     , {800.00000, 100.00000, 234.95724, 1249.9686, 6.1607365}  
     , {850.00000, 100.00000, 226.77444, 1311.5305, 6.2168049}  
     , {900.00000, 100.00000, 219.16910, 1373.3507, 6.2706560}  
     , {950.00000, 100.00000, 212.07988, 1435.4217, 6.3224685}  
     , {1000.0000, 100.00000, 205.45406, 1497.7339, 6.3723982}  
250  };  };
251    
252  const unsigned ntd = sizeof(td)/sizeof(TestData);  const unsigned ntd = sizeof(td)/sizeof(TestData);

Legend:
Removed from v.1840  
changed lines
  Added in v.1841

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