Skip to content

Commit 31892c8

Browse files
committed
A few small updates to 4 modules DrModelica. Now more testcases work than previously.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk/OMNotebook/DrModelica@2705 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent d89ff08 commit 31892c8

File tree

4 files changed

+36
-24
lines changed

4 files changed

+36
-24
lines changed

Algorithms/AssignStat.onb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ protected
1616
Real y1 := cos(1.84) + x - 1.2E-2;
1717
algorithm
1818
res := y1;
19-
end foo;
20-
</Input>
19+
end foo; </Input>
2120
<Output>Ok</Output>
2221
</InputCell>
2322
<GroupCell closed="false" >
2423
<TextCell style="Section" >
25-
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:18pt; font-weight:600; color:#000000;">Simulation of foo&lt;/p>&lt;/body>&lt;/html></Text>
24+
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:18pt; font-weight:600; color:#000000;">Calling foo&lt;/p>&lt;/body>&lt;/html></Text>
2625
</TextCell>
2726
<InputCell style="Input" closed="false" >
28-
<Input>foo(3.0) //??? Error, wrong result</Input>
29-
<Output>0.0</Output>
27+
<Input>foo(3.0) //??? Error, wrong result, should be 1.722 - Error if using default values or declaration assignments</Input>
28+
<Output>5.28326e-308</Output>
3029
</InputCell>
3130
</GroupCell>
3231
</GroupCell>

Arrays/ArithmeticOp.onb

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ end AddSub2; </Input>
4545
<Output>{{1,1},{2,2}}</Output>
4646
</InputCell>
4747
<InputCell style="Input" closed="false" >
48-
<Input>2.0*{{1, 1}, {2, 2}} // ??Error - no value interactively</Input>
49-
<Output>[done]</Output>
48+
<Input>2.0*{{1, 1}, {2, 2}} // Works</Input>
49+
<Output>{{2.0,2.0},{4.0,4.0}}</Output>
5050
</InputCell>
5151
<InputCell style="Input" closed="false" >
5252
<Input>{{1, 1}, {2, 2}} + {{1, 2}, {3, 4}} // ??Error - no value interactively</Input>
@@ -89,7 +89,7 @@ end record</Output>
8989
</TextCell>
9090
<InputCell style="Input" closed="false" >
9191
<Input>class Div
92-
Real Div1[1, 3], Div2, Div3;
92+
Real[3] Div1, Div2, Div3;
9393
equation
9494
Div1 = {2, 4, 6} / 2; // Result: {1, 2, 3}
9595
Div2 = 6 / {1, 2, 3}; // Not allowed!
@@ -99,7 +99,7 @@ end Div;</Input>
9999
</InputCell>
100100
<InputCell style="Input" closed="false" >
101101
<Input>class Div2
102-
Real Div1[1, 3];
102+
Real Div1[3];
103103
equation
104104
Div1 = {2, 4, 6} / 2; // Result: {1, 2, 3}
105105
end Div2;</Input>
@@ -113,20 +113,21 @@ end Div2;</Input>
113113
<Input>simulate( Div ) //Error in model</Input>
114114
<Output>record
115115
resultFile = "Simulation failed.
116-
Type mismatch in equation {{Div1[1,1],Div1[1,2],Div1[1,3]}}={1.0,2.0,3.0} of type Real[1, 3]=Real[3]
116+
Cannot resolve type of expression 6/{1,2,3} (expressions :6, {1,2,3} types: Integer, Integer[3])
117117
Error occured while flattening model Div
118118
"
119119
end record</Output>
120120
</InputCell>
121121
<InputCell style="Input" closed="false" >
122-
<Input>simulate( Div2 ) //??Error - not yet implemented</Input>
122+
<Input>simulate( Div2 )</Input>
123123
<Output>record
124-
resultFile = "Simulation failed.
125-
Type mismatch in equation {{Div1[1,1],Div1[1,2],Div1[1,3]}}={1.0,2.0,3.0} of type Real[1, 3]=Real[3]
126-
Error occured while flattening model Div2
127-
"
124+
resultFile = "Div2_res.plt"
128125
end record</Output>
129126
</InputCell>
127+
<InputCell style="Input" closed="false" >
128+
<Input>val(Div1[2],0.)</Input>
129+
<Output>2.0</Output>
130+
</InputCell>
130131
</GroupCell>
131132
</GroupCell>
132133
<GroupCell closed="false" >
@@ -153,6 +154,10 @@ end Multiplication; </Input>
153154
<Input>{{1, 2}, {3, 4}} * {1, 2} //??Error - no value interactively</Input>
154155
<Output>[done]</Output>
155156
</InputCell>
157+
<InputCell style="Input" closed="false" >
158+
<Input>{1, 2, 3} * [1; 2; 10]</Input>
159+
<Output>{35}</Output>
160+
</InputCell>
156161
<GroupCell closed="false" >
157162
<TextCell style="Subsection" >
158163
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Simulation of Multiplication&lt;/p>&lt;/body>&lt;/html></Text>
@@ -163,9 +168,14 @@ end Multiplication; </Input>
163168
resultFile = "Multiplication_res.plt"
164169
end record</Output>
165170
</InputCell>
166-
<TextCell style="Text" >
167-
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">??val should be used to look at results&lt;/p>&lt;/body>&lt;/html></Text>
168-
</TextCell>
171+
<InputCell style="Input" closed="false" >
172+
<Input>val(m1[2],0.)</Input>
173+
<Output>4.0</Output>
174+
</InputCell>
175+
<InputCell style="Input" closed="false" >
176+
<Input>val(m3,0.)</Input>
177+
<Output>11.0</Output>
178+
</InputCell>
169179
</GroupCell>
170180
</GroupCell>
171181
<GroupCell closed="false" >
@@ -175,24 +185,27 @@ end record</Output>
175185
<TextCell style="Text" >
176186
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">Array exponentiation is the same as repeated matrix multiplication and is therefore only defined when the first operand is a square matrix and the second operand is a non-negative integer.&lt;/p>&lt;/body>&lt;/html></Text>
177187
</TextCell>
178-
<InputCell style="Input" closed="true" >
188+
<InputCell style="Input" closed="false" >
179189
<Input>class Exp
180190
Real e1[2, 2];
181191
Real e2[2, 2];
182192
equation
183193
e1 = {{1, 2}, {1, 2}} ^ 0; // Result: {{1, 0}, {0, 1}}
184194
e2 = [1, 2; 1, 2] ^ 2; // Result: {{3, 6}, {3, 6}}
185195
end Exp;</Input>
186-
<Output></Output>
196+
<Output>Ok</Output>
187197
</InputCell>
188198
<GroupCell closed="false" >
189199
<TextCell style="Subsection" >
190200
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Simulation of Exponentiation&lt;/p>&lt;/body>&lt;/html></Text>
191201
</TextCell>
192202
<InputCell style="Input" closed="false" >
193-
<Input>simulate( Exp )</Input>
203+
<Input>simulate( Exp ) //??Error</Input>
194204
<Output>record
195-
resultFile = "Exp_res.plt"
205+
resultFile = "Simulation failed.
206+
Cannot resolve type of expression {{1,2},{1,2}}^0 (expressions :{{1,2},{1,2}}, 0 types: Integer[2, 2], Integer)
207+
Error occured while flattening model Exp
208+
"
196209
end record</Output>
197210
</InputCell>
198211
<TextCell style="Text" >

DrModelica.onb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Arial; font-size:38pt; font-weight:600; color:#000000;">DrModelica&lt;span style=" font-size:24pt; vertical-align:super;">Modelica Edition&lt;/span>&lt;/p>&lt;/body>&lt;/html></Text>
1111
</TextCell>
1212
<TextCell style="Text" >
13-
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">&lt;span style=" font-size:14pt;">Copyright: (c) Linköping University, PELAB, 2003-2006, Wiley-IEEE Press, Modelica Association.&lt;br />Contact: OpenModelica@ida.liu.se; OpenModelica Project web site: www.ida.liu.se/projects/OpenModelica&lt;br />Book web page: www.mathcore.com/drModelica; Book author: Peter.Fritzson@ida.liu.se&lt;br />&lt;br />DrModelica Authors: (2003 version) Susanna Monemar, Eva-Lena Lengquist Sandelin, Peter Fritzson, Peter Bunus &lt;br />DrModelica Authors: (2005 and later updates): Peter Fritzson&lt;/span>&lt;/p>&lt;/body>&lt;/html></Text>
13+
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">&lt;span style=" font-size:14pt;">Copyright: (c) Linköping University, PELAB, 2003-2007, Wiley-IEEE Press, Modelica Association.&lt;br />Contact: OpenModelica@ida.liu.se; OpenModelica Project web site: www.ida.liu.se/projects/OpenModelica&lt;br />Book web page: www.mathcore.com/drModelica; Book author: Peter.Fritzson@ida.liu.se&lt;br />&lt;br />DrModelica Authors: (2003 version) Susanna Monemar, Eva-Lena Lengquist Sandelin, Peter Fritzson, Peter Bunus &lt;br />DrModelica Authors: (2005 and later updates): Peter Fritzson&lt;/span>&lt;/p>&lt;/body>&lt;/html></Text>
1414
<Rule name="FontSize" >14</Rule>
1515
</TextCell>
1616
<TextCell style="Text" >

QuickTour/Exercise1classes.onb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<Input></Input>
3333
<Output></Output>
3434
</InputCell>
35-
<GroupCell closed="false" >
35+
<GroupCell closed="true" >
3636
<TextCell style="Subsection" >
3737
<Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Answer&lt;/p>&lt;/body>&lt;/html></Text>
3838
</TextCell>

0 commit comments

Comments
 (0)