(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 176139, 4556]*) (*NotebookOutlinePosition[ 199735, 5393]*) (* CellTagsIndexPosition[ 199166, 5375]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["MathModelica", "Title"], Cell[TextData[{ "\[Dash] a new modeling and simulation environment for ", StyleBox["Mathematica", FontSlant->"Italic"] }], "Subtitle"], Cell[TextData[{ "\n", ButtonBox["Mats Jirstrand", ButtonData:>{ URL[ "mailto:mats@mathcore.com"], None}, ButtonStyle->"Hyperlink"], " and ", ButtonBox["Johan Gunnarsson", ButtonData:>{ URL[ "mailto:johan@mathcore.com"], None}, ButtonStyle->"Hyperlink"], "\n\n", ButtonBox["MathCore AB", ButtonData:>{ URL[ "http://www.mathcore.com"], None}, ButtonStyle->"Hyperlink"], "\nMj\[ADoubleDot]rdevi Science Park", StyleBox["\n", TextAlignment->Center, TextJustification->0, FontFamily->"Arial"], "SE-583 30 Link\[ODoubleDot]ping", StyleBox["\n", TextAlignment->Center, TextJustification->0, FontFamily->"Arial"], "Sweden\n\n", ButtonBox["Peter Fritzson", ButtonData:>{ URL[ "mailto:petfr@ida.liu.se"], None}, ButtonStyle->"Hyperlink"], "\n\nPELAB \[Dash] Programming Environment Lab\nDepartment of Computer and \ Information Science\nLink\[ODoubleDot]ping University\nSE-581 83 Link\ \[ODoubleDot]ping\nSweden\n\nThird International ", StyleBox["Mathematica", FontSlant->"Italic"], " Symposium 1999,\n23-25 August, RISC, Linz, Austria" }], "Author", TextAlignment->Left, TextJustification->0, FontSize->12], Cell["Abstract", "Abstract", FontFamily->"Verdana", FontSize->18], Cell[TextData[{ "MathModelica is a ", StyleBox["Mathematica", FontSlant->"Italic"], " extension, which provides a modeling, and simulation environment for ", StyleBox["Mathematica", FontSlant->"Italic"], " based on the new standard of physical modeling languages called Modelica. \ Modelica is a new object-oriented multi-domain modeling language based on \ algebraic and differential equations. In this paper we present a language and \ an environment, MathModelica, that integrates different phases of the \ Modelica development lifecycle. This is achieved by using the ", StyleBox["Mathematica", FontSlant->"Italic"], " environment and its structured documents, \ \[OpenCurlyDoubleQuote]notebooks\[CloseCurlyDoubleQuote]. Simulation models \ are represented in the form of structured documents, which integrate source \ code, documentation and code transformation specifications, as well as \ providing control over simulation and result visualization. " }], "Text"], Cell["\<\ Import and export of Modelica code between internal structured and external \ textual representation is supported. Mathematica is an interpreted language, \ which is suitable as a scripting language for controlling simulation and \ visualization. Mathematica also supports symbolic transformations on \ equations and algebraic expressions which is useful in building mathematical \ models. \ \>", "Text"], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell["\<\ Integrated simulation environments are advantageous in order to work \ effectively and flexibly with simulations. Users prepare and run simulations \ as well as investigate simulation results. Several auxiliary activities \ accompany simulation experiments: requirements are specified, models are \ designed, documentation is associated with appropriate places in the models, \ input and output data as well as possible constraints on such data are \ documented and stored together with the simulation model. The user should be \ able to reproduce experimental results. Therefore input data and parts of \ output data as well as the experimenter\[CloseCurlyQuote]s notes should be \ stored for future analysis. \ \>", "Text"], Cell["\<\ Traditionally, simulation and accompanying activities have been expressed \ using heterogeneous media and tools: \ \>", "Text"], Cell["\<\ a simulation model is traditionally designed on paper using traditional \ mathematical notation; \ \>", "Itemize"], Cell["\<\ simulation programs are written in a low-level programming language and \ stored on text files; \ \>", "Itemize"], Cell["\<\ input and output data (if stored at all) are saved in proprietary formats \ needed for particular applications and numerical libraries; \ \>", "Itemize"], Cell["\<\ documentation is written on paper or in separate files that are not \ integrated with the program files; \ \>", "Itemize"], Cell["\<\ the graphical results are printed on paper or saved using proprietary \ formats. \ \>", "Itemize"], Cell["\<\ When the result of the research and experiments, such as a scientific paper, \ is written, the user normally gathers together input data, algorithms, output \ data and its visualizations as well as notes and descriptions. One of the \ major problem in simulation development environments is that gathering \ correct versions of all these components from various files and formats is \ difficult and error-prone. \ \>", "Text"], Cell[CellGroupData[{ Cell["The Modelica Language", "Subsection", TextAlignment->Left, TextJustification->0], Cell[TextData[{ "There is definitely an interoperability problem amongst the large variety \ of modeling and simulation environments available today ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "ElmqvistM:ESS97"], ButtonBox["\[VeryThinSpace]", ButtonData:>"ElmqvistM:ESS97", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], " . The main cause of this problem is the absence of a state-of-the-art, \ standardized external model representation. Modeling languages often do not \ adequately support the structuring of large, complex models and the process \ of model evolution in general." }], "Text"], Cell[TextData[{ "The language called Modelica ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "Modelica:1998"], ButtonBox["\[VeryThinSpace]", ButtonData:>"Modelica:1998", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], " for hierarchical physical modeling is developed through an international \ effort. It is an object-oriented language ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "ElmqvistM:ESS97"], ButtonBox["\[VeryThinSpace]", ButtonData:>"ElmqvistM:ESS97", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], " ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "FritzsonE:ECOOP98"], ButtonBox["\[VeryThinSpace]", ButtonData:>"FritzsonE:ECOOP98", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], " for modeling of physical systems. The language unifies and generalizes \ previous object-oriented modeling languages. Modelica is intended to become a \ de facto standard. It offers three important features: 1) non-causal modeling \ based on differential and algebraic equations; 2) multidomain modeling \ capability, i.e. it is possible to combine electrical, mechanical, \ thermodynamic, hydraulic etc. model components within the same application \ model; 3) a general type system that unifies object-orientation, multiple \ inheritance, and templates within a single class construct." }], "Text", CellDingbat->None], Cell[TextData[{ "Modelica models are built from classes. Like in other object-oriented \ languages, a class contains variables, i.e., class attributes representing \ data. The main difference compared to traditional object-oriented languages \ is that instead of functions (methods) the programmer uses equations to \ specify behavior. Equations can be written explicitly, like ", StyleBox["a=b", FontFamily->"Courier"], ", or can be inherited from other classes. Equations can also be specified \ by the ", StyleBox["connect", FontFamily->"Courier"], " statement. Equations here includes differential equations (ODE and DAE)." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "MathModelica - A ", StyleBox["Mathematica", FontSlant->"Italic"], " Extension" }], "Subsection"], Cell[TextData[{ "Our approach to the integration problem is based on the ", StyleBox["Mathematica", FontSlant->"Italic"], " environment and its programmable notebooks. Every notebook corresponds to \ one document (one file) and contains a tree structure of cells. A cell can \ include other cells and/or arbitrary text or graphics. In particular a cell \ can include a code fragment or a graph with computational results." }], "Text"], Cell["The contents of cells can be", "Text"], Cell["\<\ parts of models (a formal description that can be used for verification, \ compilation and execution of some simulation model); \ \>", "Itemize"], Cell["\<\ text/documentation (used as comments to executable, formal model \ specifications);\ \>", "Itemize"], Cell["\<\ dialogue forms for specification and modification of input data;\ \>", "Itemize"], Cell["\<\ result tables (the results can be immediately represented in table form);\ \>", "Itemize"], Cell["\<\ graphical result representation (with 2D vector and raster graphics as well \ as 3D vector and surface graphics);\ \>", "Itemize"], Cell["\<\ 2D graphs that are used for various model structure visualizations: \ \>", "Itemize"], Cell["class diagrams", "Itemize2"], Cell["variable dependency diagrams ", "Itemize2"], Cell["data structure diagrams", "Itemize2"], Cell[TextData[{ "Apart from the ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook interface, the ", StyleBox["Mathematica", FontSlant->"Italic"], " system with its kernel, programming language, and symbolic representation \ of code and mathematical expressions provides a powerful environment for the \ modeling and simulation technology as given by the Modelica language. Having \ a language for differential equations (DAEs) ", StyleBox["Mathematica", FontSlant->"Italic"], " ability to perform symbolic computations/transformations on expressions \ is very important. The ", StyleBox["MathLink", FontSlant->"Italic"], " interface that lets ", StyleBox["Mathematica", FontSlant->"Italic"], " communicate with other processes seamlessly can be used to, e.g., \ integrate external special purpose simulators, or graphical modeling editors. \ The functional and rule based language is not only good for expressing \ mathematica operations, but also good transformations of (code) formats to be \ interpreted, e.g., existing numerical data and tables that are needed to be \ integrated into a simulation." }], "Text"], Cell[TextData[{ "MathModelica is the name of an extension of ", StyleBox["Mathematica", FontSlant->"Italic"], " that is an implementation of a modeling and simulation environment based \ on the Modelica language. The goal has been to integrate the Modelica \ language into the language of ", StyleBox["Mathematica", FontSlant->"Italic"], " as close as possible. This makes it possible for the user to utilize both \ ", StyleBox["Mathematica", FontSlant->"Italic"], " and the Modelica language without severe restrictions." }], "Text"], Cell[TextData[{ "MathModelica means both a language and an environment. The MathModelica \ language is a language close to the ", StyleBox["Mathematica", FontSlant->"Italic"], " syntax with the extension of a syntax for data types, i.e., the data \ types of symbols and functions in ", StyleBox["Mathematica", FontSlant->"Italic"], " expressions can be specified in a convenient way. Section 2 will describe \ the language of MathModelica. The MathModelica environment means a collection \ of modeling tools (graph editors) and simulation engines where ", StyleBox["Mathematica", FontSlant->"Italic"], " is the center and user frontend. Section 3 will describe this environment \ briefly." }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["MathModelia \[Dash] the language", "Section"], Cell[CellGroupData[{ Cell["Syntax", "Subsection"], Cell[TextData[{ "A specific feature of ", StyleBox["Mathematica", FontSlant->"Italic"], " is that models (or code) are normally not written as free formatted text. \ Instead, ", StyleBox["Mathematica", FontSlant->"Italic"], " expressions (terms) are used. These can be conveniently written in a \ tree-like prefix form, or entered using standard mathematical notation. Every \ term is a number, an identifier or a form such as:" }], "Text"], Cell[TextData[{ "\t", "head", "[", Cell[BoxData[ \(TraditionalForm\`term\_1\)]], ",..., ", Cell[BoxData[ \(TraditionalForm\`term\_n\)]], "]" }], "Program"], Cell["\<\ In order to satisfy this requirement, we designed the new MathModelica \ language. Note that MathModelica has the same abstract syntax and the same \ semantics as Modelica, but different concrete syntax. This means that \ essentially the same language constructs are written differently, as \ illustrated below.\ \>", "Text"], Cell[TextData[{ "The MathModelica language uses some ", StyleBox["Mathematica", FontSlant->"Italic"], " notation, such as:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ RowBox[{ FormBox[\(term\_1\), "TraditionalForm"], ";"}], "..."}], ";", \(term\_n\)}], TraditionalForm]]], ",\n\t{", Cell[BoxData[ FormBox[ RowBox[{ FormBox[\(term\_1\), "TraditionalForm"], ",", "...", ",", \(term\_n\)}], TraditionalForm]]], "},\n\t", Cell[BoxData[ \(TraditionalForm\`term\_1\)]], " ", Cell[BoxData[ \(TraditionalForm\`term\_2\)]], ",\n\t", Cell[BoxData[ FormBox[ RowBox[{ FormBox[\(term\_1\), "TraditionalForm"], "\[Equal]", \(term\_2\)}], TraditionalForm]]] }], "Program"], Cell["\<\ and arbitrary arithmetic expressions composed from terms. We will not present \ the complete syntax of MathModelica and it's relation to Modelica here, but \ we will use some examples.\ \>", "Text"], Cell["\<\ Note! The syntax and command names pruposed in this paper are preliminary and \ can be changed in future versions of MathModelica.\ \>", "Text"], Cell[CellGroupData[{ Cell["Type Operator", "Subsubsection"], Cell["Consider the Modelica code:", "Text"], Cell[TextData[{ StyleBox["\tmodel", FontWeight->"Bold"], " FirstOrder\n\t\tReal x(start=1);\n\t\t", StyleBox["parameter", FontWeight->"Bold"], " Real a=1;\n\t", StyleBox["equation", FontWeight->"Bold"], "\n\t\tder(x)=-a*x;\n\t", StyleBox["end", FontWeight->"Bold"], " FirstOrder;" }], "Program"], Cell[TextData[{ "The above example is a class definition of the model named ", StyleBox["\"FirstOrder\"", FontFamily->"Courier"], ". This model includes one dynamic variable x of type Real with the initial \ value (", StyleBox["start", FontFamily->"Courier"], ") set to 1. The symbol ", StyleBox["a", FontFamily->"Courier"], " is declared as a parameter which means that its value must be a constant \ and given by the user. To simulate this model means to compute values of the \ variable ", StyleBox["x", FontFamily->"Courier"], " starting from the value 1 such that the equations of the model are \ satisfied. The dynamics (differential equations) of the model is given after \ the ", StyleBox["equation", FontFamily->"Courier"], " keyword. The operator ", StyleBox["der", FontFamily->"Courier"], " is derivation with respect to time. If time is represented by the symbol \ ", Cell[BoxData[ \(TraditionalForm\`t\)]], ", ", StyleBox["der(x)", FontFamily->"Courier"], " would mean ", Cell[BoxData[ \(TraditionalForm\`\[DifferentialD]\(x(t)\)\/\[DifferentialD]t\)]], ". The model definition can contain any number of equations." }], "Text"], Cell["The MathModelica syntax of the Modelica example above is", "Text"], Cell[BoxData[ \(Model[ FirstOrder, \[IndentingNewLine]Real\ x[ {Start \[Equal] 1}]; \[IndentingNewLine]Parameter\ Real\ a \[Equal] 1; \[IndentingNewLine]Equation[\[IndentingNewLine]x' \[Equal] \(-a\)\ x\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input", IndentingNewlineSpacings->4], Cell[TextData[{ "Note that the structure of the MathModelica code is the same as for \ Modelica but the syntax is a valid ", StyleBox["Mathematica", FontSlant->"Italic"], " expression. A few things needs to be explained here:" }], "Text"], Cell[TextData[{ "In Modelica the character '", StyleBox["=", FontFamily->"Courier"], "' stand for an equation and not for assignment. Therefor '", StyleBox["==", FontFamily->"Courier"], "' should be used in MathModelica which means ", StyleBox["Equal[]", FontFamily->"Courier"], "." }], "Itemize"], Cell[TextData[{ "Space in ", StyleBox["Mathematica", FontSlant->"Italic"], " means normally multiplication (", StyleBox["Times", FontFamily->"Courier"], "). To provide a easy to write and read syntax for data types we have \ introduced a operator for prefixed attributes. In this case this operator is \ called ", StyleBox["TypeMark", FontFamily->"Courier"], ", and it applies in certain specific places in the MathModelica language \ where multiplication (", StyleBox["Times", FontFamily->"Courier"], ") is forbidden and therefore introduces no ambiguities." }], "Itemize"], Cell[TextData[{ "To illustrate how ", StyleBox["TypeMark", FontFamily->"Courier"], " works we can take a look at the ", StyleBox["FullForm", FontFamily->"Courier"], " of a simple declaration statement that is held to prevent any \ calculations. The constant ", StyleBox["dpi", FontFamily->"Courier"], " is declared and assigned the value of 2*3.14." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(Declare[\[IndentingNewLine]Constant\ Real\ dpi\ = \ 2\ 3.14\ \[IndentingNewLine]]\ // \ Hold\)\ // \ FullForm\)], "Input"], Cell[BoxData[ TagBox[ StyleBox[ \(Hold[Declare[Set[TypeMark[Constant, Real, dpi], Times[2, 3.14`]]]] \), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]], "Output"] }, Open ]], Cell[TextData[{ "We see that spaces between the type keywords are correctly interpreted to \ ", StyleBox["TypeMark", FontFamily->"Courier"], "." }], "Text"], Cell[TextData[{ "To use space as the type operator simplifies the writing of code including \ data types, especially when there is several hundred variables to declare in \ realistic modeling projects. Once the code is written we can ask ", StyleBox["Mathematica", FontSlant->"Italic"], " to list the code such that the type operator and multiplication are \ presented differently. This is possible by the command ", StyleBox["MathModelicaForm", FontFamily->"Courier"], " where the ", StyleBox["TypeMark", FontFamily->"Courier"], " operator is printed using '\[SpaceIndicator]'. The command ", StyleBox["GetModel[]", FontFamily->"Courier"], " returns the model definition." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MathModelicaForm[GetModel[FirstOrder]]\)], "Input"], Cell[BoxData[ TagBox[ RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"FirstOrder", ",", "\[IndentingNewLine]", RowBox[{ \(Real\ \ \[SpaceIndicator]\ \ x[{Start == 1}]\), ";", "\[IndentingNewLine]", RowBox[{ \(Parameter\ \ \[SpaceIndicator]\ \ Real\ \ \[SpaceIndicator]\ \ a\ == 1\), ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", RowBox[{ SuperscriptBox["x", "\[Prime]", MultilineFunction->None], "==", \(\(-a\)\ x\)}], "\[IndentingNewLine]", "]"}]}]}]}], "\[IndentingNewLine]", "]"}], HoldForm]], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Field Selector", "Subsubsection"], Cell[TextData[{ "The second extension to the ", StyleBox["Mathematica", FontSlant->"Italic"], " language necessary for the MathModelica language is the field selector. \ Consider the record definition below." }], "Text"], Cell[BoxData[ \(Record[ Person, \[IndentingNewLine]String\ Name; \[IndentingNewLine]Integer\ \ Age\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "This type definition creates the type ", StyleBox["Person", FontFamily->"Courier"], " including two fields: ", StyleBox["Name", FontFamily->"Courier"], " and ", StyleBox["Age", FontFamily->"Courier"], ". Declaration and initialization of a record variable can then be done as" }], "Text"], Cell[BoxData[ \(\(Declare[\[IndentingNewLine]Person\ p1\[IndentingNewLine]];\)\)], "Input"], Cell[BoxData[ \(\(p1\ = \ Person["\", 23];\)\)], "Input"], Cell[TextData[{ "The record variable ", StyleBox["p1", FontFamily->"Courier"], " will now contain the expression ", StyleBox["Person[\"John\",23]", FontFamily->"Courier"], " where ", StyleBox["Person[]", FontFamily->"Courier"], " is a constructor for the record type." }], "Text"], Cell[TextData[{ "To extract fields in a record or a general class, we use the ", StyleBox["Member", FontFamily->"Courier"], " function" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Member[p1, Name]\)], "Input"], Cell[BoxData[ \("John"\)], "Output"] }, Open ]], Cell[TextData[{ "which selects the field named ", StyleBox["Name", FontFamily->"Courier"], " and returns it's value. The infix operator symbol for the field selector \ is '.' in many common programming languages. To introduce '.' as the infix \ field selector in MathModelica is therefore natural, except for the fact that \ ", StyleBox["Mathematica", FontSlant->"Italic"], " uses '.' for ", StyleBox["Dot", FontFamily->"Courier"], " (tensor product). Still, the importance to have a infix operator for the \ field selector is extensive since the equations generated by the MathModelica \ environment will contain many variables which are represented by the ", StyleBox["Member", FontFamily->"Courier"], " function. To keep the format easy both to read and to write it is \ necessary to have a short one character long infix operator. Unfortunately \ there are no free one character operators that can be easily typed on the \ keyboard. The '.' is therefore chosen since it is possible for the \ MathModelica environment to distinguish between ", StyleBox["Member", FontFamily->"Courier"], " and ", StyleBox["Dot", FontFamily->"Courier"], ", by analyzing the type of the first argument of ", StyleBox["Dot", FontFamily->"Courier"], ". If the type is a class then ", StyleBox["Dot", FontFamily->"Courier"], " is converted to ", StyleBox["Member", FontFamily->"Courier"], "." }], "Text"], Cell["Using '.' on a record variable returns the field", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(p1 . Name\)], "Input"], Cell[BoxData[ \("John"\)], "Output"] }, Open ]], Cell["whereas '.' on vectors returns the scalar product.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \({1, 2} . {3, 4}\)], "Input"], Cell[BoxData[ \(11\)], "Output"] }, Open ]], Cell[TextData[{ "In StandardForm the ", StyleBox["Member", FontFamily->"Courier"], " and ", StyleBox["Dot", FontFamily->"Courier"], " command are distinguished since the ", StyleBox["Member", FontFamily->"Courier"], " function is printed using the '\[Hacek]' ([Hacek]) character." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(pi . Age\ \ . \ \ {a, b}\)], "Input"], Cell[BoxData[ \(\((p1 \(\(\[NegativeMediumSpace]\)\(\[Hacek]\)\(\[NegativeMediumSpace]\)\)\ Age)\) . {a, b}\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Circuit Example", "Subsection"], Cell["\<\ The details of the MathModelica language will be described by an example of a \ circuit model that will be given in the form of MathModelica expressions in \ this section. Note that we here only describe the modeling in terms of \ programming MathModelica textually. The MathModelica environment also \ includes a graphical modeling paradigms also that is based on MathModelica \ language. The graphical environment has an one-to-one correspondence with the \ textual MathModelica language.\ \>", "Text"], Cell[TextData[{ "MathModelica models are built from classes. Like in other object-oriented \ languages, class contains variables, i.e. class attributes representing data. \ The main difference compared with traditional object-oriented languages is \ that instead of functions (methods) we use equations to specify behavior. \ Equations can be written explicitly, like ", StyleBox["a=b", FontFamily->"Courier"], ", or be inherited from other classes. Equations can also be specified by \ the ", StyleBox["Connect", FontFamily->"Courier"], " statement. The statement ", StyleBox["Connect[v1,v2]", FontFamily->"Courier"], " expresses coupling between variables ", StyleBox["v1", FontFamily->"Courier"], " and ", StyleBox["v2", FontFamily->"Courier"], ". These variables are called connectors and belong to the connected \ objects. This gives a flexible way of specifying topology of physical systems \ described in an object-oriented way using MathModelica." }], "Text"], Cell["\<\ In the following sections we introduce some basic and distinctive syntactical \ and semantic features of MathModelica, such as connectors, encapsulation of \ equations, inheritance, declaration of parameters and constants. Powerful \ parametrization capabilities (which are advanced features of MathModelica) \ are discussed in Section 2.4.\ \>", "Text"], Cell[CellGroupData[{ Cell["Connection Diagram", "Subsubsection"], Cell[TextData[{ "As an introduction to Modelica we will present a model of a simple \ electrical circuit as shown in Figure ", CounterBox["NumberedFigure", "fig:circuit"], ButtonBox["\[VeryThinSpace]", ButtonData:>"fig:circuit", ButtonStyle->"Hyperlink"], "." }], "Text"], Cell["\<\ The system can be broken into a set of connected electrical standard \ components. We have a voltage source, two resistors, an inductor, a capacitor \ and a ground point. Models of such components are available in Modelica class \ libraries.\ \>", "Text"], Cell[TextData[{ "A declaration like one below specifies that ", StyleBox["R1", FontFamily->"Courier"], " to be of class ", StyleBox["Resistor", FontFamily->"Courier"], " and sets the default value of the resistance, ", StyleBox["R", FontFamily->"Courier"], ", to 10." }], "Text"], Cell["\tResistor R1(R=10);", "Program"], Cell[GraphicsData["Metafile", "\<\ CF5dJ6E]HGAYHf4PEfU^I6mgLb15CDHPAVmbKF5d0@0003^H0@0007`0000500000@0004d1003c0000 W00001l0002V:000ZQd00215CDH00040V3/006T100030000300006@00000000000@0000300100@00 l000000000000000000004H0LP1Q06d0I@1=0640J`1U0780000001@0000<00003@0001@0000<0000 3@0001P0000<000000000RD0000<00002000P0d0000@000000000000001M0000J000004000020000 800002P000180000800002P000080000200000400@00000080000000000000000000000000000000 00000000000000000000000000000000000002D0000<00000@0001<0000<00000P000180000<0000 0P0005H0000/0000Q00003H0002O0000=`0000@0002403H0W`0f09l0=`2403L0EP0002`0002N0000 =P0009l0001F0000100009h0=P2O03H0W`1F09h0EP1F0000;00008@0001E0000WP0005H000040000 Q01E09h0E@2N05H0Q01F05H0000/0000Q00003H000250000E@0000@0002403H0Q@0f08D0E@2405D0 500000`0000=0000500000`0000=0000500000`0000=0000EP0002`0000Z0000:@0004D0000Z0000 100002X0:@1502T0A@0Z02X0:P1F0000;00004@0000Y0000A@0005L000040000A00Y04D0:@1505L0 A01G05H0000/0000:P0005H000140000E`0000@0000Z05H0A01F04@0E`0Z05L0EP0002`0000Z0000 :@0002/0001F0000100002X0:@0[02T0:`1F02X0EP0D0000300000d0000D0000300000d0000D0000 300000d0001F0000;0000:80002J0000X`0009`000040000XP2L0:<0W02S09X0XP2J05H0000/0000 P00009X000210000W00000@0002109`0P02L0800VP2109X0EP0002`000210000VP000:80002L0000 10000:80W02R09X0P@2J0840W00D0000300000d0000D0000300000d0000D0000300000d0001F0000 ;0000:80002V0000X`000:P000040000XP2X0:<0Z02S0:H0XP2V05H0000/0000P@000:H000220000 Z00000@000220:P0P@2X0840YP220:H0EP0002`000220000YP000:80002X000010000:80Z02R0:H0 PP2V0880Z00D0000300000d0000D0000300000d0000D0000300000d0001F0000;00003D0001F0000 =P0005H000040000=P1F03H0EP0e05H0=@1F05H0000/0000=@0008<0000f0000P`0000@0000f08<0 =P2303D0P`0e08<0EP0002`0000e0000EP0003H000230000100003H0EP0e05H0=@2303H0P`0D0000 300000d0000D0000300000d0000D0000300000d0001F0000;0000940001E0000TP0005D000040000 TP1E0980E@2A05D0T@1E05H0000/0000T@0009/0002B0000V`0000@0002B09/0TP2K0940V`2A09/0 EP0002`0002A0000E@000980002K000010000980E@2A05D0T@2K0980V`0D0000300000d0000D0000 300000d0000D0000300000d0000D0000300000d0000D0000300000d0001F0000W0400>X0001W0000 8P4009T0001P00008@5o01l1MP0O0GL07`5g01T1K`0I0Fl06@5_0101JP0@0FX0405Z00H1J0060FP0 1P5X0?/0JP3k06X0n`1Z0?80K`3c06l0l`1_0>d0M`3]07H0k@1f0>/0O`3[07l0j`1o0>d0R@3]08T0 k@290?<0T03c0900l`2@0?`0UP3k09H0n`2F00H1V0060IP01P6H0101UP0@0IH0406F01T1T00I0I00 6@6@01l1R@0O0HT07`690241O`0Q0Gl08P5o0281O`0P0HT080690201RP0J0I406P6A01X1T@0A0IL0 4@6G0101U`060IT01P6I00H1V@3k09L0n`2G0?/0U`3b0940lP2A0?80T@3/08X0k02:0>`0R@3Z07l0 jP1o0>X0O`3/07H0k01f0>`0MP3b06h0lP1^0?80KP3k06T0n`1Y0?/0J@060FL01P5W00H1I`0@0FT0 405Y0101J@0I0Fh06@5^01X1KP0P0GH0805f0201MP0R0Gl0EP0003@0000Q0@00O`000281001o0000 1P000241O`0Q0Gl08@5o0281O`0R0Gl08P5o01@0000<00003@0001@0000<00003@0001@0000<0000 3@0001@0000<00003@0001@0000<00003@0005H0000/0000=P000;@0000g0000]00000@0000g0;@0 =`2d03H0]00f0;@0EP0002`0000f0000]00003L0003;0000100003H0]00g0;@0=`3;03H0b`1F0000 ;00003H0003:00001`400l0P00D0000 300000d0000D0000300000d0000D0000300000d0001B0000C0400080003[oooo1`00000000000000 T04000000003@P4BE01Y06d0I@1c0000000000000000000000000000000000000000000000000000 0000000000000000000000008APTl1809?0B01P0000C00001@0000<000394neg1`XQ62T<2U/Y30YK :bG]Ml1WkgOG2P00e`X:2QHJkGOG2PX:i>lB00L:8APTl1809?0B0>f:D03G2PX:?EE@063`4P1D?DP1 600001<0000500000`0000l0000800000000090100000000;04002`1000PoiDP00006`0000072R4H e`X:2RT<2U_G2PX:2?0B0=aED0072R4H9?0B0000000000000000000000000000000000410@410@41 0@4B02D0000<00000P000180000<00000@0005@0001H0000QP0003L0002H0000C@00004000000?Y1 003j@HH0000g00000P0004`00000000000000000003ooooooooooe00001B03402`0000P0000D0000 300000d0001D0000K0000381001O0000C@4007D000010000003j@@00nT4b0@00G`0000D0001<0000 0000000000000000oooooooooomH0000M@0P02P0M00Y0?gm2@0000@0000500001@0000D0000D0000 300000d0001D0000E0000:d0002C0000^0000:T000010000003j@@00nT6]0000T`000040001<0000 0000000000000000oooooooooom@0000@`3mo@`0000D0000300000d0001D0000F00002d0000`0000 @00004H000010000003j@@00nT4]0000<0000080001<00000000000000000000oooooooooom@0000 DP0b00/000090000500000`0000=0000E00005@000190000Q`0005<0002M00000@000000nT400?Y1 B@0008L000010000C00000000000000000000?ooooooooooD00004`0oOd;0000500000`0000=0000 E00005P0000=0@00T@000281002W00000@000000nT400?Y13@40094000020000C000000000000000 00000?ooooooooooD0000440@`0;00002`0001@0000<00003@0001@0000<00003@000180000<0000 0P0005H0000/0000Z`000>00002[0000h@0000@0002[0>40Z`3Q0:/0h02[0>00EP0002`0001g0000 h00007L0003Q0000100007L0h@1g0>40M`3P07L0h01F0000;00007L0003P0000Z`000>4000040000 Z`3Q0:/0h01g0>00M`3Q01@0000<00003@0001@0000<00003@0001@0000<00003@0005H0000/0000 T000040T03Q0900h@1F0000;0000900003?0000T@000>4000040000T@3?0900c`2@0>40 T@3Q01@0000<00003@0001@0000<00003@0001@0000<00003@0005H0000/0000WP000>L0002N0000 j00000@0002N0>P0WP3X09h0i`2N0>L0EP0002`000240000i`0008@0003X0000100008@0j0240>P0 Q03W08@0i`1F0000;00008@0003W0000WP000>P000040000WP3X09h0i`240>L0Q03X01@0000<0000 3@0001@0000<00003@0001@0000<00003@0005H0000/0000U`000>d0002G0000kP0000@0002G0>h0 U`3^09L0k@2G0>d0EP0002`0002:0000k@0008X0003^0000100008X0kP2:0>h0RP3]08X0k@1F0000 ;00008X0003]0000U`000>h000040000U`3^09L0k@2:0>d0RP3^01@0000<00003@0001@0000<0000 3@000180000<00000@0005@0001D0000K@000=d0001i0000l`00004000000?Y1003j@Fd0003M0000 0@0004`00000000000000000003ooooooooooe0000170?gm3@0001@0000<00003@0005@0001H0000 Q@000040002H00005`00004000000?Y1003j@HD0000100000P0004`00000000000000000003ooooo oooooe00001>0340300000P0000D0000300000d0001D0000F00007T0002]0000S0000<<000010000 003j@@00nT5i0000[@000080001<00000000000000000000oooooooooom@0000CP0b00`000080000 500000`0000=0000E00005P0002G0000G`000:X0001e00000@000000nT400?Y1U`0005l000020000 C00000000000000000000?ooooooooooD00004h0<`0<0000200001@0000<00003@0005@0001H0000 700005<0000_0000J@00004000000?Y1003j@A`0001C00000P0004`00000000000000000003ooooo oooooe00001>03@0300000P0000D0000300000d0000U0000300000d0080X000030000080001B0000 C0400080003[oooo1`00000000000000_08000000003@P4BE01Y06d0I@1c00000000000000000000 000000000000000000000000000000000000000000000000000000008APTl1809?0B01T0000D0000 1@0000@000394neg1`XQ62T<2U`Y30YL:bG]Ml1WkgOG2P00e`X:3AHJkGOG2PX=i>lB00L:8APTl180 9?0B0>f:D03G2PX=?EE@063`4P34>TP16@0001@000050000100000`00009000000000;`200000000 ;04002`1000PoiDP00006`0000072R4He`X:3BT<2UcG2PX=2?0B0=aED0072R4H9?0B000000000000 0000000000000000000000410@410@410@4B02D0000<00000P0005@0001D0000Q@0001`0002=0000 <`00004000000?Y1003j@HD0000L00000@0004`00000000000000000003ooooooooooe00000[0?gm 2@0001@0000<00003@0005@0001D0000:`0000d0000c00009000004000000?Y1003j@B/0000=0000 0@0004`00000000000000000003ooooooooooe00000[0?gm2@0001@0000<00003@0005@0001D0000 QP000800002>0000U`00004000000?Y1003j@HH0002000000@0004`00000000000000000003ooooo oooooe00000[0?gm2@0001@0000<00003@0005@0001D0000=P000640000n0000N000004000000?Y1 003j@CH0001Q00000@0004`00000000000000000003ooooooooooe00000[0?gm2@0001@0000<0000 3@0005@0001D0000204004d0000@0@00I000004000000?Y1003j@@P1001=00000@0004`000000000 00000000003ooooooooooe00000[0?gm2@0001@0000<00003@0001@0000<00003@0001@0000<0000 3@000180000<00000P0005H0000/0000=P000;<0000f0000]00000@0000f0;@0=P2d03H0/`0f0;<0 EP000?@0000P0000X`0004X0002d0000=P0003H0]00U0;009@2`02D0/00P0:`0802[0200Z`0P0:T0 802Y0200Z@0R0:P08P2X0280Z00j0:<0>P2S03X0X`150:@0AP2T04H0Y0190:H0B@2V04T0YP1:0:P0 BP2Y04X0Z@180:`0A`2/04L0Z`170:/0B@2X04T0Z0190:P0B02V04P0YP180:L0A@2U04D0Y@150:D0 >P2T03X0Y00j0:@08P2Y0280Z@0R0:T0802Z0200ZP0Q0:T08@2[0240Z`0Q0:/09P2_02H0[`0U0:l0 =P2c05H0000d0000@P000:/000170000[P0000H000170:`0@P2^0480[P120:d0@P2]04L0Z`1F0000 ;00003H0002^0000=P000:l000040000=P2_03H0[`0f0:h0=P2^05H0000/0000=P000:d000120000 [`0000@000120:h0@P2]03H0[P0f0:l0500000`0000=0000500000`0000=0000500000`0000=0000 500000`0000=0000500000`0000=0000EP0002`0000e0000[@0003D0002^0000100003D0[P0e0:h0 =@2]03D0[@1F0000m00001l0002M0000BP000:h0000f0000=@2^02D0ZP0U0:X09@2Z0200YP0P0:D0 802U01l0X`0O0:<07`2S0280XP0R0:808P2R03X0W@0j09d0>P2M04D0WP1509h0A@2N04P0W`1909l0 B@2O04X0XP1:0:<0BP2S04L0YP160:H0AP2U04H0Y@190:80B@2R04T0XP1809l0B02O04P0X01509l0 A@2O04D0W`0j09h0>P2N03X0WP0R0:<08P2S0280X`0O0:@07`2T0200X`0Q0:D08@2U0240Y@0V0:T0 9P2Y02D0Z@0e0:d0EP0003@000110000Y@0004H0002X00001P0004H0YP110:P0@@2X0440Y`110:L0 AP2U05H0000/0000=@000:P0000e0000Z@0000@0000e0:T0=@2Y03D0Z00e0:P0EP0002`0000e0000 Y`000440002Y000010000440Z0110:L0=@2X03D0Z@0D0000300000d0000D0000300000d0000D0000 300000d0000D0000300000d0000D0000300000d0001F0000;00003D0002W0000=@000:P000040000 =@2X03D0Z00e0:L0=@2W05H0003d0000800009L0001:0000Z00003H0000e0:P09@2T02D0Y00U0:@0 802P0200W`0P09l0802N0200WP0P09h08P2L0280W00R09`0>P2G03X0U`0j09L0A@2H04H0V01609P0 B@2J04T0VP1909X0BP2L04X0W@1:09d0A`2P04H0X01609l0AP2O04T0W01909`0B@2L04P0VP1809X0 B02K04D0V@1509T0A@2I03X0V00j09P0>P2H0280W@0R09d08`2M0240W`0Q09l08@2N0240W`0Q09l0 8@2O02H0X`0V0:<09@2S03D0Y`1F0000=0000440002O0000AP000:8000060000AP2P0440XP110:80 @@2Q0440X@1609l0EP0002`0000e0000XP0003D0002S0000100003D0X`0e0:<0=@2R03D0XP1F0000 ;00003D0002Q0000@@000:<000040000@@2R0440X@0e0:80=@2S01@0000<00003@0001@0000<0000 3@0001@0000<00003@0001@0000<00003@0001@0000<00003@0005H0000/0000=@000:80000e0000 X`0000@0000e0:<0=@2S03D0XP0e0:80EP000?@0000O0000TP0004X0002S0000=P0003D0X`0U09h0 9@2N02D0WP0P09X0802J0200VP0O09T07`2H01l0V00Q09H08@2F0240UP0j0980>P2B03X0TP140980 A02B04@0TP1809@0B@2D04T0U01:09H0BP2G04X0U`1709X0AP2J04H0V@1609T0B@2F04T0UP1909H0 B02D04P0U01809D0A02C04@0T`1409<0>P2C03X0T`0j09<08@2G0240U`0R09L0802I0200V@0P09P0 8@2I0240V@0Q09T09P2M02H0W@0U09d0=@2R05H0000d0000@@0009T000160000W00000H0001609X0 @@2L0440W01109/0@@2K04H0V@1F0000;00003D0002L0000=@0009d000040000=@2M03D0W@0e09`0 =@2L05H0000/0000=@0009/000110000W@0000@0001109`0@@2K03D0W00e09d0500000`0000=0000 500000`0000=0000500000`0000=0000500000`0000=0000500000`0000=0000EP0002`0000e0000 RP0003D0002;0000100003D0R`0e08/0=@2:03D0RP1F0000m00001l0001j0000B@0008/0000f0000 =@2;02@0Q`0T08L0902701l0P`0O08807`2201l0P00O08007`200240O`0Q07l08@1o03T0NP0i07X0 >@1j04@0N`1407/0A01k04L0O01807`0B01l04T0O`190800B@2004L0P`1608<0AP2204H0PP1807l0 B01o04P0O`1707`0A`1l04L0O@1407`0A01l04@0O00i07/0>@1k03T0N`0Q08008@200240P00O0840 7`210200P00P088080220200PP0U08H09@2602@0QP0e08X0EP0003@000110000PP0004H000240000 1P0004H0P`1108@0@@240440P`1108<0AP2205H0000/0000=@0008@0000e0000Q@0000@0000e08D0 =@2503D0Q00e08@0EP0002`0000e0000P`0004400025000010000440Q01108<0=@2403D0Q@0D0000 300000d0000D0000300000d0000D0000300000d0000D0000300000d0000D0000300000d0001F0000 ;00003D0002@0000=@00094000040000=@2A03D0T@0e0900=@2@05H0003d00007`00080000190000 T@0003H0000e09409@2=02D0S@0U08d07`2901l0R00O08P07`2601l0QP0O08H08@250240Q@0Q08D0 >@2003T0P00i0800A02104@0P@140840A`2204P0PP180880B@2504T0QP1908H0A`2804H0R01608L0 AP2704P0Q@1808D0B02504L0PP170880A`2304@0PP140880A02203T0P@0i0840>@210240QP0Q08H0 8@2601l0Q`0O08L080260200R00P08P0802802H0S00V08`09@2<03D0T01F0000=000044000270000 AP0008X000060000AP280440RP1108X0@@290440R@1608L0EP0002`0000e0000RP0003D0002;0000 100003D0R`0e08/0=@2:03D0RP1F0000;00003D000290000@@0008/000040000@@2:0440R@0e08X0 =@2;01@0000<00003@0001@0000<00003@0001@0000<00003@0001@0000<00003@0001@0000<0000 3@0005H0000/0000=@0009H0000e0000U`0000@0000e09L0=@2G03D0UP0e09H0EP000?@0000O0000 QP0004T0002G0000=P0003D0U`0U09809@2B02D0TP0P08l0802>0200SP0O08`07`2<01l0S00Q08X0 8@2:0240RP0j08H0>P2603X0QP1408L0A02704@0Q`1708P0B02804P0R01908X0B@2;04T0R`1708h0 AP2>04H0S@1608d0B02:04P0RP1808X0A`2804L0R01708T0A02804@0R01408P0>P2703X0Q`0j08L0 8@2;0240R`0R08/0802=0200S@0P08`08@2>0240SP0Q08h09P2A02H0T@0U0940=@2F05H0000d0000 @@0008d000160000T00000H0001608h0@@2@0440T01108l0@@2?04H0S@1F0000;00003D0002@0000 =@00094000040000=@2A03D0T@0e0900=@2@05H0000/0000=@0008l000110000T@0000@000110900 @@2?03D0T00e0940500000`0000=0000500000`0000=0000500000`0000=0000500000`0000=0000 500000`0000=0000EP0002`0000e0000W00003D0002M0000100003D0W@0e09d0=@2L03D0W01F0000 m00001l0002<0000B@0009d0000f0000=@2M02D0V00U09P09@2H01l0U@0O09@07`2D01l0TP0O0980 7`2B0240T00Q09008@2@03T0S00i08`0>@2<04@0S01508`0A@2<04P0SP1808h0B02>04T0T0190940 B@2A04L0U01609@0AP2C04H0T`180900B02@04P0T01708h0A`2>04L0S`1408d0A02=04@0S@0i08d0 >@2=03T0S@0Q09408@2A0280T@0P09<0802C0200TP0P09@0802D01l0U00U09L09@2G02D0U`0e09`0 EP0003@000110000T`0004H0002F00001P0004H0U01109H0@@2F0440U@1109D0AP2C05H0000/0000 =@0009H0000e0000U`0000@0000e09L0=@2G03D0UP0e09H0EP0002`0000e0000U@000440002G0000 10000440UP1109D0=@2F03D0U`0D0000300000d0000D0000300000d0000D0000300000d0000D0000 300000d0000D0000300000d0000D0000300000d0000C000030000040001F0000H0000340001N0000 >00006T0000A0000=@1N0380G`0a0680<@1T0340I@0b06P0=@1Y03D0J@0e06T0=`1X03P0I@0h06@0 >01R03L0G`0e05h0=@1N03D0GP0D0000300000d0000D0000300000d0000C000030000080001F0000 W0400340001N0000>@0006X0001P0000=@1O0380H00c05l0<`1O0380HP0b068001U03P0I00h06@0>01T03P0HP0h0680>01R03L0G`0g0600 =`1P03D0G`0e05l0=@1O03D0G`0e05l0=@1O03D0G`0e05l0=@1N03D0GP0e05h0=@1N03D0GP0e05h0 =@1N03D0GP0g05l0=`1O03P0G`0i0680>@1R03T0HP0i06@0>@1T03T0I00i06D0>@1U03T0I@0h06P0 >01X03L0J@0e06X0=@1Z03D0JP0e06X0=@1Z03D0JP0e06X0=@1Z03D0JP0b06T006h0 SP1`08l0L`2B07@0TP1d0980M02D07<0U@1`09D0KP2E06d0U01Z0980J@2B06T0TP1Y01@0000<0000 3@0001@0000<00003@0001<0000<00000P0005H0002L0@00SP0006T0002F0000M@000600002B06X0 S`1[0900JP2@06X0S`1]08l0K@2?06d0S`1^08l0KP2?06h0S`1`08l0L02?0700T01c08l0L`2?07<0 TP1d0980M02B07@0TP1d0980M02B07@0TP1d0980M02B07@0U01c09@0L`2D07<0U@1`09D0L02E0700 U@1^09D0KP2E06h0U@1]09D0K@2E06d0U01Z09@0J`2D06/0TP1Z0980JP2B06X0TP1Z0980JP2B06X0 TP1Z0980JP2B06T0TP1Y0980J@2B06T0TP1Y0980J@2B06T0TP1Y09@0JP2D06X0U@1Z09H0K@2F06d0 UP1]09H0KP2F06h0UP1^09H0L02F0700UP1`09D0L`2E07<0U01d0980M@2B07D0TP1e0980M@2B07D0 TP1e0980M@2B07D0TP1e08l0M02?07@0S`1c08h0L02>0700SP1`08h0KP2>06h0SP1^08h0K@2>06d0 SP1]08l0JP2?06X0S`1Z0980J@1F0000=0000980001Y0000TP0006X000060000TP1Z0980JP2B06X0 TP1Y0980J@2B06T0500000`0000=0000500000`0000=0000500000`0000=0000500000`0000=0000 500000`0000=0000500000`0000=0000500000`0000=00004`0000`000010000EP000600002=0000 a00009@0003>00004@000940a02>009<0c@2D000000940cP2A00940cP2A00940cP2C008h0cP2>0001`0SP0L08d07`2=01l0S@0O08d0802=0200S@0P08d08P2=0280S@0R08h09@2=02D0 S@0U09009P2@02H0T00V09009P2@02H0T00V09009P2@02H0T00V09809@2B02D0TP0U09<08P2C0280 T`0R09<0802C0200T`0P09<07`2C01l0T`0O0980702B01d0TP0M0900702@01`0T00L0900702@01`0 T00L0900702@01`0T00K09006`2@01/0T00K09006`2@01/0T00K09006`2B01`0TP0L09<0702D01l0 U00O09@07`2D0200U00P09@0802D0280U00R09@08P2C02D0T`0U09809P2@02L0T00W09009`2@02L0 T00W09009`2@02L0T00W09009`2=02H0S@0V08d09@2<0280S00R08`08P2<0200S00P08`0802<01l0 S00O08`07`2=01`0S@0L08d0702@01/0EP0003@0002@00006`000900000L00001P000900702@01`0 T00L09006`2@01/0T00K01@0000<00003@0001@0000<00003@0001@0000<00003@0001@0000<0000 3@0001@0000<00003@0005H0000/00001P4006L000070@00I`0000@000060FL01P5W00L1I`070FL0 EP0002`000050@008@0000H1000Q0000100000D18@050B401P4Q00H18@1F0000;00000D1000Q0000 1`4006L0000400001P5W00L1I`060B401@4Q01@0000<00003@0001@0000<00003@0001@0000<0000 3@0005H0000/00001@40024000050@008P0000@000050B801@4R00D18@050B40EP0002`0000f0000 800003H0000Q0000100003H08@0f0240=P0P03H0801F0000;00003H0000P00001@40028000040000 1@4R00D18@0f0200=P0Q01@0000<00003@0001@0000<00003@0001@0000<00003@0005H0000/0000 =`000240000h00008@0000@0000h0240>00Q03L08@0g0240EP0002`0000g00009`0003P0000W0000 100003P09`0h02L0=`0W03L09`1F0000;00003L0000Q0000>00002L000040000>00Q03L08@0g02L0 >00W01@0000<00003@0001@0000<00003@0001P0000<0000003o0RD0000<00003@00P2P0000<0000 0P000580001<0@000P000>_oool:000000000000002l0P00000000=20C5306l0M@1b06T0I@1b0000 0000000000000000000000000000000000000000000000000000000000000000000Q62C`4P0Tl180 5@0001800003000000000@XB04E00004P0000<000000000000000d000000000 _0800000000/0@00;040023oUB00000j000000L:8ASG2PX@:@`:GML:2Q08l180g5E@00L:8APTl180 000000000000000000000000000000000@410@410@410A809@0000`0000200004P0000`000010000 E00005@0003A000020000=h0000K00000@000000nT400?Y1d@0000P000010000C000000000000000 00000?ooooooooooD0000340oOd=0000500000`0000=0000500000`0000=0000500000`0000=0000 E00005@0001n0000E`0008/0001Z00000@000000nT400?Y1OP0005L000010000C000000000000000 00000?ooooooooooD0000380oOd=0000500000`0000=0000E00005@0003;0000[P000=P000310000 0@000000nT400?Y1b`000:h000010000C00000000000000000000?ooooooooooD00003<0oOd=0000 500000`0000=0000E00005@0001I00001@0006H0000H00000@000000nT400?Y1F@0000D000010000 C00000000000000000000?ooooooooooD00003@0oOd=0000500000`0000=0000500000`0000=0000 E00005@000150000D`000580001V00000@000000nT400?Y1A@0005<000010000C000000000000000 00000?ooooooooooD00003D0oOd=0000500000`0000=0000E00005@0001<0000[00005T0002o0000 0@000000nT400?Y1C0000:`000010000C00000000000000000000?ooooooooooD00003H0oOd=0000 500000`0000=0000E00005@000250000a`000980003J00000@000000nT400?Y1Q@000000050000000000@00005000 \>"], "NumberedFigure", ImageSize->{328, 242}, ImageMargins->{{94, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, CellTags->"fig:circuit"], Cell["\<\ A MathModelica description of the complete circuit appears as follows:\ \>", "Text"], Cell[BoxData[ \(Model[ Circuit, \[IndentingNewLine]Resistor\ R1[ {R == 10}]; \[IndentingNewLine]Capacitor\ C[ {C == 0.01}]; \[IndentingNewLine]Resistor\ R2[ {R \[Equal] 100}]; \[IndentingNewLine]Inductor\ L[ {L \[Equal] 0.1}]; \[IndentingNewLine]VsourceAC\ AC; \ \[IndentingNewLine]Ground\ G; \[IndentingNewLine]Equation[\[IndentingNewLine]\ \tConnect[AC . p, R1 . p]; "\"; \[IndentingNewLine]\t Connect[R1 . n, C . p]; \[IndentingNewLine]\t Connect[C . n, AC . n]; \[IndentingNewLine]\tConnect[R1 . p, R2 . p]; "\"; \[IndentingNewLine]\t Connect[R2 . n, L . p]; \[IndentingNewLine]\t Connect[L . n, C . n]; \[IndentingNewLine]\tConnect[AC . n, G . p]; "\"\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "A composite model like the circuit model described above specifies the \ system topology, i.e. the components and the connections between the \ components. The connections specify interactions between the components. In \ some previous object-oriented modeling languages connectors are referred to \ cuts, ports or terminals. The keyword ", StyleBox["Connect", FontFamily->"Courier"], " is a special operator that generates equations taking into account what \ kind of interaction is involved as explained in Section 2.2.3." }], "Text"], Cell["\<\ Variables declared within classes are public by default, if they are not \ preceded by the keyword protected which has the same semantics as in Java. \ Additional public or protected sections can appear within a class, preceded \ by the corresponding keyword.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Type Definitions", "Subsubsection"], Cell["\<\ The MathModelica language is a typed language where new types can be defined. \ Here the type of voltage and current are defined.\ \>", "Text"], Cell[BoxData[ \(Type[Voltage, \ Real[{Unit \[Equal] "\"}]]\)], "Input"], Cell[TextData[{ "This defines the symbol ", StyleBox["Voltage", FontFamily->"Courier"], " to be the type of a ", StyleBox["Real", FontFamily->"Courier"], " which is a basic predefined type. Each type (including the basic types) \ has a collection of default attributes such as unit of measure, initial \ value, minimum and maximum value. These default attributes can be changed \ when declaring a new type. In the case above the unit of measure of ", StyleBox["Voltage", FontFamily->"Courier"], " is changed to ", StyleBox["\"V\"", FontFamily->"Courier"], ". The corresponding definition is also made for the current." }], "Text"], Cell[BoxData[ \(Type[Current, Real[{Unit \[Equal] "\"}]]\)], "Input"], Cell[TextData[{ "In MathModelica, the basic structuring element is a class. There are seven \ restricted class categories with specific keywords, such as ", StyleBox["Type", FontFamily->"Courier"], " (a class that is an extension of built-in classes, such as ", StyleBox["Real", FontFamily->"Courier"], ", or of other defined types) and ", StyleBox["Connector", FontFamily->"Courier"], " (a class that does not have equations and can be used in connections). \ For a valid model replacing the type and connector keywords by the keyword ", StyleBox["Class", FontFamily->"Courier"], " is fully equivalent, because the restrictions imposed by such a \ specialized class are fulfilled by a valid model. Other specific class \ categories are ", StyleBox["Model", FontFamily->"Courier"], ", ", StyleBox["Record", FontFamily->"Courier"], ", and ", StyleBox["InOutBlock", FontFamily->"Courier"], "." }], "Text"], Cell[TextData[{ "The idea of restricted classes is advantageous because the modeler does \ not have to learn several different concepts, but just one: the class \ concept. All properties of a class, such as syntax and semantic of \ definition, instantiation, inheritance, generic properties are identical to \ all kinds of restricted classes. Furthermore, the construction of \ MathModelica translators is simplified considerably because only the syntax \ and semantic of a class have to be implemented along with some additional \ checks on restricted classes. The basic types, such as ", StyleBox["Real", FontFamily->"Courier"], " or ", StyleBox["Integer", FontFamily->"Courier"], " are built-in type classes, i.e., they have all the properties of a class. \ The previous definitions can be expressed as follows using the keyword ", StyleBox["Type", FontFamily->"Courier"], " which is equivalent to class, but limits the defined type to be extension \ of a built-in type, record or array." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Connector Classes", "Subsubsection"], Cell["A connector class is defined as follows:", "Text"], Cell[BoxData[ \(Connector[ Pin, \[IndentingNewLine]Voltage\ v; \[IndentingNewLine]Flow\ Current\ i\ \[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "Connection statements are used to connect instances of connection classes. \ A connection statement ", StyleBox["Connect[Pin1,Pin2]", FontFamily->"Courier"], ", with ", StyleBox["Pin1", FontFamily->"Courier"], " and ", StyleBox["Pin2", FontFamily->"Courier"], " of connector class ", StyleBox["Pin", FontFamily->"Courier"], ", connects the two pins so that they form one node (in this case one \ electrical connection). This implies two equations, namely:" }], "Text"], Cell["\<\ \tPin1.v = Pin2.v \tPin1.i + Pin2.i = 0\ \>", "Program"], Cell[TextData[{ "The first equation says that the voltages of the connected wire ends are \ the same. The second equation corresponds to Kirchhoff's current law saying \ that the currents sum to zero at a node (assuming positive value while \ flowing into the component). The sum-to-zero equations are generated when the \ prefix ", StyleBox["Flow", FontFamily->"Courier"], " is used in the declaration. Similar laws apply to flow rates in a piping \ network and to forces and torques in mechanical systems." }], "Text"], Cell["\<\ When developing models and model libraries for a new application domain, it \ is good to start by defining a set of connector classes. A common set of connector classes \ used in all components in the library supports compatibility of the component models.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Virtual (Partial) Classes", "Subsubsection"], Cell["\<\ A common property of many electrical components is that they have two pins. \ This means that it is useful to define an \[OpenCurlyDoubleQuote]interface\ \[CloseCurlyDoubleQuote] model class,\ \>", "Text"], Cell[BoxData[ \(Partial\ Model[TwoPin, \ "\", \ \[IndentingNewLine]Pin\ {p, n}; \[IndentingNewLine]Voltage\ v; \[IndentingNewLine]Current\ i; \ \[IndentingNewLine]Equation[\[IndentingNewLine]v \[Equal] p . v - n . v; \[IndentingNewLine]0 \[Equal] p . i + n . i; \[IndentingNewLine]i \[Equal] p . i\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "that has two pins, ", StyleBox["p", FontFamily->"Courier"], " and ", StyleBox["n", FontFamily->"Courier"], ", a quantity, ", StyleBox["v", FontFamily->"Courier"], ", that defines the voltage drop across the component and a quantity, ", StyleBox["i", FontFamily->"Courier"], ", that defines the current into the pin ", StyleBox["p", FontFamily->"Courier"], ", through the component and out from the pin ", StyleBox["n", FontFamily->"Courier"], "." }], "Text"], Cell[GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHg0R4700LicWooOomooacV121Je@05Ool00f]I 8@MNm`0^Ool002Uoo`06000icT8?8@Le[GNl17oo00=JeB47F]D01Woo00=6 <5kgOol0PWoo00IkgR47000@PeJd>Lh2124013W>OomoofLh0P0000H0;Goo000YOol00`00@Pmoo`02Ool00b475:Aoo`09Ool01E[F 001Nmc6;3680Q7oo00H002DYOoiooacV8@L:Ool01g_N120mkgooDY<006]I 02aoo`00:Goo00<002U:Ool00Woo00<000 F]J1Ool027Nl00000000124LiP00>Lh9Ool01C6<00000000Mk`00`0000Ooh9Ool01E[F@Pm2 3d8?Ooh00d8?00=F]7ooOol0:Goo000WOol027_N8@LQ1cW>7>H001BTF]H9 Ool01Ukg8@LQ1b47G_LicP0R4700LicWooOomooacV121Je@03Ool00eJd8@LQ1`038@L00cW>Oomo o`0ZOol002Uoo`06000icT8?8@Le[GNl17oo00=JeB47F]D00goo00=g_48? @Pl0148?1goo00<007ooOol0KWoo00<007ooOol01Woo00IkgR47000@PeJd >Lh2124013W>OomoofLh0P0000/aRgooOomooeJd8@LLiP005:@Q1cW>02ao o`00:Goo0P0000DLh:Ool01GNl00000000E[@0;Woo000WOol02G_N8@L000009BU23aS5 001Nm`0:Ool0136;8@L4836<2Goo00<007ooOol02Woo00=23`00Ool0HGoo 00<007ooOol01Woo00QooT8?@PmJeCg_8@LicWon2Woo00EooT8?@Pm23f]I 02ioo`009goo00QkgR478@LicQcV000DY5[F2goo00@aRb478@M6<0Uoo`03 001oogoo00Yoo`03@Pl007oo065oo`03001oogoo01Yoo`03E[@Q1ekg02io o`00>goo00=g_48?F]H02Goo00<007ooOol027oo00A23`000000069oo`03 001oogoo01Yoo`03@Pl005Jd02ioo`00>Goo00D007ooIcP0036<00Uoo`03 001oogoo00Qoo`04IcQ23d8?@PmROol00`00Oomoo`0JOol00fLh@Pm[F@0^ Ool003Uoo`<000038@M6<7oo00Qoo`03001oogoo00Yoo`037oo10001goo2000 3Woo1000Egoo2@001Goo1000@7oo000iOol00`00Oomoo`06Ool:0004Ool> 001EOol;0005Ool4000oOol0049oo`/000=oo`l005Aoo`/000Moo`03001o ogoo03ioo`00@Goo300037oo1@00E7oo3000B7oo000>Oolo0007oo00Moo`@0 06moo`03001oogoo04]oo`00>goo00=23`00Ool02Goo00<007ooOol0KWoo 00<007ooOol0Bgoo000kOol00d8?001oo`09Ool00`00Oomoo`1^Ool00`00 Oomoo`1;Ool003Uoo`0348<0000000<00003E[Aoogoo00Eoo`03001oogoo 06ioo`03001oogoo04]oo`00>Goo00A:DT8?8@L000923`03JeUoogoo00Eo o`03001oogoo039oo`03Nmh481S503Uoo`03001oogoo04]oo`00>goo00=2 3`00Ool02Goo00<007ooOol0goo00=F]247Ool02Goo00<007ooOol00aR66LhIcQkgVmk0fLh=Woo00<007ooOol017oo0`000S6< 0P0000<@PgooOol0?Goo000iOol00fLh0000000200000eJdOomoo`06Ool0 0`00Oomoo`1^Ool00`00Oomoo`04Ool00d8?124Ha@02F]H00aS5125:DP0o Ool003Uoo`07Mk`icP00:DXicTYBOoh01goo00<007ooOol0KWoo00<007oo Ool01Goo00H@Pc6Woo00=g_000AS000goo 00<48C6;Ool017ooLP001Woo0P0000D48000000003W>041oo`00>Woo00=g _000DY<00goo00<Goo00Uo oU[E000DY6mkOom6<000BU80a7oo000iOol016Lh000000@Q0`00007_NF]E23ekg0"], "NumberedFigure", TextAlignment->Center, TextJustification->0, ImageSize->{262, 91}, ImageMargins->{{107, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "The equations define generic relations between quantities of a simple \ electrical component. In order to be useful a constitutive equation must be \ added. The keyword ", StyleBox["Partial", FontFamily->"Courier"], " indicates that this model class is incomplete. The keyword is optional. \ It is meant as an indication to a user that it is not possible to use the \ class as it is to instantiate components." }], "Text"], Cell["\<\ String after the class name is a comment that is a part of the language, \ i.e., these comments are associated with the definition and are normally \ displayed by dialogs and forms presenting details about class definitions.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Equations and Non-Causal Modeling", "Subsubsection"], Cell["\<\ Non-causal modeling means modeling based on equations instead of assignment \ statements. Equations do not specify which variables are inputs and which are \ outputs, whereas in assignment statements variables on the left-hand side are \ always outputs (results) and variables on the right-hand side are always \ inputs. Thus, the causality of equations-based models is unspecified and \ fixed only when the equation systems are solved. This is called non-causal \ modeling.\ \>", "Text"], Cell["\<\ The main advantage with non-causal modeling is that the solution direction of \ equations will adapt to the data flow context in which the solution is \ computed. The data flow context is defined by telling which variables are \ needed as outputs and which are external inputs to the simulated system.\ \>", "Text"], Cell["\<\ The non-causality of MathModelica (Modelica) library classes makes these more \ reusable than traditional classes containing assignment statements where the \ input-output causality is fixed.\ \>", "Text"], Cell["For example the equation from resistor class below:", "Text"], Cell["\tR*i = v;", "Program"], Cell[TextData[{ "can be used in two ways. The variable ", StyleBox["v", FontFamily->"Courier"], " can be computed as a function of ", StyleBox["i", FontFamily->"Courier"], ", or the variable ", StyleBox["i", FontFamily->"Courier"], " can be computed as a function of ", StyleBox["v", FontFamily->"Courier"], " as shown in the two assignment statements below:" }], "Text"], Cell["\<\ \ti := v/R; \tv := R*i;\ \>", "Program"], Cell[TextData[{ "In the same way the following equation from the class ", StyleBox["TwoPin", FontFamily->"Courier"] }], "Text"], Cell["\tv = p.v - n.v", "Program"], Cell["can be used in three ways:", "Text"], Cell["\<\ \tv := p.v - n.v; \tp.v := v + n.v; \tn.v := p.v - v;\ \>", "Program"] }, Open ]], Cell[CellGroupData[{ Cell["Inheritance, Parameters and Constants", "Subsubsection"], Cell[TextData[{ "To define a model for a resistor we exploit ", StyleBox["TwoPin", FontFamily->"Courier"], " and add a definition of a parameter for the resistance and Ohm's law to \ define the behavior:" }], "Text"], Cell[BoxData[ \(Model[Resistor, \ "\", \[IndentingNewLine]Extends[ TwoPin]; \[IndentingNewLine]Parameter\ Real\ R[ {unit \[Equal] "\"}]; \ "\"; \[IndentingNewLine]Equation[\[IndentingNewLine]R\ i \[Equal] v\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "The keyword ", StyleBox["Parameter", FontFamily->"Courier"], " specifies that the variable is constant during a simulation run, but can \ change values between runs. This means that parameter is a special kind of \ constant, which is implemented as a static variable that is initialized once \ and never changes its value during a specific execution. A parameter is a \ variable that makes it simple for a user to modify the behavior of a model." }], "Text"], Cell["\<\ A MathModelica constant never changes and can be substituted inline.\ \>", "Text"], Cell[TextData[{ "The keyword ", StyleBox["Extends", FontFamily->"Courier"], " specifies the parent class. All variables, equations and connects are \ inherited from the parent. Multiple inheritance is supported in \ MathModelica." }], "Text"], Cell["\<\ Just like in C++ variables, equations and connections of the parent class \ cannot be removed in the subclass.\ \>", "Text"], Cell["\<\ In C++ a virtual function can be replaced by a function with the same name in \ the child class. In Modelica 1.0 the equations cannot be named and therefore \ we cannot replace equations. When classes are inherited, equations are \ accumulated. This makes the equation-based semantics of the child classes \ consistent with the semantics of the parent class.\ \>", "Text"], Cell["\<\ An innovation of MathModelica is that the type of a variable of the parent \ class can be replaced. We describe this in more detail in Section 2.4.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Time and Model Dynamics", "Subsubsection"], Cell[TextData[{ "Dynamic systems are models where behavior evolves as a function of time. \ We use a predefined variable ", StyleBox["Time", FontFamily->"Courier"], ", which steps forward during system simulation." }], "Text"], Cell["A class for the voltage source can be defined as:", "Text"], Cell[BoxData[ \(Model[VsourceAC, \ "\", \[IndentingNewLine]Extends[ TwoPin]; \[IndentingNewLine]Parameter\ Real\ VA\ \[Equal] \ 220; \ "\"; \[IndentingNewLine]Parameter\ Real\ f \[Equal] \ 50; \ "\"; \[IndentingNewLine]Protected[\ \[IndentingNewLine]Constant\ Real\ PI\ \[Equal] \ 3.141592\[IndentingNewLine]]; \[IndentingNewLine]Equation[\ \[IndentingNewLine]v \[Equal] VA*Sin[2\ PI\ f\ Time]\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "class for an electrical capacitor and inductor can also reuse the ", StyleBox["TwoPin", FontFamily->"Courier"], " as follows:" }], "Text"], Cell[BoxData[ \(Model[Capacitor, \ "\", \[IndentingNewLine]Extends[ TwoPin]; \[IndentingNewLine]Parameter\ Real\ C[ {unit \[Equal] "\"}]; \ "\"; \[IndentingNewLine]Equation[\[IndentingNewLine]C\ v' \[Equal] i\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(Model[Inductor, \ "\", \[IndentingNewLine]Extends[ TwoPin]; \[IndentingNewLine]Parameter\ Real\ L[ {unit \[Equal] "\"}]; \ "\"; \[IndentingNewLine]Equation[\[IndentingNewLine]L\ i' \[Equal] v\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "where ", StyleBox["der(v)", FontFamily->"Courier"], " means the time derivative of v." }], "Text"], Cell[TextData[{ "During system simulation the variables ", Cell[BoxData[ \(TraditionalForm\`i\)]], " and ", Cell[BoxData[ \(TraditionalForm\`v\)]], " evolve as functions of time. The solver of differential equations \ computes the values of ", Cell[BoxData[ \(TraditionalForm\`i(t)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`v(t)\)]], " (", Cell[BoxData[ \(TraditionalForm\`t\)]], " is time) so that ", Cell[BoxData[ \(TraditionalForm\`C\ v' \((t)\) = i(t)\)]], " for all values of ", Cell[BoxData[ \(TraditionalForm\`t\)]], "." }], "Text"], Cell["\<\ Finally, we define the ground point as a reference value for the voltage \ levels\ \>", "Text"], Cell[BoxData[ \(Model[Ground, \ "\", \[IndentingNewLine]Pin\ p; \[IndentingNewLine]Equation[\ \[IndentingNewLine]p . v \[Equal] 0\[IndentingNewLine]]\[IndentingNewLine]] \)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[StyleBox["The Complete Circuit Model", "Subsubsection"]] , "Subsubsection"], Cell[TextData[{ "Finally we let the MathModelica system print out the complete code for the \ circuit model. Each ", StyleBox["Class", FontFamily->"Courier"], ", ", StyleBox["Model", FontFamily->"Courier"], ", ", StyleBox["Type", FontFamily->"Courier"], ", and ", StyleBox["Connector", FontFamily->"Courier"], " definition above stores the definitions in a symbol table. The command ", StyleBox["ListSymbolTable", FontFamily->"Courier"], " generates a list of the class definitions available in the symbol table. \ ", StyleBox["MakeModel", FontFamily->"Courier"], " package these definitions into a single model. The complete model in the \ ", StyleBox["MathModelicaFullForm", FontFamily->"Courier"], " format is stored in variable ", StyleBox["m", FontFamily->"Courier"], "." }], "Text"], Cell[BoxData[ \(\(m = MakeModel[ListSymbolTable[]];\)\)], "Input"], Cell[TextData[{ "The ", StyleBox["MathModelicacFullForm", FontFamily->"Courier"], " format is converted to input form and then the command ", StyleBox["MathModelicaForm", FontFamily->"Courier"], " is used to pretty print the code." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MathModelicaFullFormToInputForm[m] // MathModelicaForm\)], "Input"], Cell[BoxData[ TagBox[ RowBox[{ StyleBox["ModelicaModel", FontWeight->"Bold"], "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"Capacitor", ",", StyleBox["\<\"Ideal electrical capacitor\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ",", "\[IndentingNewLine]", RowBox[{\(Extends[TwoPin]\), ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ \(Parameter\ \ \[SpaceIndicator]\ \ Real\ \ \[SpaceIndicator]\ \ C\ [{unit == "F"}]\), ";", StyleBox["\<\"Capacitance\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]]}], ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"C", " ", SuperscriptBox["v", "\[Prime]", MultilineFunction->None]}], "==", "i"}], "\[IndentingNewLine]", "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"Circuit", ",", "\[IndentingNewLine]", RowBox[{ \(Resistor\ \ \[SpaceIndicator]\ \ R1[{R == 10}]\), ";", "\[IndentingNewLine]", RowBox[{ \(Capacitor\ \ \[SpaceIndicator]\ \ C[{C == 0.01`}]\), ";", "\[IndentingNewLine]", RowBox[{ \(Resistor\ \ \[SpaceIndicator]\ \ R2[{R == 100}]\), ";", "\[IndentingNewLine]", RowBox[{ \(Inductor\ \ \[SpaceIndicator]\ \ L[{L == 0.1`}]\), ";", "\[IndentingNewLine]", RowBox[{ \(VsourceAC\ \ \[SpaceIndicator]\ \ AC\), ";", "\[IndentingNewLine]", RowBox[{ \(Ground\ \ \[SpaceIndicator]\ \ G\), ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", RowBox[{ \(Connect[ AC \(\(\[NegativeMediumSpace]\)\(\[Hacek]\)\ \(\[NegativeMediumSpace]\)\) p, R1 \(\(\[NegativeMediumSpace]\)\(\[Hacek]\)\(\ \[NegativeMediumSpace]\)\) p]\), ";", StyleBox["\<\"Capacitor circuit\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ";", "\[IndentingNewLine]", RowBox[{ \(Connect[ R1 \(\(\[NegativeMediumSpace]\)\(\[Hacek]\ \)\(\[NegativeMediumSpace]\)\) n, C \(\(\[NegativeMediumSpace]\)\(\[Hacek]\)\ \(\[NegativeMediumSpace]\)\) p]\), ";", "\[IndentingNewLine]", RowBox[{ \(Connect[ C \(\(\[NegativeMediumSpace]\)\(\[Hacek]\ \)\(\[NegativeMediumSpace]\)\) n, AC \(\(\[NegativeMediumSpace]\)\(\[Hacek]\ \)\(\[NegativeMediumSpace]\)\) n]\), ";", "\[IndentingNewLine]", RowBox[{ \(Connect[ R1 \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) p, R2 \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) p]\), ";", StyleBox["\<\"Inductor circuit\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ";", "\[IndentingNewLine]", RowBox[{ \(Connect[ R2 \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) n, L \(\(\[NegativeMediumSpace]\)\(\[Hacek]\ \)\(\[NegativeMediumSpace]\)\) p]\), ";", "\[IndentingNewLine]", RowBox[{ \(Connect[ L \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) n, C \(\(\[NegativeMediumSpace]\)\(\[Hacek]\ \)\(\[NegativeMediumSpace]\)\) n]\), ";", "\[IndentingNewLine]", RowBox[{ \(Connect[ AC \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) n, G \(\(\[NegativeMediumSpace]\)\(\[Hacek]\ \)\(\[NegativeMediumSpace]\)\) p]\), ";", StyleBox["\<\"Ground\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]]}]}]}]}]} ]}]}], "\[IndentingNewLine]", "]"}]}]}]}]} ]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Type", FontWeight->"Bold"], "[", \(Current, \[IndentingNewLine]Real[{unit == "A"}]\), "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"Ground", ",", StyleBox["\<\"Ground\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ",", "\[IndentingNewLine]", RowBox[{ \(Pin\ \ \[SpaceIndicator]\ \ p\), ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", \(p \(\(\[NegativeMediumSpace]\)\(\[Hacek]\)\(\ \[NegativeMediumSpace]\)\) v == 0\), "\[IndentingNewLine]", "]"}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"Inductor", ",", StyleBox["\<\"Ideal electrical inductor\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ",", "\[IndentingNewLine]", RowBox[{ \(Extends[TwoPin]\), ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ \(Parameter\ \ \[SpaceIndicator]\ \ Real\ \ \[SpaceIndicator]\ \ L\ [{unit == "H"}]\), ";", StyleBox["\<\"Inductance\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]]}], ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"L", " ", SuperscriptBox["i", "\[Prime]", MultilineFunction->None]}], "==", "v"}], "\[IndentingNewLine]", "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Connector", FontWeight->"Bold"], "[", \(\(Pin, \ \[IndentingNewLine]\(\(Voltage\ \ \[SpaceIndicator]\ \ v\)\(;\)\)\)\ \[IndentingNewLine]\(\ Flow\ \ \[SpaceIndicator]\ \ Current\ \ \[SpaceIndicator]\ \ i\)\), "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"Resistor", ",", StyleBox["\<\"Ideal electrical resistor\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ",", "\[IndentingNewLine]", RowBox[{ \(Extends[TwoPin]\), ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ \(Parameter\ \ \[SpaceIndicator]\ \ Real\ \ \[SpaceIndicator]\ \ R\ [{unit == "ohm"}]\), ";", StyleBox["\<\"Resistance\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]]}], ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", \(R\ i == v\), "\[IndentingNewLine]", "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"TwoPin", ",", StyleBox[ "\<\"Superclass of elements with two electrical \ pins\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ",", "\[IndentingNewLine]", RowBox[{ \(Pin\ \ \[SpaceIndicator]\ \ {p, n}\), ";", "\[IndentingNewLine]", RowBox[{ \(Voltage\ \ \[SpaceIndicator]\ \ v\), ";", "\[IndentingNewLine]", RowBox[{ \(Current\ \ \[SpaceIndicator]\ \ i\), ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", \(\(\(v == p \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) v - n \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) v\)\(;\)\)\[IndentingNewLine]\(\(\(0 == p \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) i + n \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) i\)\(;\)\)\[IndentingNewLine]\(i == p \(\(\[NegativeMediumSpace]\)\(\ \[Hacek]\)\(\[NegativeMediumSpace]\)\) i\)\)\), "\[IndentingNewLine]", "]"}]}] }]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Type", FontWeight->"Bold"], "[", \(Voltage, \[IndentingNewLine]Real[ {unit == "A"}]\), "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Model", FontWeight->"Bold"], "[", RowBox[{"VsourceAC", ",", StyleBox["\<\"Sine-wave voltage source\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], ",", "\[IndentingNewLine]", RowBox[{ \(Extends[TwoPin]\), ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ \(Parameter\ \ \[SpaceIndicator]\ \ Real\ \ \ \[SpaceIndicator]\ \ \(VA == 220\)\), ";", StyleBox["\<\"Amplitude [V]\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ \(Parameter\ \ \[SpaceIndicator]\ \ Real\ \ \ \[SpaceIndicator]\ \ \(f == 50\)\), ";", StyleBox["\<\"Frequency [Hz]\"\>", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Protected", FontWeight->"Bold"], "[", "\[IndentingNewLine]", \(Constant\ \ \[SpaceIndicator]\ \ Rea\ l\ \ \[SpaceIndicator]\ \ \(PI == 3.141592`\)\), "\[IndentingNewLine]", "]"}] , ";", "\[IndentingNewLine]", RowBox[{ StyleBox["Equation", FontWeight->"Bold"], "[", "\[IndentingNewLine]", \(v == VA\ Sin[ \((\((2\ PI)\)\ f)\)\ Time]\), "\[IndentingNewLine]", "]"}]}]}]}]}]}] , "\[IndentingNewLine]", "]"}]}]}]}]}]}]}]}]}]}] , "\[IndentingNewLine]", "]"}], HoldForm]], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["The MathModelica Notion of Subtypes", "Subsection"], Cell[TextData[{ "The notion of subtyping in MathModelica is influenced by type theory of \ Abbadi and Cardelli ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "ref:AbadiL:1996"], ButtonBox["\[VeryThinSpace]", ButtonData:>"ref:AbadiL:1996", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], " . The notion of inheritance in MathModelica is separated from the notion \ of subtyping. According to the definition, a class A is a subtype of class B \ if class A contains all the public variables declared in the class B, and \ types of these variables are subtypes of types of corresponding variables in \ B. The main benefit of this definition is additional flexibility in the \ composition of types. For instance, the class ", StyleBox["TempResistor", FontFamily->"Courier"], " is a subtype of ", StyleBox["Resistor", FontFamily->"Courier"], "." }], "Text"], Cell[BoxData[ \(Model[ TempResistor, \[IndentingNewLine]Extends[ TwoPin]; \[IndentingNewLine]Parameter\ Real\ {R, RT, Tref}; \[IndentingNewLine]Real\ T; \[IndentingNewLine]Equation[\ \[IndentingNewLine]\(v \[Equal] i\ \((R + RT*\((T - Tref)\))\);\)\[IndentingNewLine]]\[IndentingNewLine]] \)], "Input"], Cell[TextData[{ "Subtyping is used for example in class instantiation, redeclarations and \ function calls. If variable ", StyleBox["a", FontSize->10], " is of type A, and A is a subtype of B, then ", StyleBox["a", FontFamily->"Courier"], " can be initialized by a variable of type B. Redeclaration is discussed in \ the next section." }], "Text"], Cell[TextData[{ "Note that TempResistor does not inherit the ", StyleBox["Resistor", FontFamily->"Courier"], " class. There are different equations for evaluation of ", StyleBox["v", FontFamily->"Courier"], ". If equations are inherited from ", StyleBox["Resistor", FontFamily->"Courier"], " then the set of equations will become inconsistent in ", StyleBox["TempResistor", FontFamily->"Courier"], ", since MathModelica currently does not support named equations and \ replacement of equations. For example, the specialized equation below from ", StyleBox["TempResistor", FontFamily->"Courier"], ":" }], "Text"], Cell["\tv=i*(R+RT*(T-Tref))", "Program"], Cell[TextData[{ "and the general equation from class ", StyleBox["Resistor", FontFamily->"Courier"] }], "Text"], Cell["\tv=R*i", "Program"], Cell["are inconsistent.", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Class Parametrization", "Subsection"], Cell["\<\ A distinctive feature of object-oriented programming languages and \ environments is ability to fetch classes from standard libraries and reuse \ them for particular needs. Obviously, this should be done without \ modification of the library codes. The two main mechanisms that serve for \ this purpose are:\ \>", "Text"], Cell[TextData[{ StyleBox["inheritance", FontSlant->"Italic"], ". It is essentially \[OpenCurlyDoubleQuote]copying\[CloseCurlyDoubleQuote] \ class definition and adding more elements (variables, equations and \ functions) to it." }], "Itemize"], Cell[TextData[{ StyleBox["class parametrization", FontSlant->"Italic"], " (also called generic classes or types). It is replacing a generic type \ identifier in whole class definition by an actual type." }], "Itemize"], Cell["\<\ In MathModelica we have a new way to control class parametrization. Assume \ that a library class is defined as\ \>", "Text"], Cell[BoxData[ \(Model[ SimpleCircuit, \[IndentingNewLine]Resistor\ {R1[{R \[Equal] 100}], \ R2[{R \[Equal] 200}], \ R3[{R \[Equal] 300}]}; \ \[IndentingNewLine]Equation[\[IndentingNewLine]Connect[R1 . p, \ R2 . p]; \[IndentingNewLine]Connect[R1 . p, \ R3 . p]\[IndentingNewLine]]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "Assume that in our particular application we would like to reuse the \ definition of ", StyleBox["SimpleCircuit", FontFamily->"Courier"], ": we want to use the parameter values given for ", StyleBox["R1.R", FontFamily->"Courier"], " and ", StyleBox["R2.R", FontFamily->"Courier"], " and the circuit topology, but exchange ", StyleBox["Resistor", FontFamily->"Courier"], " with the temperature-dependent resistor model, ", StyleBox["TempResistor", FontFamily->"Courier"], ", discussed above." }], "Text"], Cell[TextData[{ "This can be accomplished by redeclaring ", StyleBox["R1", FontFamily->"Courier"], " and ", StyleBox["R2", FontFamily->"Courier"], " as follows." }], "Text"], Cell[BoxData[ \(Type[ RedefinedSimpleCircuit, \[IndentingNewLine]SimpleCircuit[ {\[IndentingNewLine]Redeclare[ TempResistor\ R1], \[IndentingNewLine]Redeclare[ TempResistor\ R2]\[IndentingNewLine]}]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "Since ", StyleBox["TempResistor", FontFamily->"Courier"], " is a subtype of ", StyleBox["Resistor", FontFamily->"Courier"], ", it is possible to replace the ideal resistor model. Values of the \ additional parameters of ", StyleBox["TempResistor", FontFamily->"Courier"], " can be added in the redeclaration:" }], "Text"], Cell["\<\ \tRedeclare[TempResistor R1[{RT\[Equal]0.1, Tref\[Equal]20.0}]]\ \>", "Program"], Cell[TextData[{ "This is a very strong modification but it should be noted that all \ equations that could be defined in ", StyleBox["SimpleCircuit", FontFamily->"Courier"], " are still valid." }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["MathModelica \[Dash] the environment", "Section"], Cell[CellGroupData[{ Cell["MathModelicaFullForm", "Subsection"], Cell["\<\ The MathModelica syntax presented so far is the syntax that can be given as \ input (InputForm) to the MathModelica system, this syntax is also used when \ code is printed in StandardForm where indentations and the special character \ for the type operator are used.\ \>", "Text"], Cell[TextData[{ "Internally in the MathModelica system uses another format called \ MathModelicaFullForm. This format is the abstract syntax ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "cite:AhoSU:Compilers:1986"], ButtonBox["\[VeryThinSpace]", ButtonData:>"cite:AhoSU:Compilers:1986", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], " of the MathModelica language where all the elements of the language are \ separated canonically to be easy to extract and compare for the functions \ operating on the MathModelica language. See also the semantic implementation \ of ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "cite:K\[ARing]gedalF:1998"], ButtonBox["\[VeryThinSpace]", ButtonData:>"cite:K\[ARing]gedalF:1998", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], "." }], "Text"], Cell["\<\ The following simple constant declaration\ \>", "Text"], Cell[BoxData[ \(Declare[\[IndentingNewLine]Constant\ Real[2, 2]\ \ unitarr\ = \ {{1, 0}, {0, 1}}; \ "\<2D Identity\>"\[IndentingNewLine]]\)], "Input"], Cell["is stored internally in the MathModelicaFullForm format as", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(GetMathModelicaFullForm[unitarr]\)], "Input", Evaluatable->False], Cell[BoxData[ \(Hold[ Declaration[TYPE[Real, {2, 2}, {Constant}, {}], VariableComponent[unitarr, ValueBinding[{{1, 0}, {0, 1}}], {}, {}, StringRows["2D Identity"]]]]\)], "Output"] }, Open ]], Cell[TextData[{ "A declaration of a global variable is represented by the ", StyleBox["Declaration", FontFamily->"Courier"], " node in the abstract syntax. This node has two arguments: the type and \ the component. The type is represented by the ", StyleBox["TYPE", FontFamily->"Courier"], " node which stores the name, array dimension, type attributes (", StyleBox["Constant", FontFamily->"Courier"], ") and type modifications (which is empty in this case). The component \ argument contains a ", StyleBox["VariableComponent", FontFamily->"Courier"], " including the name of the variable, the initialization (", StyleBox["ValueBinding", FontFamily->"Courier"], "), and in the end the comment string (", StyleBox["StringRows", FontFamily->"Courier"], ") that is associated with the variable." }], "Text"], Cell[TextData[{ "If we instead declare the type of a function we will get a similar \ expression in MathModelicaFullForm. (The syntax for function declarations \ have been introduced by the MathCode C++ system. ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "cite:MathCode"], ButtonBox["\[VeryThinSpace]", ButtonData:>"cite:MathCode", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], ")" }], "Text"], Cell[BoxData[ \(Declare[\[IndentingNewLine]foo[Real\ x_] \[Rule] Real[3]\[IndentingNewLine]]\)], "Input"], Cell[TextData[{ "This declaration specifies that the ", StyleBox["Mathematica", FontSlant->"Italic"], " function foo[x] has the ", StyleBox["Real", FontFamily->"Courier"], " type for the input argument ", StyleBox["x", FontFamily->"Courier"], ", and a ", StyleBox["Real", FontFamily->"Courier"], " vector for the return value. The MathModelicaFullForm is in this case:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(GetMathModelicaFullForm[foo]\)], "Input"], Cell[BoxData[ \(Hold[ Declaration[ TYPE[FunctionType[{TYPE[Real, {}, {}, {}]}, {TYPE[Real, {3}, {}, {}]}, {}], {}, {}, {}], FunctionComponent[foo, {x}, {Null}, foo[x_], Null, Null]]]\)], "Output"] }, Open ]], Cell[TextData[{ "The function declaration will also create a ", StyleBox["Declaration", FontFamily->"Courier"], " node with two arguments: type and component. In this case the type \ expression (", StyleBox["TYPE", FontFamily->"Courier"], ") has a ", StyleBox["FunctionType", FontFamily->"Courier"], " node as it's first argument instead of a name of a type (like ", StyleBox["Real", FontFamily->"Courier"], " in the array declaration above). The ", StyleBox["FunctionType", FontFamily->"Courier"], " node stores a list of the input arguments types and another list with the \ type of the output values. Note that these type are also represented by the ", StyleBox["TYPE", FontFamily->"Courier"], " node, i.e. any type can be built of nested ", StyleBox["TYPE", FontFamily->"Courier"], " expressions. The component is in this case a ", StyleBox["FunctionComponent", FontFamily->"Courier"], " which stores the function name, input argument symbol names (the formal \ parameters), output names, and the pattern of the function among other things \ not discussed here." }], "Text"], Cell["\<\ There are several goals behind the design of the MathModelicaFullForm format:\ \ \>", "Text"], Cell["\<\ Abstract Syntax: The format separates the different constructions in the \ language systematically making the navigation of types and code easier. \ \>", "Itemize"], Cell["\<\ The preserving the syntax structure of the Modelica or MathModelica code. \ This means that the mapping from Modelica to MathModelicaFullForm should be \ injective, and that transformations from Modelica to MathModelicaFullForm \ into MathModelica input form should be reversible.\ \>", "Itemize"], Cell[TextData[{ "Symbol table format. The MathModelicaFullForm should be possible to use in \ the symbol table. Specially the representation of types with the ", StyleBox["TYPE", FontFamily->"Courier"], " node should be ready for efficient type inference, i.e., deriving the \ types of general expressions." }], "Itemize"], Cell["\<\ Internal standard: The MathModelicaFullForm format should be used by all the \ components in the MathModelica system. Therefore it must be easily parsed and \ unparsed. By generating the FullForm format of MathModelicaFullForm we get a \ pure tree syntax of the format which is very easy for external programs to \ parse. The unparsing (e.g., to Modelica) is easy and can be done by simple \ table driven unparsers if the MathModelicaFullForm is has a well designed \ abstract syntax.\ \>", "Itemize"] }, Open ]], Cell[CellGroupData[{ Cell["Typed Pattern Matching", "Subsection"], Cell[TextData[{ "The type system in MathModelica is mainly used for generating the \ simulation code, whereas the ", StyleBox["Mathematica", FontSlant->"Italic"], " computation is not affected of the type of a symbol or a function. \ However, the types can be used in pattern matching." }], "Text"], Cell[TextData[{ "Assume we have a list of equations including typed variables, and that \ some of these variables have the type ", StyleBox["Angle", FontFamily->"Courier"], ". In particular we are interested in the expressions in the equations of \ the form ", StyleBox["Sin[exp]", FontFamily->"Courier"], " where the ", StyleBox["exp", FontFamily->"Courier"], " is of the type ", StyleBox["Angle", FontFamily->"Courier"], ". Assume that the values of the angle expressions are always close to \ zero, then to improve simulation performance we could replace each Sin \ expression with it's third order approximation." }], "Text"], Cell["This can be done by the following rule.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(r1 = TypedPattern[Sin[Angle\ x_]] \[Rule] Normal[Series[Sin[x], {x, 0, 3}]]\)], "Input"], Cell[BoxData[ \(HoldPattern[Sin[x_?\((TypeQ[Angle])\)]] \[Rule] x - x\^3\/6\)], "Output"] }, Open ]], Cell[TextData[{ "The ", StyleBox["TypedPattern", FontFamily->"Courier"], " command works as the inbuilt ", StyleBox["HoldPattern", FontFamily->"Courier"], " except that type information are extracted and the pattern is rewritten \ using a predicate test called ", StyleBox["TypeQ", FontFamily->"Courier"], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Simulation", "Subsection"], Cell["\<\ In Section 2.2 the MathModelica model of the circuit was defined. This \ circuit model will here be simulated.\ \>", "Text"], Cell[TextData[{ "To simulate a MathModelica model a sequence of transformations must be \ done. The MathModelica code (or MathModelicaFullForm format) is the starting \ point and an executable binary file is the final result of the \ transformation. The simulation is performed by executing the binary file \ which generates a data file with the simulation data, that is then loaded \ into ", StyleBox["Mathematica.", FontSlant->"Italic"], " We will here present each of these steps to perform the a simulation. \ Note that the whole sequence is normally automated but is here manually done \ for illustration." }], "Text"], Cell[TextData[{ "In Section 2.2.8, the MathModelicaFullForm model was stored in the the \ variable ", StyleBox["m", FontFamily->"Courier"], ". The first step is to export the MathModelicaFullForm format to the \ Modelica format since the external simulation engine supports Modelica." }], "Text"], Cell[BoxData[ \(\(ExportModelica["\", m];\)\)], "Input"], Cell["The resulting file is", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(!! circuit.mo\)\)], "Input"], Cell["\<\ model Capacitor \"Ideal electrical capacitor\" extends TwoPin; parameter Real C(Unit=\"F\") \"Capacitance\"; equation C*(der(v))=i; end Capacitor; model Circuit Resistor R1(R=10); Capacitor C(C=0.01); Resistor R2(R=100); Inductor L(L=0.1); VsourceAC AC; Ground G; equation connect(AC.p,R1.p) \"Capacitor circuit\"; connect(R1.n,C.p); connect(C.n,AC.n); connect(R1.p,R2.p) \"Inductor circuit\"; connect(R2.n,L.p); connect(L.n,C.n); connect(AC.n,G.p) \"Ground\";; end Circuit; type Current = Real(Unit=\"A\"); model Ground \"Ground\" Pin p; equation p.v=0; end Ground; model Inductor \"Ideal electrical inductor\" extends TwoPin; parameter Real L(Unit=\"H\") \"Inductance\"; equation L*(der(i))=v; end Inductor; connector Pin Voltage v; flow Current i; end Pin; model Resistor \"Ideal electrical resistor\" extends TwoPin; parameter Real R(Unit=\"ohm\") \"Resistance\"; equation R*i=v; end Resistor; model TwoPin \"Superclass of elements with two electrical pins\" Pin p, n; Voltage v; Current i; equation v=p.v-(n.v); 0=p.i+n.i; i=p.i;; end TwoPin; type Voltage = Real(Unit=\"A\"); model VsourceAC \"Sine-wave voltage source\" extends TwoPin; parameter Real VA=220 \"Amplitude [V]\"; parameter Real f=50 \"Frequency [Hz]\"; protected constant Real PI=3.141592; equation v=VA*(sin(2*PI*f*Time)); end VsourceAC;\ \>", "Print"] }, Open ]], Cell[TextData[{ "The command ", StyleBox["OpenModel", FontFamily->"Courier"], " will make the external simulation engine to load the Modelica file." }], "Text"], Cell[BoxData[ \(OpenModel["\"]\)], "Input"], Cell[TextData[{ "The command ", StyleBox["InstantiateModel", FontFamily->"Courier"], " instantiate a model object of the type ", StyleBox["Circuit", FontFamily->"Courier"], ". Each component in that model class will also be instatiated." }], "Text"], Cell[BoxData[ \(\(InstantiateModel["\"];\)\)], "Input"], Cell[TextData[{ "The command ", StyleBox["TranslateModel", FontFamily->"Courier"], " starts a sequence of transformations:" }], "Text"], Cell["\<\ The set of differential equations is extracted from the Modelica classes into \ one set of equations. This process is called flattening of the Modelica \ model, since it is equivalent to write the complete set of equations for the \ model into one single class.\ \>", "Itemize"], Cell["\<\ After flattening, all the equations are sorted. Simplification algorithms can \ eliminate many of them. If two syntactically equivalent equations appear only \ one copy of the equations is kept. Then they can be converted to assignment \ statements. If a strongly connected set of equations appears, these can be \ transformed by a symbolic solver. The symbolic solver performs a number of \ algebraic transformations to simplify the dependencies between the variables. \ It can also solve a system of differential equations if it has a symbolic \ solution.\ \>", "Itemize"], Cell["\<\ Finally, C/C++ code is generated, and it is linked with a numeric solver.\ \>", "Itemize"], Cell[BoxData[ \(\(TranslateModel["\"];\)\)], "Input"], Cell["\<\ The Modelica technology gives a high level modeling paradigm in which \ compilers, and algebraic transformation can gain performance in the \ simulation runs, by reducing the number of equations, and solving equations \ symbolically. In the MathModelica environment the user can improve the \ symbolic transformation using domain specific knowledge to derive \ transformation rules that are applied on the equations before the simulation \ code is generated. The MathModelica environment is an open system where the \ user has access to the different layers of transformations.\ \>", "Text"], Cell["\<\ The final transformation produces a C code for the mode in the file \ \"dsmodel.c\".\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(!! dsmodel.c\)\)], "Input"], Cell["\<\ #include /* Prototypes for functions used in model */ /* Codes used in model */ /* */ /* */ /* DSblock model generated by Dymola from Modelica model. */ /* DSblock C-code: */ #include /* Define variable names. */ #define Sections_ #define R1_p_direction Variable(0) #define R1_n_direction Variable(1) #define R1_R Variable(2) #define C_p_direction Variable(3) #define C_n_direction Variable(4) #define C_C Variable(5) #define R2_p_direction Variable(6) #define R2_n_direction Variable(7) #define R2_R Variable(8) #define L_p_direction Variable(9) #define L_n_direction Variable(10) #define L_L Variable(11) #define AC_p_direction Variable(12) #define AC_n_direction Variable(13) #define AC_VA Variable(14) #define AC_f Variable(15) #define AC_PI Variable(16) #define G_p_direction Variable(17) #define C_n_v Variable(18) #define AC_n_v Variable(19) #define L_n_v Variable(20) #define G_p_v Variable(21) #define AC_p_v Variable(22) #define R1_p_i Variable(23) #define R1_n_v Variable(24) #define R1_n_i Variable(25) #define R1_v Variable(26) #define C_p_i Variable(27) #define C_n_i Variable(28) #define R2_p_i Variable(29) #define R2_n_v Variable(30) #define R2_n_i Variable(31) #define R2_v Variable(32) #define L_n_i Variable(33) #define L_v Variable(34) #define AC_p_i Variable(35) #define AC_n_i Variable(36) #define AC_v Variable(37) #define G_p_i Variable(38) #define C_v State(0) #define der_C_v Derivative(0) #define L_i State(1) #define der_L_i Derivative(1) #define CPUClk Output(0) TranslatedEquations CPUClk = CurrentClockTime; InitialSection R1_p_direction = 1; R1_n_direction = (-1); R1_R = 10; C_p_direction = 1; C_n_direction = (-1); C_C = 0.01; R2_p_direction = 1; R2_n_direction = (-1); R2_R = 100; L_p_direction = 1; L_n_direction = (-1); L_L = 0.1; AC_p_direction = (-1); AC_n_direction = 1; AC_VA = 220; AC_f = 50; AC_PI = 3.141592; G_p_direction = 1; C_n_v = 0; AC_n_v = 0; L_n_v = 0; G_p_v = 0; OutputSection DynamicsSection AC_v = 220*sin(314.1592*Time); AC_p_v = AC_v; R1_n_v = C_v; R1_v = AC_p_v-R1_n_v; R1_p_i = 0.1*R1_v; R1_n_i = -R1_p_i; C_p_i = -R1_n_i; der_C_v = 100.0*C_p_i; R2_n_i = -L_i; R2_p_i = -R2_n_i; R2_v = 100*R2_p_i; R2_n_v = AC_p_v-R2_v; L_v = R2_n_v; der_L_i = 10.0*L_v; AcceptedSection C_n_i = -C_p_i; L_n_i = -L_i; AC_p_i = -(R1_p_i+R2_p_i); AC_n_i = -AC_p_i; G_p_i = -(L_n_i+C_n_i+AC_n_i); DefaultSection EndTranslatedEquations #include DeclareVariable(\"R1_p_direction\") DeclareConstant(1) DeclareVariable(\"R1_n_direction\") DeclareConstant((-1)) DeclareVariable(\"R1_R\") DeclareConstant(10) DeclareVariable(\"C_p_direction\") DeclareConstant(1) DeclareVariable(\"C_n_direction\") DeclareConstant((-1)) DeclareVariable(\"C_C\") DeclareConstant(0.01) DeclareVariable(\"R2_p_direction\") DeclareConstant(1) DeclareVariable(\"R2_n_direction\") DeclareConstant((-1)) DeclareVariable(\"R2_R\") DeclareConstant(100) DeclareVariable(\"L_p_direction\") DeclareConstant(1) DeclareVariable(\"L_n_direction\") DeclareConstant((-1)) DeclareVariable(\"L_L\") DeclareConstant(0.1) DeclareVariable(\"AC_p_direction\") DeclareConstant((-1)) DeclareVariable(\"AC_n_direction\") DeclareConstant(1) DeclareVariable(\"AC_VA\") DeclareConstant(220) DeclareVariable(\"AC_f\") DeclareConstant(50) DeclareVariable(\"AC_PI\") DeclareConstant(3.141592) DeclareVariable(\"G_p_direction\") DeclareConstant(1) DeclareVariable(\"C_n_v\") DeclareConstant(0) DeclareVariable(\"AC_n_v\") DeclareConstant(0) DeclareVariable(\"L_n_v\") DeclareConstant(0) DeclareVariable(\"G_p_v\") DeclareConstant(0) DeclareVariable(\"AC_p_v\") DeclareVariable(\"R1_p_i\") DeclareVariable(\"R1_n_v\") DeclareVariable(\"R1_n_i\") DeclareVariable(\"R1_v\") DeclareVariable(\"C_p_i\") DeclareVariable(\"C_n_i\") DeclareVariable(\"R2_p_i\") DeclareVariable(\"R2_n_v\") DeclareVariable(\"R2_n_i\") DeclareVariable(\"R2_v\") DeclareVariable(\"L_n_i\") DeclareVariable(\"L_v\") DeclareVariable(\"AC_p_i\") DeclareVariable(\"AC_n_i\") DeclareVariable(\"AC_v\") DeclareVariable(\"G_p_i\") DeclareState(\"C_v\", \"der_C_v\", 0, 0.0) DeclareState(\"L_i\", \"der_L_i\", 1, 0.0) DeclareOutput(\"CPUClk\") DeclareAlias(\"R1_p_v\", \" \", \"AC_p_v\", 1) DeclareAlias(\"R2_p_v\", \" \", \"AC_p_v\", 1) DeclareAlias(\"R1_i\", \" \", \"R1_p_i\", 1) DeclareAlias(\"C_p_v\", \" \", \"R1_n_v\", 1) DeclareAlias(\"C_i\", \" \", \"C_p_i\", 1) DeclareAlias(\"R2_i\", \" \", \"R2_p_i\", 1) DeclareAlias(\"L_p_v\", \" \", \"R2_n_v\", 1) DeclareAlias(\"L_p_i\", \" \", \"L_i\", 1) DeclareAlias(\"AC_i\", \" \", \"AC_p_i\", 1) #define NX_ 2 #define NX2_ 0 #define NU_ 0 #define NY_ 1 #define NW_ 39 #define NP_ 0 #define NRel_ 0 #define NCons_ 0 #define NA_ 9 #include \ \>", "Print"] }, Open ]], Cell[TextData[{ "The initial values can be taken from the model definition. If necessary, \ the user specifies the parameter values. Numeric solvers for differential \ equations (such as LSODE, part of ODEPACK ", StyleBox["[", FontColor->RGBColor[0, 0, 1]], CounterBox["Reference", "cite:Hindmarsh:1983"], ButtonBox["\[VeryThinSpace]", ButtonData:>"cite:Hindmarsh:1983", ButtonStyle->"Hyperlink"], StyleBox["]", FontColor->RGBColor[0, 0, 1]], " ) give the user possibility to ask about the value of specific variable \ in a specific time moment. As the result a function of time, e.g. ", Cell[BoxData[ \(TraditionalForm\`R2 . v \((t)\)\)]], " can be computed for a time interval ", Cell[BoxData[ \(TraditionalForm\`\([t\_0\ , \ t\_1]\)\)]], " and displayed as a graph or saved in a file. This data presentation is \ the final result of system simulation." }], "Text"], Cell[TextData[{ "The command ", StyleBox["SimulateModel", FontFamily->"Courier"], " will compile and link the C code file and execute the resulting binary \ file. The parameter values are taken form the default settings given in the \ Modelica model and in the defaults of the simulation engine. The parameter \ values can be changed between the simulation runs." }], "Text"], Cell[BoxData[ \(SimulateModel["\"]\)], "Input"], Cell["We can check that the simulation data in produced.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FileNames["\<*.mat\>"]\)], "Input"], Cell[BoxData[ \({"DSRES.MAT"}\)], "Output"] }, Open ]], Cell[TextData[{ "The simulation data is load back into ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\((simdata = GetSimulationData["\"])\) // Short\)], "Input"], Cell[BoxData[ TagBox[ RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"\<\"CPUClk\"\>", "\[Rule]", TagBox[\(InterpolatingFunction[{{0.`, 1.`}}, "<>"]\), False, Editable->False]}], ",", \(\[LeftSkeleton]49\[RightSkeleton]\), ",", RowBox[{"\<\"AC.i\"\>", "\[Rule]", TagBox[\(InterpolatingFunction[{{0.`, 1.`}}, "<>"]\), False, Editable->False]}]}], "}"}], "}"}], Short]], "Output"] }, Open ]], Cell["\<\ The simulation data is automatically converted to rules of \ InterpolatingFunctions, in the same format as NDSolve produce.\ \>", "Text"], Cell["\<\ A simple plot of one of the variables in the simulation data in the time \ interval [0, 0.2].\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(Plot[C . p . v[t] /. simdata, {t, 0. , 0.2}];\)\)], "Input"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .61803 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 4.7619 0.199027 0.0304685 [ [.2619 .18653 -12 -9 ] [.2619 .18653 12 0 ] [.5 .18653 -9 -9 ] [.5 .18653 9 0 ] [.7381 .18653 -12 -9 ] [.7381 .18653 12 0 ] [.97619 .18653 -9 -9 ] [.97619 .18653 9 0 ] [.01131 .04668 -12 -4.5 ] [.01131 .04668 0 4.5 ] [.01131 .35137 -6 -4.5 ] [.01131 .35137 0 4.5 ] [.01131 .50371 -12 -4.5 ] [.01131 .50371 0 4.5 ] [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 g .25 Mabswid [ ] 0 setdash .2619 .19903 m .2619 .20528 L s [(0.05)] .2619 .18653 0 1 Mshowa .5 .19903 m .5 .20528 L s [(0.1)] .5 .18653 0 1 Mshowa .7381 .19903 m .7381 .20528 L s [(0.15)] .7381 .18653 0 1 Mshowa .97619 .19903 m .97619 .20528 L s [(0.2)] .97619 .18653 0 1 Mshowa .125 Mabswid .07143 .19903 m .07143 .20278 L s .11905 .19903 m .11905 .20278 L s .16667 .19903 m .16667 .20278 L s .21429 .19903 m .21429 .20278 L s .30952 .19903 m .30952 .20278 L s .35714 .19903 m .35714 .20278 L s .40476 .19903 m .40476 .20278 L s .45238 .19903 m .45238 .20278 L s .54762 .19903 m .54762 .20278 L s .59524 .19903 m .59524 .20278 L s .64286 .19903 m .64286 .20278 L s .69048 .19903 m .69048 .20278 L s .78571 .19903 m .78571 .20278 L s .83333 .19903 m .83333 .20278 L s .88095 .19903 m .88095 .20278 L s .92857 .19903 m .92857 .20278 L s .25 Mabswid 0 .19903 m 1 .19903 L s .02381 .04668 m .03006 .04668 L s [(-5)] .01131 .04668 1 0 Mshowa .02381 .35137 m .03006 .35137 L s [(5)] .01131 .35137 1 0 Mshowa .02381 .50371 m .03006 .50371 L s [(10)] .01131 .50371 1 0 Mshowa .125 Mabswid .02381 .07715 m .02756 .07715 L s .02381 .10762 m .02756 .10762 L s .02381 .13809 m .02756 .13809 L s .02381 .16856 m .02756 .16856 L s .02381 .2295 m .02756 .2295 L s .02381 .25996 m .02756 .25996 L s .02381 .29043 m .02756 .29043 L s .02381 .3209 m .02756 .3209 L s .02381 .38184 m .02756 .38184 L s .02381 .41231 m .02756 .41231 L s .02381 .44278 m .02756 .44278 L s .02381 .47324 m .02756 .47324 L s .02381 .01622 m .02756 .01622 L s .02381 .53418 m .02756 .53418 L s .02381 .56465 m .02756 .56465 L s .02381 .59512 m .02756 .59512 L s .25 Mabswid .02381 0 m .02381 .61803 L s 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .5 Mabswid .02381 .19903 m .02846 .21878 L .03068 .22823 L .03178 .23288 L .03279 .23718 L .03398 .24661 L .03527 .26087 L .03754 .28579 L .04262 .34177 L .05285 .47706 L .05786 .52972 L .06005 .55275 L .06121 .56492 L .06244 .57408 L .06369 .57837 L .06485 .58236 L .06713 .59023 L .0685 .59493 L .06978 .59935 L .07093 .60332 L .07218 .60122 L .07347 .59462 L .07489 .58738 L .07776 .57277 L .07904 .56624 L .07975 .56264 L .08042 .55923 L .08171 .54748 L .0829 .53347 L .09341 .40199 L .09917 .32009 L .10458 .25652 L .1068 .23143 L .10801 .21774 L .10913 .20501 L .11036 .19708 L .111 .19435 L .1117 .19143 L .11404 .18151 L .11539 .1758 L .11686 .16962 L .11753 .16678 L .11824 .16377 L .11952 .1624 L .12074 .1677 L .12188 .17265 L .12449 .18394 L .12687 .19425 L .12804 .19933 L .12913 .20781 L Mistroke .13011 .21871 L .13116 .23032 L .13337 .25485 L .14291 .37219 L .14793 .43896 L .15322 .49503 L .15599 .52435 L .15675 .53239 L .15756 .53803 L .15833 .54073 L .15903 .54318 L .1618 .55294 L .16436 .56196 L .16561 .56634 L .16677 .56954 L .16799 .56343 L .16933 .55669 L .17215 .54253 L .17338 .53633 L .17473 .52957 L .17593 .52357 L .17704 .5123 L .17946 .48379 L .18454 .42391 L .19509 .27742 L .20027 .2188 L .20254 .19325 L .20375 .17972 L .20504 .16717 L .20621 .1623 L .20729 .15784 L .20938 .14912 L .21177 .13922 L .21281 .13486 L .21397 .13004 L .21512 .13242 L .21635 .13781 L .21894 .14918 L .22137 .1599 L .22256 .16512 L .22364 .16987 L .22477 .18137 L .22598 .19487 L .22855 .22349 L .23372 .2821 L .24296 .40705 L .24811 .46182 L .25081 .49067 L .25147 .49768 L .25218 .50522 L Mistroke .25296 .50942 L .25368 .51202 L .25644 .52187 L .25895 .53088 L .26014 .53515 L .26144 .5398 L .26267 .53765 L .26381 .53199 L .26889 .50676 L .27029 .49985 L .27105 .49608 L .27176 .49034 L .27301 .47563 L .27439 .4595 L .28435 .33476 L .29327 .21722 L .29571 .1899 L .2983 .16089 L .29937 .14896 L .30052 .13979 L .30178 .13462 L .30296 .12976 L .30562 .11885 L .30707 .1129 L .30842 .10737 L .30958 .10307 L .31081 .10857 L .31342 .1202 L .31609 .13208 L .31741 .13792 L .31861 .1433 L .31971 .1527 L .32088 .16574 L .32333 .19323 L .33303 .31264 L .34189 .42213 L .34421 .44696 L .34543 .46006 L .34674 .47401 L .34799 .48479 L .34912 .48891 L .35134 .49694 L .35385 .50607 L .35517 .51086 L .35589 .51348 L .35656 .51592 L .35779 .51486 L .35843 .51168 L .35913 .50828 L .36148 .49671 L Mistroke .36384 .4851 L .36509 .47898 L .36641 .47249 L .36756 .46078 L .36883 .44596 L .37107 .41986 L .3798 .30946 L .38455 .2427 L .38974 .18151 L .39211 .15508 L .39342 .14057 L .39464 .1269 L .39579 .11804 L .39703 .113 L .3992 .10422 L .40196 .09302 L .40347 .0869 L .4042 .08391 L .40487 .08214 L .40607 .08754 L .40736 .09333 L .4101 .10562 L .41255 .11664 L .41322 .11967 L .41394 .12288 L .41522 .13495 L .42007 .18958 L .42944 .3084 L .43435 .37253 L .43953 .42818 L .44173 .45182 L .44297 .46428 L .44409 .46839 L .44667 .47786 L .44907 .48667 L .45122 .49459 L .45244 .49854 L .45356 .49307 L .45781 .47237 L .46021 .46069 L .46139 .45494 L .46248 .44572 L .46373 .43114 L .4651 .41524 L .4675 .38737 L .47657 .26974 L .48167 .20028 L .4872 .13898 L .48973 .11082 L .49101 .10043 L Mistroke .49173 .09752 L .49241 .0948 L .4972 .07553 L .49848 .07039 L .49915 .06768 L .49987 .0648 L .50118 .06964 L .5024 .07513 L .50713 .09657 L .50838 .10226 L .50904 .10524 L .50973 .10981 L .51101 .12423 L .51218 .13743 L .51775 .20036 L .52751 .33073 L .53177 .37963 L .53637 .42927 L .53762 .44269 L .53893 .45095 L .54006 .45512 L .54129 .4597 L .54372 .46869 L .54594 .47689 L .54724 .48173 L .54848 .47896 L .54979 .47263 L .55121 .46574 L .55355 .45439 L .5548 .44837 L .55614 .44186 L .55739 .4342 L .55853 .42098 L .56077 .39501 L .56568 .338 L .57452 .21686 L .57925 .15968 L .58184 .13091 L .5843 .10372 L .58541 .09143 L .58659 .08459 L .58788 .07943 L .58907 .07468 L .59134 .06563 L .59341 .05736 L .59467 .05234 L .59586 .0529 L .59712 .05865 L .59849 .06492 L .60099 .07631 L Mistroke .60326 .08663 L .60393 .08971 L .60466 .09303 L .60598 .10727 L .60888 .14011 L .6141 .19919 L .62441 .33836 L .62945 .39279 L .63165 .41655 L .63281 .42909 L .63404 .43738 L .63534 .44221 L .63653 .44667 L .63889 .45547 L .64136 .46469 L .64204 .46721 L .64277 .46993 L .64409 .46435 L .64689 .45086 L .64984 .43666 L .65106 .43079 L .65236 .42453 L .6531 .41605 L .65378 .4082 L .65511 .39284 L .66522 .26802 L .67075 .19091 L .67592 .13181 L .67818 .10685 L .67929 .09456 L .68032 .08316 L .68151 .07401 L .68279 .0689 L .68505 .05994 L .68756 .04999 L .68879 .04512 L .68992 .04064 L .69123 .04187 L .69191 .04502 L .69264 .04834 L .6951 .05963 L .69746 .07044 L .69862 .07575 L .69969 .08066 L .70092 .09253 L .70226 .10772 L .7046 .13427 L .71346 .24409 L .71846 .31274 L .72384 .37275 L Mistroke .72644 .40095 L .72773 .41486 L .72892 .4253 L .73 .42934 L .73114 .43365 L .73357 .44277 L .736 .45187 L .73666 .45436 L .73736 .457 L .73862 .45721 L .7398 .45159 L .74089 .44634 L .74338 .4344 L .74559 .42384 L .74667 .41864 L .74768 .41344 L .74883 .40012 L .75008 .38563 L .75228 .36026 L .76291 .22376 L .76812 .15545 L .7729 .10276 L .77399 .09071 L .77516 .07782 L .77627 .06619 L .77727 .06223 L .77947 .05356 L .78187 .04407 L .78426 .03465 L .78491 .03207 L .7856 .02934 L .78685 .03411 L .79155 .05576 L .79399 .06699 L .79469 .07023 L .79536 .07411 L .79661 .08834 L .80135 .1422 L .81214 .28241 L .81709 .34226 L .82174 .39276 L .823 .40636 L .82368 .41379 L .82432 .41712 L .82501 .41973 L .82577 .42259 L .82711 .42763 L .8296 .43705 L .83083 .44168 L .83197 .44597 L Mistroke .83305 .45004 L .83419 .44701 L .83535 .44151 L .83661 .43545 L .84085 .41524 L .842 .40974 L .84321 .40156 L .84385 .39424 L .84454 .38624 L .84576 .37221 L .85036 .31912 L .86046 .18341 L .86542 .12463 L .86999 .07433 L .87063 .0673 L .87132 .05976 L .87255 .0541 L .87385 .04903 L .87527 .04345 L .8782 .03193 L .87964 .02626 L .88034 .0235 L .88098 .02121 L .88219 .0268 L .88347 .03274 L .88619 .0453 L .88865 .05669 L .88986 .06224 L .89095 .0705 L .89208 .08336 L .89329 .0971 L .89585 .12625 L .90101 .18744 L .91026 .31249 L .91539 .36828 L .9181 .39769 L .91876 .40483 L .91946 .40957 L .92024 .41251 L .92097 .41527 L .92372 .42568 L .92623 .43521 L .92743 .43972 L .92873 .44332 L .92996 .43747 L .9311 .43204 L .93356 .4203 L .93617 .40788 L .93753 .4014 L .93831 .39628 L Mistroke .93903 .38796 L .94166 .35766 L .95162 .23353 L .95661 .16408 L .96135 .11049 L .96341 .08784 L .9656 .06377 L .96674 .05173 L .968 .04679 L .97022 .03809 L .97619 .01472 L Mfstroke % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 177.938}, ImageMargins->{{35, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHgL8G>L003oLi`Q Li`00?mcW25cW0003g>L00<007>LLi`0og>L3g>L000?Li`00`00LiacW03oLi`?Li`000mcW003001c W7>L0?mcW0mcW0003g>L00<007>LLi`0og>L3g>L000?Li`2003oLi`6Li`00`00LiacW007Li`000mc W003001cW7>L0?mcW0EcW003001cW7>L00McW0003g>L00<007>LLi`0jG>L00<007>LLi`05g>L00<0 07>LLi`027>L000?Li`00`00LiacW03YLi`2000HLi`00`00LiacW008Li`000mcW003001cW7>L0L01IcW003001cW00001QcW003001cW7>L00QcW0003g>L00<007>LLi`0cg>L00<007>L Li`05W>L00<007>L00005g>L00<007>LLi`02G>L000?Li`00`00LiacW03?Li`00`00LiacW00FLi`0 0`00Li`0000GLi`00`00LiacW009Li`000QcW08000EcW003001cW7>L0;EcW003001cW7>L01IcW003 001cW00001McW004001cW7>L000FLi`00`00LiacW009Li`000McW004001cW7>L0004Li`00`00Liac W02dLi`2000HLi`00`00Li`0000GLi`01000LiacW0005G>L00<007>LLi`02W>L000:Li`00`00Liac W002Li`3002dLi`2000HLi`00`00Li`0000FLi`01@00LiacW7>L00005G>L00<007>LLi`02W>L0000 0g>L000000020003Li`20005Li`00`00LiacW02JLi`2000HLi`2000GLi`01@00LiacW7>L00005G>L 00D007>LLiacW00001EcW003001cW7>L00YcW00027>L00<007>LLi`017>L00<007>LLi`0VW>L0P00 5g>L00@007>LLi`001IcW005001cW7>LLi`0000ELi`01@00LiacW7>L00005G>L00<007>LLi`02W>L 0008Li`30004Li`00`00LiacW02JLi`2000GLi`01000LiacW0005W>L00D007>LLiacW00001EcW005 001cW7>LLi`0000ELi`00`00LiacW00:Li`000mcW003001cW7>L09UcW003001cW00001McW004001c W7>L000FLi`01@00LiacW7>L000057>L00<007>LLi`00g>L00<007>LLi`04W>L00<007>LLi`02W>L 000?Li`00`00LiacW020Li`00`00LiacW00FLi`00`00Li`0000GLi`01@00LiacW7>L000057>L00<0 07>LLi`00W>L00<007>LLi`04W>L00<007>LLi`00g>L00<007>LLi`04W>L00<007>LLi`02W>L000? Li`00`00LiacW020Li`2000GLi`00`00Li`0000GLi`01@00LiacW7>L000057>L00<007>LLi`00W>L 00<007>LLi`04W>L00<007>LLi`00g>L00<007>LLi`04W>L00<007>LLi`02W>L000?Li`00`00Liac W01oLi`00`00Li`0000GLi`01000LiacW0005G>L00<007>LLi`00W>L00<007>LLi`04W>L00<007>L Li`00g>L00<007>LLi`04G>L00<007>LLi`00g>L00<007>LLi`04W>L00<007>LLi`02W>L000?Li`2 0020Li`00`00Li`0000FLi`01@00LiacW7>L00005G>L00<007>LLi`00W>L00<007>LLi`04W>L00<0 07>LLi`00g>L00<007>LLi`04G>L00<007>LLi`00g>L00<007>LLi`04G>L00<007>LLi`02g>L000? Li`00`00LiacW01VLi`00`00LiacW00FLi`00`00Li`0000FLi`01@00LiacW7>L00005G>L00<007>L Li`00W>L00<007>LLi`04W>L00<007>LLi`00g>L00<007>LLi`04G>L00<007>LLi`00g>L00<007>L Li`04G>L00<007>LLi`02g>L000?Li`00`00LiacW01VLi`00`00LiacW00FLi`00`00Li`0000FLi`0 0`00LiacW002Li`00`00LiacW00BLi`00`00LiacW002Li`00`00LiacW00BLi`00`00LiacW003Li`0 0`00LiacW00ALi`00`00LiacW003Li`00`00LiacW00ALi`00`00LiacW00;Li`000mcW003001cW7>L 06IcW003001cW7>L01EcW005001cW7>LLi`0000ELi`00`00LiacW002Li`00`00LiacW00BLi`00`00 LiacW003Li`00`00LiacW00ALi`00`00LiacW003Li`00`00LiacW00ALi`00`00LiacW003Li`00`00 LiacW00ALi`00`00LiacW00;Li`000mcW003001cW7>L06EcW08001Mc