Changeset 499
- Timestamp:
- 04/20/07 14:15:32 (20 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
Modelica/branches/maintenance/2.2.1/Modelica/Media/Air.mo
r474 r499 3 3 package SimpleAir "Air: Simple dry air model (0..100 degC)" 4 4 5 extends Interfaces.PartialSimpleIdealGasMedium 6 (mediumName="SimpleAir",5 extends Interfaces.PartialSimpleIdealGasMedium( 6 mediumName="SimpleAir", 7 7 cp_const=1005.45, 8 8 MM_const=0.0289651159, … … 17 17 import Modelica.Constants; 18 18 19 constant FluidConstants[nS] fluidConstants =19 constant FluidConstants[nS] fluidConstants= 20 20 FluidConstants(iupacName={"simple air"}, 21 21 casRegistryNumber={"not a real substance"}, 22 22 chemicalFormula={"N2, O2"}, 23 23 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 26 27 annotation (Documentation(info="<html> 27 28 <h2>Simple Ideal gas air model for low temperatures<h1> … … 107 108 MassFraction X_steam "mass fraction of steam water"; 108 109 MassFraction X_air "mass fraction of air"; 109 MassFraction X_sat 110 MassFraction X_sat 110 111 "steam water mass fraction of saturation boundary in kg_water/kg_moistair"; 111 MassFraction x_sat 112 MassFraction x_sat 112 113 "steam water mass content of saturation boundary in kg_water/kg_dryair"; 113 114 AbsolutePressure p_steam_sat "Partial saturation pressure of steam"; … … 120 121 121 122 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); 125 126 X_steam = Xi[Water]-X_liquid; 126 127 X_air = 1-Xi[Water]; … … 143 144 phi = p/p_steam_sat*Xi[Water]/(Xi[Water] + k_mair*X_air); 144 145 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" 147 149 input ThermodynamicState state "shermodynamic state"; 148 150 output MassFraction X_sat "steam mass fraction of sat. boundary"; 149 protected 150 algorithm 151 algorithm 151 152 X_sat := k_mair/(state.p/min(saturationPressure(state.T),0.999*state.p) - 1 + k_mair); 152 153 end Xsaturation; 153 154 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" 155 157 input AbsolutePressure p "Pressure"; 156 158 input Temperature T "Temperature"; 157 159 input Real phi "relative humidity (0 ... 1.0)"; 158 160 output MassFraction X_steam "steam Mass fractions"; 159 protected 161 protected 160 162 constant Real k = 0.621964713077499 "ratio of molar masses"; 161 163 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); 164 166 end massFraction_pTphi; 165 167 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" 167 170 extends Modelica.Icons.Function; 168 171 input AbsolutePressure p "Pressure"; … … 170 173 input MassFraction X[:]=reference_X "Mass fractions"; 171 174 output ThermodynamicState state; 172 algorithm 173 state := if size(X,1) == nX then ThermodynamicState(p=p,T=T, X=X) 174 elseThermodynamicState(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)})); 175 178 end setState_pTX; 176 179 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" 178 182 extends Modelica.Icons.Function; 179 183 input AbsolutePressure p "Pressure"; … … 181 185 input MassFraction X[:]=reference_X "Mass fractions"; 182 186 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 elseThermodynamicState(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)})); 186 190 end setState_phX; 187 /*191 /* 188 192 redeclare function setState_psX "Return thermodynamic state as function of p, s and composition X" 189 193 extends Modelica.Icons.Function; … … 196 200 else ThermodynamicState(p=p,T=T_psX(p,s,X), X=cat(1,X,{1-sum(X)})); 197 201 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" 200 205 extends Modelica.Icons.Function; 201 206 input Density d "density"; … … 203 208 input MassFraction X[:]=reference_X "Mass fractions"; 204 209 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 elseThermodynamicState(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)})); 208 213 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" 211 217 algorithm 212 218 R := dryair.R*(1-state.X[Water]) + steam.R*state.X[Water]; … … 286 292 p := state.p; 287 293 end pressure; 288 294 289 295 redeclare function extends temperature "return temperature of ideal gas" 290 296 algorithm 291 297 T := state.T; 292 298 end temperature; 293 299 294 300 redeclare function extends density "return density of ideal gas" 295 301 algorithm 296 302 d := state.p/(gasConstant(state)*state.T); 297 303 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)" 301 307 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 305 312 s := SingleGasNasa.s0_Tlow(dryair, state.T)*(1-state.X[Water]) 306 313 + SingleGasNasa.s0_Tlow(steam, state.T)*state.X[Water] 307 314 - gasConstant(state)*Modelica.Math.log(state.p/reference_p) 308 315 + 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)); 310 317 end specificEntropy; 311 318 312 319 redeclare function extends specificHeatCapacityCp 313 320 "Return specific heat capacity at constant pressure" 314 321 annotation(Inline=false,smoothOrder=5); 315 algorithm322 algorithm 316 323 cp:= SingleGasNasa.cp_Tlow(dryair, state.T)*(1-state.X[Water]) 317 324 + SingleGasNasa.cp_Tlow(steam, state.T)*state.X[Water]; 318 end specificHeatCapacityCp;325 end specificHeatCapacityCp; 319 326 320 327 redeclare function extends specificHeatCapacityCv … … 344 351 345 352 function h_pTX 346 "Compute specific enthalpy from pressure, temperature and mass fraction"353 "Compute specific enthalpy from pressure, temperature and mass fraction" 347 354 extends Modelica.Icons.Function; 348 355 input SI.Pressure p "Pressure"; … … 351 358 output SI.SpecificEnthalpy h "Specific enthalpy at p, T, X"; 352 359 annotation(Inline=false,smoothOrder=1); 353 protected360 protected 354 361 SI.AbsolutePressure p_steam_sat "Partial saturation pressure of steam"; 355 362 SI.MassFraction x_sat "steam water mass fraction of saturation boundary"; … … 368 375 end h_pTX; 369 376 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); 374 380 end specificEnthalpy; 375 381 376 redeclare function extends specificInternalEnergy "Return specific internal energy" 382 redeclare function extends specificInternalEnergy 383 "Return specific internal energy" 377 384 extends Modelica.Icons.Function; 378 385 algorithm 379 386 u := h_pTX(state.p,state.T,state.X) - gasConstant(state)*state.T; 380 387 end specificInternalEnergy; 381 388 382 389 redeclare function extends specificGibbsEnergy "Return specific Gibbs energy" 383 390 extends Modelica.Icons.Function; … … 385 392 g := h_pTX(state.p,state.T,state.X) - state.T*specificEntropy(state); 386 393 end specificGibbsEnergy; 387 388 redeclare function extends specificHelmholtzEnergy "Return specific Helmholtz energy" 394 395 redeclare function extends specificHelmholtzEnergy 396 "Return specific Helmholtz energy" 389 397 extends Modelica.Icons.Function; 390 398 algorithm 391 399 f := h_pTX(state.p,state.T,state.X) - gasConstant(state)*state.T - state.T*specificEntropy(state); 392 400 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" 396 403 input AbsolutePressure p "Pressure"; 397 404 input SpecificEnthalpy h "specific enthalpy"; 398 405 input MassFraction[:] X "mass fractions of composition"; 399 406 output Temperature T "temperature"; 400 protected407 protected 401 408 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)" 403 410 extends Modelica.Media.Common.OneNonLinearEquation; 404 411 redeclare record extends f_nonlinear_Data 405 "Data to be passed to non-linear function"412 "Data to be passed to non-linear function" 406 413 extends Modelica.Media.IdealGases.Common.DataRecord; 407 414 end f_nonlinear_Data; 408 415 409 416 redeclare function extends f_nonlinear 410 417 algorithm 411 418 y := h_pTX(p,x,X); 412 419 end f_nonlinear; 413 420 414 421 // Dummy definition has to be added for current Dymola 415 422 redeclare function extends solve 416 423 end solve; 417 424 end Internal; 418 425 419 426 algorithm 420 427 T := Internal.solve(h, 200, 6000, p, X[1:nXi], steam); 421 428 end T_phX; 422 429 423 430 package Utilities "utility functions" 424 431 function spliceFunction … … 483 490 484 491 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. 495 The 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> 504 The 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. 486 511 </html>")); 487 512 end MoistAir;
