| 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"; |
| 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; |
| 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)"); |
| 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: |
| | 3946 | the equations for the basic properties. </p> |
| | 3947 | <p> |
| | 3948 | The BaseProperties model contains the following <b>7+nXi variables</b> |
| | 3949 | (nXi is the number of independent mass fractions defined in package |
| | 3950 | PartialMedium): |
| 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 | | |
| | 3982 | In order to implement an actual medium model, one can extend from this |
| | 3983 | base model and add <b>5 equations</b> that provide relations among |
| | 3984 | these variables. Equations will also have to be added in order to |
| | 3985 | set all the variables within the ThermodynamicState record state.</p> |
| | 3986 | <p> |
| | 3987 | If standardOrderComponents=true, the full composition vector X[nX] |
| | 3988 | is determined by the equations contained in this base class, depending |
| | 3989 | on the independent mass fraction vector Xi[nXi]. </p> |
| | 3990 | <p>Additional <b>2 + nXi</b> equations will have to be provided |
| | 3991 | when using the BaseProperties model, in order to fully specify the |
| | 3992 | thermodynamic conditions. The input connector qualifier applied to |
| | 3993 | p, h, and nXi indirectly declares the number of missing equations, |
| | 3994 | permitting advanced equation balance checking by Modelica tools. |
| | 3995 | Please note that this doesn't mean that the additional equations |
| | 3996 | should be connection equations, nor that exactly those variables |
| | 3997 | should be supplied, in order to complete the model. |
| | 3998 | For further information, see the Modelica.Media User's guide, and |
| | 3999 | Section 4.7 (Balanced Models) of the Modelica 3.0 specification. </p> |
| | 4000 | </html>")); |