/[ascend]/trunk/models/johnpye/iapws95.a4c
ViewVC logotype

Diff of /trunk/models/johnpye/iapws95.a4c

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

revision 326 by johnpye, Fri Feb 24 00:41:08 2006 UTC revision 327 by johnpye, Fri Feb 24 02:04:49 2006 UTC
# Line 75  MODEL iapws95_1phase REFINES thermo_stat Line 75  MODEL iapws95_1phase REFINES thermo_stat
75      R "specific gas constant for water"      R "specific gas constant for water"
76          :== 0.46151805 {kJ/kg/K};          :== 0.46151805 {kJ/kg/K};
77            
78      tau = Tc / T;      z_tau: tau = Tc / T;
79      delta = rho / rhoc;      z_delta: delta = rho / rhoc;
80            
81            
82      range_0 IS_A set OF integer_constant;      range_0 IS_A set OF integer_constant;
# Line 261  MODEL iapws95_1phase REFINES thermo_stat Line 261  MODEL iapws95_1phase REFINES thermo_stat
261    
262      r3_b1[range_r3] IS_A factor;      r3_b1[range_r3] IS_A factor;
263      FOR i IN range_r3 CREATE      FOR i IN range_r3 CREATE
264          r3_b1[i] = -alpha[i]*d1^2 - beta[i]* (tau - gamma[i])^2;          z_r3_b1[i]: r3_b1[i] = -alpha[i]*d1^2 - beta[i]* (tau - gamma[i])^2;
265      END FOR;      END FOR;
266    
267      PSI[range_r4] IS_A factor;      PSI[range_r4] IS_A factor;
# Line 281  MODEL iapws95_1phase REFINES thermo_stat Line 281  MODEL iapws95_1phase REFINES thermo_stat
281      d2DELTAbi_ddeltadtau[range_r4] IS_A factor;      d2DELTAbi_ddeltadtau[range_r4] IS_A factor;
282    
283      FOR i IN range_r4 CREATE      FOR i IN range_r4 CREATE
284          PSI[i] = exp(-C[i]*d1^2 - D[i]*t1^2);          z_PSI[i]: PSI[i] = exp(-C[i]*d1^2 - D[i]*t1^2);
285          (*theta_expr:*) theta[i] =  1 - tau + A[i] * (d1^2)^( 1/(2 * beta_r4[i]) );          z_theta[i]: theta[i] =  1 - tau + A[i] * (d1^2)^( 1/(2 * beta_r4[i]) );
286          (*DELTA_expr:*) DELTA[i] = theta[i]^2 + B[i] * (d1^2)^a[i];          z_DELTA[i]: DELTA[i] = theta[i]^2 + B[i] * (d1^2)^a[i];
287    
288          (*dDELTA_ddelta_expr:*) dDELTA_ddelta[i] = d1*(A[i]*theta[i]*2/beta_r4[i]*          z_dDELTA_ddelta[i]: dDELTA_ddelta[i] = d1*(A[i]*theta[i]*2/beta_r4[i]*
289                  (d1^2)^(1/(2*beta_r4[i]) - 1) + 2*B[i]*a[i]*                  (d1^2)^(1/(2*beta_r4[i]) - 1) + 2*B[i]*a[i]*
290                  (d1^2)^(a[i] - 1) );                  (d1^2)^(a[i] - 1) );
291    
292          (*dPSI_ddelta_expr:*) dPSI_ddelta[i] = -2*C[i]*d1*PSI[i];          z_dPSI_ddelta[i]: dPSI_ddelta[i] = -2*C[i]*d1*PSI[i];
293    
294          (*dDELTAbi_ddelta_expr:*) dDELTAbi_ddelta[i] = b[i] * DELTA[i]^(b[i]-1) * dDELTA_ddelta[i];          z_dDELTAbi_ddelta[i]: dDELTAbi_ddelta[i] = b[i] * DELTA[i]^(b[i]-1) * dDELTA_ddelta[i];
295    
296          (*dDELTAbi_dtau_expr:*) dDELTAbi_dtau[i] = -2 * theta[i] * b[i] * DELTA[i]^(b[i]-1);          z_dDELTAbi_dtau[i]: dDELTAbi_dtau[i] = -2 * theta[i] * b[i] * DELTA[i]^(b[i]-1);
297          (*dPSI_dtau_expr:*) dPSI_dtau[i] = -2 * D[i] * t1 * PSI[i];          z_dPSI_dtau[i]: dPSI_dtau[i] = -2 * D[i] * t1 * PSI[i];
298    
299          (*d2PSI_ddelta2_expr:*) d2PSI_ddelta2[i] = (2 * C[i] * d1^2 - 1) * 2 * C[i] *  PSI[i];          z_d2PSI_ddelta2[i]: d2PSI_ddelta2[i] = (2 * C[i] * d1^2 - 1) * 2 * C[i] *  PSI[i];
300    
301          (*d2DELTA_ddelta2_expr:*) d2DELTA_ddelta2[i] = 1/d1*dDELTA_ddelta[i] + d1^2*(4*B[i]*a[i]*          z_d2DELTA_ddelta2[i]: d2DELTA_ddelta2[i] = 1/d1*dDELTA_ddelta[i] + d1^2*(4*B[i]*a[i]*
302                  (a[i]-1)*(d1^2)^(a[i]-2) + 2*A[i]^2*                  (a[i]-1)*(d1^2)^(a[i]-2) + 2*A[i]^2*
303                  (1/(beta_r4[i]^2))*((d1^2) ^ (1/(2*beta_r4[i])-1))^2) +                  (1/(beta_r4[i]^2))*((d1^2) ^ (1/(2*beta_r4[i])-1))^2) +
304                  A[i]*theta[i]*4/beta_r4[i]*(1/(2*beta_r4[i]) - 1)*                  A[i]*theta[i]*4/beta_r4[i]*(1/(2*beta_r4[i]) - 1)*
305                  (d1^2)^(1/(2*beta_r4[i]) - 2);                  (d1^2)^(1/(2*beta_r4[i]) - 2);
306            
307          (*d2DELTAbi_ddelta2_expr:*) d2DELTAbi_ddelta2[i] =b[i] * (          z_d2DELTAbi_ddelta2[i]: d2DELTAbi_ddelta2[i] =b[i] * (
308                  DELTA[i]^(b[i]-1) *d2DELTA_ddelta2[i]                  DELTA[i]^(b[i]-1) *d2DELTA_ddelta2[i]
309                   + (b[i]-1) * DELTA[i]^(b[i]-2) * dDELTA_ddelta[i]^2 );                   + (b[i]-1) * DELTA[i]^(b[i]-2) * dDELTA_ddelta[i]^2 );
310                    
311          (*d2DELTAbi_dtau2_expr:*) d2DELTAbi_dtau2[i] = 2 * b[i] * DELTA[i]^(b[i]-1) +          z_d2DELTAbi_dtau2[i]: d2DELTAbi_dtau2[i] = 2 * b[i] * DELTA[i]^(b[i]-1) +
312                  4 * theta[i]^2 * b[i]*(b[i]-1) * DELTA[i]^(b[i]-2);                  4 * theta[i]^2 * b[i]*(b[i]-1) * DELTA[i]^(b[i]-2);
313            
314          (*d2PSI_dtau2_expr:*) d2PSI_dtau2[i] = (2 * D[i] * t1^2 - 1) * 2 * D[i] * PSI[i];          z_d2PSI_dtau2[i]: d2PSI_dtau2[i] = (2 * D[i] * t1^2 - 1) * 2 * D[i] * PSI[i];
315    
316          (*d2PSI_ddeltadtau_expr:*) d2PSI_ddeltadtau[i] = 4 * C[i] * D[i] * d1 * t1 * PSI[i];          z_d2PSI_ddeltadtau[i]: d2PSI_ddeltadtau[i] = 4 * C[i] * D[i] * d1 * t1 * PSI[i];
317            
318          (*d2DELTAbi_ddeltadtau_expr:*) d2DELTAbi_ddeltadtau[i] =          z_d2DELTAbi_ddeltadtau[i]: d2DELTAbi_ddeltadtau[i] =
319                  - A[i] * b[i]* (2/beta_r4[i]) * DELTA[i]^(b[i]-1) * d1 * (d1^2)^(1/(2*beta_r4[i])-1)                  - A[i] * b[i]* (2/beta_r4[i]) * DELTA[i]^(b[i]-1) * d1 * (d1^2)^(1/(2*beta_r4[i])-1)
320                  - 2 * theta[i] * b[i] *(b[i]-1) * DELTA[i]^(b[i]-2) * dDELTA_ddelta[i];                  - 2 * theta[i] * b[i] *(b[i]-1) * DELTA[i]^(b[i]-2) * dDELTA_ddelta[i];
321    
# Line 323  MODEL iapws95_1phase REFINES thermo_stat Line 323  MODEL iapws95_1phase REFINES thermo_stat
323    
324      phir_r2[range_r2] IS_A factor;      phir_r2[range_r2] IS_A factor;
325      FOR i IN range_r2 CREATE      FOR i IN range_r2 CREATE
326          phir_r2[i] = n[i] * delta^d[i] * tau^t[i] *          z_phir_r2[i]: phir_r2[i] = n[i] * delta^d[i] * tau^t[i] *
327                      exp(-delta^c[i]);                      exp(-delta^c[i]);
328      END FOR;      END FOR;
329    
# Line 341  MODEL iapws95_1phase REFINES thermo_stat Line 341  MODEL iapws95_1phase REFINES thermo_stat
341    
342      phirdelta_r2[range_r2] IS_A factor;      phirdelta_r2[range_r2] IS_A factor;
343      FOR i IN range_r2 CREATE      FOR i IN range_r2 CREATE
344          phirdelta_r2[i] = n[i] * exp(-delta^c[i]) * (delta^(d[i]-1) *          z_phirdelta_r2[i]: phirdelta_r2[i] = n[i] * exp(-delta^c[i]) * (delta^(d[i]-1) *
345                     tau^t[i] * (d[i] - c[i] * delta^c[i]) );                     tau^t[i] * (d[i] - c[i] * delta^c[i]) );
346      END FOR;      END FOR;
347    
# Line 357  MODEL iapws95_1phase REFINES thermo_stat Line 357  MODEL iapws95_1phase REFINES thermo_stat
357    
358      phirtau_r2[range_r2] IS_A factor;      phirtau_r2[range_r2] IS_A factor;
359      FOR i IN range_r2 CREATE      FOR i IN range_r2 CREATE
360          phirtau_r2[i] = n[i]*t[i]*delta^d[i]*tau^(t[i]-1) * exp(-delta^c[i]);          z_phirtau_r2[i]: phirtau_r2[i] = n[i]*t[i]*delta^d[i]*tau^(t[i]-1) * exp(-delta^c[i]);
361      END FOR;      END FOR;
362    
363      phirtau IS_A factor;      phirtau IS_A factor;
# Line 371  MODEL iapws95_1phase REFINES thermo_stat Line 371  MODEL iapws95_1phase REFINES thermo_stat
371    
372      phirdeltadelta_r2[range_r2] IS_A factor;      phirdeltadelta_r2[range_r2] IS_A factor;
373      FOR i IN range_r2 CREATE      FOR i IN range_r2 CREATE
374          phirdeltadelta_r2[i] =          z_phirdeltadelta_r2[i]: phirdeltadelta_r2[i] =
375              n[i] * exp(-delta^c[i]) * (              n[i] * exp(-delta^c[i]) * (
376                      delta^(d[i]-2) *                      delta^(d[i]-2) *
377                      tau^t[i] * (                      tau^t[i] * (
# Line 402  MODEL iapws95_1phase REFINES thermo_stat Line 402  MODEL iapws95_1phase REFINES thermo_stat
402    
403      phirtautau_r2[range_r2] IS_A factor;      phirtautau_r2[range_r2] IS_A factor;
404      FOR i IN range_r2 CREATE      FOR i IN range_r2 CREATE
405          phirtautau_r2[i] = n[i]*t[i]*(t[i]-1)* delta^d[i] *          z_phirtautau_r2[i]: phirtautau_r2[i] = n[i]*t[i]*(t[i]-1)* delta^d[i] *
406                      tau^(t[i]-2) * exp(- delta^c[i] );                      tau^(t[i]-2) * exp(- delta^c[i] );
407      END FOR;      END FOR;
408    
# Line 421  MODEL iapws95_1phase REFINES thermo_stat Line 421  MODEL iapws95_1phase REFINES thermo_stat
421    
422      phirdeltatau_r2[range_r2] IS_A factor;      phirdeltatau_r2[range_r2] IS_A factor;
423      FOR i IN range_r2 CREATE          FOR i IN range_r2 CREATE    
424          phirdeltatau_r2[i] =          z_phirdeltatau_r2[i]: phirdeltatau_r2[i] =
425              n[i]*t[i] * delta^(d[i]-1) * tau^(t[i]-1)              n[i]*t[i] * delta^(d[i]-1) * tau^(t[i]-1)
426              * (d[i] - c[i] * delta^c[i]) * exp(-delta^c[i]);              * (d[i] - c[i] * delta^c[i]) * exp(-delta^c[i]);
427      END FOR;      END FOR;
# Line 441  MODEL iapws95_1phase REFINES thermo_stat Line 441  MODEL iapws95_1phase REFINES thermo_stat
441    
442      (*--------- THERMO PROPERTY RELATIONS ----------- *)      (*--------- THERMO PROPERTY RELATIONS ----------- *)
443    
444      pressure: p      za_pressure: p
445          = rho * R * T * (1 + delta*phirdelta);          = rho * R * T * (1 + delta*phirdelta);
446    
447      internal_energy: u      za_internal_energy: u
448          = R * T * tau * (phi0tau + phirtau);          = R * T * tau * (phi0tau + phirtau);
449    
450      enthalpy: h      za_enthalpy: h
451          = R * T * (1 + tau*(phi0tau + phirtau) + delta*phirdelta);          = R * T * (1 + tau*(phi0tau + phirtau) + delta*phirdelta);
452    
453      entropy: s      za_entropy: s
454          = R * (tau*(phi0tau + phirtau) - phi0 - phir);          = R * (tau*(phi0tau + phirtau) - phi0 - phir);
455    
456      c_isochoric: cv      za_c_isochoric: cv
457          = - R * tau^2 * (phi0tautau + phirtautau);          = - R * tau^2 * (phi0tautau + phirtautau);
458    
459      c_isobaric: cp      za_c_isobaric: cp
460          = - R * (          = - R * (
461                tau^2 * (phi0tautau + phirtautau)                tau^2 * (phi0tautau + phirtautau)
462                +  ( ( 1 + delta*phirdelta - delta*tau*phirdeltatau )^2 )                +  ( ( 1 + delta*phirdelta - delta*tau*phirdeltatau )^2 )
# Line 472  MODEL iapws95_1phase REFINES thermo_stat Line 472  MODEL iapws95_1phase REFINES thermo_stat
472    
473  METHODS  METHODS
474  METHOD default_self;  METHOD default_self;
475      RUN ClearAll;      RUN reset;
     RUN specify;  
476      RUN values;      RUN values;
477  END default_self;  END default_self;
478    
# Line 552  METHOD default_self; Line 551  METHOD default_self;
551      RUN reset;      RUN reset;
552      RUN values;      RUN values;
553      Sl.rho := 800 {kg/m^3};      Sl.rho := 800 {kg/m^3};
554        Sl.delta := 2.48;
555        Sl.d1 := 1.48;
556        Sv.delta := 0.012;
557        Sv.d1 := -0.987;
558        RUN scale_self;
559        RUN bound_self;
560  END default_self;  END default_self;
561    
562  METHOD specify;  METHOD specify;
# Line 562  METHOD values; Line 567  METHOD values;
567      T := 390 {K};      T := 390 {K};
568      x := 0.5;      x := 0.5;
569  END values;  END values;
570    
571    METHOD scale_self;
572        Sl.rho.nominal := 800 {kg/m^3};
573        Sv.rho.nominal := 1 {kg/m^3};
574    END scale_self;
575    
576    METHOD bound_self;
577        (*Sl.tau.lower_bound := 1; *)(* T = T_c *)
578        (*Sl.tau.upper_bound :=  2.3690133; *)(* T = 273.15 *)
579            
580        Sl.d1.lower_bound := -1;
581        Sv.d1.lower_bound := -1;
582    END bound_self;
583    
584  END iapws95_2phase;      END iapws95_2phase;    
585    
586    
# Line 576  METHOD values; Line 594  METHOD values;
594      p := 10 {bar};      p := 10 {bar};
595      h := 2998 {kJ/kg};      h := 2998 {kJ/kg};
596  END values;  END values;
597        
598  METHOD self_test;  METHOD self_test;
599      ASSERT abs(T - 548.15 {K}) < 1 {K};      ASSERT abs(T - 548.15 {K}) < 1 {K};
600      ASSERT abs(rho - 8.43 {kg/m^3}) < 0.2 {kg/m^3};      ASSERT abs(rho - 8.43 {kg/m^3}) < 0.2 {kg/m^3};
601  END self_test;  END self_test;
602        
603  END iapws95_2phase_ph_test;  END iapws95_2phase_ph_test;
604    
605  MODEL iapws95_2phase_ph_test2 REFINES iapws95_2phase;  MODEL iapws95_2phase_ph_test2 REFINES iapws95_2phase;
# Line 598  METHOD self_test; Line 617  METHOD self_test;
617      ASSERT abs(rho - 959 {kg/m^3}) < 3 {kg/m^3};      ASSERT abs(rho - 959 {kg/m^3}) < 3 {kg/m^3};
618  END self_test;  END self_test;
619    
620  END iapws95_2phase_ph_test;  END iapws95_2phase_ph_test2;
621    
622    (*
623        This last model *will* converge with careful coaxing
624        You need to alternate between ROW2NORM scaling
625        and RELNOM scaling using the QRSlv engine.
626        Some tweaking of delta/d1 values may be necessary as
627        well.
628    *)
629    MODEL iapws95_2phase_ph_test3 REFINES iapws95_1phase;
630    
631    METHODS
632    METHOD specify;
633        FIX p,h;
634    END specify;
635    METHOD values;
636        p := 1 {bar};
637        h := 104.9 {kJ/kg};
638        (* free vars *)
639        delta := 3;
640        d1 := 2;
641        rho := 900;
642    END values;
643    METHOD self_test;
644        ASSERT abs(T - 298.15 {K}) < 1 {K};
645        ASSERT abs(rho - 997 {kg/m^3}) < 3 {kg/m^3};
646    END self_test;
647    
648    END iapws95_2phase_ph_test3;
649    

Legend:
Removed from v.326  
changed lines
  Added in v.327

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