Changeset 649

Show
Ignore:
Timestamp:
10/03/2007 05:55:41 PM (15 months ago)
Author:
fcasella
Message:

Updated PartialMedium.BaseProperties model for Modelica 3.0 compliance
Updated PartialMedium.BaseProperties documentation

Files:
1 modified

Legend:

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

    r607 r649  
    35053505       
    35063506      replaceable package Medium = Modelica.Media.Air.DryAirNasa  
    3507             extends Modelica.Media.IdealGases.Common.SingleGasNasa  
     3507            constrainedby Modelica.Media.IdealGases.Common.SingleGasNasa  
    35083508        "Medium model"     annotation (choicesAllMatching=true); 
    35093509       
     
    36023602      replaceable package Medium =  
    36033603          Modelica.Media.IdealGases.MixtureGases.FlueGasLambdaOnePlus  
    3604             extends Modelica.Media.IdealGases.Common.MixtureGasNasa  
     3604            constrainedby Modelica.Media.IdealGases.Common.MixtureGasNasa  
    36053605        "Medium model"     annotation (choicesAllMatching=true); 
    36063606       
     
    38833883    end ThermodynamicState; 
    38843884     
    3885     replaceable record BasePropertiesRecord  
    3886       "Variables contained in every instance of BaseProperties"  
    3887       extends Modelica.Icons.Record; 
    3888       AbsolutePressure p "Absolute pressure of medium"; 
     3885     
     3886    replaceable partial model BaseProperties  
     3887      "Base properties (p, d, T, h, u, R, MM and, if applicable, X and Xi) of a medium"  
     3888      InputAbsolutePressure p "Absolute pressure of medium"; 
     3889      InputMassFraction[nXi] Xi(start=reference_X[1:nXi])  
     3890        "Structurally independent mass fractions"; 
     3891      InputSpecificEnthalpy h "Specific enthalpy of medium"; 
    38893892      Density d "Density of medium"; 
    38903893      Temperature T "Temperature of medium"; 
    38913894      MassFraction[nX] X(start=reference_X)  
    38923895        "Mass fractions (= (component mass)/total mass  m_i/m)"; 
    3893       MassFraction[nXi] Xi(start=reference_X[1:nXi])  
    3894         "Structurally independent mass fractions" annotation (Hide=true); 
    3895       SpecificEnthalpy h "Specific enthalpy of medium"; 
    38963896      SpecificInternalEnergy u "Specific internal energy of medium"; 
    38973897      SpecificHeatCapacity R "Gas constant (of mixture if applicable)"; 
    38983898      MolarMass MM "Molar mass (of mixture or single fluid)"; 
    3899       annotation(Documentation(info="<html></html>")); 
    3900     end BasePropertiesRecord; 
    3901      
    3902     replaceable partial model BaseProperties  
    3903       "Base properties (p, d, T, h, u, R, MM and, if applicable, X) of a medium"  
    3904       extends BasePropertiesRecord; 
    39053899      ThermodynamicState state  
    3906         "thermodynamic state variables for optional functions"; 
     3900        "thermodynamic state record for optional functions"; 
    39073901      parameter Boolean preferredMediumStates=false  
    39083902        "= true if StateSelect.prefer shall be used for the independent property variables of the medium" 
    3909         annotation (Hide=true, Evaluate=true, Dialog(tab="Advanced")); 
    3910       annotation (structurallyIncomplete); 
     3903        annotation (Evaluate=true, Dialog(tab="Advanced")); 
     3904      parameter Boolean standardOrderComponents = true  
     3905        "if true, and reducedX = true, the last element of X will be computed from the other ones"; 
    39113906      SI.Conversions.NonSIunits.Temperature_degC T_degC= 
    39123907          Modelica.SIunits.Conversions.to_degC(T)  
     
    39153910       Modelica.SIunits.Conversions.to_bar(p)  
    39163911        "Absolute pressure of medium in [bar]"; 
    3917       parameter Boolean standardOrderComponents = true  
    3918         "if true, last element in components is computed from 1-sum(Xi)"; 
     3912      annotation (Icon(Rectangle(extent=[-100,100; 100,-100], style(fillColor=7)), Text(extent= 
     3913               [-152,164; 152,102], string="%name"))); 
     3914       
     3915      // Local connector definition, used for equation balancing check 
     3916      connector InputAbsolutePressure = input SI.AbsolutePressure; 
     3917      connector InputSpecificEnthalpy = input SI.SpecificEnthalpy; 
     3918      connector InputMassFraction = input SI.MassFraction; 
     3919       
     3920    equation  
     3921      if standardOrderComponents then 
     3922        Xi = X[1:nXi]; 
     3923        if nX > 1 then 
     3924          if fixedX then 
     3925            X = reference_X; 
     3926          end if; 
     3927          if reducedX and not fixedX then 
     3928            X[nX] = 1 - sum(Xi); 
     3929          end if; 
     3930          for i in 1:nX loop 
     3931            assert(X[i] >= -1.e-5 and X[i] <= 1 + 1.e-5, "Mass fraction X[" + 
     3932                   String(i) + "] = " + String(X[i]) + "of substance " 
     3933                   + substanceNames[i] + "\nof medium " + mediumName + " is not in the range 0..1"); 
     3934          end for; 
     3935        end if; 
     3936      end if; 
     3937       
     3938      assert(p >= 0.0, "Pressure (= " + String(p) + " Pa) of medium \"" + 
     3939        mediumName + "\" is negative\n(Temperature = " + String(T) + " K)"); 
    39193940      annotation (Documentation(info="<html> 
    39203941<p> 
     
    39233944variables that every medium model is supposed to support. 
    39243945A specific medium inherits from model <b>BaseProperties</b> and provides 
    3925 the equations for the basic properties. Note, that in package 
    3926 PartialMedium the following constants are defined: 
    3927 </p> 
    3928 <table border=1 cellspacing=0 cellpadding=2> 
    3929   <tr><td valign=\"top\"><b>Type</b></td> 
    3930       <td valign=\"top\"><b>Name</b></td> 
    3931       <td valign=\"top\"><b>Description</b></td></tr> 
    3932   <tr><td valign=\"top\">String</td><td valign=\"top\">mediumName</td> 
    3933       <td valign=\"top\">Unique name of the medium (used to check whether two media in a model 
    3934           are the same)</td></tr> 
    3935   <tr><td valign=\"top\">String</td><td valign=\"top\">substanceNames</td> 
    3936       <td valign=\"top\">Names of the mixture substances that are treated 
    3937           as independent. 
    3938           If medium consists of a single substance, set substanceNames=fill(\"\",0). 
    3939           If medium consists of n substances, provide either n-1 or n 
    3940           substance names, depending whether mass fractions 
    3941           PartialMedium.BaseProperties.X shall have 
    3942           dimension PartialMedium.nX = n-1 or PartialMedium.nX = n</td></tr> 
    3943   <tr><td valign=\"top\">Boolean</td><td valign=\"top\">incompressible</td> 
    3944       <td valign=\"top\">= true, if density is constant; otherwise set it to false</td></tr> 
    3945 </table> 
    3946 <p> 
    3947 In every medium <b>3+nX equations</b> have to be defined that 
    3948 provide relations between the following <b>5+nX variables</b>, declared 
    3949 in model BaseProperties, where nX is the number of independent 
    3950 mass fractions defined in package PartialMedium: 
     3946the equations for the basic properties. </p> 
     3947<p> 
     3948The BaseProperties model contains the following <b>7+nXi variables</b> 
     3949(nXi is the number of independent mass fractions defined in package 
     3950PartialMedium): 
    39513951</p> 
    39523952<table border=1 cellspacing=0 cellpadding=2> 
     
    39693969      <td valign=\"top\">J/kg</td> 
    39703970      <td valign=\"top\">specific internal energy</td></tr> 
    3971   <tr><td valign=\"top\">X[nX]</td> 
     3971  <tr><td valign=\"top\">Xi[nXi]</td> 
    39723972      <td valign=\"top\">kg/kg</td> 
    39733973      <td valign=\"top\">independent mass fractions m_i/m</td></tr> 
     3974  <tr><td valign=\"top\">R</td> 
     3975      <td valign=\"top\">J/kg.K</td> 
     3976      <td valign=\"top\">gas constant</td></tr> 
     3977  <tr><td valign=\"top\">M</td> 
     3978      <td valign=\"top\">kg/mol</td> 
     3979      <td valign=\"top\">molar mass</td></tr> 
    39743980</table> 
    39753981<p> 
    3976 In some components, such as \"Ambient\", explicit equations for 
    3977 medium variables are provided as \"boundary conditions\". 
    3978 For example, the \"Ambient\" component may define a temperature 
    3979 T_ambient. 
    3980 </html>"),   Icon(Rectangle(extent=[-100,100; 100,-100], style(fillColor=7)), Text(extent= 
    3981                [-152,164; 152,102], string="%name"))); 
    3982     equation  
    3983       if standardOrderComponents then 
    3984         Xi = X[1:nXi]; 
    3985         if nX > 1 then 
    3986           if fixedX then 
    3987             X = reference_X; 
    3988           end if; 
    3989           if reducedX and not fixedX then 
    3990             X[nX] = 1 - sum(Xi); 
    3991           end if; 
    3992           for i in 1:nX loop 
    3993             assert(X[i] >= -1.e-5 and X[i] <= 1 + 1.e-5, "Mass fraction X[" + 
    3994                    String(i) + "] = " + String(X[i]) + "of substance " 
    3995                    + substanceNames[i] + "\nof medium " + mediumName + " is not in the range 0..1"); 
    3996           end for; 
    3997         end if; 
    3998       end if; 
    3999        
    4000       assert(p >= 0.0, "Pressure (= " + String(p) + " Pa) of medium \"" + 
    4001         mediumName + "\" is negative\n(Temperature = " + String(T) + " K)"); 
    4002        
     3982In order to implement an actual medium model, one can extend from this 
     3983base model and add <b>5 equations</b> that provide relations among  
     3984these variables. Equations will also have to be added in order to 
     3985set all the variables within the ThermodynamicState record state.</p> 
     3986<p> 
     3987If standardOrderComponents=true, the full composition vector X[nX]  
     3988is determined by the equations contained in this base class, depending  
     3989on the independent mass fraction vector Xi[nXi]. </p> 
     3990<p>Additional <b>2 + nXi</b> equations will have to be provided  
     3991when using the BaseProperties model, in order to fully specify the  
     3992thermodynamic conditions. The input connector qualifier applied to  
     3993p, h, and nXi indirectly declares the number of missing equations, 
     3994permitting advanced equation balance checking by Modelica tools. 
     3995Please note that this doesn't mean that the additional equations  
     3996should be connection equations, nor that exactly those variables 
     3997should be supplied, in order to complete the model. 
     3998For further information, see the Modelica.Media User's guide, and  
     3999Section 4.7 (Balanced Models) of the Modelica 3.0 specification. </p> 
     4000</html>")); 
    40034001    end BaseProperties; 
    40044002