Changeset 712

Show
Ignore:
Timestamp:
10/16/2007 05:21:34 PM (15 months ago)
Author:
kproelss
Message:

fixed small bugs in entropy functions for ideal gas mixtures

Location:
Modelica/trunk/Modelica/Media
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • Modelica/trunk/Modelica/Media/Air.mo

    r704 r712  
    9393    constant IdealGases.Common.DataRecord dryair = IdealGases.Common.SingleGasesData.Air; 
    9494    constant IdealGases.Common.DataRecord steam = IdealGases.Common.SingleGasesData.H2O; 
     95    constant SI.MolarMass[2] MMX = {steam.MM,dryair.MM}  
     96      "Molar masses of components"; 
    9597     
    9698    import Modelica.Media.Interfaces; 
     
    124126       
    125127    protected  
    126       constant SI.MolarMass[2] MMX = {steam.MM,dryair.MM}  
    127         "Molar masses of components"; 
    128        
    129128      MassFraction X_liquid "Mass fraction of liquid or solid water"; 
    130129      MassFraction X_steam "Mass fraction of steam water"; 
     
    816815Specific entropy is calculated from the thermodynamic state record, assuming ideal gas behavior and including entropy of mixing. Liquid or solid water is not taken into account, the entire water content X[1] is assumed to be in the vapor state (relative humidity below 1.0). 
    817816</html>")); 
     817       
    818818    protected  
    819      MoleFraction[2] Y = massToMoleFractions(state.X,{steam.MM,dryair.MM})  
     819      MoleFraction[2] Y = massToMoleFractions(state.X,{steam.MM,dryair.MM})  
    820820        "molar fraction"; 
    821821   algorithm  
    822      s := SingleGasNasa.s0_Tlow(dryair, state.T)*(1-state.X[Water]) 
     822     s:=SingleGasNasa.s0_Tlow(dryair, state.T)*(1-state.X[Water]) 
    823823       + SingleGasNasa.s0_Tlow(steam, state.T)*state.X[Water] 
    824        - gasConstant(state)*Modelica.Math.log(state.p/reference_p) 
    825        + sum(if Y[i] > Modelica.Constants.eps then -Y[i]*Modelica.Math.log(Y[i]) else  
    826                    Y[i] for i in 1:size(Y,1)); 
     824       - (state.X[Water]*Modelica.Constants.R/MMX[Water]*(if state.X[Water]<Modelica.Constants.eps then state.X[Water] else Modelica.Math.log(Y[Water]*state.p/reference_p)) 
     825         + (1-state.X[Water])*Modelica.Constants.R/MMX[Air]*(if (1-state.X[Water])<Modelica.Constants.eps then (1-state.X[Water]) else Modelica.Math.log(Y[Air]*state.p/reference_p))); 
    827826   end specificEntropy; 
    828827     
     
    10501049         
    10511050        //trigger events 
    1052         pd[i] = medium_T[i].Xi[1]*medium_T[i].MM/medium_T[i].MMX[1]*p_const; 
     1051        pd[i] = medium_T[i].Xi[1]*medium_T[i].MM/MMX[1]*p_const; 
    10531052        fog[i] = pd[i] >= Medium.saturationPressure(T_const[i]); 
    10541053      end for; 
  • Modelica/trunk/Modelica/Media/IdealGases/Common/package.mo

    r704 r712  
    918918  redeclare function extends specificEntropy "Return specific entropy"  
    919919    extends Modelica.Icons.Function; 
    920   algorithm  
    921     s := s_TX(state.T, state.X) - gasConstant(state)*Modelica.Math.log(state.p/reference_p) 
    922       + MixEntropy(massToMoleFractions(state.X,data.MM)); 
     920  protected  
     921    Real[nX] Y(unit="mol/mol")=massToMoleFractions(state.X, data.MM)  
     922      "Molar fractions"; 
     923  algorithm  
     924     s := s_TX(state.T, state.X) - sum(state.X[i]*Modelica.Constants.R/MMX[i]* 
     925      (if Y[i]>=Modelica.Constants.eps then Modelica.Math.log(Y[i]*state.p/ 
     926      reference_p) else Y[i]) for i in 1:nX); 
     927     
    923928  end specificEntropy; 
    924929