List[Null, Null, Null, Null, Null, Null, Null, Notebook[List[Cell[CellGroupData[List[Cell["Exercise 1", "Title"], Cell[CellGroupData[List[Cell["Question", "Section"], Cell["Can you really put an algorithm section inside an equation section?", "Text"], Cell[CellGroupData[List[Cell["Answer", "Subsection"], Cell["Yes, you didn't think so, did you?", "Text"]], Closed]]], Open]], Cell[CellGroupData[List[Cell["Writing an Algorithm Section", "Section"], Cell[TextData[List["Create the class, ", StyleBox["Average", Rule[FontFamily, "Courier"]], ", which calculates the average between two integers, using an algorithm section. \n"]], "Text"], Cell["", "ModelicaInput"], Cell["\n\nMake then an instance of the class and send in some values.", "Text"], Cell["", "ModelicaInput"], Cell["\n\nSimulate and then test the result of the instance class by writing instanceVariable.classVariable[time] as below:", "Text"], Cell[BoxData[RowBox[List["instanceVariable", ".", RowBox[List["classVariable", "[", "0", "]"]]]]], "Input"], Cell[CellGroupData[List[Cell["Answer", "Subsection"], Cell[CellGroupData[List[Cell["Average class", "Subsubsection"], Cell["class Average\n  parameter Real a;\n  parameter Real b;\n  Real result;\nalgorithm\n  result := (a + b) / 2;  \nend Average;", "ModelicaInput"]], Closed]], Cell[CellGroupData[List[Cell["The instance", "Subsubsection"], Cell["class AverageInst\nAverage aver(a = 15, b = 23);\nend AverageInst;", "ModelicaInput"]], Closed]], Cell[CellGroupData[List[Cell["Simulation of AverageInst", "Subsubsection"], Cell["simulate( AverageInst );", "ModelicaInput"], Cell[BoxData["\"<SimulationData: \\!\\(AverageInst\\) : 2004-1-30 9:44:29.6502065 : \\!\\({0.`, 1.`}\\) : 502 data points : 1 events : 5 variables>\\n\\!\\({\\*TagBox[\\(aver . a\\), HoldForm], \\*TagBox[\\(aver . b\\), HoldForm], \\*TagBox[\\(aver . result\\), HoldForm], \\*TagBox[\\\"\[UnderBracket]derdummy\\\", HoldForm], \\*TagBox[\\\"\[UnderBracket]dummy\\\", HoldForm]}\\)\""], "Output"], Cell[BoxData[RowBox[List["aver", ".", RowBox[List["result", "[", "0", "]"]]]]], "Input"]], Closed]]], Closed]]], Open]], Cell[CellGroupData[List[Cell["A harder exercise", "Section"], Cell[TextData[List["Write a class, ", StyleBox["AverageExtended", Rule[FontFamily, "Courier"]], ", that calculates the average of 4 variables (a, b, c and d).\n"]], "Text"], Cell["", "ModelicaInput"], Cell["\n\nMake then an instance of the class and send in some values.", "Text"], Cell["", "ModelicaInput"], Cell["\n\nSimulate and then test the result of the instance class by writing     instanceVariable.classVariable[time] as below. We choose time = 0.", "Text"], Cell[BoxData[RowBox[List["instanceVariable", ".", RowBox[List["classVariable", "[", "0", "]"]]]]], "Input"], Cell[CellGroupData[List[Cell["Answer", "Subsection"], Cell[CellGroupData[List[Cell["AverageExtended", "Subsubsection"], Cell["Note that the sum is calculated in an equation section to show that it is possible to mix algorithm and equation sections in a class. ", "Text"], Cell["class AverageExtended\n  parameter Real a;\n  parameter Real b;\n  parameter Real c;\n  parameter Real d;\n  Real sum;\n  Real aver;\n  Real nrOfVariables = 4;\nequation\n  sum = a + b + c + d;\nalgorithm\n  aver := sum / nrOfVariables;\nend AverageExtended;", "ModelicaInput"]], Closed]], Cell[CellGroupData[List[Cell["The instance", "Subsubsection"], Cell["class AverageExtInst\n  AverageExtended aver(a = 15, b = 23);\nend AverageExtInst;", "ModelicaInput"]], Closed]], Cell[CellGroupData[List[Cell["Simulate of AverageExtended", "Subsubsection"], Cell["simulate( AverageExtInst );", "ModelicaInput"], Cell[BoxData["\"<SimulationData: \\!\\(AverageExtInst\\) : 2004-1-30 9:45:14.9471619 : \\!\\({0.`, 1.`}\\) : 502 data points : 1 events : 9 variables>\\n\\!\\({\\*TagBox[\\(aver . a\\), HoldForm], \\*TagBox[\\(aver . aver\\), HoldForm], \\*TagBox[\\(aver . b\\), HoldForm], \\*TagBox[\\(aver . c\\), HoldForm], \\*TagBox[\\(aver . d\\), HoldForm], \\*TagBox[\\(aver . nrOfVariables\\), HoldForm], \\*TagBox[\\(aver . sum\\), HoldForm], \\*TagBox[\\\"\[UnderBracket]derdummy\\\", HoldForm], \\*TagBox[\\\"\[UnderBracket]dummy\\\", HoldForm]}\\)\""], "Output"], Cell["\nThen you can look at the values of the variables at a specific point in time by writing:  instanceVariable.classVariable[time]. We choose time = 0 below.", "Text"], Cell[BoxData[RowBox[List["{", RowBox[List[RowBox[List["aver", ".", RowBox[List["sum", "[", "0", "]"]]]], ",", " ", RowBox[List["aver", ".", RowBox[List["aver", "[", "0", "]"]]]]]], "}"]]], "Input"]], Closed]]], Closed]]], Open]]], Open]]], Rule[FrontEndVersion, "5.1 for Microsoft Windows"], Rule[ScreenRectangle, List[List[0, 1280], List[0, 951]]], Rule[WindowSize, List[784, 909]], Rule[WindowMargins, List[List[0, Automatic], List[Automatic, 1]]], Rule[StyleDefinitions, "MathModelica.nb"]], Null, Null, Null, Null, Null]