Show
Ignore:
Timestamp:
04/20/07 14:15:32 (19 months ago)
Author:
kproelss
Message:

added documentation to moist air model

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/maintenance/2.2.1/Modelica/Media/Air.mo

    r474 r499  
    33  package SimpleAir "Air: Simple dry air model (0..100 degC)"  
    44     
    5     extends Interfaces.PartialSimpleIdealGasMedium 
    6       (mediumName="SimpleAir", 
     5    extends Interfaces.PartialSimpleIdealGasMedium( 
     6       mediumName="SimpleAir", 
    77       cp_const=1005.45, 
    88       MM_const=0.0289651159, 
     
    1717    import Modelica.Constants; 
    1818     
    19     constant FluidConstants[nS] fluidConstants = 
     19    constant FluidConstants[nS] fluidConstants= 
    2020      FluidConstants(iupacName={"simple air"}, 
    2121                     casRegistryNumber={"not a real substance"}, 
    2222                     chemicalFormula={"N2, O2"}, 
    2323                     structureFormula={"N2, O2"}, 
    24                      molarMass=Modelica.Media.IdealGases.Common.SingleGasesData.N2.MM) "constant data for the fluid"; 
    25          
     24                     molarMass=Modelica.Media.IdealGases.Common.SingleGasesData.N2.MM)  
     25      "constant data for the fluid"; 
     26     
    2627    annotation (Documentation(info="<html> 
    2728                              <h2>Simple Ideal gas air model for low temperatures<h1> 
     
    107108      MassFraction X_steam "mass fraction of steam water"; 
    108109      MassFraction X_air "mass fraction of air"; 
    109       MassFraction X_sat 
     110      MassFraction X_sat  
    110111        "steam water mass fraction of saturation boundary in kg_water/kg_moistair"; 
    111       MassFraction x_sat 
     112      MassFraction x_sat  
    112113        "steam water mass content of saturation boundary in kg_water/kg_dryair"; 
    113114      AbsolutePressure p_steam_sat "Partial saturation pressure of steam"; 
     
    120121       
    121122      p_steam_sat = min(saturationPressure(T),0.999*p); 
    122       X_sat = min(p_steam_sat * k_mair/max(100*Constants.eps, p - p_steam_sat)*(1 - Xi[Water]), 1.0) 
    123                         "Water content at saturation with respect to actual water content"; 
    124       X_liquid = max(Xi[Water] - X_sat, 0.0);  
     123      X_sat = min(p_steam_sat * k_mair/max(100*Constants.eps, p - p_steam_sat)*(1 - Xi[Water]), 1.0)  
     124        "Water content at saturation with respect to actual water content"; 
     125      X_liquid = max(Xi[Water] - X_sat, 0.0); 
    125126      X_steam  = Xi[Water]-X_liquid; 
    126127      X_air    = 1-Xi[Water]; 
     
    143144      phi = p/p_steam_sat*Xi[Water]/(Xi[Water] + k_mair*X_air); 
    144145    end BaseProperties; 
    145  
    146     function Xsaturation "steam water mass fraction of saturation boundary in kg_water/kg_moistair" 
     146     
     147    function Xsaturation  
     148      "steam water mass fraction of saturation boundary in kg_water/kg_moistair"  
    147149      input ThermodynamicState state "shermodynamic state"; 
    148150      output MassFraction X_sat "steam mass fraction of sat. boundary"; 
    149       protected 
    150     algorithm 
     151    algorithm  
    151152      X_sat := k_mair/(state.p/min(saturationPressure(state.T),0.999*state.p) - 1 + k_mair); 
    152153    end Xsaturation; 
    153154     
    154     function massFraction_pTphi "compute the steam mass fraction from relative humidity and T" 
     155    function massFraction_pTphi  
     156      "compute the steam mass fraction from relative humidity and T"  
    155157      input AbsolutePressure p "Pressure"; 
    156158      input Temperature T "Temperature"; 
    157159      input Real phi "relative humidity (0 ... 1.0)"; 
    158160      output MassFraction X_steam "steam Mass fractions"; 
    159     protected 
     161    protected  
    160162      constant Real k = 0.621964713077499 "ratio of molar masses"; 
    161163      AbsolutePressure psat = saturationPressure(T) "saturation pressure"; 
    162     algorithm 
    163       X_steam = phi*k/(k*phi+p/psat-phi); 
     164    algorithm  
     165      X_steam :=phi*k/(k*phi + p/psat - phi); 
    164166    end massFraction_pTphi; 
    165167     
    166     redeclare function setState_pTX "Return thermodynamic state as function of p, T and composition X"  
     168    redeclare function setState_pTX  
     169      "Return thermodynamic state as function of p, T and composition X"  
    167170      extends Modelica.Icons.Function; 
    168171      input AbsolutePressure p "Pressure"; 
     
    170173      input MassFraction X[:]=reference_X "Mass fractions"; 
    171174      output ThermodynamicState state; 
    172     algorithm 
    173       state := if size(X,1) == nX then ThermodynamicState(p=p,T=T, X=X) 
    174         else ThermodynamicState(p=p,T=T, X=cat(1,X,{1-sum(X)})); 
     175    algorithm  
     176      state := if size(X,1) == nX then ThermodynamicState(p=p,T=T, X=X) else  
     177            ThermodynamicState(p=p,T=T, X=cat(1,X,{1-sum(X)})); 
    175178    end setState_pTX; 
    176179     
    177     redeclare function setState_phX "Return thermodynamic state as function of p, h and composition X"  
     180    redeclare function setState_phX  
     181      "Return thermodynamic state as function of p, h and composition X"  
    178182      extends Modelica.Icons.Function; 
    179183      input AbsolutePressure p "Pressure"; 
     
    181185      input MassFraction X[:]=reference_X "Mass fractions"; 
    182186      output ThermodynamicState state; 
    183     algorithm 
    184       state := if size(X,1) == nX then ThermodynamicState(p=p,T=T_phX(p,h,X),X=X) 
    185         else ThermodynamicState(p=p,T=T_phX(p,h,X), X=cat(1,X,{1-sum(X)})); 
     187    algorithm  
     188      state := if size(X,1) == nX then ThermodynamicState(p=p,T=T_phX(p,h,X),X=X) else  
     189            ThermodynamicState(p=p,T=T_phX(p,h,X), X=cat(1,X,{1-sum(X)})); 
    186190    end setState_phX; 
    187 /*     
     191    /*     
    188192    redeclare function setState_psX "Return thermodynamic state as function of p, s and composition X"  
    189193      extends Modelica.Icons.Function; 
     
    196200        else ThermodynamicState(p=p,T=T_psX(p,s,X), X=cat(1,X,{1-sum(X)}));         
    197201    end setState_psX; 
    198 */     
    199     redeclare function setState_dTX "Return thermodynamic state as function of d, T and composition X"  
     202*/ 
     203    redeclare function setState_dTX  
     204      "Return thermodynamic state as function of d, T and composition X"  
    200205      extends Modelica.Icons.Function; 
    201206      input Density d "density"; 
     
    203208      input MassFraction X[:]=reference_X "Mass fractions"; 
    204209      output ThermodynamicState state; 
    205     algorithm 
    206       state := if size(X,1) == nX then ThermodynamicState(p=d*({steam.R,dryair.R}*X)*T,T=T,X=X) 
    207         else ThermodynamicState(p=d*({steam.R,dryair.R}*cat(1,X,{1-sum(X)}))*T,T=T, X=cat(1,X,{1-sum(X)})); 
     210    algorithm  
     211      state := if size(X,1) == nX then ThermodynamicState(p=d*({steam.R,dryair.R}*X)*T,T=T,X=X) else  
     212            ThermodynamicState(p=d*({steam.R,dryair.R}*cat(1,X,{1-sum(X)}))*T,T=T, X=cat(1,X,{1-sum(X)})); 
    208213    end setState_dTX; 
    209        
    210     redeclare function extends gasConstant "gas constnat: computation neglects liquid fraction" 
     214     
     215    redeclare function extends gasConstant  
     216      "gas constnat: computation neglects liquid fraction"  
    211217    algorithm  
    212218      R := dryair.R*(1-state.X[Water]) + steam.R*state.X[Water]; 
     
    286292    p := state.p; 
    287293   end pressure; 
    288  
     294     
    289295   redeclare function extends temperature "return temperature of ideal gas"  
    290296   algorithm  
    291297     T := state.T; 
    292298   end temperature; 
    293  
     299     
    294300   redeclare function extends density "return density of ideal gas"  
    295301   algorithm  
    296302     d := state.p/(gasConstant(state)*state.T); 
    297303   end density; 
    298  
    299    redeclare function extends specificEntropy 
    300      "return specific entropy (liquid part neglected, mixing entropy included)"  
     304     
     305   redeclare function extends specificEntropy  
     306      "return specific entropy (liquid part neglected, mixing entropy included)"  
    301307       annotation(Inline=false,smoothOrder=5); 
    302    protected 
    303      MoleFraction[2] Y = massToMoleFractions(state.X,{steam.MM,dryair.MM}) "molar fraction"; 
    304    algorithm 
     308    protected  
     309     MoleFraction[2] Y = massToMoleFractions(state.X,{steam.MM,dryair.MM})  
     310        "molar fraction"; 
     311   algorithm  
    305312     s := SingleGasNasa.s0_Tlow(dryair, state.T)*(1-state.X[Water]) 
    306313       + SingleGasNasa.s0_Tlow(steam, state.T)*state.X[Water] 
    307314       - gasConstant(state)*Modelica.Math.log(state.p/reference_p) 
    308315       + sum(if Y[i] > Modelica.Constants.eps then -Y[i]*Modelica.Math.log(Y[i]) else  
    309                    Y[i] for i in 1:size(Y,1));; 
     316                   Y[i] for i in 1:size(Y,1)); 
    310317   end specificEntropy; 
    311     
     318     
    312319   redeclare function extends specificHeatCapacityCp  
    313320      "Return specific heat capacity at constant pressure"  
    314321     annotation(Inline=false,smoothOrder=5); 
    315   algorithm  
     322   algorithm  
    316323     cp:= SingleGasNasa.cp_Tlow(dryair, state.T)*(1-state.X[Water]) 
    317324       + SingleGasNasa.cp_Tlow(steam, state.T)*state.X[Water]; 
    318   end specificHeatCapacityCp; 
     325   end specificHeatCapacityCp; 
    319326     
    320327  redeclare function extends specificHeatCapacityCv  
     
    344351     
    345352  function h_pTX  
    346     "Compute specific enthalpy from pressure, temperature and mass fraction"  
     353      "Compute specific enthalpy from pressure, temperature and mass fraction"  
    347354    extends Modelica.Icons.Function; 
    348355    input SI.Pressure p "Pressure"; 
     
    351358    output SI.SpecificEnthalpy h "Specific enthalpy at p, T, X"; 
    352359    annotation(Inline=false,smoothOrder=1); 
    353   protected  
     360    protected  
    354361    SI.AbsolutePressure p_steam_sat "Partial saturation pressure of steam"; 
    355362    SI.MassFraction x_sat "steam water mass fraction of saturation boundary"; 
     
    368375  end h_pTX; 
    369376     
    370   redeclare function extends specificEnthalpy 
    371       "specific enthalpy" 
    372   algorithm 
    373     h := h_pTX(state.p, state.T, state.X);   
     377  redeclare function extends specificEnthalpy "specific enthalpy"  
     378  algorithm  
     379    h := h_pTX(state.p, state.T, state.X); 
    374380  end specificEnthalpy; 
    375381     
    376   redeclare function extends specificInternalEnergy "Return specific internal energy"  
     382  redeclare function extends specificInternalEnergy  
     383      "Return specific internal energy"  
    377384    extends Modelica.Icons.Function; 
    378385  algorithm  
    379386    u := h_pTX(state.p,state.T,state.X) - gasConstant(state)*state.T; 
    380387  end specificInternalEnergy; 
    381    
     388     
    382389  redeclare function extends specificGibbsEnergy "Return specific Gibbs energy"  
    383390    extends Modelica.Icons.Function; 
     
    385392    g := h_pTX(state.p,state.T,state.X) - state.T*specificEntropy(state); 
    386393  end specificGibbsEnergy; 
    387    
    388   redeclare function extends specificHelmholtzEnergy "Return specific Helmholtz energy"  
     394     
     395  redeclare function extends specificHelmholtzEnergy  
     396      "Return specific Helmholtz energy"  
    389397    extends Modelica.Icons.Function; 
    390398  algorithm  
    391399    f := h_pTX(state.p,state.T,state.X) - gasConstant(state)*state.T - state.T*specificEntropy(state); 
    392400  end specificHelmholtzEnergy; 
    393    
    394   function T_phX  
    395     "Compute temperature from specific enthalpy and mass fraction"  
     401     
     402  function T_phX "Compute temperature from specific enthalpy and mass fraction"  
    396403    input AbsolutePressure p "Pressure"; 
    397404    input SpecificEnthalpy h "specific enthalpy"; 
    398405    input MassFraction[:] X "mass fractions of composition"; 
    399406    output Temperature T "temperature"; 
    400   protected  
     407    protected  
    401408  package Internal  
    402       "Solve h(data,T) for T with given h (use only indirectly via temperature_phX)"  
     409        "Solve h(data,T) for T with given h (use only indirectly via temperature_phX)"  
    403410    extends Modelica.Media.Common.OneNonLinearEquation; 
    404411    redeclare record extends f_nonlinear_Data  
    405         "Data to be passed to non-linear function"  
     412          "Data to be passed to non-linear function"  
    406413      extends Modelica.Media.IdealGases.Common.DataRecord; 
    407414    end f_nonlinear_Data; 
    408        
     415         
    409416    redeclare function extends f_nonlinear  
    410417    algorithm  
    411418        y := h_pTX(p,x,X); 
    412419    end f_nonlinear; 
    413        
     420         
    414421    // Dummy definition has to be added for current Dymola 
    415422    redeclare function extends solve  
    416423    end solve; 
    417424  end Internal; 
    418      
     425       
    419426  algorithm  
    420427    T := Internal.solve(h, 200, 6000, p, X[1:nXi], steam); 
    421428  end T_phX; 
    422        
     429     
    423430    package Utilities "utility functions"  
    424431      function spliceFunction  
     
    483490     
    484491    annotation (Documentation(info="<html> 
    485    
     492  <h3><font color=\"#008000\" size=5>Moist Air Medium Package</font></h3> 
     493<h4><font color=\"#008000\" size=4>Thermodynamic Model</font></h4> 
     494<p>This package provides a full thermodynamic model of moist air including the fog region and temperatures below zero degC. 
     495The governing assumptions in this model are:</p> 
     496<ul> 
     497<li>the perfect gas law applies</li> 
     498<li>water volume other than that of steam is neglected</li></ul> 
     499<p>All extensive properties are expressed in terms of the total mass in order to comply with other media in this libary. However, it is rather common to express the absolute humidity in terms of mass of dry air only, which has advantages when working with charts. Therefore two absolute humidities are computed in the <b>BaseProperties</b> model: <b>X</b> denotes the absolute humidity in terms of the total mass while <b>x</b> denotes the absolute humitity per unit mass of dry air. In addition, the relative humidity <b>phi</b> is also computed.</p> 
     500<p>At the triple point temperature of water of 0.01°C or 273.16 K and a relative humidity greater than 1 fog may be present as liquid and as ice resulting in a specific enthalpy somewhere between those of the two isotherms for solid and liquid fog, respectively. For numerical reasons in this model a coexisting mixture of 50% solid and 50% liquid fog is assumed in the fog region at the triple point. 
     501 
     502<h4><font color=\"#008000\" size=4>Range of validity</font></h4> 
     503<p>From the assumptions mentioned above it follows that the <b>pressure</b> should be in the region around <b>atmospheric</b> conditions or below (a few bars may still be fine though). Additionally a very high water content at low temperatures would yield incorrect densities, because the volume of the liquid or solid phase would not be negligible anymore. The model does not provide any information on limits for water drop size in the fog region or transport information for the actual condensation or evaporation process in combination with surfaces. All excess water which is not in its vapour state is assumed to be still present in the air regarding its energy but not in terms of its spatial extent.<br><br> 
     504The thermodynamic model may be used for <b>temperatures</b> ranging from <b>240 - 400 K</b>. This holds for all functions unless otherwise stated in their description. However, although the model works at temperatures above the saturation temperature it is questionable to use the term \"relative humidity\" in this region.</p> 
     505 
     506<h4><font color=\"#008000\" size=4>Transport Properties</font></h4> 
     507<p>Several additional functions that are not needed to describe the thermodynamic system, but are required to model transport processes, like heat and mass transfer, may be called. They usually neglect the moisture influence unless otherwise stated.</p> 
     508   
     509<h4><font color=\"#008000\" size=4>Application</font></h4> 
     510<p>The model's main area of application is all processes that involve moist air cooling under near atmospheric pressure with possible moisture condensation. This is the case in all domestic and industrial air conditioning applications. Another large domain of moist air applications covers all processes that deal with the dehydration of bulk material using air as the transport medium. Engineering tasks involving moist air are often performed (or at least visualized) by using charts that contain all relevant thermodynamic data for a moist air system. These so called psychrometric charts can be generated from the medium properties in this package.  
    486511</html>")); 
    487512  end MoistAir;