diff --git a/DrModelica/AccessControl/AccessDemo.onb b/DrModelica/AccessControl/AccessDemo.onb new file mode 100644 index 00000000000..ec7a8be2737 --- /dev/null +++ b/DrModelica/AccessControl/AccessDemo.onb @@ -0,0 +1,256 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Demonstration of Access Control</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Members of a Modelica class can have two levels of visibility: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">public</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">protected</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The default is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">public</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> if nothing else is specified. Publically declared variables can be can be read or updated by any code with access to that class. Variables that are declared protected can be reched only by code inside the class as well as code in classes that inherit this class. However, only code inside the class is allowed access to the same instance of a protected variable. You can read more about this in </span><a href="Inheritance/ProtectedElements.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">Private and Protected Elements</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">AccessDemo</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a, x, z </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">u3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is public and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">w, u </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">u2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are protected in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AccessDemo</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class</span></p></td></tr></table></body></html> + + + class AccessDemo "Illustration of access prefixes" + parameter Real a = 2; + public Real x, z; + parameter Real y (fixed=true); + protected + parameter Real w (fixed=true), u(fixed=true); + Real u2; + public Real u3; +equation + x = 2; // Legal, since code inside the class + z = 5; // Legal, since code inside the class + u2 = 5; // Legal, since code inside the class + u3 = 8; // Legal, since code inside the class +end AccessDemo; + + {AccessDemo} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of AccessDemo</span></p></td></tr></table></body></html> + + + simulate( AccessDemo ) + record SimulationResult + resultFile = "AccessDemo_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot({x,u2}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">A</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> an illegal modification is done, since </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">w</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is protected it can not be modified if </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AccessDemo</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not inherited.</span></p></td></tr></table></body></html> + + + class A + AccessDemo ad(a = 2, y = 7, w = 7); // Illegal, since AccessDemo is not inherited +end A; + + {A} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of AccessDemo, A and B</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here we can see that if we try to simulate class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with the erroneous modification&quot;w = 7&quot; we get a warning for trying to modify a protected variable.</span></p></td></tr></table></body></html> + + + simulate( A ) + record SimulationResult + resultFile = "A_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">B</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In the class B </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AccessDemo</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is inherited, then it is legal to change the value u</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class B + extends AccessDemo; + Real p, q; +equation + u2 = p; // Legal, since AccessDemo is inherited + u3 = q; // Legal, since u3 is public +end B; + + {B} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of B</span></p></td></tr></table></body></html> + + + simulate( B ) + record SimulationResult + resultFile = "B_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + plot({p,u3}) + [done] + + + + + diff --git a/DrModelica/AccessControl/Exercise1.onb b/DrModelica/AccessControl/Exercise1.onb new file mode 100644 index 00000000000..209b9b1a7d1 --- /dev/null +++ b/DrModelica/AccessControl/Exercise1.onb @@ -0,0 +1,89 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Access Control</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Complete the classes <span style=" font-family:Courier New;">Access </span>and<span style=" font-family:Courier New;"> Acc </span>below. The variable <span style=" font-family:Courier New;">acc</span> is an instance of the class <span style=" font-family:Courier New;">Acc</span>, which contains the variables <span style=" font-family:Courier New;">a, b, c, d</span> and <span style=" font-family:Courier New;">e</span>, where <span style=" font-family:Courier New;">d</span> and <span style=" font-family:Courier New;">e</span> are protected. Where can the variables be set? Set a = 7.4 in the class Access.</p></body></html> + + + class Access + ... +equation + ... +end Access; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class AccessInst + Access acc; +end AccessInst; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The public variables <span style=" font-family:Courier New;">a, b</span> and <span style=" font-family:Courier New;">c</span> can be set in either class, while <span style=" font-family:Courier New;">d</span> and <span style=" font-family:Courier New;">e</span> must be set in class <span style=" font-family:Courier New;">Acc</span>. The variable a must be a parameter, since we want to change it in the class Access.</p></body></html> + + + class Access + parameter Real a; + Real b; + Real c; +protected + Integer d, e; +equation + b = 2.0; + c = 1.3; + d = 5; + e = 7; +end Access; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Since a is a parameter it can not be changed during simulation, so it can not be modified in the equation section.</p></body></html> + + + class AccessInst + Access acc(a = 7.4); +end AccessInst; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Access and AccessInst</p></body></html> + + + simulate( Access ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + simulate( AccessInst ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/AccessControl/MoonLanding.onb b/DrModelica/AccessControl/MoonLanding.onb new file mode 100644 index 00000000000..3be1bd11b5b --- /dev/null +++ b/DrModelica/AccessControl/MoonLanding.onb @@ -0,0 +1,425 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Access Control Example with Moon Landing</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/RAIN1_~1/AppData/Local/Temp/OpenModelica/4.png" width="365" height="219" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Apollo 13 rocket for landing on the moon.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Celestial Body</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This example illustrates a Rocket landing on the moon. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CelestialBody</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be used to store information about celestial bodies such as the earth and the moon. </span></p></td></tr></table></body></html> + + + class CelestialBody + constant Real g = 6.672e-11; + parameter Real radius; + parameter String name; + Real mass; +end CelestialBody; + {CelestialBody} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Rocket</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rocket</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> embodies the equations of vertical motion for a rocket which is influenced by an external gravitational force field </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">gravity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and the force </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">thrust</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> from the rocket motor, acting in the opposite direction to the gravitational force.<br /></span></p></td></tr></table></body></html> + + + class Rocket + parameter String name; + Real mass(start = 1038.358,fixed=true); + Real altitude(start = 59404,fixed=true); + Real velocity(start = -2003,fixed=true); + Real acceleration; + Real thrust; // Thrust force on the rocket + Real gravity; // Gravity forcefield + parameter Real massLossRate = 0.000277; +equation + (thrust - mass*gravity)/mass = acceleration; + der(mass) = -massLossRate * abs(thrust); + der(altitude) = velocity; + der(velocity) = acceleration; +end Rocket; + {Rocket,CelestialBody} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MoonLanding</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Apollo is an instance of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rocket</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class, so we have to use dot notation, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">apollo.thrust</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, when refering to its variables. Since no level of visibility is specified for </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">force1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">force2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> they are </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">public</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class MoonLanding + parameter Real force1 = 36350; // These variables are by default public + parameter Real force2 = 1308; +protected // These variables are protected + parameter Real thrustEndTime = 210; + parameter Real thrustDecreaseTime = 43.2; +public // These variables are public + Rocket apollo(name = "Apollo13"); + CelestialBody moon(name = "moon", mass = 7.382e22, radius = 1.738e6); +equation + apollo.thrust = if (time < thrustDecreaseTime) then force1 + else if (time < thrustEndTime) then force2 + else 0; + apollo.gravity = moon.g*moon.mass/(apollo.altitude + moon.radius) ^2; +end MoonLanding; + {MoonLanding,Rocket,CelestialBody} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of MoonLanding</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the MoonLanding model during the time interval 0 to 230.</span></p></td></tr></table></body></html> + + + simulate( MoonLanding, stopTime=230 ) + record SimulationResult + resultFile = "MoonLanding_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">//?? might stop the plot at 208 using plot( apollo.altitude, xrange={0,208} ); when xrange has been implemented. Note that 10 to the power 2 appears too low below the x-axis.</span></p></td></tr></table></body></html> + + + + + + plot( apollo.altitude) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Figure 1:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Altitude</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of the Apollo rocket over the lunar surface. Since the solution for the altitude is a function of time, it can be plotted in a diagram. It starts at an altitude of 59404 at time zero, gradually reducing it until touchdown at the lunar surface when the altitude is zero.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg'; font-size:8pt;">??</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">plot( apollo.thrust, xrange={0,208} );</span></p></td></tr></table></body></html> + + + + + + plot( apollo.thrust ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Figure 2:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Thrust</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> from the rocket motor, with an initial high thrust f1 followed by a lower thrust f2. The thrust force from the Rocket is initially high but is reduced to a low level after 43.2 seconds.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + + plot( apollo.mass ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Figure 3:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rocket</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> mass decreases when the fuel is consumed.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">??plot( apollo.gravity, xrange={0,208} );</span></p></td></tr></table></body></html> + + + + + + plot( apollo.gravity ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Figure 4:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Gradually increasing </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">gravity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> when the rocket approaches the lunar surface.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">??plot( apollo.gravity, xrange={0,208} );</span></p></td></tr></table></body></html> + + + + + + plot( apollo.velocity) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Figure 5:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Vertical </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">velocity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> relative to the lunar surface. The rocket initially has a high negative velocity when approaching the lunar surface. This is reduced to zero at touchdown giving a smooth landing.</span></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Algorithms/Assert.onb b/DrModelica/Algorithms/Assert.onb new file mode 100644 index 00000000000..9120b9a9bc8 --- /dev/null +++ b/DrModelica/Algorithms/Assert.onb @@ -0,0 +1,124 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Assert</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">assert</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> statement provides a convenient means for specifying checks on model validity within a model. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">assert</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> expression in an assert statement or equation should normally evaluate to true. When the assertion evaluates to false, the message in the second argument will be displayed to the user and the simulation will stop. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AssertTest</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> contains an example of the use of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">assert</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + class AssertTest + parameter Real lowlimit; + parameter Real highlimit; + Real x = 5; +algorithm + assert(x >= lowlimit and x <= highlimit, "Variable x out of limit"); +end AssertTest; + {AssertTest} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Test1 + AssertTest assertTest(lowlimit = 4, highlimit = 8); +end Test1; + {Test1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Test2 + AssertTest assertTest(lowlimit = 6, highlimit = 20); +end Test2; + {Test2} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Test1 and Test2 </span></p></td></tr></table></body></html> + + + simulate( Test1 ) + record SimulationResult + messages = "", + simulationTime = 0.1566063461721068 +end SimulationResult; + + + + + + + + plot( { assertTest.x, assertTest.highlimit, assertTest.lowlimit }) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In the simulation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Test2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> we see that an error occurs and by looking in the file ??dslog.txt we see that the assertion fails and returns the message &quot;Variable x out of limit&quot;.</span></p></td></tr></table></body></html> + + + simulate( Test2, stopTime=10 ) + record SimulationResult + messages = "Simulation execution failed for model: Test2 +[<interactive>:6:3-6:70:writable] +stdout | info | Simulation call assert() at time 0.020000 +| | | | Level : error +| | | | Message : Variable x out of limit +stdout | info | model terminate | Simulation terminated at time 0.02 +" +end SimulationResult; + + + + + diff --git a/DrModelica/Algorithms/AssignStat.onb b/DrModelica/Algorithms/AssignStat.onb new file mode 100644 index 00000000000..906b222d8a4 --- /dev/null +++ b/DrModelica/Algorithms/AssignStat.onb @@ -0,0 +1,54 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Simple Assignment Statements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Assignment statements may also occur as initializers in the declaration of local variables (after the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">protected</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">) or formal parameters of Modelica functions. The function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">foo</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> contains a declaration of the local variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with an initializing assignment and the formal parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with a default value assignment.<br /></span></p></td></tr></table></body></html> + + + function foo + input Real x := 2.0; + output Real res; +protected + Real y1 := cos(1.84) + x - 1.2E-2; +algorithm + res := y1; +end foo; + {foo} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Calling foo</span></p></td></tr></table></body></html> + + + foo(3.0) + 2.7220361243910194 + + + + + diff --git a/DrModelica/Algorithms/Exercise1.onb b/DrModelica/Algorithms/Exercise1.onb new file mode 100644 index 00000000000..54e4acb2aeb --- /dev/null +++ b/DrModelica/Algorithms/Exercise1.onb @@ -0,0 +1,145 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Using Algorithm Sections</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a function, myS<span style=" font-family:Courier New;">um</span>, which calculates the sum of numbers, in an array of arbitrary size. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Write a function, a<span style=" font-family:Courier New;">verage</span>, which calculates the average of numbers, in an array of arbitrary size. The <span style=" font-family:Courier New;">average</span> function should use make a function call to myS<span style=" font-family:Courier New;">um</span>.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Write a class, <span style=" font-family:Courier New;">LargestAverage</span>, that has two arrays and calculates the average of each of them. Then it compares the averages and sets a variable to true if the first array is larger than the second and otherwise false.<br /></p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">mySum</p></body></html> + + + function mySum + input Real[:] x; + output Real sum; +algorithm + for i in 1:size(x,1) loop + sum := sum + x[i]; + end for; +end mySum; + Ok + + + mySum({2.0,3.0,4.0}) + 9.0 + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">average</p></body></html> + + + function average + input Real[:] x; + output Real average; +algorithm + average := mySum(x) / size(x,1); +end average; + Ok + + + average({2.0,3.0,4.0}) // ??Works, even though it gives an error message + 3.0 +OMC-ERROR: +"Class mySum (its type) not found in scope average. +No matching function found for mySum, candidates are +Class mySum not found in scope average. +No matching function found for mySum, candidates are +Class mySum not found in scope average. +Class mySum not found in scope global scope. +" + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">LargestAverage</p></body></html> + + + class LargestAverage + parameter Integer[:] A1 = {1, 2, 3, 4, 5}; + parameter Integer[:] A2 = {7, 8, 9}; + Real averageA1, averageA2; + Boolean A1Largest(start = false); +algorithm + averageA1 := average(A1); + averageA2 := average(A2); + if averageA1 > averageA2 then + A1Largest := true; + else + A1Largest := false; + end if; +end LargestAverage; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of LargestAverage</p></body></html> + + + simulate( LargestAverage ) //?? algorithm sections outside functions not yet implemented + record + resultFile = "Simulation failed. +Class mySum (its type) not found in scope average. +No matching function found for mySum, candidates are +Class mySum not found in scope average. +No matching function found for mySum, candidates are +Class mySum not found in scope average. +No matching function found for mySum, candidates are +Class mySum not found in scope average. +No matching function found for mySum, candidates are +Class mySum not found in scope average. +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">When we look at the values in the variables we see that A2 has the largest average (8 ) and therefore the variable A1Largest is false (= 0). //?? Should use val(A1Largest[1]), etc. to get values.</p></body></html> + + + {A1Largest[1] //??val should be used to get values +, averageA1[1] + , averageA2[1] + +} + + + + + + + + + diff --git a/DrModelica/Algorithms/Exercise2.onb b/DrModelica/Algorithms/Exercise2.onb new file mode 100644 index 00000000000..27163519d16 --- /dev/null +++ b/DrModelica/Algorithms/Exercise2.onb @@ -0,0 +1,184 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 2</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Using Algorithm Sections</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Write a class, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FindSmallest</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, that finds the value and position of the smallest element in an arbitrary array.</span></p></td></tr></table></body></html> + + + //?? algorithm sections outside functions not yet implemented + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Write a class that makes an instance of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FindSmallest</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class and give the array values.</span></p></td></tr></table></body></html> + + + //?? algorithm sections outside functions not yet implemented + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">FindSmallest</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Loop through all elements in the array except the first. The smallest value is initially the first value in the array. </span></p></td></tr></table></body></html> + + + class FindSmallest + Real A[:]; + Real smallest; + Integer place; +algorithm + smallest := A[1]; + place := 1; + for i in 2:size(A, 1) loop + if A[i] < smallest then + smallest := A[i]; + place := i; + end if; + end for; +end FindSmallest; + {FindSmallest} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">FindSmallestElement</span></p></td></tr></table></body></html> + + + class FindSmallestElement + FindSmallest findsmallest(A={9, 5, 8, 7, 2, 4}); +end FindSmallestElement; + {FindSmallestElement} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of FindSmallestElement</span></p></td></tr></table></body></html> + + + simulate( FindSmallestElement ) //?? Error, algorithm section not impl. + record SimulationResult + resultFile = "FindSmallestElement_res.plt", + simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'FindSmallestElement', storeInTemp = false, noClean = false, options = '', outputFormat = 'plt'", + messages = "", + timeFrontend = 0.00861128998238603, + timeBackend = 0.0060683690245548, + timeSimCode = 0.00118639380144683, + timeTemplates = 0.00936306150642051, + timeCompile = 1.6396799732927, + timeSimulation = 0.171336580487185, + timeTotal = 1.83632137604081 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here we can see that the smallest value in the array is the element in position 5 with the value 2.</span></p></td></tr></table></body></html> + + + //{findsmallest.smallest[1], findsmallest.place[1]} //Doesn't work +//The code below does the thing the previous line intended to do +val (findsmallest.smallest, 0); +val (findsmallest.place, 0) + 2.0 +5.0 + + + + + + + diff --git a/DrModelica/Algorithms/Exercise3.onb b/DrModelica/Algorithms/Exercise3.onb new file mode 100644 index 00000000000..56a0bdd5353 --- /dev/null +++ b/DrModelica/Algorithms/Exercise3.onb @@ -0,0 +1,178 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 3</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">while-statements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Write a class that calculates the sum: 11*1-</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">12*2</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> + </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">13*3</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> - </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">14*4 </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">+ </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">15*5</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> - </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">16*6</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> ... </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Follow the algorithm:<br />        1. Initialize the sum to 0 and the first term to 1.<br />        2. If the absolut value of next term &gt;= 0.000001 do the next two steps:<br />            2.1 Add next term to the sum.<br />            2.2 Calculate a new next term.        <br />            </span></p></td></tr></table></body></html> + + + //?? algorithm sections outside functions not yet implemented + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Tip</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Every term in the sum is on the form 1/(k*k), where k increaces by one for each step. Set a variable to keep track of if the next term is negative or positive. When the program is run the sum will be 0.82247.    </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">SumCalculation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If the operator </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">abs</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used outside a when clause, state events are triggered. If this is not desired, the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">noEvent</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> function can be applied to it.</span></p></td></tr></table></body></html> + + + class SumCalculation + constant Real e = 0.000001; + Real sum(start = 0); + Real next(start = 1.0); + Integer k(start = 1); + Integer posneg(start = 1); // if the sign in front of the term is + or - +algorithm + while noEvent(abs(next)) >= e loop + sum := sum + next; // Add the sum to the next term + k := k + 1; // calculate a new next + posneg := - posneg; + next := posneg/(k*k); + end while; +end SumCalculation; + {SumCalculation} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of SumCalculation</span></p></td></tr></table></body></html> + + + simulate( SumCalculation ) //?? algorithm sections outside functions not yet implemented + record SimulationResult + resultFile = "SumCalculation_res.plt", + simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'SumCalculation', storeInTemp = false, noClean = false, options = '', outputFormat = 'plt'", + messages = "", + timeFrontend = 0.0025329336549757, + timeBackend = 0.000558520705843899, + timeSimCode = 0.000308558769340796, + timeTemplates = 0.00276864797062196, + timeCompile = 1.30488581649344, + timeSimulation = 0.10862784236544, + timeTotal = 1.41971975488505 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When the program is run the sum will be 0.82247 and it will calculate the sum of:     11*1-</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">12*2</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> + </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">13*3</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> - </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">14*4 </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">+ </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">15*5</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> ... - </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">11001*1001</span></p></td></tr></table></body></html> + + + //{sum[1], next[1], posneg[1], k[1]} +//The code below replaces the code above as it was not functional. +val(sum, 1); +val(next, 1); +val(posneg, 1); +val (k, 1) + 0.822466533924111 +9.98002996004994e-07 +1.0 +1001.0 + + + + + + + diff --git a/DrModelica/Algorithms/Exercise4.onb b/DrModelica/Algorithms/Exercise4.onb new file mode 100644 index 00000000000..6b3240da741 --- /dev/null +++ b/DrModelica/Algorithms/Exercise4.onb @@ -0,0 +1,243 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Exercise 4</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">When-statement</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Let us go back to the class <span style=" font-family:'Courier New';">LightSwitch</span>, that is initially switched off and switched on at time 5. Change this class to contain a when-statement instead of a when-equation. </p></td></tr></table></body></html> + + + //?? algorithm sections outside functions not yet implemented + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br /><br />Now change the <span style=" font-family:'Courier New';">LightSwitch</span> class so that it in the time interval 5-20 turns the light on every fifth second for one second and then it it switched off again. </p></td></tr></table></body></html> + + + //?? algorithm sections outside functions not yet implemented + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Tip</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><span style=" font-family:'Courier New';">sample(start, interval)</span> returns true and triggers time events at time instants and <span style=" font-family:'Courier New';">rem(x, y)</span> returns the integer remainder of <span style=" font-family:'Courier New';">x/y</span>, such that <span style=" font-family:'Courier New';">div(x,y) * y + rem(x, y) = x</span>.<br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">LightSwitch</p></td></tr></table></body></html> + + + class LightSwitch + Boolean on; +algorithm + when sample(5, 5) then + if rem(time, 5) == 0 then + on := true; + else + on := false; + end if; + end when; +end LightSwitch; + {LightSwitch} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">Simulation of LightSwitch</p></td></tr></table></body></html> + + + simulate( LightSwitch, stopTime=20 ) + record SimulationResult + resultFile = "Simulation failed. +Warning: In rem(time,5.0) == 0.0, == on Reals is only allowed inside functions. +Error: Internal error code generation of expression rem(time,5.0) == 0.0 failed +Error: Internal error generate_zero_crossing failed +Error: Internal error Generation of simulation code failed +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + plot( on ); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><img src="file:///C:/Users/mohto/Develop/OpenModelica1.5.0/OMNotebook/DrModelica/OMNoteboook_tempfiles/38.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">LightSwitchExtended</p></td></tr></table></body></html> + + + class LightSwitchExtended + Boolean on; +algorithm + when time < 5 or time >= 25 then + on := false; + elsewhen sample(5, 1) then + if rem(time, 5) == 0 then + on := true; + else + on := false; + end if; + end when; +end LightSwitchExtended; + {LightSwitchExtended} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">Simulation of LightSwitchExtended</p></td></tr></table></body></html> + + + simulate( LightSwitchExtended, stopTime=25 ) + record SimulationResult + resultFile = "Simulation failed. +Warning: In rem(time,5.0) == 0.0, == on Reals is only allowed inside functions. +Error: Internal error code generation of expression rem(time,5.0) == 0.0 failed +Error: Internal error generate_zero_crossing failed +Error: Internal error Generation of simulation code failed +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + plot( on ); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><img src="file:///C:/Users/mohto/Develop/OpenModelica1.5.0/OMNotebook/DrModelica/OMNoteboook_tempfiles/39.png" width="288" height="214" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAEgAAAA1ggDAAAARuGvAgAAAwBQTFRFAAAAAAD/2dnZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqOCPfgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAxxJREFUeJzt3YmO2yAAAFGc///oVVt8BhigWEvieeoRKcQNIxxXxbsNLxWF334DszMQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBBoDhTC+6Nv1h5of5GB1jHhz8+4YOLjQ6fvlpnkEsUh2w9XUHrIe6Cnr6DzmLD/jJW2Vl+v60O697WfyMs8eMQk/4eBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIFAOtD+D/SPl2lgoJWBQDlQU6FlOW4Wfc7osoEraHl78Bmjy5IN+rZO55ny7YGqnnwzz5QNNHR0mYGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBwN7guI3adfPCPFO+JVBIPDZQJpAraFdeQW03LzS9rXlGl3mKgetpdfzVQC8v88hAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQCC3N+++WJTZer48WWWeKd8eKLhxuHFvHrg3D5J7855iOy/zwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEAgffNC13+kOs+Ubwl0uXnBQJFbzyB3d0fcgm451DxTvv8UcwVtkjcvrLcvGMjLPDIQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEDAQMBAwEEjvzfs1qxu3nkFmZ9UVtMrd3fHvN/fms6fY+ckq80z5zg/p9RsL+BkUeZkHBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGurjO2UDnWa5fEZ9+NvvSmgeJt/UZo88JKlfQ35BhaRNCy8smG30I0rGCniSUV1T9kw9hIGADYCAwLlCov2Hv9H1UqkfXDR997IGBGsder6dw5Pqxof7YYXsr5T98iJY7PnsC1R5+8LFHfgbVH6tjErWj1+XWMLp47GGB6uf76gnUcNKMHf0bp1j8q331p27r6Po3UzHayzwwEDAQMBAwEDAQMBAwEDAQMBAwEPgB8tLYR5u1uLIAAAAASUVORK5CYII= + + + + + + + diff --git a/DrModelica/Algorithms/Exercise5.onb b/DrModelica/Algorithms/Exercise5.onb new file mode 100644 index 00000000000..ae57511ed85 --- /dev/null +++ b/DrModelica/Algorithms/Exercise5.onb @@ -0,0 +1,154 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Exercise 5</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">reinit</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Write a model <span style=" font-family:'Courier New';">BilliardBalls</span>, with two billiard balls that is rolling from opposite directions and bounces into each other. </p></td></tr></table></body></html> + + + //?? algorithm sections outside functions not yet implemented + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Tip</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><span style=" font-family:'Courier New';">reinit(x, value)</span> is the sam thing as <span style=" font-family:'Courier New';">x := value</span>, but <span style=" font-family:'Courier New';">reinit</span> reinitializes the value of x at a specific time and the equations still holds.</p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">BilliardBalls</p></td></tr></table></body></html> + + + model BilliardBalls + parameter Real c = 0.9; // Elasticity constant of balls + Real position1(start = 1); // Position of ball 1 + Real position2(start = 10); // Position of ball 2 + Real velocity1(start = 10); // Velocity of ball 1 + Real velocity2(start = -15); // Velocity of ball 2 +equation + der(position1) = velocity1; + der(position2) = velocity2; + der(velocity1) = 0; + der(velocity2) = 0; +algorithm + when position1 >= position2 then + reinit(velocity1, -c*velocity1); + reinit(velocity2, -c*velocity2); + end when; +end BilliardBalls; + {BilliardBalls} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">Simulation of BilliardBalls</p></td></tr></table></body></html> + + + simulate( BilliardBalls ) + record SimulationResult + resultFile = "Simulation failed. +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + plot( { velocity1, velocity2, position1, position2 } ) + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><img src="file:///C:/Users/mohto/Develop/OpenModelica1.5.0/OMNotebook/DrModelica/OMNoteboook_tempfiles/40.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + + + + + diff --git a/DrModelica/Algorithms/ForStat.onb b/DrModelica/Algorithms/ForStat.onb new file mode 100644 index 00000000000..2d15abd14ed --- /dev/null +++ b/DrModelica/Algorithms/ForStat.onb @@ -0,0 +1,163 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Iteration Using for-Statements</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">SumZ</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement is a convenient way of expressing iteration. This fits well when you know how to express the range of values over which the iteration variable should iterate. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">SumZ </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">contains a very simple </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-loop summing the five elements of the vector z.<br /></span></p></td></tr></table></body></html> + + + class SumZ + parameter Integer n = 5; + parameter Real[n] z := {10, 20, 30, 40, 50}; + Real sum(start = 0); +algorithm + sum := 0; + for i in 1:n loop + sum := sum + z[i]; + end for; +end SumZ; + {SumZ} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of SumZ</span></p></td></tr></table></body></html> + + + simulate( SumZ ) + record SimulationResult + messages = "", + simulationTime = 0.1383102477739645 +end SimulationResult; + + + + + + + plot({z[1],sum}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of SumZ and HideVariable</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Since the scope of the iteration variable is the body of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement, it may hide other variables with the same name, like the constant k in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HideVariable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class HideVariable + constant Integer k = 4; + Real z[k + 1]; +algorithm + for k in 1:k+1 loop // The iteration variable k gets values 1, 2, 3, 4, 5 + z[k] := k; + end for; +end HideVariable; + {HideVariable} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of HideVariable</span></p></td></tr></table></body></html> + + + simulate( HideVariable ) + record SimulationResult + messages = "", + simulationTime = 0.10364359674982503 +end SimulationResult; + + + + + + plot(z[3]) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Algorithms/IfStat.onb b/DrModelica/Algorithms/IfStat.onb new file mode 100644 index 00000000000..bc9553fd1d9 --- /dev/null +++ b/DrModelica/Algorithms/IfStat.onb @@ -0,0 +1,333 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">if-Statements</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The semantics of an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement is:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:11pt; font-weight:600; color:#000000;">if</span><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> expression </span><span style=" font-family:'Courier New'; font-size:11pt; font-weight:600; color:#000000;">then</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { algorithm &quot;;&quot; }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { </span><span style=" font-family:'Courier New'; font-size:11pt; font-weight:600; color:#000000;">elseif</span><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> expression </span><span style=" font-family:'Courier New'; font-size:11pt; font-weight:600; color:#000000;">then</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { algorithm &quot;;&quot; }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> [ </span><span style=" font-family:'Courier New'; font-size:11pt; font-weight:600; color:#000000;">else</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { algorithm &quot;;&quot; }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> ]</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:11pt; font-weight:600; color:#000000;">end if</span><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;">;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#000000;">inside an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">algorithm</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#000000;"> section and </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> if expression then</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { equation &quot;;&quot; }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { elseif expression then</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { equation &quot;;&quot; }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> [ else</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> { equation &quot;;&quot; }</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> ]</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;"> end if;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">inside an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">equation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> section.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If the condition after the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> evaluates to true, the statements after </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">then</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are executed. Otherwise if there are one or more elseif-parts there conditions are evaluated in order; the first that evaluates to true causes the corresponding statements to be executed. Otherwise, if present, the statements in the else-part are executed. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">elseif</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> part is conditional and can appear in zero or more iterations. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-clause is conditional depending on the variability of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-expression. In case the expression is of parameter type then the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-clause can be emitted. In case the variability of the expression condition is higher than parameter then the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-clause cann't be omitted since the single assignment rule would not hold, because the number of equations may change during a simualtion. </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">SumVector</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In the class SumVector there is an exmple of an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement which performs a combined summation and computation on a vector v.</span></p></td></tr></table></body></html> + + + class SumVector + Real sum; + parameter Real v[5] = {100, 200, -300, 400, 500}; + parameter Integer n = size(v, 1); +algorithm + sum := 0; + for i in 1:n loop + if v[i] > 0 then + sum := sum + v[i]; + elseif v[i] > -1 then + sum := sum + v[i] - 1; + else + sum := sum - v[i]; + end if; + end for; +end SumVector; + {SumVector} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of SumVector</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">After we have simulated </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">SumVector</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> we see that the sum of the absolute value of the elements in the vecor is 1500.</span></p></td></tr></table></body></html> + + + simulate( SumVector ) + record SimulationResult + resultFile = "SumVector_res.mat", + messages = "" +end SimulationResult; + + + val(sum,0) + 1500.0 + + + + + + + plot({v[3], sum}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Assignments within if-Statements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">There are a special feature regarding assignment statements inside </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements. Modelica guarantees that all the outputs of an algorithm section always have well-defined values, and that an algorithm section does </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">not</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have memory of previous invocations. This is achieved by </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">initializing</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> all </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">conditionally assigned variables</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to their start-values whenever the algorithm is invoked. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">CondAssign</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The algorithm section in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CondAssign</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below automatically assigns the start values 35 and 45 to the variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> respectively when entering the algorithm section since these variables are conditionally assigned within the algorithm section. This means that the condition </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x&gt;5 </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">becomes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">35&gt;5</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which is always true. On the other hand, the variable z is not given its start value when entering the algorithm section since it is not conditionally assigned; it is actually an input to the algorithm section.<br /></span></p></td></tr></table></body></html> + + + class CondAssign + Real x(start = 35); + Real y(start = 45); + parameter Real z := 0; +algorithm + if x > 5 then + x := 400; + end if; + if z > 10 then + y := 500; + end if; +end CondAssign; + {CondAssign,SumVector} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of CondAssign</span></p></td></tr></table></body></html> + + + simulate( CondAssign ) + record SimulationResult + resultFile = "CondAssign_res.mat", + messages = "" +end SimulationResult; + + + + + + plot({y}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">CondAssign</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The function CondAssignFunc below behaves similarily. Here the local variables x and y are automatically assigned the default initial values 35 and 45 on entry to the algorithm section that comprises its function body.<br /></span></p></td></tr></table></body></html> + + + function CondAssignFunc + input Real z; + output Real x := 35; + output Real y := 45; +algorithm + if x > 5 then + x := 400; + end if; + if z > 10 then + y := 500; + end if; +end CondAssignFunc; + {CondAssignFunc,CondAssign,SumVector} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class CondAssignFuncCall + Real a, b; +equation + (a, b) = CondAssignFunc(z = 5); +end CondAssignFuncCall; + {CondAssignFuncCall,CondAssignFunc,CondAssign,SumVector} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of CondAssignFuncCall</span></p></td></tr></table></body></html> + + + simulate( CondAssignFuncCall ) + record SimulationResult + resultFile = "CondAssignFuncCall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + {val(a,0), val(b,0)} + {400.0,45.0} + + + + + + + plot({a,b}) + [done] + + + + + + diff --git a/DrModelica/Algorithms/MultRes.onb b/DrModelica/Algorithms/MultRes.onb new file mode 100644 index 00000000000..c298574112f --- /dev/null +++ b/DrModelica/Algorithms/MultRes.onb @@ -0,0 +1,169 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Functions with Multiple Results</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />There is a special form of assignment statement that is only used when the right-hand side contains a call to a function with multiple results. The left-hand side contains a parenthesized, comma-separated list of variables receiving the results from the function call. A function with n results needs n receiving variables on the left-hand side. <br /></span></p></td></tr></table></body></html> + + + function f + input Real x; + input Real y; + output Real r1; + output Real r2; + output Real r3; +algorithm + r1 := x; + r2 := y; + r3 := x*y; +end f; + {f} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model fCall + Real x[3]; + Real a, b, c; +equation + (a, b, c) = f(1.0, 2.0); + (x[1], x[2], x[3]) = f(3.0, 4.0); +end fCall; + {fCall} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Calling the function f</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We can call </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">f</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with some input values and see what outputs it returns.</span></p></td></tr></table></body></html> + + + f(2.5, 3) + (2.5,3.0,7.5) + + + f(3, 4) + (3.0,4.0,12.0) + + + f(1.0, 2.0) + (1.0,2.0,2.0) + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of the fCall model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">fCall</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the interval from 0 to 1, then we can look at the values of the variables.</span></p></td></tr></table></body></html> + + + simulate (fCall ) + record SimulationResult + resultFile = "fCall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + {val(a,0), val(b,0), val(c,0)} + {1.0,2.0,2.0} + + + + + + + + plot( {x[1],x[2],x[3]} ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Algorithms/Reinit.onb b/DrModelica/Algorithms/Reinit.onb new file mode 100644 index 00000000000..643bf8f1642 --- /dev/null +++ b/DrModelica/Algorithms/Reinit.onb @@ -0,0 +1,256 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Reinit</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> operator occurs both as a kind of statement and in the form of an equation with the same syntax. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> operator is used to make a discontinuous change in the value of a continuous variable at a specific time event. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> operator can only be applied to variables the have had the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">der</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> operator applied to them. The effect of the operator is to stop simulation time, make a change to the value of one or more continuous variables and then resume the simulation. The first argument to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is the variable whose value should change and the second argument is the value it should change to. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> operator can only be used within a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> clause because it is meant to represent an abrupt change, which is the difference between </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and a statement or equation. </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Bouncing Ball</span></p></td></tr></table></body></html> + + + model BouncingBall "The bouncing ball model with an algorithm" + constant Real g = 9.81; // Gravitational acceleration + parameter Real c = 0.9; // Elasticity constant of ball + Real height(start = 1,fixed=true); // height above ground of ball center + Real velocity(start = 10,fixed=true); // Velocity of the ball +equation + der(height) = velocity; + der(velocity) = -g; +algorithm + when height <= 0 then + reinit(velocity, -c*velocity); + end when; +end BouncingBall; + {BouncingBall} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Bouncing Ball Simulation</span></p></td></tr></table></body></html> + + + simulate( BouncingBall, stopTime=20 ) + record SimulationResult + resultFile = "BouncingBall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { height, velocity } ) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Bouncing Ball Error</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If the assignment </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">velocity := -c*velocity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used instead of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit(velocity, -c*velocity)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> an overdeterminated system of equations are created.</span></p></td></tr></table></body></html> + + + model BouncingBallError "The bouncing ball model with an algorithm" + constant Real g = 9.81; // Gravitational acceleration + parameter Real c = 0.9; // Elasticity constant of ball + Real height(start = 1); // height above ground of the ball center + Real velocity(start = 10); // Velocity of the ball +equation + der(height) = velocity; + der(velocity) = -g; +algorithm + when height <= 0 then + velocity := -c*velocity; + end when; +end BouncingBallError; + {BouncingBallError} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Bouncing Ball Error </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When we try to simulate the erroneous Bouncing Ball model we get a complaint for having to many equations.</span></p></td></tr></table></body></html> + + + simulate( BouncingBallError, stopTime=20 ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: BouncingBallError +Error: Too many equations, over-determined system. The model has 3 equation(s) and 2 variable(s). +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed! +" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">FilterBlock1</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Another example of how to use </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is the self initializing block class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FilterBlock1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which when </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">initial()</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> becomes true defines </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to be </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">u</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This causes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">der(x)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to initially be zero according to its defining equation. </span></p></td></tr></table></body></html> + + + block FilterBlock1 "First order filter block" + parameter Real T = 1 "Time constant"; + parameter Real k = 1 "Gain"; + input Real u = 1; + output Real y; +protected + Real x; +equation + der(x) = (u - x)/T; + y = k*x; +initial algorithm + x := u; // if x is u since der(x) = (u - x)/T +end FilterBlock1; + {FilterBlock1} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">FilterBlock Simulation</span></p></td></tr></table></body></html> + + + simulate( FilterBlock1, stopTime=10 ) + record SimulationResult + resultFile = "FilterBlock1_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot(y) + [done] + + + + + diff --git a/DrModelica/Algorithms/Sections.onb b/DrModelica/Algorithms/Sections.onb new file mode 100644 index 00000000000..b59d8104673 --- /dev/null +++ b/DrModelica/Algorithms/Sections.onb @@ -0,0 +1,81 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Algorithm Sections</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Algorithm sections can also be called algorithm equations, since an algorithm section externally is treated as a group of equations involving one or more variables, and can appear among equation sections. An algorithm section is terminated by the appearance of one of the five keywords </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">equation, public, protected, algorithm</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">end</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. An algorithm section embedded among equation sections can appear as below, where the example algorithm section contains three assignment statements.<br /></span></p></td></tr></table></body></html> + + + model AlgorithmSection + Real x, z, u; + parameter Real w = 3,y = 2; + Real x1, x2, x3; +equation + x = y*2; + z = w; +algorithm + x1 := z + x; + x2 := y - 5; + x3 := x2 + y; +equation + u = x1 + x2; //x1 and x2 outputs of the algorithm section +end AlgorithmSection; + {AlgorithmSection} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Note that the code in the algorithm section uses the value of certain variables from outside the algorithm section. The variables are also called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">inputs</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to the algorithm section (in this example </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x, y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">z</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">). Analogously, variables assigned values by the algorithm define the outputs of the algorithm (in this example </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">). This makes the semantics of an algorithm section quite similar to a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">function</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with the algorithm section as its body, and with </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">input</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">output</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> formal parameters corresponding to inputs and outputs as described above. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of AlgorithmSection</span></p></td></tr></table></body></html> + + + simulate( AlgorithmSection, startTime=0, stopTime=4 ) + record SimulationResult + messages = "", + simulationTime = 0.14692879142779733 +end SimulationResult; + + + + + + + plot({x1,x2}) + [done] + + + + + diff --git a/DrModelica/Algorithms/Terminate.onb b/DrModelica/Algorithms/Terminate.onb new file mode 100644 index 00000000000..096e6ebe2a4 --- /dev/null +++ b/DrModelica/Algorithms/Terminate.onb @@ -0,0 +1,194 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Terminate</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The most common usage of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">terminate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is to give a more appropriate stopping criteria for terminating a simulation than a fixed point in time. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">terminate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> function takes a single argument of type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">String</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which is used to indicate the reason for a successful termination. This is exemplified in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">terminate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> statement within the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MoonLanding</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Celestial Body</span></p></td></tr></table></body></html> + + + class CelestialBody + constant Real g = 6.672e-11; + parameter Real radius; + parameter String name; + Real mass; +end CelestialBody; + {CelestialBody} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Rocket</span></p></td></tr></table></body></html> + + + class Rocket + parameter String name; + Real mass(start = 1038.358,fixed=true); + Real altitude(start = 59404,fixed=true); + Real velocity(start = -2003,fixed=true); + Real acceleration; + Real thrust; // Thrust force on the rocket + Real gravity; // Gravity forcefield + parameter Real massLossRate = 0.000277; +equation + (thrust - mass*gravity)/mass = acceleration; + der(mass) = -massLossRate * abs(thrust); + der(altitude) = velocity; + der(velocity) = acceleration; +end Rocket; + {Rocket} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MoonLanding</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When using this terminate condition the simulation stops when the moon lander touches the ground on the moon.</span></p></td></tr></table></body></html> + + + class MoonLanding + parameter Real force1 = 36350; + parameter Real force2 = 1308; +protected + parameter Real thrustEndTime = 210; + parameter Real thrustDecreaseTime = 43.2; +public + Rocket apollo(name = "Apollo13"); + CelestialBody moon(name = "moon", mass = 7.382e22, radius = 1.738e6); + +equation + apollo.thrust = if (time < thrustDecreaseTime) then force1 + else if (time < thrustEndTime) then force2 + else 0; + apollo.gravity = moon.g*moon.mass/(apollo.altitude + moon.radius) ^2; + +algorithm + when apollo.altitude < 0 then // Termination condition + terminate("The moon lander touches the ground of the moon"); + end when; +end MoonLanding; + {MoonLanding} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MoonLanding Simulation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When we simulate the MoonLanding class from 0 to 230 we get a message that the simulation ended before reaching 230. In the dslog.txt file we see that the simulation is terminated at T = 218.</span></p></td></tr></table></body></html> + + + simulate( MoonLanding, stopTime=230 ) + record SimulationResult + resultFile = "MoonLanding_res.mat", + messages = "[<interactive>:19:5-19:64:writable] +stdout | info | Simulation call terminate() at time 212.101081 +| | | | Message : The moon lander touches the ground of the moon +" +end SimulationResult; + + + + + + + plot( { apollo.velocity, apollo.altitude } ) //??xrange xrange={0,208} is removed + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Vertical </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">velocity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> relative to the lunar surface and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Altitude</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of the Apollo rocket over the lunar surface.</span></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Algorithms/WhenStat.onb b/DrModelica/Algorithms/WhenStat.onb new file mode 100644 index 00000000000..567944410d0 --- /dev/null +++ b/DrModelica/Algorithms/WhenStat.onb @@ -0,0 +1,525 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">when-Statements</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">When-statements </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">are used to express actions (statements) that are only executed at </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">events</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, e.g. at discontinuities or when certain conditions become true. The executed statements</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">contain </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">discrete-time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> expressions since they are computed only at event instants, even expressions that otherwise would be classified as continuous-time. <br /><br />When-statements are generally used to either reinitialize a continuous variable using the reinit operator or to change the value of a discrete variable. When-statements are closely related to when-equations, the obvious difference between them is that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements are statements containing other statements and can only be used in algorithm sections whereas </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations are equations which are only allowed in equation sections. </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WhenStat</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The when-statement below are executed at the event instant when the Boolean expression</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> x &gt; 2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> becomes true. We should note that this is different from an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement with the same condition which executes its body each time when invoked provided that the condition of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement is true. This difference is easier to understand if we consider the definition of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements in terms of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements and the edge operator in the section below.<br /></span></p></td></tr></table></body></html> + + + class WhenStat + Real x(start=1,fixed=true); + Real y1(fixed=true); + parameter Real y2 = 5; + Real y3(fixed=true); +algorithm + when x > 2 then + y1 := sin(x); + y3 := 2*x + pre(y1) + y2; + end when; +equation + der(x) = 2*x; +end WhenStat; + {WhenStat} + + + setDebugFlags("initialization") + true + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WhenStat</span></p></td></tr></table></body></html> + + + simulate( WhenStat ) + record SimulationResult + resultFile = "WhenStat_res.mat", + messages = "" +end SimulationResult; + + + + + + plot( y1 ) + [done] + + + + + + plot( y3 ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WhenStat2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If we use a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Boolean</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> vector expression containing three elements as the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">conditions</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, then the two statements will be executed at event instants when at least one of the three conditions:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> x &gt; 2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sample(0, 2)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x becomes true. Typically each condition in the vector generates its own event instants.<br /></span></p></td></tr></table></body></html> + + + class WhenStat2 + Real x(start = 1,fixed=true); + Real y1(fixed=true); + parameter Real y2 = 5; + Real y3(fixed=true); +algorithm + when {x > 2, sample(0, 2), x < 5} then + y1 := sin(x); + y3 := 2*x + y1 + y2; + end when; +equation + der(x) = 2*x; +end WhenStat2; + {WhenStat2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WhenStat2</span></p></td></tr></table></body></html> + + + simulate( WhenStat2 ) + record SimulationResult + resultFile = "WhenStat2_res.mat", + messages = "" +end SimulationResult; + + + + + + plot( y1 ) + [done] + + + + + + plot( y3 ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WhenStat</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The order between the statements in the body of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement is of cuorce significant. If you would put the assignment to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> before the assignment of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> you would get a different result and thus a different model behavior.<br /></span></p></td></tr></table></body></html> + + + class WhenStat3 + Real x(start = 1,fixed=true); + Real y1(fixed=true); + Real y2; + Real y3(fixed=true); +algorithm + when x > 2 then + y1 := sin(x); + end when; +equation + y2 = sin(y1); +algorithm + when x > 2 then + y3 := 2*x + pre(y1) + y2; + end when; +equation + der(x) = 2*x; +end WhenStat3; + {WhenStat3} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WhenStat3</span></p></td></tr></table></body></html> + + + simulate( WhenStat3 ) + record SimulationResult + resultFile = "WhenStat3_res.mat", + messages = "" +end SimulationResult; + + + + + + plot( y1 ) + [done] + + + + + + plot( y3 ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Defining when-Statements by if-Statements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement can be defined as a combination of the following:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg'; font-size:8pt;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">- An </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement</span></p></td></tr></table></body></html> + Left + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">- Boolean variables with appropriate start values</span></p></td></tr></table></body></html> + Left + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">- Calls to the edge operator in the conditional expressions of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement</span></p></td></tr></table></body></html> + Left + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Avoiding Multiple-Definition Conflicts for when-Statements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Two </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements in different algorithm sections or two </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations may not define the same variable. Without this rule a conflict between the assignment will occur if both conditions would become true at the same time instant.<br /></span></p></td></tr></table></body></html> + + + model DoubleWhenConflict + Boolean close; // Erroneous model: close defined by two equations + parameter Real x = 5; +algorithm + when x >= 5 then + close := true; + end when; + +algorithm + when x <= 5 then + close := false; + end when; +end DoubleWhenConflict; + {DoubleWhenConflict} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">DoubleWhenSequential</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">One possible way to resolve the conflict would be to put both </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements within the same algorithm section, as in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DoubleWhenSequential</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model below. The sequential execution semantics of algorithm sections allow several assignments to the same variable. If there are several </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements with assignments active at the same time instant, they will be executed in sequential order and the result of the last assignment will prevail.<br /><br />However, this method is not recommended since the modeling style is less clear than the alternative method presented in the next section. Another disadvantage is the nondeclarative style of using </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-constructs by relying on multiple sequential assignments.<br /></span></p></td></tr></table></body></html> + + + model DoubleWhenSequential + Boolean close(fixed=true); // Possible conflicting definitions resolved + // by sequential assignments in an algorithm section +algorithm + when time <= 2 then + close := true; + end when; + + when time <= 2 then + close := false; + end when; +end DoubleWhenSequential; + {DoubleWhenSequential} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DoubleWhenSequential</span></p></td></tr></table></body></html> + + + simulate( DoubleWhenSequential ) + + record SimulationResult + resultFile = "DoubleWhenSequential_res.mat", + messages = "" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">WhenPriority</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A more explicit and therefore better way to resolve the conflict would be to give one of the two event handlers higher priority, which is possible using the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">elsewhen</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> construct. Here it is well defined what happens if both conditions become true at the same time instant since the first condition (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x &gt;= 5</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">) has higher priority than the second condition (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x ).<br /></span></p></td></tr></table></body></html> + + + model WhenPriority + Boolean close (fixed=true); + parameter Real x = 5; +algorithm + when x >= 5 then + close := true; + elsewhen x <= 5 then + close := false; + end when; +end WhenPriority; + {WhenPriority} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of WhenPriority</span></p></td></tr></table></body></html> + + + simulate( WhenPriority ) + record SimulationResult + resultFile = "WhenPriority_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Algorithms/WhileStat.onb b/DrModelica/Algorithms/WhileStat.onb new file mode 100644 index 00000000000..01044bff11f --- /dev/null +++ b/DrModelica/Algorithms/WhileStat.onb @@ -0,0 +1,77 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Iteration Using while-Statements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />When using the for-loop for iteration you must be able to express the range of values over which the iteration variable should iterate in a </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">closed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> form such as an iteration expression. For cases where this is not feasible there is also a while-loop iteration construct in Modelica where the termination condition is just a Boolean expression and the range of iteration values need not be expressed in closed form as an expression. You need to declare the iteration variable separately, as well as handling the increment or decrement of this variable yourself. <br /><br />The example class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">SumSeries</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> shows the while-loop construct used for summing a serries of exponential terms until the loop condition is violated (the terms become smaller than eps). In this case it would be quite impractical to use a for-loop. <br /></span></p></td></tr></table></body></html> + + + class SumSeries + parameter Real eps = 1.E-6; + Integer i; + Real sum; + Real delta; +algorithm + i := 1; + delta := exp(-0.01 * i); + while noEvent(delta >= eps) loop + sum := sum + delta; + i := i + 1; + delta := exp(-0.01 * i); + end while; +end SumSeries; + {SumSeries} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of SumSeries</span></p></td></tr></table></body></html> + + + simulate( SumSeries ) + record SimulationResult + resultFile = "SumSeries_res.mat", + messages = "" +end SimulationResult; + + + {val(sum,0), val(delta,0)} + + {99.50073328129245,0.0000009955206204452296} + + + + + + + + plot({delta, sum, i}) + [done] + + + + + diff --git a/DrModelica/AnnUnitsQuant/Annotations.onb b/DrModelica/AnnUnitsQuant/Annotations.onb new file mode 100644 index 00000000000..c39eba85b58 --- /dev/null +++ b/DrModelica/AnnUnitsQuant/Annotations.onb @@ -0,0 +1,46 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Annotations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />An annotation can be understood as an attribute or property containing information associated with some element of a Modelica model. Examples are model documentation and graphical layout information concerning icons and connections associated with models. The graphical view usually makes models easier to understand. <br /><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is an example of an annotation containing information about the graphical layout of an icon representing a resistor model, the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">annotation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has the name </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Icon</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and contains instances of the graphical annotation elements </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rectangle</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Text</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Line</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, etc. <br /></span></p></td></tr></table></body></html> + + + model Resistor1 + annotation(Icon( + Rectangle(extent = [-70, -30, 70, 30], style(fillPattern = 1)), + Text(extent =[-100, 55; 100, 110], string = "%name = %R"), + Line(points = [-90, 0; -70, 0]), + Line(points = [70, 0; 90, 0]) + )); +end Resistor1; + + {Resistor1} + + + simulate(Resistor1) + record SimulationResult + messages = "", + simulationTime = 0.1447867848512812 +end SimulationResult; + + + + diff --git a/DrModelica/AnnUnitsQuant/FuncAnn.onb b/DrModelica/AnnUnitsQuant/FuncAnn.onb new file mode 100644 index 00000000000..1856ad58dd1 --- /dev/null +++ b/DrModelica/AnnUnitsQuant/FuncAnn.onb @@ -0,0 +1,178 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Function Annotations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Two rather special annotations are defined for functions. These are the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">derivative</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> annotation and the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">arrayLayout</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> annotation. The function derivative annotation allows you to explicitly specify the computation of the derivatives of a function to any order, e.g. in order to gain performance and/or numerical accuracy. The external function annotation </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">arrayLayout</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be used to explicitly give the layout of arrays</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Function Derivative Annotations </span></p></td></tr></table></body></html> + + + function h0 // exp(x(t)+i1) + annotation(derivative=h1); + input Integer i1; + input Real x; + input Boolean linear; // not used + output Real y; + algorithm + y := exp(x)+i1; +end h0; + + {h0} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + function h1 // (d/dt)(exp(x(t)) + annotation(derivative(order=2)=h2); + input Integer i1; + input Real x; + input Boolean linear; + input Real der_x; + output Real der_y; +algorithm + der_y := exp(x)*der_x; +end h1; + {h1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + function h2 // (d/dt)(exp(x(t)*der_x(t)) + input Integer i1; + input Real x; + input Boolean linear; + input Real der_x; + input Real der_2_x; + output Real der_2_y; +algorithm + der_2_y := exp(x)*der_x*der_x + exp(x)*der_2_x; +end h2; + {h2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Calling functions h0, h1 and h2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Below are examples of calling the h0, h1, and h2 functions.</span></p></td></tr></table></body></html> + + + fn0 := h0(2,5,true) + 150.4131591025766 + + + fn1 := h1(2,5,true,fn0) + 22323.29211301187 + + + fn2 := h2(2,5,true,fn0,fn1) + 6670787.192349472 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We could for example make a plot of the h0 function from x=4 to x=6:</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">External Function Annotations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Regarding specific annotations only for external function declarations there is an optional </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">arrayLayout</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> annotation, which can be either </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">&quot;rowMajor&quot;</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">&quot;columnMajor&quot;</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This annotation causes additional information to be passed to the compiler when necessary. It is only needed when the array storage layout deviates from the default for the external language. This is the case for the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">joinThreeVectors2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below where the C function uses column-major array representation which is different from the default row-major layout that normally is used for C.<br /></span></p></td></tr></table></body></html> + + + function joinThreeVectors2 "External C function with column-major arrays" + input Real v1[:],v2[:],v3[:]; + output Real vres[size(v1,1)+size(v2,1)+size(v3,1)]; + external "C" join3vec(v1,v2,v3,vres,size(v1,1),size(v2,1),size(v3,1)); + annotation(arrayLayout = "columnMajor"); +end joinThreeVectors2; + + {joinThreeVectors2} + + + + + diff --git a/DrModelica/AnnUnitsQuant/Graphical.onb b/DrModelica/AnnUnitsQuant/Graphical.onb new file mode 100644 index 00000000000..24740e4374c --- /dev/null +++ b/DrModelica/AnnUnitsQuant/Graphical.onb @@ -0,0 +1,634 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Graphical Annotations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Graphical Representation of Resistor </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The example below shows the use of graphical attributes in the form of annotations to define the different parts of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> icon.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical units</span></p></td></tr></table></body></html> + + + type Voltage = ElectricPotential; +type Current = ElectricCurrent; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + {Pin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Resistor</span></p></td></tr></table></body></html> + + + model Resistor //?? Uses old or new Modelica annotations + Pin p annotation(extent = [-110, -10, -90, 10], style(fillPattern = 1)); + Pin n annotation(extent = [110, -10, 90, 10]); + parameter Real R "Resistance in [Ohm]"; +equation + R*p.i = p.v - n.v; + n.i = p.i; +public + annotation(Icon( + Rectangle(extent = [-70, -30, 70, 30], style(fillPattern = 1)), + Text(extent =[-100, 55; 100, 110], string = "%name = %R"), + Line(points = [-90, 0; -70, 0]), + Line(points = [70, 0; 90, 0]) + )); +end Resistor; + + {Resistor} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Graphical Annotation Attributes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">There are a number of predefined graphical annotation attributes, which can be divided into basic attributes; built-in attributes to classes, instances, and connections; and attributes that are graphical elements to specify the appearance of class icons.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Basic Attributes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The basic attribute classes are </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Extent</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Style</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with the corresponding attributes p</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">oint</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">extent</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">style</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span></p></td></tr></table></body></html> + + + type Point = Real[2]; // {x, y} + {Point} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + type Extent = Real[2, 2]; // [x1, y1; x2, y2] + {Extent} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record Style + Integer color[3], fillColor[3]; // RGB + Integer pattern, fillPattern, thickness, gradient, // ??Explanations + smooth, arrow, textStyle; + String font; +end Style; + {Style} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Built-in Attributes to Classes, Instances and Connections</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The annotation elements </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CoordinateSystem</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Placement</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Route</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below are by default associated with classes, instances, and connection equations respectively. This means that these elements including their attributes exist even if they are not mentioned explicitly in the annotations of these entities. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Route</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> annotation element also has alternative names such as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Line</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Polygon</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> defined in the next section. <br /></span></p></td></tr></table></body></html> + + + record CoordinateSystem // Attribute to class + Extent extent; + Point grid; + Point size; +end CoordinateSystem; + {CoordinateSystem} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record Placement // Attribute for components + Extent extent; + Real rotation; +end Placement; + {Placement} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record Route // Attribute for connect equations + Point points[:]; + Style style; + String label; +end Route; + {Route} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Definitions of Graphical Elements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following predefined graphical elements are used as graphical annotation elements including annotation attributes when defining the appearance of class icons. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Line</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> graphical element can also be used for connection lines.</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;"><br /></span></p></td></tr></table></body></html> + + + record Line = Route; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record Polygon = Route; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record GraphicItem + Extent extent; + Style style; +end GraphicItem; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record Rectangle = GraphicItem; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record Ellipse = GraphicItem; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record Text + extends GraphicItem; + String string; +end Text; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + record BitMap + extends GraphicItem; + String URL; // Name of Bitmap file +end BitMap; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Choices Annotations for Variables and Enumerations Types</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The choices annotation is applicable to both replaceable and nonreplaceable elements. For example, consider the following Integer type called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">KindOfController</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used to represent a choice of controller in the modeling process. This choice is made from the following enumeration of three recommended alternatives:<br /></span></p></td></tr></table></body></html> + + + type KindOfController = Integer(min = 1,max = 3) + annotation(choices( + choice = 1 "P", + choice = 2 "PI", + choice = 3 "PID")); + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Assume that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">KindOfController</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used in a model A as below:<br /></span></p></td></tr></table></body></html> + + + model A + parameter KindOfController x; +end A; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />If you interactively choose the third alternative from the menu this corresponds to giving the default value 3 for the instantiated variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the following code for an instance </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of the model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">:<br /></span></p></td></tr></table></body></html> + + + class AInst +A a2(x=3 "PID"); +end AInst; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Choices Annotations for Replaceable Model Elements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The choices annotation can also be used to generate menus with redeclaration alternatives for replaceable models. For example, consider the following replaceable model with a choices annotation:</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Resistor</span></p></td></tr></table></body></html> + + + model Resistor + Pin p annotation(extent = [-110, -10, -90, 10], style(fillPattern = 1)); + Pin n annotation(extent = [110, -10, 90, 10]); + parameter Real R "Resistance in [Ohm]"; +equation + R*p.i = p.v - n.v; + n.i = p.i; +public + annotation(Icon( + Rectangle(extent = [-70, -30, 70, 30], style(fillPattern = 1)), + Text(extent =[-100, 55; 100, 110], string = "%name = %R"), + Line(points = [-90, 0; -70, 0]), + Line(points = [70, 0; 90, 0]) + )); +end Resistor; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">MyResistor</span></p></td></tr></table></body></html> + + + class ResistorAnnotation +replaceable model MyResistor = Resistor + annotation(choices( + choice(redeclare model MyResistor = lib2.Resistor "Resistor 1"), + choice(redeclare model MyResistor = lib2.Resistor2 "Resistor 2"))); +end ResistorAnnotation; + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">MyCircuit</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If the user would choose the first alternative, the following code might be produced if </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is part of the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the chosen name of the instantiated component is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">:</span></p></td></tr></table></body></html> + + + model MyCircuit + + model MyResistorModel + extends Electrical.Interfaces.ResistorModel; + // declarations and equations + end MyResistorModel; + + encapsulated package MyComponents = + Electrical.Components (redeclare model ResistorModel = MyResistorModel); + + MyComponents.Transformer tr1; + MyComponents.Transducer td2; + + // ... + +end MyCircuit; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class MyCircuitInst + MyCircuit x(redeclare model MyResistor = lib2.Resistor); +end MyCircuitInst; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Additional Examples of Replaceable Class Declarations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Additional examples of replaceable class declarations with redeclaration choices are shown below. In the first example you can choose between a resistor and a capacitor as choices of components with two pins, and in the second example a friction function is implemented as a constant, a table, or defined as an exponentiation function depending on your choice.<br /></span></p></td></tr></table></body></html> + + + class NewResistor +replaceable Resistor Load(R=2) + extends TwoPin; + annotation(choices( + choice(redeclare lib2.Resistor Load(a={2}) "Resistor"), + choice(redeclare Capacitor Load(L=3) "Capacitor"))); +end NewResistor; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class NewFrictionFunction + replaceable FrictionFunction a(func = exp) + extends TwoPin; + annotation(choices( + choice(redeclare ConstantFriction a(c = 1) "Friction Constant"), + choice(redeclare TableFriction a(table = "...") "Friction-table"), + choice(redeclare FunctionFriction a(func = exp) "Friction-exp") + )); +end NewFrictionFunction; + + + + + + + + diff --git a/DrModelica/AnnUnitsQuant/SynPlac.onb b/DrModelica/AnnUnitsQuant/SynPlac.onb new file mode 100644 index 00000000000..d5712e8e703 --- /dev/null +++ b/DrModelica/AnnUnitsQuant/SynPlac.onb @@ -0,0 +1,314 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Annotation Syntax and Placement</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Annotation Choice</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Annotation elements can also be structured as redeclarations. Here is an example of a level-three nested <span style=" font-family:'Courier New';">choices</span> redeclaration annotation using short class definitions in the redeclarations:<br /></p></td></tr></table></body></html> + + + class AnnotationChoice +annotation(choices( + choice(redeclare model MyResistor = lib2.Resistor(a = {2})), + choice(redeclare model MyResistor = lib2.Resistor2))); +end AnnotationChoice; + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Class Annotations</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The <span style=" font-family:'Courier New';">Resistor2</span> example below illustrates that annotation elements can occur anywhere among the list of elements in a class. The <span style=" font-family:'Courier New';">public</span> keyword is used to end the <span style=" font-family:'Courier New';">equation</span> section before starting the annotation, otherwise the annotation becomes associated with the equation section:</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Electrical units</p></td></tr></table></body></html> + + + type Voltage = ElectricPotential; +type Current = ElectricCurrent; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Electrical Connectors</p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Resistor2</p></td></tr></table></body></html> + + + model Resistor2 + Pin p, n; + parameter Real R "Resistance in [Ohm]"; +equation + R*p.i = p.v - n.v; + n.i = p.i; +public + annotation(Icon( + Rectangle(extent = [-70, -30, 70, 30], style(fillPattern = 1)) + )); +end Resistor2; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Class annotations for classes defined by short class definitions are placed at the end of the declaration. For example, the <span style=" font-family:'Courier New';">Icon</span> annotation is placed at the end of the <span style=" font-family:'Courier New';">Velocity</span> declaration below, after the optional string comment:<br /></p></td></tr></table></body></html> + + + type Velocity = Real[3](unit="m/s") "a comment" + annotation(Icon( + Rectangle(extent = [-70, -30, 70, 30], style(fillPattern = 1)))); + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br /><span style=" font-family:'Courier New';">Annotations</span> can also be used to attach documentation information to a package:</p></td></tr></table></body></html> + + + package Modelica + annotation(Documentation(info = " ")); +end Modelica; + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Variable Annotations</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">A variable annotation associates information with a declared variable. Such an annotation is placed at the end of the variable declaration after the optional string comment. </p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Electrical Connectors</p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Variable Annotation Example</p></td></tr></table></body></html> + + + class P + Pin p annotation(extent=[-110, -10; -90, 10]); +end P; + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Import Annotations</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">As for variable annotations, <span style=" font-style:italic;">import annotations</span> are placed at the end of the <span style=" font-family:'Courier New';">import</span> statement after the optional string comment, e.g.:</p></td></tr></table></body></html> + + + class I + import Modelica.Mechanics.Rotational "Rotational import" annotation(); +end I; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Equation Annotations</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The most common form of <span style=" font-style:italic;">equation annotation</span> is annotations to connect equations. It is natural to associate graphical attributes such as lines with a certain position, length, and color to such equations. Notice that the declaration is placed at the end, after the optional comment, as in Variable and Import Annotations. <br /></p></td></tr></table></body></html> + + + class C +equation + connect(p1.n, p2.p) "comment"; + annotation(Line(points = [-90, 0; -70, 0])); +end C; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Statement and Algorithm Annotations</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Statements can also be annotated, even though the need is less obvious than for connection equations. As for equations, <span style=" font-style:italic;">statement annotations</span> are placed at the end of the statement after the optional string comment, e.g.:<br /></p></td></tr></table></body></html> + + + class S +algorithm + name := x+2*y "comment" annotation( ); +end S; + + + + + + + diff --git a/DrModelica/AnnUnitsQuant/UnitsQuant.onb b/DrModelica/AnnUnitsQuant/UnitsQuant.onb new file mode 100644 index 00000000000..78c7d0187b5 --- /dev/null +++ b/DrModelica/AnnUnitsQuant/UnitsQuant.onb @@ -0,0 +1,307 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Units and Quantities</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />What is the meaning of unit and quantity? <br />Well, <span style=" font-style:italic;">quantity</span>, also called <span style=" font-style:italic;">dimension</span>, is <span style=" font-style:italic;">what</span> you measure, i.e. any measurable extent or magnitude such as length, mass, time, etc. A <span style=" font-style:italic;">unit</span> is a "yardstick" by which you <span style=" font-style:italic;">express</span> your measurements. For example, a measurement of the length quantity can be expressed as a number of meter units.</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Quantity, Unit, and displayUnit in Modelica</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The Modelica notions of quantity and unit with a concrete representation as string attributes to the Real predefined class, are seen below. <br /></p></td></tr></table></body></html> + + + type Real + parameter String quantity = ""; + parameter String unit = ""; + parameter String displayUnit = ""; +end Real; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Below are examples of definitions and uses of types corresponding to some physical quantities. Remember that the <span style=" font-family:'Courier New';">final</span> prefix on <span style=" font-family:'Courier New';">quantity</span> and <span style=" font-family:'Courier New';">unit</span> means that these attributes cannot be changed by further modification of the types <span style=" font-family:'Courier New';">Force</span> and <span style=" font-family:'Courier New';">Angle</span>.<br /><br /><br />Definintion of quantity types:</p></td></tr></table></body></html> + + + type Force = Real(final quantity = "Force", final unit = "N"); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Angle = Real(final quantity = "Angle", final unit = "rad", + displayUnit = "deg"); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Use of the quantity types</p></td></tr></table></body></html> + + + class QuantityTypes + Force f1; + Force f2(displayUnit="kp"); + Angle alpha; + Angle beta(displayUnit="rad"); +end QuantityTypes; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />The quantity attribute can be used as a grouping mechanism in interactive Modelica environments. The quantity name is needed because it is in general not possible to determine just from the unit whether two different units belong to the same physical quantity. For example, consider the following two types:<br /></p></td></tr></table></body></html> + + + type Energy = Real(final quantity = "Energy", final unit = "J"); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Torque = Real(final quantity = "MomentOfForce", final unit = "N.m"); + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Modelica.SIunits</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />The Modelica standard library package Modelica.SIunits contains predefined quantity and connector types in the form shown in the above examples. This library contains approximately 450 predefined types comprising the complete set of ISO SI standard units, which is quite helpful when defining the interfaces of a model. Some additional examples from this library are shown below:<br /></p></td></tr></table></body></html> + + + type ElectricCurrent = Real(final quantity="ElectricCurrent", + final unit= "A"); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Current = ElectricCurrent; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Resistance = Real(final quantity="Resistance", + final unit="Ohm", min=0); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Inductance = Real(final quantity="Inductance", + final unit="H", min=0); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Time = Real(final quantity="Time", final unit="s" ); + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Length = Real(final quantity="Length", final unit="m" ); + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Position = Real(final quantity="Length", final unit="m"); + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type AngularVelocity = Real(final quantity="AngularVelocity", + final unit="rad/s", + displayUnit="rev/min"); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type AngularAcceleration = Real(final quantity="AngularAcceleration", + final unit="rad/s2"); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type MomentOfInertia = Real(final quantity="MomentOfInertia", + final unit="kg.m2"); + + + + + + diff --git a/DrModelica/ApplicationEx/3DDoublePendulum.onb b/DrModelica/ApplicationEx/3DDoublePendulum.onb new file mode 100644 index 00000000000..4ca8831cf47 --- /dev/null +++ b/DrModelica/ApplicationEx/3DDoublePendulum.onb @@ -0,0 +1,135 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">A 3D Double Pendulum</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In this section an idealized model of a double pendulum is considered. This pendulum consists of two boxes linked by a hinge. The upper box is lined by a hinge to a non-movable platform, i.e. an inertial system. Both the boxes can move in the XY plane. The corresponding kinematic outline consists of two revolute joints, one frame translation and one inertial system. <br /><br />The motion of dynamic system cannot be defined just by its kinematic outline, since an outline does not contain mass objects yet. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Body</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> represents mechanical objects with mass. This class has a connector </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">frame_a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> as well as the parameters </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">m</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (mass of the body), </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">rCM[3]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (position of center of mass with respect to frame a) and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">I[3, 3]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (inertia tensor with respect to the position of the center of the mass; it's defined by 6 numbers since it's symmetric).<br /></span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">See the Modelica Book, Section 15.10.6.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">A Double Pendulum Consisting of two Cylinders</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In this example the pendulum consists of two cylinders. The textual representation of Modelica model is following: </span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/1.png" width="1206" height="688" /></p></td></tr></table></body></html> + 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oijmL1hSm8UFSz484bLffWj7v730xMLe3ik/+aap6g9i1bKlY1+ZbhZtXDwAAIxXOUMfRMHpGRkZ/vNbbr3lvq84rWo7swAAoAO19LmItFf/gT3d3fNeu/jXNEnbmQUAAJ3JKSIAAADhFBEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACAkIgAAACERAQAACIkIAABASEQAAABCIgIAABASEQAAgJCIAAAAhEQEAAAgJCIAAAAhEQEAAAiJCAAAQEhEAAAAQiICAAAQEhEAAICQiAAAAIREBAAAICQiAAAAIREBAAAIiQgAAEBIRAAAAEIiAgAAEBIRAACAkIgAAACERAQAACD+F1YdIcpWMkblAAAAAElFTkSuQmCC + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + loadModel(Modelica) // If not loaded + true + + + model doublePendulumCylinders + import Modelica.Mechanics.MultiBody.Parts; + import Modelica.Mechanics.MultiBody.Joints; + import Modelica.Mechanics.MultiBody.Types; + parameter Real L1=0.3 "length of 1st arm"; + parameter Real L2=0.4 "length of 2nd arm"; + parameter Real D=0.1 "diameter"; + inner Modelica.Mechanics.MultiBody.World world; + Joints.Revolute revolute1(phi(fixed = true), w(fixed = true)); + Joints.Revolute revolute2(phi(fixed = true), w(fixed = true)); + Parts.BodyCylinder body1(r={L1,0,0},diameter=D); + Parts.BodyCylinder body2(r={L2,0,0},diameter=D,color={255,255,0}); +equation + connect(world.frame_b, revolute1.frame_a); + connect(revolute1.frame_b, body1.frame_a); + connect(revolute2.frame_b, body2.frame_a); + connect(body1.frame_b, revolute2.frame_a); +end doublePendulumCylinders; + {doublePendulumCylinders} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of DoublePendulum</span></p></td></tr></table></body></html> + + + simulate(doublePendulumCylinders, stopTime=1) + record SimulationResult + resultFile = "doublePendulumCylinders_res.mat", + messages = "" +end SimulationResult; + + + + + + + + plot({body2.a_0[1], body2.a_0[2], body2.a_0[3]}) + [done] + + + + + diff --git a/DrModelica/ApplicationEx/DesignOptimization.onb b/DrModelica/ApplicationEx/DesignOptimization.onb new file mode 100644 index 00000000000..9aff1756902 --- /dev/null +++ b/DrModelica/ApplicationEx/DesignOptimization.onb @@ -0,0 +1,460 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Design Optimization</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />An important use for modeling and simulation is to improve a system design, usually before it is physically realized and manufactured. In this process it is customary to perform a number of simulations for different values of the design parameters, until a design has been obtained that best fulfills a given set of design criteria. To automate this process it is very useful if the simulation environment has programmable scripting facilities that provide the glue between optimization algorithms, executing simulations and various computational functions.<br /><br />The following example demonstrates the solution of a small but non-trivial design optimization problem containing dynamic system simulations. First we define a Modelica model of a </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">linear actuator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with a spring damped stopping, as well as a first order system that will be used to generate a kind of &quot;reference&quot; response. The goal is to find a damping for the translational spring-damper that minimizes the deviation between the step response of the linear actuator system and the step response from our &quot;reference&quot; first order system. </span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">See Section 15.7 in the Modelica Book</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">LinearActuator Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In this example we use the MathModelica environment with Mathematica as the scripting language providing the built-in optimization function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FindMinimum</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. //??Change to OpenModelica</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/16.png" width="357" height="265" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A LinearActuator model containing a spring damped connection to an anchoring point.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Consider the following model of a linear actuator, depicted in Figure 1, with a spring-damped connection to an anchoring point:</span></p></td></tr></table></body></html> + + + model LinearActuator + import Modelica.Mechanics.Translational; + import Modelica.Mechanics.Rotational; + import Modelica.Blocks.Sources; + Translational.Components.Mass mass1(m=0.5); + Translational.Components.SpringDamper springDamper1(d=3, c=20, v_rel(fixed = true), s_rel(fixed = true)); + Translational.Components.Fixed fixed1; + Rotational.Components.IdealGearR2T idealGearR2T1(ratio = 1.0); + Rotational.Components.Inertia inertia1(J=0.1); + Rotational.Components.SpringDamper springDamper2(c=15, d=2, phi_rel(fixed = true), w_rel(fixed = true)); + Rotational.Components.Inertia inertia2(J=0.1); + Rotational.Sources.Torque torque1; + Sources.Step step1; +equation + connect(inertia1.flange_b, idealGearR2T1.flangeR); + connect(idealGearR2T1.flangeT, mass1.flange_a); + connect(mass1.flange_b, springDamper1.flange_a); + connect(springDamper1.flange_b, fixed1.flange); + connect(inertia1.flange_a, springDamper2.flange_b); + connect(springDamper2.flange_a, inertia2.flange_b); + connect(inertia2.flange_a, torque1.flange); + connect(torque1.tau, step1.y); +end LinearActuator; + {LinearActuator} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We first make a simulation of the step response for the above linear actuator with damping </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">d=2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and store the result in the scripting language variable called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">resLinActFirst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Then we plot the simulated position of the sliding mass as a function of time to take a closer look at the response.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of LinearActuator</span></p></td></tr></table></body></html> + + + loadModel(Modelica); // Load library if not already done + [done] + + + simulate( LinearActuator, stopTime=5 ) + record SimulationResult + resultFile = "LinearActuator_res.mat", + messages = "" +end SimulationResult; + + + + + + plot( mass1.s ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plot of step response from the linear actuator.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Different behavior with different values of d</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Assume that we have some freedom in choosing the damping in the translational spring-damper. A number of simulation runs show what kind of behavior we have for different values of the damping parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">d</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The Mathematica </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Table[]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> function is used to collect the results from calls to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Simulate[]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> into an array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">res</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The array then contains the results from simulations of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LinearActuator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with a damping of 2 and 14 in increments of 2, i.e. seven simulations are performed. </span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">//?? Currently needs Mathematica and needs to be transformed to OpenModelica scripting.<br /> </span></p></td></tr></table></body></html> + + + res = Table[Simulate[LinearActuator,{t,0,4}, + ParameterValues ->{springDamper1.d == s}], {s,2,15,2}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + PlotSimulation[slidingMass1.s[t], {t, 0, 4}, + SimulationResult -> res, Legend -> False] + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plots of step responses from seven simulations of the linear actuator with different camping coefficients.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now assume that we would like to choose the damping parameter d so that the resulting linear actuator system behaves as closely as possible to the following &quot;reference&quot; first order system response, obtained by solving a first order ODE using the Mathematica differential equation solver </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">NDSolve</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">:<br /></span></p></td></tr></table></body></html> + + + resReference = NDSolve[{0.2*y'[t]+y[t]== 0.05, y[0] == 0}, {y}, {t,0,4}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We make a plot to compare the step response we simulated first for a damping value d=2 and the response from the [OpenCurlyDoubleQuote]reference[CloseCurlyDoubleQuote] first order system.<br /></span></p></td></tr></table></body></html> + + + PlotSimulation[{slidingMass1.s[t], y[t] /. resReference, {t,0,4}, + SimulationResult -> resLinActFirst] + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Comparison plot between the step response of the linear actuator and the &quot;reference&quot; first</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-order system.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of an integral</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now, let us make things a little more automatic. Simulate and compute the integral of the square deviation from t = 0 to t = 4. This integral is a measure of the deviation from the &quot;reference&quot; response and is thus suitable as a goal function to be minimized.<br /></span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">//??Below needs Mathematica and needs to be transformed to OpenModelica scripting</span></p></td></tr></table></body></html> + + + Simulate[LinearActuator,{t,0,4}, + ParameterValues -> {springDamper1.d == 3}]; + + + + NIntegrate[First[(y[t] /. resReference) - slidingMass1.s[t]]^2, {t, 0, 4}] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We define a Mathematica function, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">f[a_]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, doing the same thing as above, but for different values of the spring-damper design parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">d</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The function contains two variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">res</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">t</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The expression </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">(y[t]/.resReference)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> retrieves the interpolating function representing the variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y[t]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, i.e. the reference response.<br /></span></p></td></tr></table></body></html> + + + f[a_] := Module[{res, t}, + res=Simulate[LinearActuator, {t, 0, 4},ParameterValues ->{springDamper1.d == a}]; + NIntegrate[First[(y[t]/.resReference)-slidingMass1.s[t]]2,{t,0,4}]]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We tabulate some results for </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">2 [LessEqual] d [LessEqual] 10</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> into an array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">resDeviations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">:</span></p></td></tr></table></body></html> + + + resDeviations = Table[{d, f[d]}, {d, 2, 10, 0.5}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The tabulated values are interpolated into a Mathematica interpolating function. The default interpolation order is 3.</span></p></td></tr></table></body></html> + + + fpre=Interpolation[resDeviations] + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A plot of the interpolationg function fpre:</span></p></td></tr></table></body></html> + + + Plot[fpre[d], {d, 2, 10}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plot of the deviation function for finding the value of the damping parameter that gives a minimum deviation from the reference response.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The minimizing value of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">d</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be computed using </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FindMinimum</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + FindMinimum[fpre[d], {d, 4}] + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A simulation with the optimal parameter value:</span></p></td></tr></table></body></html> + + + Simulate[LinearActuator, {t, 0, 4}, + ParameterValues -> {springDamper1.d == 5.28642}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A plot comparing the [OpenCurlyDoubleQuote]reference[CloseCurlyDoubleQuote] first order system and linear actuator system responses together with a plot of the squared deviation amplified by a factor 100.<br /></span></p></td></tr></table></body></html> + + + PlotSimulation[{slidingMass1.s[t], + y[t] /. resReference, + 100*(slidingMass1.s[t] - (y[t] /. resReference))^2}, + {t, 0, 4}, Legend -> False]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Comparison plot of the first and second order system step responses together with the squared error.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/ApplicationEx/FourierAnalysis.onb b/DrModelica/ApplicationEx/FourierAnalysis.onb new file mode 100644 index 00000000000..bfddfad7a9c --- /dev/null +++ b/DrModelica/ApplicationEx/FourierAnalysis.onb @@ -0,0 +1,331 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Frequency Analysis of Simulation Data</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Fourier Analysis</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">The Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Consider a weak axis excited by a torque pulse train. The axis is modeled by three segments joined by two torsion springs. The following diagram is imported from the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">MathModelica</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Lite</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Graphic Editor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> where the model was defined. (See Section 15.8 in the Modelica Book).</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/17.png" width="516" height="69" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAIEAAAARQgDAAAAAkcORAAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAABgYGFBQUIyMjKysrNDM0PTw9RkVGTU1NUE9QW1lbZmRmaGhoa21rdnR2fHx8fXt9AAD/jIyMkI6QmJaYnZqdn5yfpaOlp6enq6irsK2wsrKytbK1uba5vb29wb7BxsPGx8fH0NDQ4eHh6enp////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKVD08QAAAAlwSFlzAAALEwAACxMBAJqcGAAABNFJREFUeJztmweX2yAMx9Wdjuu+ruvIDX3/r9hc8GAIkABjJ9H/vbu+YFtI4gfCNAeounjB2g6o1pdCoFIIVAqBChUCFSoEKlQIVKgQqFAhUKFCoEKFQIUEBJ/4WsNf1QLyIZCMrFJwJiIh2POeVQjORBQEe4XgskRDwKNAITgTERDsFYILk64EqlU2hjCp0MD2BKTW9oqr7hA4uRk+nFC+Qj26Dk8onUxQnSEIR/vQUjxp6PnXOfdHCJ5RAjyRE9kkBGFenQYxBPT4lI3cZnJ/7O4VpTOBILgLgnsr+hpaKyB4SWkNCN5SUgjCnpIMiClon3uIfkg9dHQdvlACLK90NT7ZrrFqZTcIYhGUQWAeiOW+KPVguwiyjMNPSvWrQKlPZrvNrpXLQeD+N2PC//LtHHynVJh7acKd+fWHUv12FezEiSFg18pFIZg5yLg/LKqMXIEw96n+3Cb0woTorab96iB4bwR7SuPV97wCxfcpmykDAbtWVkGQ/E6B/a0DVgaQkyuwUp/JPcR7PlpxW6zfzofZSlBeDzaujSKOXI+XYy+z9lgaqoQ+0dEliiW5T6lbCRKxGRkMeMsYJHNl5R5+D4rkfrwa2xtRg0AlPDJaSFz9Ryn1eMyQfTPpWt7gZJhdKytXgoQP8q8fcUJrk3v7ijOtwjnGSjj8oiTf6zpI5nwi3HJDZ+9TFt4TJO+oVovcB7uvktdL+Eqp4u2A6ZMPQr5YkvuUJSFIXm4h+EapKwRmQsFHSrytbswprk/u3L7KFMv5KvaAYFGZ5KZyLzIW+8B6+vHnNSXeS0FLn/LFsnM5WFjL5L7UkeeUOjsSOMaulZ0guOffytQxwy8orQHBU0prQ8CulZ0gaJ+LzeTebN5J9XVk9ihRLMl9Sh8IHru92QHcsA6EeCYxegzQqgu+I6VXl5IB8w0hMjldV4IH3qmgwGLZ1abajCN+r2SxbAfB8EVUGQT3Pz6/O0sI0urniO3T8Re7VhIQHF4mR01vl0HLIwcyCHZ3D3cHCB7wtg0E20v9diTcpyRXgpgMAxIIPhz2BLD7C3i7291d+hAtL+EySULAlP7dwValEKik+xSFQBVCINEqHquaSzdpNYplz2o/hVcV+izZKRzhLaKw2C9tfKuc3DOsBF6JI82fxAvPRRg+LUBVPAz6lNC40aKTCqvUnW4bw5gbZJlP09n1ODYD8OBMJGFg+a19awqSEJgOx+CmQMVOmPunNE3mhl7EVq0cT+YGg+MgMCGYQhu+6WqZBYZPgE6S0P5njpsdF+2ThZmYKlm3bqN1tARzUBOERRC4afIYk1mFiAkrR/xyQFni+mQlyeV6Ni+vnb5Pfp6kpwBhu19RklXNWwmgKC608klCILfqrCLgQhA7Gs1awjoInAY3TqF8n4STJTmijte8R7z4wL/OVXYlEFp180PY5BgbnWoDgV3h/DVcFFgWgpy1cSYAzgU4s09JQ2A/jVi2wk33W1PUSVDNSoDzSgBox8kw5gblZbow0lpRPnmY5agKgnHmy5j/4JFVtFrHvihHytbxdqrxyYIguk/hrAQ9tGkI1j7iqfHJXQnQhsAvdsnuVCes/D6F93aguiwpBCqFQKUQqFAhUKFCoEKFQIUKgQoVAhUqBCpUCFSoEKgO+g91PLsd3+bCtwAAAABJRU5ErkJggg== + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Diagram: WeakAxis</span></p> +<p align="center" style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + True + Center + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The corresponding Modelica code ...</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + loadModel(Modelica); // Load Modelica library if not already done + [done] + + + model WeakAxis + import Modelica.Mechanics.Rotational; + import Modelica.Blocks.Sources; + Rotational.Sources.Torque torque1; + Rotational.Components.Inertia inertia1(J = 1.0, phi(fixed = true), w(fixed = true)); + Rotational.Components.Spring spring1(c=0.7); + Rotational.Components.Inertia inertia2(J = 1.0, phi(fixed = true), w(fixed = true)); + Rotational.Components.Spring spring2(c=1); + Rotational.Components.Inertia inertia3(J = 1.0, phi(fixed = true), w(fixed = true)); + Sources.Pulse pulse1(width=1,period=200); +equation + connect(pulse1.y, torque1.tau); + connect(torque1.flange, inertia1.flange_a); + connect(inertia1.flange_b,spring1.flange_a); + connect(spring1.flange_b, inertia2.flange_a); + connect(inertia2.flange_b,spring2.flange_a); + connect(spring2.flange_b, inertia3.flange_a); +end WeakAxis; + {WeakAxis} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of WeakAxis</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the model in 100 seconds ...</span></p></td></tr></table></body></html> + + + simulate( WeakAxis, stopTime=200 ) + record SimulationResult + resultFile = "WeakAxis_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">... and plot the angular velocity of the rightmost axis-segment.</span></p></td></tr></table></body></html> + + + + + + + plot( { inertia3.w, torque1.tau } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Now, lets sample Inertia3.w using a sample frequency 4Hz ...<br /></span></p></td></tr></table></body></html> + + + data1=Table[Inertia3.w[t],{t,0,200,.25}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />... remove the mean ...<br /></span></p></td></tr></table></body></html> + + + mean=Apply[Plus, data1]/Length[data1]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span></p></td></tr></table></body></html> + + + data2=data1-mean; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Compute the absolute values of the discrete Fourier transform ...<br /></span></p></td></tr></table></body></html> + + + fdata1=Abs[Fourier[data2]]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />... and plot the 80 first points of data.<br /></span></p></td></tr></table></body></html> + + + ListPlot[fdata1[[Range[80]]],PlotRange->All,PlotStyle->{Red,PointSize[0.015]}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/18.png" width="398" height="245" /></p></td></tr></table></body></html> + + + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The peaks<br /></span></p></td></tr></table></body></html> + + + {fdata1[[30]],fdata1[[52]]} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is easy to write a function that repeat the above operations. FourierPlot also scales the axes such that amplitude of trigonometric components are plotted against frequency (Hz).<br /></span></p></td></tr></table></body></html> + + + FourierPlot[Inertia3.w[t],{t,0,200},0.5,PlotRange->All,PlotJoined->True,PlotStyle->Red] + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/19.png" width="381" height="235" /></p></td></tr></table></body></html> + + + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />It can be shown that the frequencies of the eigenmodes of the system is given by the imaginary parts of the eigenvalues of the following matrix (c</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000; vertical-align:sub;">1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">and c</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000; vertical-align:sub;">2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">are the spring constants) ...<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/20.png" width="485" height="93" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">... which fits very well with the peaks in the diagram above.</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/ApplicationEx/FrequencyAnalysisEvaluated.onb b/DrModelica/ApplicationEx/FrequencyAnalysisEvaluated.onb new file mode 100644 index 00000000000..34e545d1174 --- /dev/null +++ b/DrModelica/ApplicationEx/FrequencyAnalysisEvaluated.onb @@ -0,0 +1,437 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Frequency Analysis of Simulation Data</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Fourier Analysis</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">ModelDiagramCode</span></p></td></tr></table></body></html> + + + Model[WeakAxis, + Modelica.Mechanics.Rotational.Torque Torque1; + Modelica.Mechanics.Rotational.Inertia Inertia1; + Modelica.Mechanics.Rotational.Spring Spring1[{c == 0.7`}]; + Modelica.Mechanics.Rotational.Inertia Inertia2; + Modelica.Mechanics.Rotational.Spring Spring2[{c == 1}]; + Modelica.Mechanics.Rotational.Inertia Inertia3; + Modelica.Blocks.Sources.Pulse Pulse1[{width == {1}, period == {100}}]; + Equation[ + Connect[Pulse1.outPort, Torque1.inPort]; + Connect[Torque1.flange_b, Inertia1.flange_a]; + Connect[Inertia1.flange_b, Spring1.flange_a]; + Connect[Spring1.flange_b, Inertia2.flange_a]; + Connect[Inertia2.flange_b, Spring2.flange_a]; + Connect[Spring2.flange_b, Inertia3.flange_a]; + ] + ] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">The Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Consider a weak axis excited by a torque pulse train. The axis is modeled by three segments joined by two torsion springs. The following diagram is imported from the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">MathModelica</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Model Editor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> where the model was defined.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/2.png" width="516" height="69" /></p></td></tr></table></body></html> + Center + WeakAxis + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Diagram: WeakAxis</span></p> +<p align="center" style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + True + Center + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The corresponding Modelica code ...</span></p></td></tr></table></body></html> + + + loadModel(Modelica); + [done] + + + model WeakAxis + Modelica.Mechanics.Rotational.Sources.Torque Torque1; + Modelica.Mechanics.Rotational.Components.Inertia Inertia1; + Modelica.Mechanics.Rotational.Components.Spring Spring1(c=0.7); + Modelica.Mechanics.Rotational.Components.Inertia Inertia2; + Modelica.Mechanics.Rotational.Components.Spring Spring2(c=1); + Modelica.Mechanics.Rotational.Components.Inertia Inertia3; + Modelica.Blocks.Sources.Pulse Pulse1(width= 1,period= 200); +equation + connect(Pulse1.y, Torque1.tau); + connect(Torque1.flange, Inertia1.flange_a); + connect(Inertia1.flange_b, Spring1.flange_a); + connect(Spring1.flange_b, Inertia2.flange_a); + connect(Inertia2.flange_b, Spring2.flange_a); + connect(Spring2.flange_b, Inertia3.flange_a); +end WeakAxis; + + {WeakAxis} + + + simulate(WeakAxis, stopTime=200) + record SimulationResult + messages = "", + simulationTime = 0.21992237179926655 +end SimulationResult; + + + + + + + plot({Inertia3.w, Torque1.tau}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the model in 100 seconds ...</span></p></td></tr></table></body></html> + + + Simulation[WeakAxis,{t,0,200}]; + +OMC-ERROR: +"Error: Variable Simulation[WeakAxis,{t,0,200}] not found in scope <global scope> +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">... and plot the angular velocity of the rightmost axis-segment.</span></p></td></tr></table></body></html> + + + PlotSimulation[{Inertia3.w[t],Torque1.[Tau][t]},{t,0,200}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now, lets sample Inertia3.w using a sample frequency 4Hz ...</span></p></td></tr></table></body></html> + + + data1=Table[Inertia3.w[t],{t,0,200,.25}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">... remove the mean ...</span></p></td></tr></table></body></html> + + + mean=Apply[Plus, data1]/Length[data1]; + + + + data2=data1-mean; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Compute the absolute values of the discrete Fourier transform ...</span></p></td></tr></table></body></html> + + + fdata1=Abs[Fourier[data2]]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">... and plot the 80 first points of data.</span></p></td></tr></table></body></html> + + + ListPlot[fdata1[[Range[80]]],PlotRange->All,PlotStyle->{Red,PointSize[0.015]}]; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The peaks</span></p></td></tr></table></body></html> + + + {fdata1[[30]],fdata1[[52]]} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is easy to write a function that repeat the above operations. FourierPlot also scales the axes such that amplitude of trigonometric components are plotted against frequency (Hz).</span></p></td></tr></table></body></html> + + + FourierPlot[Inertia3.w[t],{t,0,200},0.5,PlotRange->All,PlotJoined->True,PlotStyle->Red] + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It can be shown that the frequencies of the eigenmodes of the system is given by the imaginary parts of the eigenvalues of the following matrix (c</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000; vertical-align:sub;">1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">and c</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000; vertical-align:sub;">2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">are the spring constants) ...</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/3.png" width="485" height="93" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">... which fits very well with the peaks in the diagram above.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Initialization</span></p></td></tr></table></body></html> + True + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Load MathModelica</span></p></td></tr></table></body></html> + True + + + Needs["MathModelica`"] + + + True + True + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Load color and graphics package</span></p></td></tr></table></body></html> + True + + + Needs["Graphics`Colors`"] + + + True + + + Needs["Graphics`Graphics`"] + + + True + + + FourierPlot[signal_,{t_,tmin_,tmax_ +} +,T_,options___ +] +:=Module[{data1,n,mean,data2,fdata1,fdata2,f +} +,[IndentingNewLine]data1=Table[signal,{t,tmin,tmax,T +} + +] + +;[IndentingNewLine]n=Length[data1] + +;[IndentingNewLine]mean=Apply[Plus, data1 +] +/n + +;[IndentingNewLine]data2=data1-mean + +;[IndentingNewLine]fdata1=2/n + + Abs[Fourier[data2] +] + + +;[IndentingNewLine]fdata2=Drop[fdata1,-Round[n/2. +] + + +] + +;[IndentingNewLine]f=Range[0,1/(2*T +) + +,(1/(2 T +) + +-0 +) +/Round[n/2. +] + + +] + +;[IndentingNewLine]ListPlot[Transpose[{f,fdata2 +} +] +,options +] +; +[IndentingNewLine] +] + + + + True + + + FourierPlot[Sin[2[Pi] t +] ++5Sin[2 [Pi] 1.55t +] + + +,{t,0,200 +} +,0.25,PlotRange[Rule]All +,PlotJoined[Rule]True + +] + + + + + + + diff --git a/DrModelica/ApplicationEx/InterfacingtoNonMechModComp.onb b/DrModelica/ApplicationEx/InterfacingtoNonMechModComp.onb new file mode 100644 index 00000000000..55133962385 --- /dev/null +++ b/DrModelica/ApplicationEx/InterfacingtoNonMechModComp.onb @@ -0,0 +1,186 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Interfacing to Non-Mechanical Model Components</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">??Should be updated to new MultiBody library</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />When a multidomain model in Modelica is designed, the mechanical part of the model physically interacts with some other parts of the model. The mechanical part should usually be connected with the part describing the drive train, which is in turn connected to the part describing the energy source, e.g. electrical circuit. There are standard Modelica libraries for all these components. <br /><br />However, sometimes the attention is focused on an isolated mechanical part of the model. In this case the reference positions as well as forces and torques acting on the model can be specified directly. <br /><br />There exist three major ways to set up an interface between the mechanical part of Modelica model and other parts. These ways correspond to three connector types: <span style=" font-family:Courier New;">Multiboby.Interfaces.Frame, Rotational.Interfaces.Flange</span> and <span style=" font-family:Courier New;">Translational.Interfaces.Flange</span>. </p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Using Multibody.Interfaces.Frame</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Any object with connector of type <span style=" font-family:Courier New;">Frame_a</span> or <span style=" font-family:Courier New;">Frame_b</span> can be connected to a model of external force or torque. This external force (or torque) will be applied to the corresponding point on the relevant body. The example below includes a force acting on the end of the pendulum in direction of the local Y-axis (perpendicular to the pendulum bar). When force is attached to the pendulum it does not oscillate; it rotates instead.<br /></p></body></html> + + + class ExtForcePendulum + import ModelicaAdditions.MultiBody.Parts; + import ModelicaAdditions.MultiBody.Joints; + import ModelicaAdditions.MultiBody.Forces; + import Modelica.Blocks.Sources; + Parts.InertialSystem inertialSystem1; + Joints.Revolute revolute1; + Parts.CylinderBody cylinderBody1(r = {1, 0, 0}); + Forces.ExtForce extForce1; + Sources.Constant constant1(k = {0, 1190, 0}); +equation + connect(inertialSystem1.frame_b, revolute1.frame_a); + connect(revolute1.frame_b, cylinderBody1.frame_a); + connect(cylinderBody1.frame_b, extForce1.frame_b); + connect(constant1.outPort, extForce1.inPort); +end ExtForcePendulum; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Sometimes it is necessary to specify external force in global coordinates. One connect statement should be replaced by equation (see below). The input signal <span style=" font-family:Courier New;">ExtForce</span> object is adjusted according to the orientation matrix <span style=" font-family:Courier New;">S</span> of the <span style=" font-family:Courier New;">ExtForce</span> frame. When such constant force (in direction of vector {1,1,0} in the global coordinate system) is applied to the pendulum, it oscillates near the equilibrium point.<br /></p></body></html> + + + class ExtGlobalForcePendulum + import ModelicaAdditions.MultiBody.Parts; + import ModelicaAdditions.MultiBody.Joints; + import ModelicaAdditions.MultiBody.Forces; + import Modelica.Blocks.Sources; + Parts.InertialSystem inertialSystem1; + Joints.Revolute revolute1; + Parts.CylinderBody cylinderBody1(r = {1, 0, 0}); + Forces.ExtForce extForce1; + Sources.Constant constant1(k = {5000, 5000, 0}); +equation + connect(inertialSystem1.frame_b, revolute1.frame_a); + connect(revolute1.frame_b, cylinderBody1.frame_a); + connect(cylinderBody1.frame_b, extForce1.frame_b); + transpose(extForce1.frame_b.S) * constant1.outPort.signal = extForce.inPort.signal; +end ExtGlobalForcePendulum; + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Using Rotational.Interfaces.Flange</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The <span style=" font-family:Courier New;">Rotational</span> library describes varius elements for one-dimensional rotational motion. These elements can be attached to the Revolute joint from <span style=" font-family:Courier New;">MultiBody</span> library. A torque, spring, damper or any other component can be attached to the flanges of the revolute joint. The example below illustrates a one-dimensional spring and damper (from <span style=" font-family:Courier New;">Rotational</span> library) attached to the revolute joint of a simple pendulum.<br /></p></body></html> + + + class PendulumWithDamper + import ModelicaAdditions.MultiBody.Parts; + import ModelicaAdditions.MultiBody.Joints; + import ModelicaAdditions.MultiBody.Forces; + import Modelica.Blocks.Sources; + import Modelica.Mechanics.Rotational; + Parts.InertialSystem inertialSystem1; + Parts.CylinderBody cylinderBody1(r = {1, 0, 0}); + Joints.Revolute revolute1; + Rotational.SpringDamper springDamper1(c = 500, phi_rel0 = 1, d = 500); +equation + connect(inertialSystem1.frame_b, revolute1.frame_a); + connect(springDamper1.flange_a, revolute1.bearing); + connect(springDamper1.flange_b, revolute1.axis); + connect(revolute1.frame_b, cylinderBody1.frame_a); +end PendulumWithDamper; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Often it is necessary to move the joint to the desired position. This can be done by <span style=" font-family:Courier New;">Rotational.Position</span> component. The angle is given by a signal that come from a <span style=" font-family:Courier New;">Block</span> library element.The example below illustrates a <span style=" font-family:Courier New;">Step</span> block attached to such component.<br /></p></body></html> + + + class PendulumWithPosition + import ModelicaAdditions.MultiBody.Parts; + import ModelicaAdditions.MultiBody.Joints; + import Modelica.Blocks.Sources; + import Modelica.Mechanics.Rotational; + Parts.InertialSystem inertialSystem1; + Parts.CylinderBody cylinderBody1(r = {1, 0, 0}); + Joints.Revolute revolute1; + Sources.Step step1(startTime = {0.5}); + Rotational.Position position1(f_crit = 5); +equation + connect(revolute1.frame_b, cylinderBody1.frame_a); + connect(springDamper1.flange_a, revolute1.bearing); + connect(springDamper1.flange_b, revolute1.axis); + connect(revolute1.frame_b, cylinderBody1.frame_a); +end PendulumWithPosition; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />In class Position the reference angle is filtered and the second derivative of the filtered curve is used to compute the reference acceleration of the flange. Angular position of the joint is computed from this acceleration. For filtering, a second order Bessel filter is used. The critical frequency (also called cut-off frequency) of the filter is defined via parameter <span style=" font-family:Courier New;">f_crit</span> in [Hz]. This value should be selected in such a way that it is higher as the essential low frequencies in the signal.<br /><br />Another way to steer a joint is to set up a <span style=" font-style:italic;">Proportional Derivative (PD) controller</span>. Instead of computing angular position, the PD controller creates an active torque, which acts on the joint. It behaves like a motor; parameters <span style=" font-family:Courier New;">k</span> and <span style=" font-family:Courier New;">d</span> can be tuned in order to adjust the reaction speed and power.<br /></p></body></html> + + + class SimpleRotationalController + "Input signal acting as reference value for angle, + gives external torque on a flange" + import Modelica.Blocks; + import Modelica.Mechanics.Rotational; + parameter Real k = 1; + parameter Real d = 1; + Blocks.Interfaces.InPort inPort(final n = 1); + Rotational.Interfaces.Flange_b flange_b; +equation + flange_b.tau = k * (flange_b.phi - inPort.signal[1]) + + d * der(flange_b.phi); +end SimpleRotationalController; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class PendulumWithSteering + import ModelicaAdditions.MultiBody.Parts; + import ModelicaAdditions.MultiBody.Joints; + import Modelica.Blocks.Sources; + Parts.InertialSystem inertialSystem1; + Parts.CylinderBody cylinderBody1(r = {1, 0, 0}); + Joints.Revolute revolute1; + Sources.Step step1(startTime = {0.5}); + SimpleRotationalController ctrl(k = 5000, d = 500); +equation + connect(revolute1.frame_b, cylinderBody1.frame_a); + connect(step1.outPort, ctrl.inPort); + connect(ctrl.flange_b, revolute1.axis); + connect(inertialSystem1.frame_b, revolute1.frame_a); +end PendulumWithSteering; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />The Translational library describes various elements for one-dimensional translational motion. These elements can be attached to the <span style=" font-family:Courier New;">Prismatic</span> joint from <span style=" font-family:Courier New;">MultiBody</span> library.A force, spring, damper or any other component can be attached to the flanges of the prismatic joint. Below a <span style=" font-family:Courier New;">Position</span> component is attached to prismatic joint, and steers the position of the first body according to the signal from the <span style=" font-family:Courier New;">Step</span> block. In addition a free flying body is attached to the first body. It is connected by a 3D spring and damper to the first one. The example demonstrates how <span style=" font-family:Courier New;">FreeMotion</span> class is used.<br /></p></body></html> + + + class PrismaticPosition + import ModelicaAdditions.MultiBody.Parts; + import ModelicaAdditions.MultiBody.Joints; + import ModelicaAdditions.MultiBody.Forces; + import Modelica.Blocks.Sources; + import Modelica.Mechanics.Translational; + Parts.InertialSystem inertialSystem1; + Parts.CylinderBody cylinderBody1; + Joints.Prismatic prismatic1; + Forces.SpringDamperPar springDamperPar1(c = 10000, s0 = 0.3, d = 500); + Joints.FreeMotion freeMotion1; + Parts.CylinderBody cylinderBody2; + Translational.Position position1; + Sources.Step step1(startTime = {0.5}); +equation + connect(prismatic1.frame_b, cylinderBody1.frame_a); + connect(prismatic1.frame_a, inertialSystem1.frame_b); + connect(springDamperPar1.frame_a, cylinderBody1.frame_b); + connect(cylinderBody1.frame_b, freeMotion1.frame_a); + connect(freeMotion1.frame_b, cylinderBody2.frame_a); + connect(springDamperPar1.frame_b, cylinderBody2.frame_a); + connect(position1.flange_b, prismatic1.axis); + connect(step1.outPort, position1.inPort); +end PrismaticPosition; + + + + + + diff --git a/DrModelica/ApplicationEx/KinematicLoops.onb b/DrModelica/ApplicationEx/KinematicLoops.onb new file mode 100644 index 00000000000..2b78e4f8ddc --- /dev/null +++ b/DrModelica/ApplicationEx/KinematicLoops.onb @@ -0,0 +1,157 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Kinematic Loops</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">??Should be updated to new MultiBody library</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The chain consisting of joints and coordinate transforms may form a loop, also called closed </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">kinematic loop</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. In order to handle such loops correctly, special joints from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CutJoints</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> library are used. In order to make possible for the user to specify valid initial state for such mechanical system, a hint can be given to the translator, and a joint with state variable is selected. The parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">startValueFixed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is set to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for this purpose. The example below shows a system with a single closed kinematic loop. The upper bar (a cylinder with small radius) is fixed; three other bars are connected by revolute joints. The whole system behaves like a pendulum.<br /><br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/14.png" width="304" height="209" /></p></td></tr></table></body></html> + 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 + + + class RevoluteLoop2D + import ModelicaAdditions.MultiBody.Parts; + import ModelicaAdditions.MultiBody.Joints; + import ModelicaAdditions.MultiBody.CutJoints; + Parts.InertialSystem InertialSystem1; + Parts.CylinderBody cylinderBody1(r = {1, 0, 0}, Radius = 0.02, + Material = {0.5, 0.5, 0, 0}); + Joints.Revolute revolute1(startValueFixed = true, q(start = -1.0)); + Parts.CylinderBody cylinderBody2(r = {0, -1, 0}); + Joints.Revolute revolute2; + Parts.CylinderBody cylinderBody3(r = {-1, 0, 0}, Material = {0,1, 0, 0.5}); + Joints.Revolute revolute3; + Parts.CylinderBody cylinderBody4(r = {0, 1, 0}); + CutJoints.Revolute2Dloop revolute2Dloop1; +equation + connect(InertialSystem1.frame_b, cylinderBody1.frame_a); + connect(cylinderBody1.frame_b, revolute1.frame_a); + connect(revolute1.frame_b, cylinderBody2.frame_a); + connect(InertialSystem1.frame_b, revolute3.frame_a); + connect(revolute3.frame_b, cylinderBody4.frame_a); + connect(cylinderBody2.frame_b, revolute2.frame_a); + connect(cylinderBody3.frame_a, revolute2.frame_b); + connect(revolute2Dloop1.frame_b, cylinderBody3.frame_b); + connect(cylinderBody4.frame_b, revolute2Dloop1.frame_a); +end RevoluteLoop2D; + + {RevoluteLoop2D} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of RevoluteLoop2D</span></p></td></tr></table></body></html> + + + loadModel(Modelica, {"2.2"}); + [done] + + + setCommandLineOptions("+std=2.x"); + [done] + + + loadModel(ModelicaAdditions); + [done] + + + setCommandLineOptions("+std=2.x"); + + [done] + + + simulate( RevoluteLoop2D, stopTime=10 ) + record SimulationResult + messages = "Simulation failed for model: RevoluteLoop2D +[C:/OpenModelica1.9.0/lib/omlibrary/ModelicaAdditions/MultiBody/CutJoints.mo:332:7-332:76:writable] Error: The language feature constrain function is not supported. Suggested workaround: rewrite code without using constrainequation + constrain(revolute2Dloop1.constraintResidue[1],revolute2Dloop1.constraintResidue_d[1],revolute2Dloop1.constraintResidue_dd[1]); + +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + plot( cylinderBody3.body.frame_a.r0[2] ) + false + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/15.png" width="288" height="214" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAEgAAAA1ggDAAAARuGvAgAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAAAAD/2dnZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqOCPfgAAAAlwSFlzAAALEwAACxMBAJqcGAAABX5JREFUeJzt3YmSmzAQBFDB/390ylmMQce0hK4eMV2bDRnLMvMiTDkma7dbxLjZO8AeAwIxIBADAjEgEAMCMSAQAwIxIBADAjEgEAMCMSAQAwIxIBADAjEgEAMCMSAQAwIxIJBCIOfCuznnDXGJW3+bwV1SjzM/pTsSG++CP7rYre6+Lc1Kw5O3K58l8ffrO/7/1rFS/n47vh03fMfc73sFSo/x55mcxD5sR35DDpzLIeauXwfT7tcvX9cHS4/Zbw85Pxk7cZpIQJehkbadT5Aac3tILUDn8XDZ/B5w5+Jx56bzD5/f0jq/gzEKDrGqkc/uy6ARSfZu1fx15tyXYrlEQrpbPDEgEAMCMSAQAwIxIBADAjEgEAMCMSAQAwIxIBADAjEgEAMCMSAQDPRyQgMCMSAQAwLB7f+9e1hVjc9LW70lYwXVA42sbtGuS6a9ZwBQYpdpq/c8BGJohAYoNssWPX7LqvMpyIFYie/JAIodYxxA2dWSCbxoWEHbPrLqpT/Q2PZIgBgaMaBJVS9Zr8WCWbbzW151dtN9gSJLqBRIE6aXMStIE6YX3UA9ML34QNdLBc+LTwnaq6pue7JaChS/nFtZ01VVP79Lu53zL/Y+L4/W3nQToPOP3tXwHyftTXcGWpXiEdDlvwsIhxhDI7OA4iO8WRgaUQBUUmWkoALSw+Yn67VYLyBGTD9TVxAjmx/lQO0x/bwBaNuF6ruARIqsahCtQPUU7YCGncV6Na1wBTFQDAdiaI8EiKERA5pUDWJAHc5iDI0wAQ3bOYZqEAMyIANqWQ1iQE3OYvdZGBphAgpm2YKNNjvHUA3SHkg3WxDh6o7rjxarBtLCFiTrreduQHxsQYSrO/ZZQDMxg0jXB+3H+/T+izEmoNZsQTKACneOt5oxNIxwdccqQFtk6zlQYgRb048oMqphlALVUywD1IuiIVDytZhqCuoVxEABnpvPdAbiopgKxNX0VCCu9kiArvNxtUcA5C8htMnQNMkKWoNNzjAgXjY5k4EYMOUoAurFJkc9UD2bnA5nMd5NW0H5m7k+LwDCR5uYlYCePl+L0QlUf+paBqgtRR+gQWexERRKVtA8iolAbE13A7r/7I7fCIZGGIBSV3dcZmRrbxRQ5OqO20d/RoHWYBOTsYK80xgG0sYmpu4QW4NNjHR1x9NDTBubmNzT/FigsWxiNAH1YhOjH6ieTUzuazGGpnuxiVl1BYFqts/6QHeKlwDlNP0SoNYUioHGUHQBan0Wm0lBtoL4KKYB8TU9DYivPRKg75x87VEDrcEmJfssVgKkjU1KlxWkjU3KdCAGNimkQGPZpKgC6sUmZQGgB2z5PiPPYlOqPkW8KmSdFZRH8QqgGopqoOgns1wnVU5RC5R+61ld062BIp/MUgvESNFyBX0Psfs/KSqnaAq0Xy9eoGhkPlD8k1kuczO2NxRIGBEFWoNNSB8gbWxCRgLxYgrJfy02FmgsmxDWFTSWTcgKQPWYQhYHCiXi1XSWAcqlWAqorulhQCPOYuMoiFbQ7KanAM1uxIAmVdMxIBADAik8i81uhBKo984xVNMxIJACoM+8sxtRCFRSZaCgBuLFTKfgLDYWaCxmOrQrqLAa67mkmgwzUG3T5EAj26MBmt9Id6DgrWZpsD9ii059rbpoNTHD7zVMRiOuYOzuCsbeCZxzziVv9eO8bJtfmVCNFRtUXQKkaAW9Ic5fUjn3eFXuR5gBoRgQyMvbx2kL5IqmKxntygaXjZTGNwXyzwBodNHgPrvh0PjGh1hZy/mjixZQydIcDFTWRUHXZZq0K6h0sj49MwOVHgkFT6ZdDrFjFQ97kl4xBgRiQCAGBGJAIAYEYkAgBgRiQCAGBGJAIAYEYkAgBgTyD9VS0A6V2ywDAAAAAElFTkSuQmCC + + + plot( cylinderBody3.body.frame_a.r0[1] ) + false + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/16.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + + + diff --git a/DrModelica/ApplicationEx/Mechatronic.onb b/DrModelica/ApplicationEx/Mechatronic.onb new file mode 100644 index 00000000000..0c13b993c36 --- /dev/null +++ b/DrModelica/ApplicationEx/Mechatronic.onb @@ -0,0 +1,695 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Mechatronic Systems - A DC Motor</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The term </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">mechatronic</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is commonly used for systems consisting of both mechanical and electrical parts, i.e. a special kind of multi-domain system. An electric motor is a common example of such a system, and a DC-motor (DC = Direct Current) is the simplest kind of electrical motor. <br />Modeling a DC-motor illustrates the ease of constructing multi-domain models in Modelica simply by connecting components from different domains. This particular model contains components from three domains: mechanical components such as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">inertia1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, the electrical components </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">resistor1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">inductor1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">signalVoltage1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ground1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> as well as pure signal components such as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">step1.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/15.png" width="526" height="207" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A multi-domain DCMotorCircuit model with mechanical, electrical andsignal-block components.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">IMPORTANT: To simulate the DCMotorCircuit model, you first need to select all group cells containing all needed models below, and push shift-return.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">DCMotorCircuit Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DCMotorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class is declared below. What is different from previous examples is that certain connections couple components from different domains, e.g. the signal block </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">step1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is connected to the electrical component </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">signalVoltage1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the electrical component </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">emf1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is connected to the mechanical component </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">inertia1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model DCMotorCircuit + Resistor resistor1(R = 10); + Inductor inductor1(L = 0.2, i(fixed = true)); + Ground ground1; + Inertia inertia1(J = 1, w(fixed = true)); + EMF emf1(rotFlange_b(phi(fixed = true))); + Step step1; + SignalVoltage signalVoltage1; +equation + connect(step1.outPort, signalVoltage1.inPort); + connect(signalVoltage1.p, resistor1.p); + connect(resistor1.n, inductor1.p); + connect(inductor1.n, emf1.p); + connect(emf1.rotFlange_b, inertia1.rotFlange_a); + connect(signalVoltage1.n, ground1.p); + connect(ground1.p, emf1.n); +end DCMotorCircuit; + {DCMotorCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />To avoid confusion with the translational </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Flange_a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> connector class we have renamed the rotational flange connector class to be called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">RotFlange_a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in this example, even though it is called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Flange_a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Mechanics.Rotational.Interfaces</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> library. Connectors have the same names as their classes apart from the first letter being lower-case, and a number being appended at the end.<br /><br />In the following we present the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DCMotorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model including its parts and used classes in roughly a top-down manner, with the most interesting parts first. This gives the best overview and is also fine from a Modelica language point of view since classes can be used before they are defined.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">DC MotorCircuit Component Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DCMotorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model contains instances of mechanical, electrical and signal classes, which are declared below.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Mechanical Component Classes: Inertia, Rigid</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Inertia</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class models the behavior of rotating masses. It inherits some properties from the base class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rigid</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model Inertia "1D rotational component with inertia" + extends Rigid; + parameter MomentOfInertia J = 1 "Moment of inertia"; + AngularVelocity w "Absolute angular velocity of component"; + AngularAcceleration a "Absolute angular acceleration of component"; +equation + w = der(phi); + a = der(w); + J*a = rotFlange_a.tau + rotFlange_b.tau; +end Inertia; //From Modelica.Mechanics.Rotational + {Inertia} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + partial model Rigid // Rotational class Rigid + "Base class for the rigid connection of two rotational 1D flanges" + Angle phi "Absolute rotation angle of component"; + RotFlange_a rotFlange_a "(left) driving flange (axis directed into plane)"; + RotFlange_b rotFlange_b "(right) driven flange (axis directed out of plane)"; +equation + rotFlange_a.phi = phi; + rotFlange_b.phi = phi; +end Rigid; // From Modelica.Mechanics.Rotational.Interfaces + {Rigid} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Component Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">EMF</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class below converts electrical energy to rotational mechanical energy. The instance </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">emf1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">EMF</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (Electro Magnetic Force) is probably the most interesting component in the circuit since it converts electrical energy to mechanical rotational energy. This class is an idealized model of the most important properties of a voltage-to-rotation converter excluding resistance, inductance and inertia.<br /><br />The rest of the declared classes are the usual simple electrical components which are presented once more for completeness.<br /></span></p></td></tr></table></body></html> + + + model EMF "Electromotoric force (electric/mechanic transformer)" + extends TwoPin; + parameter Real k(unit = "N.m/A") = 1 "Transformation coefficient"; + AngularVelocity w "Angular velocity of rotFlange_b"; + RotFlange_b rotFlange_b; // Rotational Flange_b +equation + w = der(rotFlange_b.phi); + v = k*w; + rotFlange_b.tau = - k*i; +end EMF; // From Modelica.Electrical.Analog.Basic + {EMF} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + partial model TwoPin // Same as OnePort in Modelica.Electrical.Analog.Interfaces + "Component with two electrical pins p and n and current i from p to n" + Voltage v "Voltage drop between the two pins (= p.v - n.v)"; + Current i "Current flowing from pin p to pin n"; + PositivePin p; + NegativePin n; +equation + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end TwoPin; + {TwoPin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class Resistor "Ideal linear electrical Resistor" + extends TwoPin; // Same as OnePort + parameter Real R(unit = "Ohm") "Resistance"; +equation + R*i = v; +end Resistor; // From Modelica.Electrical.Analog.Basic + {Resistor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class Inductor "Ideal linear electrical Inductor" + extends TwoPin; // Same as OnePort + parameter Real L(unit = "H") "Inductance"; +equation + v = L*der(i); +end Inductor; // From Modelica.Electrical.Analog.Basic + {Inductor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class Ground "Ground node" + Pin p; +equation + p.v = 0; +end Ground; // From Modelica.Electrical.Analog.Basic + {Ground} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Signal and Signal Voltage Classes: SignalVoltage, MO, Step</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">signalVoltage</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class converts an input signal to a voltage. This is used in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DCMotorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to convert a step signal generated by the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">step1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> instance of the simplified </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Step</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class below to a step voltage. The full version of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Step</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class that can handle any number of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">input</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">output</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> signals. The combination of the s</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">tep1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">signalVoltage1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> components is a voltage generator that feeds a step voltage into the rest of the circuit. The partial class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MO</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is simply a base class inherited by </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Step</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model SignalVoltage "Generic Voltage source using the input signal as source Voltage" + extends TwoPin; // Same as OnePort + InPort inPort(n=1); +equation + inPort.signal[1] = v; +end SignalVoltage; // From Modelica.Electrical.Analog.Sources + {SignalVoltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + partial block MO "Multiple Output continuous control block" + parameter Integer nout = 1 "Number of outputs"; + OutPort outPort(n = nout) "Connector of Real output signals"; +protected + Real n[nout] = outPort.signal; +end MO; // From Modelica.Blocks.Interfaces + {MO} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + block Step "Generate step signals of type Real" + extends MO(nout = 1); + parameter Real height = 1 "Height of steps"; + parameter Real offset = 0 "Offset of output signals"; + parameter Time startTime = 0 "Output = offset for time < startTime"; +equation + outPort.signal[1] = offset + (if time < startTime then 0 else height); +end Step; // Version simplified from Step in Modelica.Blocks.Sources + {Step} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">DCMotorCircuit Connector Classes</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Mechanical Connector Classes: RotFlange_a, RotFlange_b </span></p></td></tr></table></body></html> + + + connector RotFlange_a "1D rotational flange (filled square)" + Angle phi "Absolute rotational angle of flange"; + flow Torque tau "Torque in the flange"; +end RotFlange_a; //From Modelica.Mechanical.Rotational.Interfaces + {RotFlange_a} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector RotFlange_b "1D rotational flange (filled square)" + Angle phi "Absolute rotational angle of flange"; + flow Torque tau "Torque in the flange"; +end RotFlange_b; //From Modelica.Mechanical.Rotational.Interfaces + {RotFlange_b} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + {Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector PositivePin "Positive pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end PositivePin; //From Modelica.Electrical.Analog.Interfaces + {PositivePin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector NegativePin "Negative pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end NegativePin; //From Modelica.Electrical.Analog.Interfaces + {NegativePin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Block Signal Connectors</span></p></td></tr></table></body></html> + + + connector InPort "Connector with input signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + input Real signal[n] "Real input signals"; +end InPort; // From Modelica.Blocks.Interfaces + {InPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector OutPort "Connector with output signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + output Real signal[n] "Real output signals"; +end OutPort; // From Modelica.Blocks.Interfaces + {OutPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Types from Modelica.SIunits</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following are different types from the library </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Modelica.SIunits</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used by the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DCMotorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Electrical units</span></p></td></tr></table></body></html> + + + type ElectricPotential = Real; +type ElectricCurrent = Real(quantity = "ElectricCurrent", unit = "A"); +type Resistance = Real(quantity = "Resistance", unit = "Ohm", min = 0); +type Inductance = Real(quantity = "Inductance", unit = "H", min = 0); +type Voltage = ElectricPotential; +type Current = ElectricCurrent; + {ElectricPotential,ElectricCurrent,Resistance,Inductance,Voltage,Current} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Mechanical units</span></p></td></tr></table></body></html> + + + type Force = Real(quantity = "Force", unit = "N"); +type Angle = Real(quantity = "Angle", unit = "rad", displayUnit = "deg"); +type Torque = Real(quantity = "Torque", unit = "N.m"); +type AngularVelocity = Real(quantity = "AngularVelocity", unit = "rad/s", displayUnit = "rev/min"); +type AngularAcceleration = Real(quantity = "AngularAcceleration", unit = "rad/s2"); +type MomentOfInertia = Real(quantity = "MomentOfInertia", unit = "kg.m2"); + {Force,Angle,Torque,AngularVelocity,AngularAcceleration,MomentOfInertia} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Other units</span></p></td></tr></table></body></html> + + + type Length = Real(quantity = "Length", unit = "m"); +type Time = Real(quantity = "Time", unit = "s"); +type Distance = Length(min = 0); +type Position = Length; + {Length,Time,Distance,Position} + + + + type Time = Real (final quantity="Time", final unit="s"); + {Time} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of DCMotorCircuit</span></p></td></tr></table></body></html> + + + simulate( DCMotorCircuit, stopTime=150 ) + record SimulationResult + resultFile = "DCMotorCircuit_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( signalVoltage1.i ) + [done] + + + + + diff --git a/DrModelica/ApplicationEx/PressureDynamics.onb b/DrModelica/ApplicationEx/PressureDynamics.onb new file mode 100644 index 00000000000..d8e8aadf06c --- /dev/null +++ b/DrModelica/ApplicationEx/PressureDynamics.onb @@ -0,0 +1,217 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Pressure Dynamics in 1D Ducts - Solving Wave Equations by Discretized PDEs</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Currently Modelica cannot handle partial differential equations directly since there is only the notion of differentiation with respect to time built into the language. However, in many cases derivatives with respect to other variables such as for example spatial dimensions can be handled by simple discretizations schemes represented using the array capabilities in Modelica. Here we will give an example of how the one dimensional wave equation can be represented in Modelica and how OpenModelica can be used for simulation and display of the results, as well as representing the result as a 2D interpolating function.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WaveEquationSample Model</span></p></td></tr></table></body></html> + + + loadModel(Modelica) // If not loaded + true + + + model WaveEquationSample + import Modelica.SIunits; + parameter SIunits.Length L = 10 "Length of duct"; + parameter Integer n = 30 "Number of sections"; + parameter SIunits.Length dL = L/n "Section length"; + parameter SIunits.Velocity c = 1; + SIunits.Pressure[n] p(start = initialPressure(n), fixed = {i > 1 and i < n for i in 1:n}); + Real[n] dp(start = fill(0,n), fixed = {i > 1 and i < n for i in 1:n}); +equation + p[1] = exp(-(-L/2)^2); + p[n] = exp(-(L/2)^2); + dp = der(p); + for i in 2:n-1 loop + der(dp[i]) = c^2 * (p[i+1] - 2 * p[i] + p[i-1]) / dL^2; + end for; +end WaveEquationSample; + {WaveEquationSample} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here we are using a Modelica function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">initialPressure</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (defined further below) to specify the initial value of the pressure along the duct. <br />Assume that we would like an initial pressure profile in the duct of the form [ExponentialE]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000; vertical-align:super;">-x2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, depicted in Figure 1 below by the following plot command:</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">See Modelica book Section 15.9. Should import figure 15.59 into a cell below.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The initial pressure profile of the duct</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">initialPressure</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> returns the initial pressure profile function in discretized form as an array.</span></p></td></tr></table></body></html> + + + function initialPressure + input Integer n; + output Real p[n]; +protected + parameter Modelica.SIunits.Length L = 10; +algorithm + for i in 1:n loop + p[i] := exp(-(-L/2 + (i - 1) / (n - 1) * L)^2); + end for; +end initialPressure; + {initialPressure} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WaveEquationSample</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">WaveEquationSample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model...</span></p></td></tr></table></body></html> + + + simulate( WaveEquationSample, stopTime=10 ) + record SimulationResult + resultFile = "WaveEquationSample_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + plot({p[2], p[1],p[3]}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The simulation result, i.e. the array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">p</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, shows how the pressure evolves at equidistant positions in the duct as functions of time. This is represented by the array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">p</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of 1D interpolation functions of time, that are packed into a Mathematica 2D interpolation function and plotted using the following two commands:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A 3D plot of the pressure distribution in the duct.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Let us also plot the wave as a function of position x for a fixed point in time (t = 1.2) to observe the pressure distribution in more detail:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The wave as a function of position at time</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> = 1.2.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Arrays/ArithmeticOp.onb b/DrModelica/Arrays/ArithmeticOp.onb new file mode 100644 index 00000000000..6c6bf8746f6 --- /dev/null +++ b/DrModelica/Arrays/ArithmeticOp.onb @@ -0,0 +1,389 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Arithmetic Array Operators</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Arithmetic operators on arrays and certain combinations of arrays and scalars are available through the standard arithmetic operators, addition (+), subtraction (-), division (/), multiplication as well as through the exponentiation (^) operator. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Addition and Subtraction</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Strangely enough, elementwise operations for the combination of an array and a scalar operand are defined for multiplication and division but not for addition and subtraction.</span></p></td></tr></table></body></html> + + + class AddSub + Real Add1 = {1, 2, 3} + 1; // Not allowed! + Real Add2 = {1, 2, 3} + {1, 2}; // Not allowed, different array sizes! + Real Add3[2, 2] = {{1, 1}, {2, 2}} + {{1, 2}, {3, 4}}; + // Result: {{2, 3}, {5, 6}} + Real Sub1[3] = {1, 2, 3} - {1, 2, 0}; // Result: {0, 0, 3} +end AddSub; + {AddSub} + + + class AddSub2 + Real Add3[2, 2] = {{1, 1}, {2, 2}} + {{1, 2}, {3, 4}}; + // Result: {{2, 3}, {5, 6}} + Real Sub1[3] = {1, 2, 3} - {1, 2, 0}; // Result: {0, 0, 3} +end AddSub2; + {AddSub2,AddSub} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Try interactive:</span></p></td></tr></table></body></html> + + + {{1, 1}, {2, 2}} // Works + {{1,1},{2,2}} + + + [1, 1; 2, 2] //Works + {{1,1},{2,2}} + + + 2.0*{{1, 1}, {2, 2}} // Works + {{2.0,2.0},{4.0,4.0}} + + + {{1, 1}, {2, 2}} + {{1, 2}, {3, 4}} // Works + {{2,3},{5,6}} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of AddSub and AddSub2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When we try to simulate AddSub, it does not work since different array sizes are not allowed in Addition operand </span></p></td></tr></table></body></html> + + + simulate( AddSub ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: AddSub +[<interactive>:2:3-2:28:writable] Error: Cannot resolve type of expression {1,2,3} + 1. The operands have types Integer[3], Integer in component <NO COMPONENT>. +Error: Error occurred while flattening model AddSub +" +end SimulationResult; + + + simulate( AddSub2 ) + record SimulationResult + resultFile = "AddSub2_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Look at results:</span></p></td></tr></table></body></html> + + + val(Sub1[1],1.) + 0.0 + + + + + + + + plot({Sub1[1], Sub1[3],Add3[1,1]}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Division</span></p></td></tr></table></body></html> + + + class Div + Real[3] Div1, Div2, Div3; +equation + Div1 = {2, 4, 6} / 2; // Result: {1, 2, 3} + Div2 = 6 / {1, 2, 3}; // Not allowed! + Div3 = {1, 2, 3} / {1, 2, 2}; // Not allowed! +end Div; + {Div,AddSub2,AddSub} + + + class Div2 + Real Div1[3]; +equation + Div1 = {2, 4, 6} / 2; // Result: {1, 2, 3} +end Div2; + {Div2,Div,AddSub2,AddSub} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Div and Div2</span></p></td></tr></table></body></html> + + + simulate( Div ) //Error in model + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: Div +[<interactive>:5:3-5:23:writable] Error: Cannot resolve type of expression 6 / {1,2,3}. The operands have types Integer, Integer[3] in component <NO COMPONENT>. +Error: Error occurred while flattening model Div +" +end SimulationResult; + + + simulate( Div2 ) + record SimulationResult + resultFile = "Div2_res.mat", + messages = "" +end SimulationResult; + + + val(Div1[2],0.) + 2.0 + + + + + + + + plot({Div1[1],Div1[2],Div1[3]}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Multiplication</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The array multiplication operator is only defined for vectors and matrices and has several different definitions depending on the type of its arguments. If both operands are vectors then array multiplication means scalar product, otherwise, if the operands are vectors or matrices then it means matrix multiplication. If one of the operands is a scalar, then the multiplication operation is defined as elementwise multiplication, which however is not available when both operands are arrays despite the fact that analogous elementwise operations are defined for addition and subtraction. The reason is that we have already used the multiplication notation (*) for the more common operation of matrix multiplication.<br /></span></p></td></tr></table></body></html> + + + class Multiplication + Real m1[3] = {1, 2, 3} * 2; // Elementwise mult: {2, 4, 6}; + Real m2[3] = 3 * {1, 2, 3}; // Elementwise mult: {3, 6, 9}; + Real m3 = {1, 2, 3} * {1, 2, 2}; // Scalar product: 11; + Real m4[2] = {{1, 2}, {3, 4}} * {1, 2}; // Matrix mult: {5, 11}; + Real m5[1] = {1, 2, 3} * {{1}, {2}, {10}}; // Matrix mult: {35}; + Real m6[1] = {1, 2, 3} * [1; 2; 10]; // Matrix mult: {35}; + Real m7[2, 2] = {{1, 2}, {3, 4}} * {{1, 2}, {2, 1}}; // Matrix mult: {{5, 4}, {11, 10}}; + Real m8[2, 2] = [1, 2; 3, 4] * [1, 2; 2, 1]; // Matrix mult: {{5, 4}, {11, 10}}; +end Multiplication; + {Multiplication,Div2,Div,AddSub2,AddSub} + + + {{1, 2}, {3, 4}} * {1, 2} + {5,11} + + + {1, 2, 3} * [1; 2; 10] + {35} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Multiplication</span></p></td></tr></table></body></html> + + + simulate( Multiplication ) + record SimulationResult + resultFile = "Multiplication_res.mat", + messages = "" +end SimulationResult; + + + val(m1[2],0.) + 4.0 + + + val(m3,0.) + 11.0 + + + + + + + plot({m1[2],m3}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Exponentiation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" 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.</span></p></td></tr></table></body></html> + + + class Exp + Real e1[2, 2]; + Real e2[2, 2]; +equation + e1 = {{1, 2}, {1, 2}} ^ 0; // Result: {{1, 0}, {0, 1}} + e2 = [1, 2; 1, 2] ^ 2; // Result: {{3, 6}, {3, 6}} +end Exp; + {Exp,Multiplication,Div2,Div,AddSub2,AddSub} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Exponentiation</span></p></td></tr></table></body></html> + + + simulate( Exp ) + record SimulationResult + resultFile = "Exp_res.mat", + messages = "" +end SimulationResult; + + + val(e1[1,1],0) + 1.0 + + + + + + + plot({e1[1,1],e2[1,2]}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Arrays/Built-inFunc.onb b/DrModelica/Arrays/Built-inFunc.onb new file mode 100644 index 00000000000..0bb8bbb015b --- /dev/null +++ b/DrModelica/Arrays/Built-inFunc.onb @@ -0,0 +1,394 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Built-in Array Functions</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Array Dimension and Size Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following examples illustrate built-in functions that return the number of dimensions of an array (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ndims(A)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">), the sizes of its dimensions (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">size(A, i)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">), or the size of a specific dimension (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">size(A)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">).</span></p></td></tr></table></body></html> + + + class DimSize + parameter Real[4, 1, 6] x = fill(1., 4, 1, 6); + parameter Real dim = ndims(x); // Returns 3 + parameter Real dimsize = size(x, 1); // Returns 4 + parameter Real specsize[3] = size(x); // Returns the vector {4, 1, 6} +equation + // size(2*x + x) = size(x); // This equation holds +end DimSize; + {DimSize} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DimSize</span></p></td></tr></table></body></html> + + + simulate( DimSize ) + record SimulationResult + resultFile = "DimSize_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at an array element value at time=1:</span></p></td></tr></table></body></html> + + + val(x[4,1,4],1) + 1.0 + + + + + + plot(x[4,1,4]) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Dimensionality Conversion Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following conversion functions convert scalars, vectors, and arrays to scalars or matrices by adding or removing 1-sized dimensions.</span></p></td></tr></table></body></html> + + + class DimConvert + Real[3] v1 = {1.0, 2.0, 3.0}; + Real[3,1] m1 = matrix(v1); // m1 contains {{1.0}, {2.0}, {3.0}} + Real[3] v2 = vector(m1); // v2 contains {1.0, 2.0, 3.0} + + Real[1,1,1] m2 = {{{4}}}; + Real s1 = scalar(m2); // s1 contains 4.0 + Real[2,2,1] m3 = {{{1.0}, {2.0}}, {{3.0}, {4.0}}}; + Real[2,2] m4 = matrix(m3); // m4 contains {{1.0, 2.0}, {3.0, 4.0}} +end DimConvert; + {DimConvert,DimSize} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DimConvert</span></p></td></tr></table></body></html> + + + simulate( DimConvert ) + record SimulationResult + resultFile = "DimConvert_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at an array element value at time=1:</span></p></td></tr></table></body></html> + + + val(m1[3,1],1) + 3.0 + + + + + + + plot({m1[3,1],s1}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Specialized Constructor Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">An array constructor function constructs and returns an array computed from its arguments. Most of the constuctor functions in the table below construct an array by filling in values according to a certain pattern. </span></p></td></tr></table></body></html> + + + class ConstructFunc + Real z[2,3] = zeros(2, 3); // Constructs the matrix {{0,0,0}, {0,0,0}} + Real o[3] = ones(3); // Constructs the vector {1, 1, 1} + Real f[2,2] = fill(2.1,2,2); // Constructs the matrix {{2.1, 2.1}, {2.1, 2.1}} + Boolean check[3, 4] = fill(true, 3, 4); // Fills a Boolean matrix + Real id[3,3] = identity(3); // Creates the matrix {{1,0,0}, {0,1,0}, {0, 0, 1}} + Real di[3,3] = diagonal({1, 2, 3}); // Creates the matrix {{1, 0, 0}, {0, 2, 0}, {0, 0, 3}} + Real ls[5] = linspace(0.0, 8.0, 5); // Computes the vector {0.0, 2.0, 4.0, 6.0, 8.0} +end ConstructFunc; + {ConstructFunc,DimConvert,DimSize} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ConstructFunc</span></p></td></tr></table></body></html> + + + simulate( ConstructFunc ) + record SimulationResult + resultFile = "ConstructFunc_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at an array element value at time=0:</span></p></td></tr></table></body></html> + + + val(di[3,2],0) + 0.0 + + + + + + + plot({di[3,2],f[2,2]}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Reduction Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">An array reduction function &quot;reduces&quot; an array to a scalar value, i.e. computes a scalar value from the array.</span></p></td></tr></table></body></html> + + + class Reduce + Real minimum, maximum, summ, prod; +equation + minimum = min({1, -1, 7}); // Gives the value -1 + maximum = max([1, 2, 3; 4, 5, 6]); // Gives the value 6 + summ = sum({{1, 2, 3}, {4, 5, 6}}); // Gives the value 21 + prod = product({3.14, 2, 2}); // Gives the value 12.56 +end Reduce; + {Reduce,ConstructFunc,DimConvert,DimSize} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Reduce</span></p></td></tr></table></body></html> + + + simulate( Reduce ) + record SimulationResult + resultFile = "Reduce_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(summ,0) + 21.0 + + + + + + + plot({summ,prod}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Matrix and Vector Algebra Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following set of functions are rather common in matrix and vector algebra, but are not associated with any Modelica operator symbol. </span></p></td></tr></table></body></html> + + + class AlgebraFunc + Real transp1[2,2] = transpose([1, 2; 3, 4]); // Gives [1, 2; 3, 4] of type Integer[2, 2] + Real transp2[2,2,1] = transpose({{{1},{2}},{{3},{4}}}); + // Gives {{{1},{2}},{{3},{4}}} of type Integer[2, 2, 1] + Real out[2, 2] = outerProduct({2,1}, {3,2}); // Gives {{6, 4}, {3, 2}} + Real symm[2, 2] = symmetric({{1, 2}, {3, 1}}); // Gives {{1, 2}, {2, 1}} + Real c[3] = cross({1, 0, 0}, {0, 1, 0}); // Gives {0, 0, 1} + Real s[3, 3] = skew({1, 2, 3}); // Gives {{0, -3, 2}, {3, 0, -1}, {-2, 1, 0}}; +end AlgebraFunc; + {AlgebraFunc,Reduce,ConstructFunc,DimConvert,DimSize} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of AlgebraFunc</span></p></td></tr></table></body></html> + + + simulate( AlgebraFunc ) + record SimulationResult + resultFile = "AlgebraFunc_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(transp2[2,1,1],0) + 9.750135904034313e+199 + + + val(s[3,3],0) + 0.0 + + + + + + + plot({s[3,3],c[3]}) + [done] + + + + + + diff --git a/DrModelica/Arrays/ConcatConstruct.onb b/DrModelica/Arrays/ConcatConstruct.onb new file mode 100644 index 00000000000..6844be7982c --- /dev/null +++ b/DrModelica/Arrays/ConcatConstruct.onb @@ -0,0 +1,334 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Array Concatenation and Construction</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />General array concatenation can be done through the array concatenation operator </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">cat(k, A, B, C, ...)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that concatenates the arrays A, B, C, .... along the k:th dimension. Concatenating along the first dimension is to concate rows and the second dimension is to concatenate colums.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Class Concat</span></p></td></tr></table></body></html> + + + class Concat + Real[5] c1 = cat(1, {1, 2}, {10, 12, 13}); // Result: {1, 2, 10, 12, 13} + Real[2, 3] c2 = cat(2, {{1, 2}, {3, 4}}, {{10}, {11}}); // Result: {{1, 2, 10}, {3, 4, 11}} +end Concat; + {Concat} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Concat</span></p></td></tr></table></body></html> + + + simulate( Concat ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Different dimension sizes in arguments to cat(1, {1,2}, {10,12,13}) +Class cat (its type) not found in scope Concat. +No matching function found for cat, candidates are +Class cat not found in scope Concat. +Error occured while flattening model Concat +" +end record + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(c1[2], 0) + + + + + simulate(Concat) + record SimulationResult + messages = "", + simulationTime = 0.23781129621163322 +end SimulationResult; + + + + + + plot(c1[4]) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">More Concatenation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A matrix can be constructed from scalar expressions by separating rows by semicolon and columns by comma. The previous example of concatenation along the second dimension can be expressed like this:</span></p></td></tr></table></body></html> + + + class Concat2 + Real[2, 3] c3 = cat(2, [1, 2; 3, 4], [10; 11]); // Same result: {{1, 2, 10}, {3, 4, 11}} +end Concat2; + {Concat2} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Concat2</span></p></td></tr></table></body></html> + + + simulate( Concat2 ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Different dimension sizes in arguments to cat(2, [1,2;3,4], [10;11]) +Class cat (its type) not found in scope Concat2. +No matching function found for cat, candidates are +Class cat not found in scope Concat2. +Error occured while flattening model Concat2 +" +end record + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(c3[1,3], 0) + + + + + simulate(Concat2) + record SimulationResult + messages = "", + simulationTime = 0.15753075864668187 +end SimulationResult; + + + val(c3[2,3],0) + 11.0 + + + + + + + plot({c3[2,3],c3[2,2]}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Type Rules for Concatenation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The arrays that is concatenated must have the same number of dimensions. The concatenation dimension k must exist. Arrays must have identical dimension sizes with the exception of the size of dimension k, which is called </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Size matching. </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Argument arrays must have equivalent maximally expanded element types. The element type of the result array is the element type of the maximally expanded type of the arguments. These rules make it possible to mix integers and real numbers as in the example below:<br /></span></p></td></tr></table></body></html> + + + class Concat3 + Real[2, 3] r1 = cat(1, {{1.0, 2.0, 3}}, {{4, 5, 6}}); + Real[2, 6] r2 = cat(2, r1, r1); +end Concat3; + {Concat3} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Concat3</span></p></td></tr></table></body></html> + + + simulate( Concat3 ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Too few equations, underdetermined system. The model has 12 variables and 1 equations +" +end record + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(r2[1,3], 0) + + + + + simulate(Concat3) + record SimulationResult + messages = "", + simulationTime = 0.24456052503164863 +end SimulationResult; + + + + + + plot(r1[2,2]) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Concatenating Larger Arrays</span></p></td></tr></table></body></html> + + + class Concat4 + Real[1, 1, 1] A = {{{1}}}; + Real[1, 1, 2] B = {{{2, 3}}}; + Real[1, 1, 3] C = {{{4, 5, 6}}}; + Real[1, 1, 6] R = cat(3,A,B,C); // Result value: {{{1, 2, 3, 4, 5, 6}}}; +end Concat4; + {Concat4} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Concat4</span></p></td></tr></table></body></html> + + + simulate( Concat4 ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Different dimension sizes in arguments to cat(3, A, B, C) +Class cat (its type) not found in scope Concat4. +No matching function found for cat, candidates are +Class cat not found in scope Concat4. +Error occured while flattening model Concat4 +" +end record + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(C[1,1,2],0) + + + + + simulate(Concat4) + record SimulationResult + messages = "", + simulationTime = 0.15255753486481008 +end SimulationResult; + + + + + + + plot({R[1,1,5],B[1,1,2]}) + [done] + + + + + diff --git a/DrModelica/Arrays/ConcatSlice.onb b/DrModelica/Arrays/ConcatSlice.onb new file mode 100644 index 00000000000..8c0e143ee42 --- /dev/null +++ b/DrModelica/Arrays/ConcatSlice.onb @@ -0,0 +1,327 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Using Array Concatenation and Slices</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The following usage examples show a few common programming situations where both array concatenation and array slices are involved, and how to do this correctly in order to avoid certain mistakes. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Appending an Element to Vectors and Row/Column Matrices</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The first equations set XA1, XA2, XA3 and XA4 equal to row matrices and XB1, XB2 equal to column matrices respectively, created by appending an additional element to row/column matrices PA and PB.</span></p></td></tr></table></body></html> + + + class AppendElement + Real[1, 3] PA = [1, 2, 3]; // A row matrix value + Real[3, 1] PB = [1; 2; 3]; // A column matrix value + Real[3] q = {1, 2, 3}; // A vector value + + Real[1, 4] XA1, XA2, XA3, XA4; // Row matrix variables + Real[4, 1] XB1, XB2; // Column matrix variables + Real[4] y; // Vector variable + +equation + XA1 = [PA, 4]; // Append OK, since 4 is promoted to {{4}} + XA2 = cat(2, PA, {{4}}); // Append OK, same as above but not promoted + + XB1 = [PB; 4]; // Append OK, result is {{1}, {2}, {3}, {4}} + XB2 = cat(1, PB, {{2}}); // Append OK, same result + + y = cat(1, q, {4}); // Vector append OK, result is {1, 2, 3, 4} + + XA3 = [-1, zeros(1, 2), 1]; // Append OK, result is {{-1, 0, 0, 1}} + XA4 = cat(2, {{-1}}, zeros(1, 2), {{1}} ); // Append OK, result is {{-1, 0, 0, 1}} + +end AppendElement; + {AppendElement} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of AppendElement</span></p></td></tr></table></body></html> + + + simulate( AppendElement ) + record SimulationResult + resultFile = "AppendElement_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + + val(y[3],0) + 3.0 + + + + + + + plot({XA1[1,3],y[2]}) + [done] + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Composing a Blocked Matrix Board from Submatrices</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following example shows three very similar ways of constructing a blocked matrix from submatrices. The first two variants follow the rule of always making sure that returned array slices as arguments to the special purpose concatenation operators are matrices. The third variant breaks this rule, since two of the array slices return vectors, causing an error. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">BlockMatrix</span></p></td></tr></table></body></html> + + + class BlockMatrix + Real[3,3] P = [1, 2, 3; + 4, 5, 6; + 7, 8, 9]; // A 3x3 matrix value + Real[6, 6] Q; // Q consists of four 3x3 matrix blocks to be defined + // by P apart from sign +equation + Q[1:3, 1:3] = P; // Upper left block + Q[1:3, 4:6] = [Q[1:3, 1:2], -Q[1:3, {3}]]; // Upper right block + Q[4:6, 1:3] = [Q[1:2, 1:3]; -Q[{3}, 1:3]]; // Lower left block + Q[4:6, 4:6] = P; // Lower right block +end BlockMatrix; + {BlockMatrix} + + + simulate(BlockMatrix) + record SimulationResult + resultFile = "BlockMatrix_res.mat", + messages = "" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">BlockMatrix2</span></p></td></tr></table></body></html> + + + class BlockMatrix2 + Real[3, 3] P = [1, 2, 3; + 4, 5, 6; + 7, 8, 9]; + Real[6, 6] Q; +equation + Q[1:3, 1:3] = P; // Upper left block + Q[1:3, 4:6] = [Q[1:3, 1:2], -Q[1:3, 3:3]]; // Upper right block + Q[4:6, 1:3] = [Q[1:2, 1:3]; -Q[3:3, 1:3]]; // Lower left block + Q[4:6, 4:6] = P; // Lower right block +end BlockMatrix2; + {BlockMatrix2} + + + simulate(BlockMatrix2) + record SimulationResult + resultFile = "BlockMatrix2_res.mat", + messages = "" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">BlockMatrix3</span></p></td></tr></table></body></html> + + + class BlockMatrix3 + Real[3, 3] P = [1, 2, 3; + 4, 5, 6; + 7, 8, 9]; + Real[6, 6] Q; +equation + Q[1:3, 1:3] = P; // OK! + Q[1:3, 4:6] = [Q[1:3, 1:2], -Q[1:3, 3]]; // OK, correct promotion + Q[4:6, 1:3] = [Q[1:2, 1:3], -Q[3, 1:3]]; // ERROR! + Q[4:6, 4:6] = P; // OK! +end BlockMatrix3; + {BlockMatrix3} + + + simulate(BlockMatrix3) + record SimulationResult + resultFile = "", + messages = "Failed to build model: BlockMatrix3" +end SimulationResult; +OMC-ERROR: +"[<interactive>:9:3-9:42:writable] Error: Type mismatch in equation Q[{4, 5, 6},{1, 2, 3}]=cat(2, Q[{1, 2},{1, 2, 3}], promote(-Q[3,{1, 2, 3}], 1)) of type Real[3, 3]=Real[3, 4]. +Error: Error occurred while flattening model BlockMatrix3 +" + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Cyclic Permutation of Matrix Rows or Columns</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Cyclic permutation can be achieved by a combination of concatenation operations and array slices or just array slices using a permutation vector.</span></p></td></tr></table></body></html> + + + class CyclicPerm + Real[1, 3] WO = [1, 2, 3]; // Row matrix + Real[2, 3] XO = [1, 2, 3; 4, 5, 6]; // Matrix with two rows + + Real[1, 3] W; // Permuted row matrix + Real[2, 3] X; // Permuted matrix with two rows + + Integer[3] p = {2, 3, 1}; // Permutation vector + +algorithm + W := [[2, 3], 1]; // OK, result: [2, 3, 1] = {{2, 3, 1}} + W := [{{2, 3}}, {{1}}]; // OK, same result: {{2, 3, 1}} + + W := [WO[{1}, 2:3], WO[{1}, {1}]]; // OK, result: {{2, 3, 1}} + W := [WO[1:1, 2:3], WO[1:1, 1:1]]; // OK, same result: {{2, 3, 1}} + + W := WO[:, p]; // OK, same result: {{2, 3, 1}} + + W := cat(2, WO[1:1, 2:3], WO[1:1, 1:1]); // OK, same result: {{2, 3, 1}} + W := [WO[1, 2:3], WO[1, 1]]; // Error, since WO[1, 2:3] is a vector + + X := [XO[:, 2:3], XO[:, {1}]]; // OK, X becomes [2, 3, 1; 5, 6, 4] + X := XO[:, p]; // OK, X becomes [2, 3, 1; 5, 6, 4] + + X[{1},:] := [XO[{1}, 2:3], XO[{1}, {1}]]; // OK, X becomes [2,3,1; 5,6,4] + X[1, :] := [XO[1, 2:3], XO[1, 1]]; // ERROR, incompatible dimensions +end CyclicPerm; + {CyclicPerm,getPerson,PersonList,mkperson,Person} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of CyclicPerm</span></p></td></tr></table></body></html> + + + simulate( CyclicPerm ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: CyclicPerm +[<interactive>:20:3-20:30:writable] Error: Type mismatch in assignment in W := cat(2, {{WO[1,2]}, {WO[1,3]}}, {{WO[1,1]}}) of Real[1, 3] := Real[1, 2] +Error: Error occurred while flattening model CyclicPerm +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at some values at time=0:</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Arrays/Construction.onb b/DrModelica/Arrays/Construction.onb new file mode 100644 index 00000000000..b7c451fc75e --- /dev/null +++ b/DrModelica/Arrays/Construction.onb @@ -0,0 +1,196 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">General Array Construction</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />An array constructor is just a function accepting scalar or array arguments and returning an array result. The array constructor function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">array(A,B,C,...)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, with short hand notation </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">{A, B, C, ...}</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, constructs an array from its arguments according to certain rules.<br /></span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Constructing Arrays</span></p></td></tr></table></body></html> + + + type Angle = Real(unit="rad"); // The type Angle is a subtype of Real + {Angle} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class ArrayConstruction + Integer[3] a = {1, 2, 3}; // A 3-vector of type Integer[3] + Real[3] b = array(1.0, 2.0, 3); // A 3-vector of type Real[3] + + Integer[2,3] c = {{11, 12, 13}, {21, 22, 23}}; // A 2x3 matrix of type Integer[2,3] + Real[1,1,3] d ={{{1.0, 2.0, 3.0}}}; // A 1x1x3 array of type Real[1,1,3] + + Real[3] v = array(1, 2, 3.0); // The vector v is equal to {1.,2.,3.} + + parameter Angle alpha = 2.0; // The expanded type of alpha is Real + Real[3] f = array(alpha, 2, 3.0); // A 3-vector of type Real[3] + Angle[3] A = {1.0, alpha, 4}; // The expanded type of A is Real[3] +end ArrayConstruction; + {ArrayConstruction,Angle} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ArrayConstruction</span></p></td></tr></table></body></html> + + + simulate( ArrayConstruction ) + record SimulationResult + resultFile = "ArrayConstruction_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the result at time=0:</span></p></td></tr></table></body></html> + + + val(d[1,1,1],0) + 1.0 + + + + + + + plot({d[1,1,1],c[2,1]}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Range Vector Construction</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A range vector is a vector containing a range of numeric values increasing or decreasing by a fixed increment or decrement value for each additional element. For example, {1, 2, 3} is an Integer range vector starting at 1 and increasing by 1 for each element.<br /></span></p></td></tr></table></body></html> + + + class Range + Real v1[5] = 2.7 : 6.8; // v1 is {2.7, 3.7, 4.7, 5.7, 6.7} + Real v2[5] = {2.7, 3.7, 4.7, 5.7, 6.7}; // v2 is equal to v1 + + Integer v3[3] = 3 : 5; // v3 is {3, 4, 5} + Integer v4empty[0] = 3 : 2; // v4empty is an empty Integer vector + + Real v5[4] = 1.0 : 2 : 8; // v5 is {1.0, 3.0, 5.0, 7.0} + Integer v6[5] = 1 : -1 : -3; // v6 is {1, 0, -1, -2, -3} + Real[0] v7none; // v7 none is an empty Real vector +end Range; + {Range,ArrayConstruction,Angle} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Range</span></p></td></tr></table></body></html> + + + simulate( Range ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Type mismatch in modifier, expected type #NOTYPE#[0], got modifier =3:2 of type Integer[0] +Error occured while flattening model Range +" +end record + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the result at time=0:</span></p></td></tr></table></body></html> + + + val(v3[1],0) + + + + + simulate(Range) + record SimulationResult + resultFile = "Range_res.mat", + messages = "" +end SimulationResult; + + + + + + + plot({v1[4],v5[3]}) + [done] + + + + + diff --git a/DrModelica/Arrays/Declaration.onb b/DrModelica/Arrays/Declaration.onb new file mode 100644 index 00000000000..c9dcdffa42e --- /dev/null +++ b/DrModelica/Arrays/Declaration.onb @@ -0,0 +1,275 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Array Declarations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Declaring Arrays in one way</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />An array variable can be declared by appending dimensions within square brackets after a type name or after a variable name.</span></p></td></tr></table></body></html> + + + class ArrayDim + parameter Integer n = 1, m = 4, k = 5; + Real[3] positionvector = {1, 2, 3}; // 3-dimensional position vector + Real[3,3] identitymatrix = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; // transformation matrix + Integer[n,m,k] arr3d = fill(1,n,m,k); // A 3-dimensional array + Boolean[2] truthvalues = {false, true}; // A boolean vector + Voltage[10] voltvector = fill(10, 10); // A vector of voltage values +end ArrayDim; + {ArrayDim,Voltage} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ArrayDim</span></p></td></tr></table></body></html> + + + simulate( ArrayDim ) + record SimulationResult + resultFile = "ArrayDim_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the result at time=0:</span></p></td></tr></table></body></html> + + + val(voltvector[3],0) + 10.0 + + + + + + + plot({voltvector[3],positionvector[2]}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Declaring Arrays in another way</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The same declarations can be expressed as:</span></p></td></tr></table></body></html> + + + class ArrayDim2 + parameter Integer n = 1, m = 4, k = 5; + Real positionvector[3] = {1, 2, 3}; + Real identitymatrix[3,3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; + Integer arr3d[n,m,k] = fill(1,n,m,k); + Boolean truthvalues[2] = {false, true}; + Voltage voltvector[10] = fill(10, 10); +end ArrayDim2; + {ArrayDim2,ArrayDim,Voltage} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ArrayDim</span></p></td></tr></table></body></html> + + + simulate( ArrayDim2 ) + record SimulationResult + resultFile = "ArrayDim2_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the result at time=0:</span></p></td></tr></table></body></html> + + + val(voltvector[3],0) + 10.0 + + + + + + plot(voltvector[3]) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Declaring Row Matrices and Column Matrices</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Column matrices and row matrices can be declared as below:</span></p></td></tr></table></body></html> + + + class ColRowMatrix + parameter Integer n = 3; + Real[n, 1] colmat = fill(1, n, 1); // Column matrix + Real[1, n] rowmat = fill(1, 1, n); // Row matrix +end ColRowMatrix; + {ColRowMatrix,ArrayDim2,ArrayDim,Voltage} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ArrayDim</span></p></td></tr></table></body></html> + + + simulate( ColRowMatrix ) + record SimulationResult + resultFile = "ColRowMatrix_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the result at time=0:</span></p></td></tr></table></body></html> + + + val(colmat[3,1],0) + 1.0 + + + + + + plot(colmat[3,1]) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Declaring Empty Arrays</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is also allowed to declare empty arrays. An </span><a href="Empty.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">Empty Array</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has at least one dimension of size 0 and contains no array elements.</span></p></td></tr></table></body></html> + + + class Empty + Real[0, 3] M; // An empty matrix M + Integer x[0]; // An empty vector x +end Empty; + {Empty,ColRowMatrix,ArrayDim2,ArrayDim,Voltage} + + + simulate(Empty) + record SimulationResult + resultFile = "Empty_res.mat", + messages = "" +end SimulationResult; + + + + + diff --git a/DrModelica/Arrays/Empty.onb b/DrModelica/Arrays/Empty.onb new file mode 100644 index 00000000000..8eb3660ec6e --- /dev/null +++ b/DrModelica/Arrays/Empty.onb @@ -0,0 +1,224 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Empty Arrays</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Empty arrays can function as a kind of null element for certain general operations such as concatenation operations or general formulations of certain kinds of equation systems. An empty array can not be constructed by { } or [ ]. Instead an empty array is created using some other constructor from which the type can be deduced, or explicilty declared as a variable. Array variables of unspecified size can be set equal to or assigned empty array values.<br /></span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Empty Arrays</span></p></td></tr></table></body></html> + + + class Empty + Real f[0] = fill(1.,0); //An empty vector of type Real[0] since 1. is Real + Real x[0]; // An empty vector variable x of type Real[0] + + Real[0, 3] A; // An empty matrix variable A + Real B[5, 0], C[0, 0]; // Empty matrices B and C + + //Real A[:, :] = fill(0.0, 0, 1); // A Real 0 x 1 matrix + //Boolean B[:, :, :] = fill (false, 0, 1, 0); // A Boolean 0 x 1 x 0 array + + //The code used the previous two lines, and the omc compiler gave errors + //due to declaration of variables with same name with different type. + //After changing the variable names to A2 and B2 the problem was fixed. + + Real A2[:, :] = fill(0.0, 0, 1); // A Real 0 x 1 matrix + Boolean B2[:, :, :] = fill (false, 0, 1, 0); // A Boolean 0 x 1 x 0 + +end Empty; + {Empty} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Empty</span></p></td></tr></table></body></html> + + + simulate( Empty ) + record SimulationResult + resultFile = "Empty_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Adding Empty Arrays</span></p></td></tr></table></body></html> + + + class AddEmpty + Real[3, 0] A, B; + Real[0, 0] C; + Real ab[3, 0] = A + B; // Fine, the result is an empty matrix of type Real[3, 0] + //Real ac = A + C; // Error, incompatible types Real[3, 0] and Real[0, 0] +end AddEmpty; + {AddEmpty,Empty} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of AddEmpty</span></p></td></tr></table></body></html> + + + simulate( AddEmpty ) + record SimulationResult + resultFile = "AddEmpty_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Using Empty Arrays</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ABCDsystem</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model below shows how the equation section will shrink to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y = D*u</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> when some variables are empty arrays.</span></p></td></tr></table></body></html> + + + model ABCDsystem + parameter Integer n = 0; + Real u[5] = {15, 4, 3, 9, 11}; + Real x[n]; + Real y[3]; + Real A[n, n], B[n, 5], C[3, n]; + Real D[3, 5] = fill(1, 3, 5); +equation + der(x) = A*x + B*u; // This will disappear since x is empty + y = C*x + D*u; // Which is: y = D*u +end ABCDsystem; + {ABCDsystem,AddEmpty,Empty} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ABCDsystem</span></p></td></tr></table></body></html> + + + simulate( ABCDsystem) + record SimulationResult + resultFile = "ABCDsystem_res.mat", + messages = "" +end SimulationResult; + + + + + + + plot({y[2],n}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the results at time=0:</span></p></td></tr></table></body></html> + + + val(D[2, 2],0) + 1.0 + + + val(y[2],0) + 42.0 + + + val(u[1],0) + 15.0 + + + + + + diff --git a/DrModelica/Arrays/Exercise1-7-2.onb b/DrModelica/Arrays/Exercise1-7-2.onb new file mode 100644 index 00000000000..debf5b76c96 --- /dev/null +++ b/DrModelica/Arrays/Exercise1-7-2.onb @@ -0,0 +1,274 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 1</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What is a range vector?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A range vector is a vector containing a range of numeric values increasing or decreasing by a fixed increment or decrement value for each additional element.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Give an example of a range vector with 5 Integers increasing by 5 for each additional element. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">{5, 10, 15, 20, 25}</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Considering Array Ranges</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Which result do the v1, v2, v3, v4 and v5 have below?</span></p></td></tr></table></body></html> + + + class RangeVectors + Integer v1[6] = 3 : 8; + Integer v2[10] = -20 : -11; + Real v3[5] = 11.3 : 15.3; + Integer v4[0]; + Real v5[3] = 1.1 : 3.1; +end RangeVectors; + Ok + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">v1 has the value {3, 4, 5, 6, 7, 8}<br />v2 has the value {-20, -19, -18, -17, -16, -15, -14, -13, -12, -11}<br />v3 has the value {11.3, 12.3, 13.3, 14.3, 15.3}<br />v4 is an empty vector<br />v5 has the value {1.1, 2.1, 3.1}</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of RangeVectors</span></p></td></tr></table></body></html> + + + simulate( RangeVectors ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Wider Ranges</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">How can you construct the range vectors below?<br /><br />{15.0, 18.0, 21.0, 24.0, 27.0},<br />{-6.5, -8.5, -10.5} and<br />an empty Integer vector.<br /><br />Write the class containing the vectors here:</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">These vectors are just examples of how the vectors can be constructed. There is more than one solution to every vector.</span></p></td></tr></table></body></html> + + + class RangeVectors2 + Real v1[5] = 15.0 : 3 : 27.0; + Real v2[3] = -6.5 : -2 : -10.5; + Integer v3[0]; +end RangeVectors2; + Ok + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of RangeVectors2</span></p></td></tr></table></body></html> + + + simulate( RangeVectors2 ) //??Error + record SimulationResult + resultFile = "Simulation failed. +Array dimension mismatch, expression {} has type Real[0], expected array dimensions [5] +Error occured while flattening model RangeVectors2 +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + + + diff --git a/DrModelica/Arrays/Exercise1-7-3.onb b/DrModelica/Arrays/Exercise1-7-3.onb new file mode 100644 index 00000000000..d2a7b533cd0 --- /dev/null +++ b/DrModelica/Arrays/Exercise1-7-3.onb @@ -0,0 +1,250 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Which are the type rules for concatenation?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The arrays that is concatenated must have the same number of dimensions.<br />The concatenation dimension k, that you use, must exist.<br />Arrays must have identical dimension sizes with the exception of the size of dimension k<span style=" font-style:italic;"><br /></span>Argument arrays must have equivalent maximally expanded element types, where the element type of the result array is the element type of the maximally expanded type of the arguments.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Considering Array Concatenation</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What will be the result of the arrays below?</p></body></html> + + + class ArrayConcatenation + Real[2, 3] array1 = cat(2, [22, 34; 66, 78], [15; 52]); + Real[2, 3] array2 = cat(2, {{22, 34}, {66, 78}}, {{15}, {52}}); + + Real[2, 2] array3 = cat(1, {{11, 12}}, {{13, 14}}); + Real[3, 2] array4 = cat(1, {{7, 2}, {5, 42}}, {{24, 74}}); + Real[3, 2] array5 = cat(1, [7, 2; 5, 42], [24, 74]); + + Real[4, 2] array6 = cat(1, {{1, 2}, {11, 12}}, {{13, 14}, {3, 4}}); + Real[2,4] array7 = cat(2, {{1, 2}, {72, 51}}, {{35, 73}, {12, 23}}); +end ArrayConcatenation; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array1</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">array1 has the result {{22, 34, 15}, {66, 78, 52}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array2</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">array2 has the result {{22, 34, 15}, {66, 78, 52}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array3</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">array3 has the result {{11, 12}, {13, 14}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array4</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">array4 has the result {{7, 2}, {5, 42}, {24, 74}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array5</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">array5 has the result {{7, 2}, {5, 42}, {24, 74}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array6</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">array6 has the result {{1, 2}, {11, 12}, {13, 14}, {3, 4}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array7</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">array7 has the result {{1, 2, 35, 73}, {72, 51, 12, 23}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of ArrayConcatenation</p></body></html> + + + simulate( ArrayConcatenation ); //??Error - not yet implemented + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Using <span style=" font-family:Courier New;">cat</span></p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Now it is your turn to concatenate arrays using <span style=" font-family:Courier New;">cat</span>:<br /><br />Concatenate two 1x2-arrays along the first dimension.<br />Concatenate the arrays you just concatenated, but along the second dimension.<br />Concatenate one 2x3-array with a 2x1-array along the second dimension.<br />Concatenate two 2x2-arrays along the first dimension.<br /><br />What are the results of the array concatenations?<br /></p></body></html> + + + class MyArrayConcat + +end MyArrayConcat; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">These are examples of how you could concatenate the arrays in the exercise.</p></body></html> + + + class MyArrayConcat + Real[2, 2] myArray1 = cat(1, {{1, 2}}, {{11, 12}}); + Real[1, 4] myArray2 = cat(2, {{1, 2}}, {{11, 12}}); + + Real[2, 4] myArray3 = cat(2, [21, 32, 43; 66, 77, 55], [12; 24]); + Real[4, 2] myArray4 = cat(1, [10, 40; 55, 78], [20, 50; 31, 22]); +end MyArrayConcat; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">myArray1</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">myArray1 has the result {{1, 2}, {11, 12}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">myArray2</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">myArray2 has the result {{1, 2, 11, 12}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">myArray3</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">myArray3 has the result {{21, 32, 43, 12}, {66, 77, 55, 24}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">myArray4</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">myArray4 has the result {{10, 40}, {55, 78}, {20, 50}, {31, 22}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of</p></body></html> + + + simulate( MyArrayConcat ); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">More Dimensions</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The last thing you should do now is to concatenate three arrays with higher dimension. <br /><br />So, the arrays you should concatenate are of size 1x2x1, 1x2x2 and 1x2x3 and they should be concatenated along the first dimension. Do the concatenation in the class <span style=" font-family:Courier New;">MoreConcat</span> below.<br /><br />What is the result after the concatenations?<br /></p></body></html> + + + class MoreConcat + +end MoreConcat; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">This is an example of how you could concatenate the arrays in the exercise.</p></body></html> + + + class MoreConcat + Real[1, 2, 1] a1 = {{{1}, {2}}}; + Real[1, 2, 2] a2 = {{{3, 4}, {5, 6}}}; + Real[1, 2, 3] a3 = {{{7, 8, 9}, {10, 11, 12}}}; + Real[1, 2, 6] aReady; +equation + aReady = cat(3, a1, a2, a3); +end MoreConcat; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">aReady</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">aReady has the result {{1, 3, 4, 7, 8, 9}, {2, 5, 6, 10, 11, 12}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of MoreConcat</p></body></html> + + + simulate( MoreConcat ); //??Error - not yet implemented + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/Arrays/Exercise1-7-4.onb b/DrModelica/Arrays/Exercise1-7-4.onb new file mode 100644 index 00000000000..4fb9bb09910 --- /dev/null +++ b/DrModelica/Arrays/Exercise1-7-4.onb @@ -0,0 +1,279 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Array Indexing</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">In the class <span style=" font-family:Courier New;">ArrayIndexing</span> below you should first define a 2x3-array and set values to every position in the array. Also define a second array while you're at it, with the same size but with different values. The last thing you should do is to change a few values in each array. Then you're done!<br /><br />Oh, one more thing, what are the results after changing the values?<br /></p></body></html> + + + class ArrayIndexing + +end ArrayIndexing; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Tip</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">When you set the values in the arrays you can use the <span style=" font-family:Courier New;">fill</span> function to fill a whole array with a value. <span style=" font-family:Courier New;">fill(value, nrOfRows, nrOfColumns).</span></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class ArrayIndexing + Real array1[2, 3]; + Real array2[2, 3]; +algorithm + array1 := fill(1, 2, 3); + array2 := fill(1, 2, 3); + array1[1,1] := 10; + array1[2,1] := 23; + array2[2,1] := 100; + array2[2,2] := 100; + array2[2,3] := 100; +end ArrayIndexing; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array1</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">the result of array2 {{10, 1, 1}, {23, 1, 1}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array2</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">the result of array2 {{1, 1, 1}, {100, 100, 100}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of ArrayIndexing</p></body></html> + + + simulate( ArrayIndexing ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Type mismatch in assignment in {{array1[1,1],array1[1,2],array1[1,3]},{array1[2,1],array1[2,2],array1[2,3]}} := {{1,1,1},{1,1,1}} of Real[2, 3] := Integer[2, 3] +Error occured while flattening model ArrayIndexing +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Indexing with Scalar Expressions</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">In the class <span style=" font-family:Courier New;">ArrayIndexing2</span> below you should first define a 2x2-array and set values to every position in the array. Then define a second 2x4-array with different values. This time you should change a whole row in each array.<br /><br />What are the results after changing the values?<br /></p></body></html> + + + class ArrayIndexing2 + +end ArrayIndexing2; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class ArrayIndexing2 + Real array1[2, 2] = fill(9, 2, 2); + Real array2[2, 4] = fill(7, 2, 4); + + Real v1[2] = {2, 20}; + Real v2[4] = {6, 7, 8, 9}; + + Real array1[2] = v1; +end ArrayIndexing2; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of ArrayIndexing2</p></body></html> + + + simulate( ArrayIndexing2 ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Error duplicate elements (due to inherited elements) not identical, first element is: Real array1 = fill(9, 2, 2); +, second element is: Real array1 = v1; + +Error occured while flattening model ArrayIndexing2 +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array1</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">the result of array1 is {{9, 9}, {2, 20}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">array2</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">the result of array2 {{7, 7, 7, 7}, {6, 7, 8, 9}}</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Accessing Array Slices with Index Vectors</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is the result of the vectors v1, v2, v3, v4, v5, v6, v7, v8 and v9 below?</p></body></html> + + + class Slice + Real[3, 3] V = {{22, 14, 71}, {33, 41, 17}, {44, 11, 77}}; + Real[3, 2] W = {{12, 13}, {23, 88}, {99, 43}}; + Real[5] Y = {23, 24, 25, 26, 27}; + + Real v1[3] = V[:, 1]; + Real v2[3] = V[3, :]; + Real v3[1] = V[3, {2}]; + Real v4[3] = W[:, 2]; + + Real v5[2] = Y[{1, 2}]; + Real v6[2] = W[3, {1, 2}]; + Real v7[2] = V[3, 1:2]; + + Real v8[2] = Y[3:4]; + Real v9[3] = Y[1:2:5]; +end Slice; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v1</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v1 gets the value {22, 33, 44}.</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v2</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v2 gets the third row of V, i.e. the vector {44, 11, 77}.</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v3</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v3 gets the second element (in brackets) in the third row in V, i.e. {11}.</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v4</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v4 gets the second row of W, i.e. {13, 88, 43}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v5</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v5 gets the first and second elements of Y, i.e. {23, 24}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v6</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v6 gets the first and second elements on the third row of W, i.e. {99, 43}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v7</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v7 gets the first and second elements of the third row of V, i.e. {44, 11, 77}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v8</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v8 gets the 3:rd through 4:th elements of Y as {25, 26}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">v9</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">v9 gets the 1:st to 5:th elements step 2 elements as {23, 25, 27}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Slice</p></body></html> + + + simulate( Slice ) + record + resultFile = "Slice_res.plt" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + plot( v8[2] ) + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/52.png" width="492" height="250" /></span></p></body></html> + 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 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/53.png" width="288" height="214" /></span></p></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAEgAAAA1ggDAAAARuGvAgAAAwBQTFRFAAAAAAD/2dnZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqOCPfgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAyJJREFUeJzt3Y1S2kAYQNGV93/o/hAkG6Q3UVupnDNTTTUycPuRLV2djhN/NL76Djw6gYJAQaAgUBAoCBQECgIFgYJAQaAgUBAoCBQECgIFgYJAQaAgUNgfaIzz21/vz7/OH1k+MR99H7sf0jifO5aDsRyeLh8+dmv/j35I14k5nz8uX7YKNJZxep5AL4vllDFP0Gnd6uknaJmdzVPsdBPouSZoPmes3l6eUXOg189+O0cf0rh+xRTofbf2Hzgc6LK4W+b5TaAgUBAoCBQECgIFgYJAQaAgUBAoCBTuBNLtQqAgULgXSKGFCQoChWuJZevv5h/in9yYj8b1Pb+tJ+gk0K0xH78GUmix2gacAn3dPXowm6eYi/SWZT4IFLzUCCYoCBQECgIFgYJVLJigIFAQKAgUBApWsWCCgkBBoCBQcJEOJigIFNY/DWdv/g3rvXkbh2+wsxpWP0756/tf7M1v3fvmhS+6O49nukgPF+kblvkgUPBSI5igIFAQKAgUBApWsWCCgkBBoCBQEChYxYIJCgIFgYJAwUU6mKAgUPAjmcHWc7CzGsZ8aG9+y1MsuEgHy3wQKHipEUxQECgIFAQKAoU7JV6eyLsCmaALgYJAQaAgUPBaLJigIFAQKAgUXKSDCQoCBds+wcZhuLf1/EV35/GM+cje/NaYD0zQ1jWQ/3jkTZb5IFDwUiOYoCBQECgIFAQKVrFggoJAQaAgUBAoWMWCCQoCBYGCQMFFOpigIFCwNx9sPQeBwr1ACi1MUJj25oeL9A3LfBAoeKkRTFAQKAgUBAoCBatYMEFBoCBQECgIFKxiwQQFgYJAQaDgIh1MUBAoCLSxfeSfE+j7nL5sD+atjbfPOHj8d0//C196+9vbQONJrYIcnKBns/kbjkBBoCBQUCJ8MND6irbj9dt0Sp8/3/rB0/PO7DvxY4HWa+J2fYzTfx4dPP2T78zOG/68QDtu6wM99wzQ1HP3A/t3gQ7+GY98zB/p+YATtOOWNnf7kx/xIwZaf3t+T8Rp8938ef5860fuzO6nWA6yZT4IFAQKAgWBgkBBoCBQECgIFH4A9hvaWKU0KtoAAAAASUVORK5CYII= + + + + + + + diff --git a/DrModelica/Arrays/Exercise1-7-5.onb b/DrModelica/Arrays/Exercise1-7-5.onb new file mode 100644 index 00000000000..fbca6827d4d --- /dev/null +++ b/DrModelica/Arrays/Exercise1-7-5.onb @@ -0,0 +1,129 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Array Concatenation and More Slices</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Concatenate!</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Complete the class, <span style=" font-family:Courier New;">Concatenate</span>, like this:<br /><br />1) Create a new variable <span style=" font-family:Courier New;">V1</span> in which you append 60 to <span style=" font-family:Courier New;">A</span>.<br />2) Append 50 to <span style=" font-family:Courier New;">V1.</span><br />3) If you didn't use the <span style=" font-family:Courier New;">cat</span>-operator before, use this to append 60 to A.<br />4) Append the set of 60 to B.<br />5) If you didn't use the <span style=" font-family:Courier New;">cat</span>-operator before, use this to append 60 to B.<br />6) Append the set of 18 to v, using the <span style=" font-family:Courier New;">cat</span>-operator.<br /></p></body></html> + + + class Concatenate + Real[1, 2] A = [50, 32]; + Real[2, 1] B = [3; 7]; + Real[5] a = {4, 9, 7, 5, 2}; +end Concatenate; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Concatenate + Real[1, 2] A = [50, 32]; + Real[2, 1] B = [3; 7]; + Real[5] a = {4, 9, 7, 5, 2}; + + Real[1, 3] V1 = [A, 60]; + Real[1, 4] V2 = [V1, 50]; + Real[1, 3] V3 = cat(2, A, {{20}}); + Real[3, 1] V4 = [B; 60]; + Real[3, 1] V5 = cat(1, B, {{20}}); + Real[6] v = cat(1, a, {18}); +end Concatenate; + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Which are the results of your newly created variables?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;"> 1)</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"> The result is {50, 32, 60}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;"> 2)</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"> The result is {50, 32, 60, 50}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;"> 3)</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"> The result is {50, 32, 20}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;"> 4)</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The result is {{3}, {7}, {60}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;"> 5)</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The result is {{3}, {7}, {20}}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;"> 6)</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The result is {4, 9, 7, 5, 2, 18}</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Concatenate</p></body></html> + + + simulate( Concatenate ) + record + resultFile = "Concatenate_res.plt" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Take a look at some results:</p></body></html> + + + //??val needed to loock at variable values + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/Arrays/Exercise1-7-6.onb b/DrModelica/Arrays/Exercise1-7-6.onb new file mode 100644 index 00000000000..3aaa1cf6373 --- /dev/null +++ b/DrModelica/Arrays/Exercise1-7-6.onb @@ -0,0 +1,214 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1 - Arithmetic Array Operators </p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is this allowed? If no, why not? If yes, what is the result?</p></body></html> + + + class Add1 + Real A1[2] = {2, 3} + 1; +end Add1; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">No, elementwise operations for the combination of an array and a scalar operand are not defined for addition.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is this allowed? If no, why not? If yes, what is the result?</p></body></html> + + + class Sub5 + Real A5[3] = {3, 45, 6} - 5; +end Sub5; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">No, elementwise operations for the combination of an array and a scalar operand are not defined for subtraction.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is this allowed? If no, why not? If yes, what is the result?</p></body></html> + + + class Mult2 + Real A2[3] = {11, 14, 12} * 2; +end Mult2; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Oh yes! The result is {22, 28, 24}.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Matrix Multiplication</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a class that multiplies two matrices using the multiplication operator for matrices.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class MatrixMultiplication + Real M1[2, 3] = [2, 3, 4; 5, 6, 7]; + Real M2[3, 2] = [5, 6; 3, 2; 1, 7]; + Real prod[2, 2]; +equation + prod = M1*M2; +end MatrixMultiplication; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of MatrixMultiplication</p></body></html> + + + simulate( MatrixMultiplication ) + record + resultFile = "MatrixMultiplication_res.plt" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Take a look at a value:</p></body></html> + + + val(M1[1,2],0) //??val is needed + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is this allowed? If no,why not? If yes,what is the result?</p></body></html> + + + class MultMany + Real mult1 = {1, 1, 1, 1} * {1, 1, 1, 1}; + Real mult2[2] = {{2, 2}, {2, 2}} * {2, 2}; + Real mult3[2, 2] = {{1, 1}, {1, 1}} * {{2, 2}, {2, 2}}; + Real mult4[1] = {1, 3, 5, 7} * {{1}, {3}, {5}, {7}}; +end MultMany; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The result of mult1 is 4.<br />The result of mult1 is {8, 8}.<br />The result of mult1 is {{4, 4}, {4, 4}}.<br />The result of mult1 is {84}.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is this allowed? If yes, what is the result?</p></body></html> + + + class Div4 + Real A4[5] = {16, 14, 10, 18, 12} / 4; +end Div4; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Oh yes! The result is {4, 3.5, 2.5, 4.25, 3}.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is this allowed? If yes, what is the result?</p></body></html> + + + class Div7 + Real A4[5] = 7 / {16, 14, 10, 18, 12}; +end Div7; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">No. Elementwise operations for dividing a scalar operand with an array is not defined for division.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">How would you write {{1, 3}, {4, 5}}^2 in Modelica? Write the expression in a class. What is the result?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The result is {{13, 18}, {24, 37}}.</p></body></html> + + + class Exponent + Real m[2, 2]; +equation + m = {{1, 3}, {4, 5}} ^ 2; +end Exponent; + + + + + + + diff --git a/DrModelica/Arrays/Exercise1.onb b/DrModelica/Arrays/Exercise1.onb new file mode 100644 index 00000000000..3b3c0301bfb --- /dev/null +++ b/DrModelica/Arrays/Exercise1.onb @@ -0,0 +1,38 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Constructing Arrays</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create a record containing several vectors and matrices. It is your choice what types and values the variables should have.<br /> a vector with seven values,<br /> a matrix of four rows and two columns,<br /> a matrix of one row and five columns,<br /> two unspecified matrices<br /> and an empty matrix.<br /></p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + record Matrix + Real m1[7] = {17.1, 62.7, 7.5, 37.0, 25, 4.121, 12.333336}; + Integer m2[4, 2] = {{44, 5}, {2, 800}, {7, 23}, {2032, 77}}; + String[1, 5] m3 = {{"Magnus", "circle", "boy", "Marina", "Miranda"}}; + String m4[:]; + Boolean m5[:, 2]; + Boolean m6[0]; +end Matrix; + Ok + + + + + + diff --git a/DrModelica/Arrays/Exercise2.onb b/DrModelica/Arrays/Exercise2.onb new file mode 100644 index 00000000000..092a20a6977 --- /dev/null +++ b/DrModelica/Arrays/Exercise2.onb @@ -0,0 +1,51 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Expanded Type</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Consider the classes <span style=" font-family:Courier New;">Student</span>, <span style=" font-family:Courier New;">Class</span> and <span style=" font-family:Courier New;">GraduateClass</span> below. Which is the expanded type of <span style=" font-family:Courier New;">GraduateClass</span>?</p></body></html> + + + class Student + constant Real legs = 2; + constant Real arms = 2; + parameter Real nrOfBooks; + parameter String name = "Dummy"; +end Student; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + type Class = Student[35]; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class GraduateClass + Class[42] c; +end GraduateClass; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The expanded type is <span style=" font-family:Courier New;">Student</span>[42, 35].</p></body></html> + + + + + + diff --git a/DrModelica/Arrays/FlexSize.onb b/DrModelica/Arrays/FlexSize.onb new file mode 100644 index 00000000000..e5ed689f554 --- /dev/null +++ b/DrModelica/Arrays/FlexSize.onb @@ -0,0 +1,208 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Flexible Array Sizes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The possibility to declare arrays with unspecified dimension sizes is quite important in order to design flexible models that can adapt to different problem sizes. An unspecified dimension size is stated by using a colon (:) instead of the usual integer expression for dimension size. </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">The unspecified dimension sizes will eventually be determined when the array variable is bound to some value.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Unspecified Arrays</span></p></td></tr></table></body></html> + + + class Unspecified + Real[:, :] y; // A matrix with two unknown dimension sizes + Real[:, 3] y2; // A matrix where the number of columns is known + Real M[:, size(M, 1)]; // A square matrix of unknown size +end Unspecified; + + {Unspecified} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Let's specify the array sizes</span></p></td></tr></table></body></html> + + + class Specify + Unspecified unspec(y = fill(1, 3, 5), + y2 = fill(1, 5, 3), + M = fill(1, 2, 2)); +end Specify; + {Specify,Unspecified} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Unspecified</span></p></td></tr></table></body></html> + + + simulate( Specify ) + record SimulationResult + resultFile = "Specify_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + val(unspec.y2[5,3],0) + 1.0 + + + + + + plot(unspec.y2[5,3]) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">More on unspecified arrays</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Several arrays with unknown sizes can of course be declared in the same declaration:</span></p></td></tr></table></body></html> + + + class UnspecArr + Real[:] v1, v2; // Vectors v1 and v2 have unknown sizes +end UnspecArr; + {UnspecArr,Specify,Unspecified} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The actual size of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> need not be the same even though they are part of the same declaration, since the above declaration is equivalent to two separate declarations.</span></p></td></tr></table></body></html> + + + class UnspecArr2 + Real[:] v1; + Real[:] v2; +end UnspecArr2; + {UnspecArr2,UnspecArr,Specify,Unspecified} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Let's specify the array sizes</span></p></td></tr></table></body></html> + + + class Specify2 + UnspecArr unspecarr(v1 = {3, 7, 12}, + v2 = {2, 92}); +end Specify2; + {Specify2,UnspecArr2,UnspecArr,Specify,Unspecified} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Specify2</span></p></td></tr></table></body></html> + + + simulate( Specify2 ) + record SimulationResult + resultFile = "Specify2_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + val(unspecarr.v1[3],0) + 12.0 + + + + + + plot(unspecarr.v1[3]) + [done] + + + + + + diff --git a/DrModelica/Arrays/Indexing.onb b/DrModelica/Arrays/Indexing.onb new file mode 100644 index 00000000000..e1dfeda505b --- /dev/null +++ b/DrModelica/Arrays/Indexing.onb @@ -0,0 +1,378 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Array Indexing</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The indexing operator ....[....] takes two or more operands, where the first operand is the array to be indexed and the rest of the operands are index expressions. It is used to access array elements for retrieval of their values or for updating these values. In class ArrayIndex:<br /><br /></span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">arrayname[indexexpr1, indexexpr2, ......];</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">ArrayIndex Class</span></p></td></tr></table></body></html> + + + class ArrayIndex + Real[2, 2] A = {{2, 3}, {4, 5}}; // Definition of array A + Real A_Retrieval = A[2, 2]; // Retrieves the array element value 5 + Real B[2, 2]; + Real c; +algorithm + B := fill(1,2,2); // B will have the values {{1, 1}, {1, 1}} + B[2, 1] := 8; // Assignment to the array element B[2, 1] + c := A[1, 1]; +end ArrayIndex; + {ArrayIndex} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ArrayIndex</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here we simulate the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ArrayIndex</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> above.</span></p></td></tr></table></body></html> + + + simulate( ArrayIndex ) + record SimulationResult + messages = "", + simulationTime = 0.13258838241726173 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We see that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">B[2, 1]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> now has the value 8.</span></p></td></tr></table></body></html> + + + + + + + plot( { c, B[2,1] } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Indexing with Scalar Index Expressions </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Array indexing using scalar integer index expressions is usually used to retrieve or update single array elements. The value of the index expression for the i:th dimension of an array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">X</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> must be within the bounds of the size of that dimension, i.e. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">1 . Since multi-dimensional arrays are defined as arrays of arrays in Modelica, it is also possible to access sub-arrays using simple scalar indexing. For example, the array B can also be regarded as a one-dimensional array of vectors.<br /></span></p></td></tr></table></body></html> + + + class ScalarIndex + Real[2, 2] B = {{1, 2}, {4, 5}}; + Real[2] v = {10, 11}; + Real[4, 2] M; + + Real B_Ret1 = B[1, 2]; // Retrieves the value 2 + //Real B_Ret2[2] = B[2]; // Retrieves B[2] giving {4, 5} + + Real v_Ret1 = v[2]; // Retrieves the value 11 + // Real v_Ret2 = v[4]; // Error, index out of range! + +algorithm + M[4] := fill(5, 4, 2); + M[4] := v; // Updates M to become + // {{5, 5}, {5, 5}, {5, 5}, {10, 11}} +end ScalarIndex; + + {ScalarIndex} + + + simulate(ScalarIndex) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: ScalarIndex +[<interactive>:13:3-13:24:writable] Error: Type mismatch in assignment in M[4] := {{5, 5}, {5, 5}, {5, 5}, {5, 5}} of Real[2] := Integer[4, 2] +Error: Error occurred while flattening model ScalarIndex +" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Accessing Array Slices with Index Vectors </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When at least one of the index expressions in an array indexing operation is a vector expression, a subsection (slice) of the array is accessed rather than a single element. Such an index vector must be a vector of integer values, where each value must be within the size bounds for the particular array dimension. An index vector can be constructed in any way but it is often convenient to use the colon operator to construct a range vector of index values. A single colon without operands used as an index expression at a dimension k of an array of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">X</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> denotes all indices of that dimension and is equivalent to the index vector </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">1:size(X, k)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + class ArraySlice + Real x1 = X[2, 1]; // Retrieves the value 3 + Real x2[3] = X[:, 1]; // Gets the first column of X as the vector {1,3,8} + Real x3[2] = X[2, :]; // Gets the second row of X as the vector {3, 4} + Real x4[2] = X[2, 1:2]; // Same as above, i.e. {3, 4} + Real x5[2] = X[2, {1, 2}]; // Same as above, i.e. {3, 4} + Real x6[1] = X[2, {2}]; // Half of the above vector, i.e. {4} + Real x7[3, 1] = X[:, 1:1]; // Gets the first column of X as + // column matrix {{1}, {3}, {8}} + Real x8[1, 2] = X[{2}, :]; // Gets the second row of X as the row matrix {{3, 4}} + Real x9[2, 2] = X[{2, 3}, {1, 2}]; // Extract submatrix given {{3, 4}, {8, 9}} + + Real w1[3] = w[2:4]; // Get the 2:nd through 4:th elements as {16,17,18} + Real w2[2] = w[{1, 3}]; // Get the 1:st and 3:rd elements as {15, 17} + Real w3[2] = w[1:2:4]; // Get the 1:st to 4:th step 2 elements as {15,17} + + Real X[3, 2] = {{1, 2}, {3, 4}, {8, 9}}; + Real w[4] = {15, 16, 17, 18}; + Real[4] y = fill(1, 4); +algorithm + w[3:4] := {1, 2}; // Assignment causing w to become {15, 16, 1, 2} +end ArraySlice; + {ArraySlice,ScalarIndex} + + + simulate(ArraySlice) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: ArraySlice +Error: Too many equations, over-determined system. The model has 45 equation(s) and 41 variable(s). +" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Array Field Slices of Record Arrays </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is an array of records and m is a field of that record type, the expression </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A.m</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is interpreted as an array field slice operation of that record array. It returns the array of fields: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">{A[1].m, A[2].m, A[3].m, ...}</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. For example, given a record </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Person</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with three fields: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">name</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">age</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">children</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Record Person, Function mkperson and Class p</span></p></td></tr></table></body></html> + + + record Person + String name; + Integer age; + String[2] children; +end Person; + {Person} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We have defined a record constructor function: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">mkperson(name, age, children)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in Modelica returning a Person record, which is used to define the contents of a small array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">persons</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> consisting of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Person</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> records. </span></p></td></tr></table></body></html> + + + function mkperson + input String name; + input Integer age; + input String[2] children; + output Person p; +algorithm + p.name := name; + p.age := age; + p.children := children; +end mkperson; + {mkperson,Person} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Calling mkperson</span></p></td></tr></table></body></html> + + + mkperson("John",35,{"Carl","Eva"}) + record Person + name = "John", + age = 35, + children = {"Carl","Eva"} +end Person; +OMC-ERROR: +"Error: Class Person not found in scope mkperson. +[<interactive>:5:3-5:18:writable] Error: Class Person not found in scope mkperson while instantiating p. +" + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Classes PersonList and getPerson</span></p></td></tr></table></body></html> + + + class PersonList + Person[3] persons = {mkperson("John", 35, {"Carl", "Eva"} ), + mkperson("Karin", 40, {"Anders", "Dan"} ), + mkperson("Lisa", 37, {"John", "Daniel"} ) + }; +end PersonList; + {PersonList,mkperson,Person} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The field slices </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">persons.name,</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">persons.age and persons.children </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> give the following results:<br /></span></p></td></tr></table></body></html> + + + class getPerson + PersonList pList; + String name[3]; + Integer age[3]; + String[3, 2] children; +equation + name = pList.persons.name; // Returns: {"John", "Karin", "Lisa"} + age = pList.persons.age; // Returns: {35, 40, 37} + children = pList.persons.children; // Returns: {{"Carl", "Eva"}, + // {"Anders", "Dan"}, + // {"John", "Daniel"}} +end getPerson; + {getPerson,PersonList,mkperson,Person} + + + + + + diff --git a/DrModelica/Arrays/ScalarFunc.onb b/DrModelica/Arrays/ScalarFunc.onb new file mode 100644 index 00000000000..f4053f8f51b --- /dev/null +++ b/DrModelica/Arrays/ScalarFunc.onb @@ -0,0 +1,177 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Application of Scalar Functions to Arrays</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />It is possible to apply a function to array values if an obvious generalization to element-wise application of the function is possible. Modelica functions with one scalar return value can be applied to arrays element-wise, e.g. if </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a vector of reals, then </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sin(v)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a vector where each element is the result of applying the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to the corresponding element in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">One Return Value</span></p></td></tr></table></body></html> + + + class OneReturnValue + Real a = 1, b = 0, c = 1; + Real s1[3] = sin({a, b, c}); + // Vector argument, result: {sin(a), sin(b), sin(c)} + Real s2[2, 2] = sin([1, 2; 3, 4]); + // Matrix argument, result: [sin(1), sin(2); sin(3), sin(4)] +end OneReturnValue; + {OneReturnValue} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of OneReturnValue</span></p></td></tr></table></body></html> + + + simulate( OneReturnValue ) + record SimulationResult + resultFile = "OneReturnValue_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(s1[3],0) + 0.8414709848078965 + + + + + + + plot({s1[3],s2[1,2]}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Returning More Values</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Functions with more than one argument can be generalized to element-wise application. If more than one argument is generalized to an array, all of the arguments have to be of the same size, and they are traversed in parallel. This is the case in the example with the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">atan2(x, y)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below. <br /></span></p></td></tr></table></body></html> + Left + + + class SeveralArguments + Real a = 1, b = 0, c = 1, d = 0, e = 1, f = 0; + Real at[3] = atan2({a, b, c}, {d, e, f}); + // Result: {atan2(a, d), atan2(b, e), atan2(c, f)} +end SeveralArguments; + {SeveralArguments,OneReturnValue} + + + simulate(SeveralArguments) + record SimulationResult + resultFile = "SeveralArguments_res.mat", + messages = "" +end SimulationResult; + + + + + + + + plot({at[1],at[2],at[3]}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">SumVec</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Formal function parameters that are generalized to higher dimension arrays need not necessarily be scalars. For example, the function:<br /><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">atan2SumVec(v1, v2) = atan2(sum(v1), sum(v2))<br />                            <br /></span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">used below has two formal parameters </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real[:]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> computing </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">atan2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> on the sums of the argument vectors. Applying this function on a matrix which is a vector of vectors gives a result which is a vector. Calling this function with two matrices M1 and M2 as arguments gives the following result:    <br />            </span></p></td></tr></table></body></html> + + + class SumVec + Real[3] v1 = {1, 2, 3}; + Real[3] v2 = {6, 4, 5}; + Real[3] v3 = {3, 7, 6}; + Real[3] v4 = {1, 3, 8}; + Real[2, 3] M1 = {v1, v2}; + Real[2, 3] M2 = {v3, v4}; + + Real sv1[2] = atan2SumVec(M1, M2); + // atan2SumVec({v1, v2}, {v3, v4}) <=> {atan2(sum(v1), sum(v2)), atan2(sum(v3), sum(v4))} + + Real sv2[2] = atan2SumVec({{1, 2}, {3, 4}}, {{6, 7}, {8, 9}}); + // {atan2(sum({1, 2}), sum({3, 4})), atan2(sum({6, 7}), sum({8, 9}))} + // <=> {atan2(3, 7), atan2(13, 17) } +end SumVec; + {SumVec,SeveralArguments,OneReturnValue} + + + + + diff --git a/DrModelica/Arrays/TypeCheck.onb b/DrModelica/Arrays/TypeCheck.onb new file mode 100644 index 00000000000..eeccf8fe198 --- /dev/null +++ b/DrModelica/Arrays/TypeCheck.onb @@ -0,0 +1,358 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Array Types and Type Checking</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ColorPixel</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is possible to declare user-defined array types analogously to other user-defined types. For example, a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ColorPixel</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be defined as a three-element vector representing the three base colors, and a variable image declared as a matrix of such pixels.<br /><br />The expanded type of an array is the multidimensional array which is constructed by taking the first dimensions from the variable declaration and subsequent dimensions from the maximally expanded array element type of the declaration. Note that we are not using ColorPixel[512, 512] as in the book, because of the incredible amount of variables it would imply.<br /></span></p></td></tr></table></body></html> + + + type ColorPixel = Real[3]; + {ColorPixel} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class ColorPixelInst + ColorPixel[10, 10] image = fill(10, 10, 10, 3); +end ColorPixelInst; + {ColorPixelInst} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ColorPixelInst</span></p></td></tr></table></body></html> + + + simulate( ColorPixelInst ) + record SimulationResult + resultFile = "ColorPixelInst_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at the value at time=0:</span></p></td></tr></table></body></html> + + + val(image[1,6,3],0) + 10.0 + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Voltage and Current</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Consider the definition of the notion of the expanded type in the example below. The user-defined types </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Voltage</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Current</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are defined using type definitions.</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Pin</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is defined through the declaration of a connector. The type of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">i</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Voltage</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the expanded type of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">i</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This is not allowed in the current version of Modelica, so the simulation of this example won't work.</span></p></td></tr></table></body></html> + + + type MultiPin = Pin[5]; + {MultiPin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The type of p is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MultiPin[4]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, expanded type is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin[4, 5]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class MPInst + MultiPin[4] p; +end MPInst; + {MPInst} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Point</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The array variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">p1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">p2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have identical expanded types of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real[10,3]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which makes the two equations in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PointSum</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> correct.</span></p></td></tr></table></body></html> + + + type Point = Real[3]; + {Point} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class PointInst + Point[10] p1 = fill(8, 10, 3); + Real[10, 3] p2 = fill(16, 10, 3); + Real r[3] = p1[2, :]; // Equivalent to r[3] = p1[2] +//equation + //p2[5, :] = p1[2, :] + p1[4, :]; // Equivalent to p2[5] = p1[2] + p2[4] +end PointInst; + {PointInst} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class PointSum + extends PointInst(p2[5, :] = p1[2, :] + p1[4, :] ); + Real r[3] = p1[2, :]; // Equivalent to r[3] = p1[2] +//equation + //p2[5] = p1[2] + p2[4]; // Equivalent to p2[5, :] = p1[2, :] + p2[4, :] +end PointSum; + Error occurred building AST +Syntax Error +[<interactive>:2:23-2:23:writable] Error: Missing token: ')' + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of PointSum</span></p></td></tr></table></body></html> + + + simulate( PointInst ) + record SimulationResult + resultFile = "PointInst_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + simulate( PointSum ) + record SimulationResult + resultFile = "", + messages = "Simulation Failed. Model: PointSum does not exist! Please load it first before simulation." +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Circuits/Acausal.onb b/DrModelica/Circuits/Acausal.onb new file mode 100644 index 00000000000..02a145f80f2 --- /dev/null +++ b/DrModelica/Circuits/Acausal.onb @@ -0,0 +1,234 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Acausal Physical Modeling - Simple Circuit</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="407" height="318" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 1:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Connection diagram of the acausal simple circuit model.</span></p></td></tr></table></body></html> + Center + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + Center + Model1 + + + loadModel(Modelica) // Load if not already loaded + true + + + model SimpleCircuit + Modelica.Electrical.Analog.Basic.Resistor Resistor1; + Modelica.Electrical.Analog.Basic.Inductor Inductor1; + Modelica.Electrical.Analog.Basic.Ground Ground1; + Modelica.Electrical.Analog.Basic.Resistor Resistor2; + Modelica.Electrical.Analog.Basic.Capacitor Capacitor1; + Modelica.Electrical.Analog.Sources.SineVoltage SineVoltage1; + +equation + connect(SineVoltage1.p, Resistor2.p); + connect(Resistor1.n, Inductor1.p); + connect(Resistor2.n, Capacitor1.p); + connect(Inductor1.n, Ground1.p); + connect(Capacitor1.n, Ground1.p); + connect(Resistor1.p, Resistor2.p); + connect(SineVoltage1.n, Ground1.p); +end SimpleCircuit; + {SimpleCircuit} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now we take a look at the flattened model:</span></p></td></tr></table></body></html> + + + instantiateModel(SimpleCircuit) // Take a look at the flattened model - not needed but instructive + "class SimpleCircuit + Real Resistor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Resistor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Resistor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Resistor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Boolean Resistor1.useHeatPort = false \"=true, if HeatPort is enabled\"; + Real Resistor1.LossPower(quantity = \"Power\", unit = \"W\") \"Loss power leaving component via HeatPort\"; + Real Resistor1.T_heatPort(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) \"Temperature of HeatPort\"; + parameter Real Resistor1.R(quantity = \"Resistance\", unit = \"Ohm\", start = 1.0) \"Resistance at temperature T_ref\"; + parameter Real Resistor1.T_ref(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = 300.15 \"Reference temperature\"; + parameter Real Resistor1.alpha(quantity = \"LinearTemperatureCoefficient\", unit = \"1/K\") = 0.0 \"Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))\"; + Real Resistor1.R_actual(quantity = \"Resistance\", unit = \"Ohm\") \"Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))\"; + parameter Real Resistor1.T(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = Resistor1.T_ref \"Fixed device temperature if useHeatPort = false\"; + Real Inductor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Inductor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Inductor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Inductor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Inductor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Inductor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real Inductor1.L(quantity = \"Inductance\", unit = \"H\", start = 1.0) \"Inductance\"; + parameter Real Inductor1.IC(quantity = \"ElectricCurrent\", unit = \"A\") = 0.0 \"Initial Value\"; + parameter Boolean Inductor1.UIC = false; + Real Ground1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Ground1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Resistor2.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Resistor2.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Resistor2.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor2.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Resistor2.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor2.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Boolean Resistor2.useHeatPort = false \"=true, if HeatPort is enabled\"; + Real Resistor2.LossPower(quantity = \"Power\", unit = \"W\") \"Loss power leaving component via HeatPort\"; + Real Resistor2.T_heatPort(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) \"Temperature of HeatPort\"; + parameter Real Resistor2.R(quantity = \"Resistance\", unit = \"Ohm\", start = 1.0) \"Resistance at temperature T_ref\"; + parameter Real Resistor2.T_ref(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = 300.15 \"Reference temperature\"; + parameter Real Resistor2.alpha(quantity = \"LinearTemperatureCoefficient\", unit = \"1/K\") = 0.0 \"Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))\"; + Real Resistor2.R_actual(quantity = \"Resistance\", unit = \"Ohm\") \"Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))\"; + parameter Real Resistor2.T(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = Resistor2.T_ref \"Fixed device temperature if useHeatPort = false\"; + Real Capacitor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Capacitor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Capacitor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Capacitor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Capacitor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Capacitor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real Capacitor1.C(quantity = \"Capacitance\", unit = \"F\", min = 0.0, start = 1.0) \"Capacitance\"; + parameter Real Capacitor1.IC(quantity = \"ElectricPotential\", unit = \"V\") = 0.0 \"Initial Value\"; + parameter Boolean Capacitor1.UIC = false; + Real SineVoltage1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real SineVoltage1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real SineVoltage1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real SineVoltage1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real SineVoltage1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real SineVoltage1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real SineVoltage1.offset(quantity = \"ElectricPotential\", unit = \"V\") = 0.0 \"Voltage offset\"; + parameter Real SineVoltage1.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Time offset\"; + parameter Real SineVoltage1.V(quantity = \"ElectricPotential\", unit = \"V\", start = 1.0) \"Amplitude of sine wave\"; + parameter Real SineVoltage1.phase(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") = 0.0 \"Phase of sine wave\"; + parameter Real SineVoltage1.freqHz(quantity = \"Frequency\", unit = \"Hz\", start = 1.0) \"Frequency of sine wave\"; + output Real SineVoltage1.signalSource.y \"Connector of Real output signal\"; + parameter Real SineVoltage1.signalSource.amplitude = SineVoltage1.V \"Amplitude of sine wave\"; + parameter Real SineVoltage1.signalSource.freqHz(quantity = \"Frequency\", unit = \"Hz\", start = 1.0) = SineVoltage1.freqHz \"Frequency of sine wave\"; + parameter Real SineVoltage1.signalSource.phase(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") = SineVoltage1.phase \"Phase of sine wave\"; + parameter Real SineVoltage1.signalSource.offset = SineVoltage1.offset \"Offset of output signal\"; + parameter Real SineVoltage1.signalSource.startTime(quantity = \"Time\", unit = \"s\") = SineVoltage1.startTime \"Output = offset for time < startTime\"; + protected constant Real SineVoltage1.signalSource.pi = 3.141592653589793; +equation + assert(1.0 + Resistor1.alpha * (Resistor1.T_heatPort - Resistor1.T_ref) >= 0.000000000000001,\"Temperature outside scope of model!\"); + Resistor1.R_actual = Resistor1.R * (1.0 + Resistor1.alpha * (Resistor1.T_heatPort - Resistor1.T_ref)); + Resistor1.v = Resistor1.R_actual * Resistor1.i; + Resistor1.LossPower = Resistor1.v * Resistor1.i; + Resistor1.v = Resistor1.p.v - Resistor1.n.v; + 0.0 = Resistor1.p.i + Resistor1.n.i; + Resistor1.i = Resistor1.p.i; + Resistor1.T_heatPort = Resistor1.T; + Inductor1.L * der(Inductor1.i) = Inductor1.v; + Inductor1.v = Inductor1.p.v - Inductor1.n.v; + 0.0 = Inductor1.p.i + Inductor1.n.i; + Inductor1.i = Inductor1.p.i; + Ground1.p.v = 0.0; + assert(1.0 + Resistor2.alpha * (Resistor2.T_heatPort - Resistor2.T_ref) >= 0.000000000000001,\"Temperature outside scope of model!\"); + Resistor2.R_actual = Resistor2.R * (1.0 + Resistor2.alpha * (Resistor2.T_heatPort - Resistor2.T_ref)); + Resistor2.v = Resistor2.R_actual * Resistor2.i; + Resistor2.LossPower = Resistor2.v * Resistor2.i; + Resistor2.v = Resistor2.p.v - Resistor2.n.v; + 0.0 = Resistor2.p.i + Resistor2.n.i; + Resistor2.i = Resistor2.p.i; + Resistor2.T_heatPort = Resistor2.T; + Capacitor1.i = Capacitor1.C * der(Capacitor1.v); + Capacitor1.v = Capacitor1.p.v - Capacitor1.n.v; + 0.0 = Capacitor1.p.i + Capacitor1.n.i; + Capacitor1.i = Capacitor1.p.i; + SineVoltage1.signalSource.y = SineVoltage1.signalSource.offset + (if time < SineVoltage1.signalSource.startTime then 0.0 else SineVoltage1.signalSource.amplitude * sin(6.283185307179586 * SineVoltage1.signalSource.freqHz * (time - SineVoltage1.signalSource.startTime) + SineVoltage1.signalSource.phase)); + SineVoltage1.v = SineVoltage1.signalSource.y; + SineVoltage1.v = SineVoltage1.p.v - SineVoltage1.n.v; + 0.0 = SineVoltage1.p.i + SineVoltage1.n.i; + SineVoltage1.i = SineVoltage1.p.i; + Resistor1.p.i + Resistor2.p.i + SineVoltage1.p.i = 0.0; + Resistor1.n.i + Inductor1.p.i = 0.0; + Inductor1.n.i + Ground1.p.i + Capacitor1.n.i + SineVoltage1.n.i = 0.0; + Resistor2.n.i + Capacitor1.p.i = 0.0; + Resistor1.p.v = Resistor2.p.v; + Resistor1.p.v = SineVoltage1.p.v; + Inductor1.p.v = Resistor1.n.v; + Capacitor1.p.v = Resistor2.n.v; + Capacitor1.n.v = Ground1.p.v; + Capacitor1.n.v = Inductor1.n.v; + Capacitor1.n.v = SineVoltage1.n.v; +end SimpleCircuit; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it:</span></p></td></tr></table></body></html> + + + simulate(SimpleCircuit, startTime=0, stopTime=5) + record SimulationResult + messages = "", + simulationTime = 0.14603505380964357 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plot it:</span></p></td></tr></table></body></html> + + + + + + + plot({Resistor1.i,Resistor2.i}) + [done] + + + diff --git a/DrModelica/Circuits/DCmotor.onb b/DrModelica/Circuits/DCmotor.onb new file mode 100644 index 00000000000..d0e347bba49 --- /dev/null +++ b/DrModelica/Circuits/DCmotor.onb @@ -0,0 +1,208 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">DC Motor</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="505" height="297" /></p></td></tr></table></body></html> + Center + Model2 + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 1:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> DC Motor</span></p></td></tr></table></body></html> + Center + + + loadModel(Modelica) // Load if not already loaded + true + + + model DCMotor + Modelica.Electrical.Analog.Basic.Resistor Resistor1; + Modelica.Electrical.Analog.Basic.Inductor Inductor1; + Modelica.Electrical.Analog.Basic.EMF EMF1; + Modelica.Mechanics.Rotational.Components.Inertia Inertia1; + Modelica.Electrical.Analog.Basic.Ground Ground1; + Modelica.Electrical.Analog.Sources.ConstantVoltage ConstantVoltage1; + +equation + connect(Resistor1.n, Inductor1.p); + connect(Inductor1.n, EMF1.p); + connect(EMF1.flange, Inertia1.flange_a); + connect(EMF1.n, Ground1.p); + connect(ConstantVoltage1.n, Ground1.p); + connect(ConstantVoltage1.p, Resistor1.p); +end DCMotor; + {DCMotor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + instantiateModel(DCMotor) // Take a look at the flattened model - not needed + "class DCMotor + Real Resistor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Resistor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Resistor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Resistor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Boolean Resistor1.useHeatPort = false \"=true, if HeatPort is enabled\"; + Real Resistor1.LossPower(quantity = \"Power\", unit = \"W\") \"Loss power leaving component via HeatPort\"; + Real Resistor1.T_heatPort(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 0.0, start = 288.15, nominal = 300.0) \"Temperature of HeatPort\"; + parameter Real Resistor1.R(quantity = \"Resistance\", unit = \"Ohm\", start = 1.0) \"Resistance at temperature T_ref\"; + parameter Real Resistor1.T_ref(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 0.0, start = 288.15, nominal = 300.0) = 300.15 \"Reference temperature\"; + parameter Real Resistor1.alpha(quantity = \"LinearTemperatureCoefficient\", unit = \"1/K\") = 0.0 \"Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))\"; + Real Resistor1.R_actual(quantity = \"Resistance\", unit = \"Ohm\") \"Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))\"; + parameter Real Resistor1.T(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 0.0, start = 288.15, nominal = 300.0) = Resistor1.T_ref \"Fixed device temperature if useHeatPort = false\"; + Real Inductor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Inductor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Inductor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Inductor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Inductor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Inductor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real Inductor1.L(quantity = \"Inductance\", unit = \"H\", start = 1.0) \"Inductance\"; + parameter Real Inductor1.IC(quantity = \"ElectricCurrent\", unit = \"A\") = 0.0 \"Initial Value\"; + parameter Boolean Inductor1.UIC = false; + parameter Boolean EMF1.useSupport = false \"= true, if support flange enabled, otherwise implicitly grounded\"; + parameter Real EMF1.k(quantity = \"ElectricalTorqueConstant\", unit = \"N.m/A\", start = 1.0) \"Transformation coefficient\"; + Real EMF1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins\"; + Real EMF1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from positive to negative pin\"; + Real EMF1.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"Angle of shaft flange with respect to support (= flange.phi - support.phi)\"; + Real EMF1.w(quantity = \"AngularVelocity\", unit = \"rad/s\") \"Angular velocity of flange relative to support\"; + Real EMF1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real EMF1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real EMF1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real EMF1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real EMF1.flange.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"Absolute rotation angle of flange\"; + Real EMF1.flange.tau(quantity = \"Torque\", unit = \"N.m\") \"Cut torque in the flange\"; + parameter Real EMF1.fixed.phi0(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") = 0.0 \"Fixed offset angle of housing\"; + Real EMF1.fixed.flange.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"Absolute rotation angle of flange\"; + Real EMF1.fixed.flange.tau(quantity = \"Torque\", unit = \"N.m\") \"Cut torque in the flange\"; + input Real EMF1.internalSupport.tau(quantity = \"Torque\", unit = \"N.m\") = -EMF1.flange.tau \"External support torque (must be computed via torque balance in model where InternalSupport is used; = flange.tau)\"; + Real EMF1.internalSupport.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"External support angle (= flange.phi)\"; + Real EMF1.internalSupport.flange.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"Absolute rotation angle of flange\"; + Real EMF1.internalSupport.flange.tau(quantity = \"Torque\", unit = \"N.m\") \"Cut torque in the flange\"; + Real Inertia1.flange_a.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"Absolute rotation angle of flange\"; + Real Inertia1.flange_a.tau(quantity = \"Torque\", unit = \"N.m\") \"Cut torque in the flange\"; + Real Inertia1.flange_b.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"Absolute rotation angle of flange\"; + Real Inertia1.flange_b.tau(quantity = \"Torque\", unit = \"N.m\") \"Cut torque in the flange\"; + parameter Real Inertia1.J(quantity = \"MomentOfInertia\", unit = \"kg.m2\", min = 0.0, start = 1.0) \"Moment of inertia\"; + parameter enumeration(never, avoid, default, prefer, always) Inertia1.stateSelect = StateSelect.default \"Priority to use phi and w as states\"; + Real Inertia1.a(quantity = \"AngularAcceleration\", unit = \"rad/s2\") \"Absolute angular acceleration of component (= der(w))\"; + Real Inertia1.phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\", StateSelect = StateSelect.default) \"Absolute rotation angle of component\"; + Real Inertia1.w(quantity = \"AngularVelocity\", unit = \"rad/s\", StateSelect = StateSelect.default) \"Absolute angular velocity of component (= der(phi))\"; + Real Ground1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Ground1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real ConstantVoltage1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real ConstantVoltage1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real ConstantVoltage1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real ConstantVoltage1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real ConstantVoltage1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real ConstantVoltage1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real ConstantVoltage1.V(quantity = \"ElectricPotential\", unit = \"V\", start = 1.0) \"Value of constant voltage\"; +equation + assert(1.0 + Resistor1.alpha * (Resistor1.T_heatPort - Resistor1.T_ref) >= 0.000000000000001,\"Temperature outside scope of model!\"); + Resistor1.R_actual = Resistor1.R * (1.0 + Resistor1.alpha * (Resistor1.T_heatPort - Resistor1.T_ref)); + Resistor1.v = Resistor1.R_actual * Resistor1.i; + Resistor1.LossPower = Resistor1.v * Resistor1.i; + Resistor1.v = Resistor1.p.v - Resistor1.n.v; + 0.0 = Resistor1.p.i + Resistor1.n.i; + Resistor1.i = Resistor1.p.i; + Resistor1.T_heatPort = Resistor1.T; + Inductor1.L * der(Inductor1.i) = Inductor1.v; + Inductor1.v = Inductor1.p.v - Inductor1.n.v; + 0.0 = Inductor1.p.i + Inductor1.n.i; + Inductor1.i = Inductor1.p.i; + EMF1.fixed.flange.phi = EMF1.fixed.phi0; + EMF1.internalSupport.flange.tau = EMF1.internalSupport.tau; + EMF1.internalSupport.flange.phi = EMF1.internalSupport.phi; + EMF1.v = EMF1.p.v - EMF1.n.v; + 0.0 = EMF1.p.i + EMF1.n.i; + EMF1.i = EMF1.p.i; + EMF1.phi = EMF1.flange.phi - EMF1.internalSupport.phi; + EMF1.w = der(EMF1.phi); + EMF1.k * EMF1.w = EMF1.v; + EMF1.flange.tau = (-EMF1.k) * EMF1.i; + Inertia1.phi = Inertia1.flange_a.phi; + Inertia1.phi = Inertia1.flange_b.phi; + Inertia1.w = der(Inertia1.phi); + Inertia1.a = der(Inertia1.w); + Inertia1.J * Inertia1.a = Inertia1.flange_a.tau + Inertia1.flange_b.tau; + Ground1.p.v = 0.0; + ConstantVoltage1.v = ConstantVoltage1.V; + ConstantVoltage1.v = ConstantVoltage1.p.v - ConstantVoltage1.n.v; + 0.0 = ConstantVoltage1.p.i + ConstantVoltage1.n.i; + ConstantVoltage1.i = ConstantVoltage1.p.i; + Resistor1.p.i + ConstantVoltage1.p.i = 0.0; + Resistor1.n.i + Inductor1.p.i = 0.0; + Inductor1.n.i + EMF1.p.i = 0.0; + EMF1.n.i + Ground1.p.i + ConstantVoltage1.n.i = 0.0; + EMF1.flange.tau + Inertia1.flange_a.tau = 0.0; + EMF1.fixed.flange.tau + EMF1.internalSupport.flange.tau = 0.0; + EMF1.fixed.flange.phi = EMF1.internalSupport.flange.phi; + Inertia1.flange_b.tau = 0.0; + Inductor1.p.v = Resistor1.n.v; + EMF1.p.v = Inductor1.n.v; + EMF1.flange.phi = Inertia1.flange_a.phi; + ConstantVoltage1.n.v = EMF1.n.v; + ConstantVoltage1.n.v = Ground1.p.v; + ConstantVoltage1.p.v = Resistor1.p.v; +end DCMotor; +" + + + simulate(DCMotor, startTime=0, stopTime=25) + record SimulationResult + messages = "", + simulationTime = 0.1548192243237387 +end SimulationResult; + + + + + + plot(Inertia1.flange_a.tau) + [done] + + + + + + plot(Inertia1.flange_a.phi) + [done] + + + + diff --git a/DrModelica/Classes/CreateInst.onb b/DrModelica/Classes/CreateInst.onb new file mode 100644 index 00000000000..bc251fae2e8 --- /dev/null +++ b/DrModelica/Classes/CreateInst.onb @@ -0,0 +1,169 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Creating Instances</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A class decleration creates a type name which makes it possible to declare variables of that type, also known as an instance of the class. First we declare the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class Point "Point in a three-dimensional space" + public + parameter Real x; + parameter Real y; + parameter Real z; +end Point; + {Point} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />To create new instances the &quot;new&quot; keyword is not used as is common in object-oriented programming languages, since it does not exist in Modelica. In </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPoints</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> three instances of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are created.</span></p></td></tr></table></body></html> + + + class MyPoints + Point point1(x = 1, y = 2, z = 3); + Point point2; + Point point3; +end MyPoints; + {MyPoints} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPointsInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> creates three new </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Points</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> by instantiating </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPoints</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. There are two different ways to give the variables initial values when creating the instance as shown in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPointsInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPointsInst2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class MyPointsInst + MyPoints pts(point1(x= 1, y = 2, z = 3)); +end MyPointsInst; + {MyPointsInst} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MyPointsInst2 + MyPoints pts(point1.x = 1, point1.y = 2, point1.z = 3); +end MyPointsInst2; + {MyPointsInst2} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of MyPoints</span></p></td></tr></table></body></html> + + + simulate( MyPoints ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + simulate( MyPointsInst ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + simulate(MyPointsInst2) + record SimulationResult + messages = "", + simulationTime = 0.3633998592905796 +end SimulationResult; + + + + + + + + plot({point1.x, point1.y,point1.z}) + [done] + + + simulate(MyPoints) + record SimulationResult + messages = "", + simulationTime = 0.14615155335794341 +end SimulationResult; + + + + + + + + plot({point1.x, point1.y,point1.z}) + + [done] + + + + diff --git a/DrModelica/Classes/Exercise1.onb b/DrModelica/Classes/Exercise1.onb new file mode 100644 index 00000000000..9b56133c60c --- /dev/null +++ b/DrModelica/Classes/Exercise1.onb @@ -0,0 +1,81 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1 - Classes</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating a Class</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create a class, <span style=" font-family:Courier New;">Multiply</span>, that calculates the product of two variables, which are <span style=" font-family:Courier New;">Real</span> numbers with given values. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Make the previous class into a model.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Multiply + parameter Real x = 2; + parameter Real y = 3; + Real product; +equation + product = x*y; +end Multiply; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Multiply</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">We simulate Multiply in the interval {0, 1}, since we see that both x, y and product will get constant values. Then we can plot these variables.</p></body></html> + + + simulate( Multiply ); + [done] + + + plot(product) + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/27.png" width="492" height="250" /></span></p></body></html> + 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 + + + plot(x) //??Error - for some reason plotting does not work on parameters + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;">[Error] Unable to find plot image "C:/OpenModelica1.4.3/bin/omc_tmp_plot.png"</p></body></html> + + + plot(product) + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/28.png" width="492" height="250" /></span></p></body></html> + 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 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + plot( {x,y,product} ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;">[Error] Unable to find plot image "C:/OpenModelica1.4.3/bin/omc_tmp_plot.png"</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/29.png" width="288" height="214" /></span></p></body></html> + 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 + + + + + + + diff --git a/DrModelica/Classes/Exercise2.onb b/DrModelica/Classes/Exercise2.onb new file mode 100644 index 00000000000..37662b342c7 --- /dev/null +++ b/DrModelica/Classes/Exercise2.onb @@ -0,0 +1,108 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2 - Function Call</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating a Function and Making a Function Call</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a function, <span style=" font-family:Courier New;">AddTen</span>, that returns the input number plus the Integer 10. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Make a function call to AddTen with the input 3.5.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Try calling your function by writing <span style=" font-weight:600;">"AddTen(number)"</span> as shown below. </p></body></html> + + + AddTen(3.5) + 13.5 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + AddTen(5) + 15.0 + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + function AddTen + input Real x; + output Real result; +algorithm + result := x + 10; +end AddTen; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class AddTenCall + Real res; +equation + res = AddTen(3.5); +end AddTenCall; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Call AddTen directly</p></body></html> + + + AddTen(3.5) + 13.5 + + + AddTen(5) + 15.0 + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of AddTenCall</p></body></html> + + + simulate( AddTenCall ) + record + resultFile = "AddTenCall_res.plt" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Get the value of res at time=0, after which we plot the variable.</p></body></html> + + + val(res,0) //??val needed + + + + plot( res ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/30.png" width="492" height="250" /></span></p></body></html> + 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 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/31.png" width="288" height="214" /></span></p></body></html> + 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 + + + + + + + diff --git a/DrModelica/Classes/Exercise3.onb b/DrModelica/Classes/Exercise3.onb new file mode 100644 index 00000000000..fd0d3b79e90 --- /dev/null +++ b/DrModelica/Classes/Exercise3.onb @@ -0,0 +1,62 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 3 - Local Classes</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating a Local Class</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create a class, <span style=" font-family:Courier New;">Addition</span>, and define the class Add below as a local class in Addition.</p></body></html> + + + class Add + Real x = 1; + Real y = 2; + Real z; +equation + x + y = z; +end Add; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Addition + + class Add + Real x = 1; + Real y = 2; + Real z; + equation + x + y = z; + end Add; + +end Addition; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Addition</p></body></html> + + + simulate( Addition ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/Classes/Exercise4.onb b/DrModelica/Classes/Exercise4.onb new file mode 100644 index 00000000000..05bc6c6e6ed --- /dev/null +++ b/DrModelica/Classes/Exercise4.onb @@ -0,0 +1,106 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 4 - Instances</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating Instances</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Consider the class <span style=" font-family:Courier New;">Student</span> below.</p></body></html> + + + class Student + constant Real legs = 2; + constant Real arms = 2; + parameter Real nrOfBooks; + parameter String name = "Dummy"; +end Student; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Create an instance of the class <span style=" font-family:Courier New;">Student</span>. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Create another instance and give the student the name "Alice", who has 65 books.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />You also want to create a student called "Burt" with 32 books.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class StudentInst + Student s; +end StudentInst; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class StudentAlice + Student stud(name = "Alice", nrOfBooks = 65); +end StudentAlice; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class StudentBurt + Student stud(name = "Burt", nrOfBooks = 32); +end StudentBurt; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Student, StudentAlice and StudentBurt</p></body></html> + + + simulate( StudentInst ); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + simulate( StudentAlice ); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + simulate( StudentBurt ); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/Classes/Nested.onb b/DrModelica/Classes/Nested.onb new file mode 100644 index 00000000000..d5caf608d65 --- /dev/null +++ b/DrModelica/Classes/Nested.onb @@ -0,0 +1,278 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Local Classes </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In Modelica it is possible to defin</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">e</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> local classes nested inside a class, like </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Lpin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below. </span></p></td></tr></table></body></html> + + + class C1 + class Lpin // Local class + Real p; + end Lpin; + + //class Voltage = Real(unit="kV"); //this works in Dymola but not it OM + type Voltage = Real(unit="kV"); // This is an alternative + + Voltage v1 = 5, v2 = 1; + Lpin pn(p = 2); +end C1; + + {C1} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of C1</span></p></td></tr></table></body></html> + + + simulate( C1 ) + record SimulationResult + messages = "", + simulationTime = 0.12012690977842483 +end SimulationResult; + + + + + + plot({v1}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Classes That Contain Local Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Local classes are considered as elements of the type of the class within which they are declared. The &quot;</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">field name</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">&quot; of such a local class is the class name, and the type is the type representation of the local class as a set of pairs according to our general type representation.<br /></span></p></td></tr></table></body></html> + + + class Main + constant Real x = 3.14; // constant variable (class field) x + + class LocalClass1 // Local class + Integer x; + equation + x = 2; // Refers to local x inside LocalClass1 + end LocalClass1; + + class LocalClass2 // Local class + Real y; + equation + x = y; // Refers to x in Main + end LocalClass2; + + LocalClass1 L1x; // field L1x, instance of LocalClass1 + LocalClass2 L2x; // field L2x, instance of LocalClass2 + +end Main; + {Main} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Main</span></p></td></tr></table></body></html> + + + simulate( Main ) + record SimulationResult + messages = "", + simulationTime = 0.21496645227849906 +end SimulationResult; + + + + + + + plot({L1x.x, L2x.y}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Alternative to Local Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The local classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LocalClass1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LocalClass2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> could be moved outside the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Main</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with some changes of names. </span></p></td></tr></table></body></html> + + + class Main_LocalClass1 // Hypothetical LocalClass1 outside Main + Integer x; +equation + x = 2; // Refers to local x inside Main_LocalClass1 +end Main_LocalClass1; + {Main_LocalClass1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Main_LocalClass2 // Hypothetical LocalClass2 outside Main + Real y; + Main main; +equation + main.x = y; // Refers to x in the main instance of Main +end Main_LocalClass2; + {Main_LocalClass2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Main2 // Hypothetical Main referrring to + // outside LocalClass1 and LocalClass2 + Real x; // class field x + Main_LocalClass1 L1x; // field L1x, instance of Main_LocalClass1 + Main_LocalClass2 L2x; // field L2x, instance of Main_LocalClass2 +equation + x = 3.14; +end Main2; + {Main2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Main2</span></p></td></tr></table></body></html> + + + simulate( Main2 ) + record SimulationResult + messages = "", + simulationTime = 0.10712796968184933 +end SimulationResult; + + + + + + + plot({L1x.x, L2x.y}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Classes/Partial.onb b/DrModelica/Classes/Partial.onb new file mode 100644 index 00000000000..4b91e72e186 --- /dev/null +++ b/DrModelica/Classes/Partial.onb @@ -0,0 +1,371 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Partial Classes Describe Common Properties</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Types from Modelica.SIunits</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">TwoPin</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class prefix </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">partial</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used to indicate that a class is incomplete such that it cannot be instatiated. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoPin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be used to define our own </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Capacitor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Inductor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, Voltage source AC and Ground classes.<br /></span></p></td></tr></table></body></html> + + + partial class TwoPin "Superclass of elements with two electrical pins" + Pin p, n; + Voltage v; + Current i; +equation + v = p.v - n.v; + p.i + n.i = 0; + i = p.i; +end TwoPin; + {TwoPin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Resistor</span></p></td></tr></table></body></html> + + + class Resistor "Ideal electrical Resistor" + extends TwoPin; + parameter Real R(unit = "Ohm") "Resistance"; +equation + R*i = v; +end Resistor; + {Resistor} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Capacitor</span></p></td></tr></table></body></html> + + + class Capacitor "Ideal electrical Capacitor" + extends TwoPin; + parameter Real C(unit = "F") "Capacitance"; +equation + C*der(v) = i; +end Capacitor; + {Capacitor} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Inductor</span></p></td></tr></table></body></html> + + + class Inductor "Ideal electrical Inductor" + extends TwoPin; + parameter Real L(unit = "H") "Inductance"; +equation + v = L*der(i); +end Inductor; + {Inductor} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">VsourceAC</span></p></td></tr></table></body></html> + + + class VsourceAC "Sin-wave voltage source" + extends TwoPin; + parameter Voltage VA = 220 "Amplitude"; + parameter Real f(unit = "Hz") = 50 "Frequency"; + constant Real PI = 3.141592653589793; + input Voltage u; +equation + v = u; + u = VA*sin(2*PI*f*time); +end VsourceAC; + {VsourceAC} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Ground</span></p></td></tr></table></body></html> + + + class Ground + Pin p; +equation + p.v = 0; +end Ground; + {Ground} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">SimpleCircuit</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Based on these classes we can declare the Simple Circuit Model: </span></p></td></tr></table></body></html> + + + class SimpleCircuit + Resistor R1(R = 10); + Capacitor C(C = 0.01, v(fixed = true)); + Resistor R2(R = 100); + Inductor L(L = 0.1, i(fixed = true)); + VsourceAC AC(f = 1); + Ground G; +equation + connect(AC.p, R1.p); // 1, Capacitor circuit + connect(R1.n, C.p); // Wire 2 + connect(C.n, AC.n); // Wire 3 + connect(R1.p, R2.p); // 2, Inductor circuit + connect(R2.n, L.p); // Wire 5 + connect(L.n, C.n); // Wire 6 + connect(AC.n, G.p); // 7, Ground +end SimpleCircuit; + {SimpleCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">SimpleCircuit Simulation</span></p></td></tr></table></body></html> + + + simulate( SimpleCircuit ) + record SimulationResult + resultFile = "SimpleCircuit_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( {R1.v, R2.v } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( {R1.i,R2.i} ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Classes/Restricted.onb b/DrModelica/Classes/Restricted.onb new file mode 100644 index 00000000000..5a20f8d0119 --- /dev/null +++ b/DrModelica/Classes/Restricted.onb @@ -0,0 +1,478 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Restricted Classes</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> concept is fundamental to Modelica, almost anything in Modelica is a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Special keywords, replacing the word </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, are used for different purposes, not changing the syntax of the structure. The keywords </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">model, connector, record, block</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have some restrictions compared to the class keyword and they can be used in specific cases.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">model</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> keyword is used for modeling purposes. The only restriction is that a</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> model</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> may not be used in connections.</span></p></td></tr></table></body></html> + + + model SimpleCar + Wheel w1, w2, w3, w4 "Four wheels"; + Chassis chassis; +end SimpleCar; + {SimpleCar} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Record</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">record</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a class for specifying a record data structure. Equations are not allowed in a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">record</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> at all and a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">record</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> may not be used in a connection.</span></p></td></tr></table></body></html> + + + record person + Real age; + String name; +end person; + {person} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Type</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The restricted class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is often used to introduce new type names. A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> may be an extension to either a predefined type (e.g. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Integer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">), a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">record</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or some kind of array.</span></p></td></tr></table></body></html> + + + type Matrix = Real[3, 3]; + {Matrix} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connector</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Connector</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> classes are used for communication between objects. No equations are allowed at all in a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connector</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class. Instances of connector classes form the interface of a component (how it connects to the outer world).</span></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Block</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">block</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a class for which the data flow direction is known for each of its variables. All variables declared in a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">block</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> must have one of the prefixes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">input</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">output</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">block</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> may not be used in connections. </span></p></td></tr></table></body></html> + + + block Multiply + input Real x; + input Real y(start=0); + output Real result; +equation + result = x*y; +end Multiply; + {Multiply} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Function</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">function</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> concept in Modelica corresponds to mathematical functions without external side effects. These are the restrictions of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">function</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Each formal parameter of the function must be prefixed by either input or output and be public and non-constant. </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A function may not be used in connections, may have no equations, and can have at most one algorithm.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">For a function to be called, it must either have an algorithm or an external function interface as its body.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A function cannot contain calls to the Modelica built-in operators, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">der, initial, terminal, sample, pre, edge, change, reinit, delay, cardinality, </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">and is not allowed to contain when-statements.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A subtype of a function type needs to be equivalent to the function type itself.</span></p></td></tr></table></body></html> + Left + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The size of each array result or array local variable of a function must either be given by the formal parameters, or given by constant or parameter expressions.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Multiply Function Example</span></p></td></tr></table></body></html> + + + function multiply + input Real x; + input Real y := 0; + output Real result; +algorithm + result := x*y; +end multiply; + {multiply} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">multiply</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be called from within a class:</span></p></td></tr></table></body></html> + + + class MultCall + Real res; +equation + res = multiply(3.5, 2.0); // Function call +end MultCall; + {MultCall} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Calling multiply</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The function multiply can also be called directly: </span></p></td></tr></table></body></html> + + + multiply(2.0, 5.0) + 10.0 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">MultCall2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The second argument can be left out, since the default value is available for this argument.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The function multiply can also be called directly: </span></p></td></tr></table></body></html> + + + class MultCall2 + Real res; +equation + res = multiply(x = 5); +end MultCall2; + {MultCall2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate MultCall2:</span></p></td></tr></table></body></html> + + + simulate(MultCall2) + record SimulationResult + messages = "", + simulationTime = 0.12892363159355436 +end SimulationResult; + + + + + + plot(res) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The function multiply can also be called directly with named arguments: </span></p></td></tr></table></body></html> + + + multiply(x=5.0) + 0.0 + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Package</span></p></td></tr></table></body></html> + Package + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">What is a Package?</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The definitions in a package should be related in some way, which is the main reason they are placed in a particular package. Parameters and variables cannot be declared in a package.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">package</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a restricted and enhanced class that is primarily used to manage name spaces and organize Modelica code. A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">package</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has the restrictions of only containing declarations of classes including all kinds of restricted classes and constants, i.e. no variable declarations. Also a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">package</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has the enhancement of being allowed to import from. </span></p></td></tr></table></body></html> + + + package SmallPack + + constant Real mypi = 3.14159; + + connector Pin + Voltage v; + flow Current i; + end Pin; + + function multiply + input Real x; + input Real y = 0; + output Real result; + algorithm + result := x*y; + end multiply; + +end SmallPack; + + + + + + + + diff --git a/DrModelica/Classes/ReuseMod.onb b/DrModelica/Classes/ReuseMod.onb new file mode 100644 index 00000000000..0d5e4f7971d --- /dev/null +++ b/DrModelica/Classes/ReuseMod.onb @@ -0,0 +1,141 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Reuse of Modified Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The class concept is the key to reusing modeling knowledge in Modelica. Assume that we would like to connect two filter models in series. Instead of creating two separate filter classes it is better to define a common filter class and create two instances of this class, which are connected. <br /></span></p></td></tr></table></body></html> + + + model LowPassFilter + parameter Real T = 1; + Real u, y(start = 1,fixed=true); +equation + T*der(y) + y = u; +end LowPassFilter; + {LowPassFilter} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class can be used to create two separate instances of the filter and connect them by using the equation </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">F2.u = F1.y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model FiltersInSeries + LowPassFilter F1(T = 2), F2(T = 3); +equation + F1.u = sin(time); + F2.u = F1.y; +end FiltersInSeries; + {FiltersInSeries} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FiltersInSeries</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be used to declare variables at a higher hierarchical level.</span></p></td></tr></table></body></html> + + + model ModifiedFiltersInSeries + FiltersInSeries F12(F1(T = 6), F2.T = 11); +end ModifiedFiltersInSeries; + {ModifiedFiltersInSeries} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of FiltersInSeries and ModifiedFiltersInSeries</span></p></td></tr></table></body></html> + + + simulate( FiltersInSeries ) + record SimulationResult + resultFile = "FiltersInSeries_res.mat", + messages = "" +end SimulationResult; + + + + + + + plot({F2.u,F1.u}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + simulate( ModifiedFiltersInSeries ) + record SimulationResult + messages = "", + simulationTime = 0.14929460145834791 +end SimulationResult; + + + + + + + plot({F12.F1.T,F12.F1.u}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Classes/Short.onb b/DrModelica/Classes/Short.onb new file mode 100644 index 00000000000..02c80a446f4 --- /dev/null +++ b/DrModelica/Classes/Short.onb @@ -0,0 +1,103 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Short Class Definition</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />There is a short syntax for defining classes, commonly used to introduce more informative type names for existing classes.</span></p></td></tr></table></body></html> + + + type Voltage = Real(Unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The same thing can be written using the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> instead:</span></p></td></tr></table></body></html> + + + type Voltage = Real; + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The short class definition is the only way to introduce a &quot;class&quot; name for an array type:</span></p></td></tr></table></body></html> + + + type Matrix10 = Real [10, 10]; + {Matrix10} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A short class definition is in most cases just a shorter syntax for defining a class that could just as well be defined using the standard inheritance syntax:</span></p></td></tr></table></body></html> + + + type Voltage + extends Real(unit = "V", min = -220.0, max = 220.0); +end Voltage; + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Which is just the same as this:</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V", min = -220.0, max = 220.0); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Writing array types is done this short way:</span></p></td></tr></table></body></html> + + + type Force3 = Real[3](unit={"N","N","N"}); + {Force3} + + + + diff --git a/DrModelica/CompConn/CardEq.onb b/DrModelica/CompConn/CardEq.onb new file mode 100644 index 00000000000..6edc830db82 --- /dev/null +++ b/DrModelica/CompConn/CardEq.onb @@ -0,0 +1,136 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Cardinality Dependent Connection Equations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">CardinalityResistor</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In certain cases there is a need to let the behavior of a model be dependent on the number of connections to certain connectors of the model. Below is an example class containing a conditional if-clause equation with a condition that is a parameter expression (the built-in function cardinality has parameter variability), i.e.the condition does not change during simulation. The function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">cardinality</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">(</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">c</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">) with formal parameter </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">c</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> returns the total number of (internal and external) occurrences of the connector </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">c</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> statements in the total model.<br /></span></p></td></tr></table></body></html> + + + model CardinalityResistor + extends Modelica.Electrical.Analog.Interfaces.OnePort; + parameter Real R(unit = "Ohm") "Resistance"; +equation + + // Handle cases if pins are not connected + if cardinality(p) == 0 and cardinality(n) == 0 then + p.v = 0; + n.v = 0; + elseif cardinality(p) == 0 then + p.i = 0; + elseif cardinality(n) == 0 then + n.i = 0; + end if; + + // Resistor equation + v = R * i; +end CardinalityResistor; + {CardinalityResistor} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of CardinalityResistor </span></p></td></tr></table></body></html> + + + model circuit + CardinalityResistor R1( R=100 ); + Modelica.Electrical.Analog.Basic.Ground Gnd; + Modelica.Electrical.Analog.Sources.SineVoltage U1(freqHz = 5, V = 110); +equation + connect( R1.n, U1.n ); + connect( R1.p, Gnd.p ); + connect( U1.p, Gnd.p ); +end circuit; + {circuit} + + + loadModel(Modelica); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it!</span></p></td></tr></table></body></html> + + + simulate( circuit ) + record SimulationResult + messages = "", + simulationTime = 0.3041442553857649 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( R1.v ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/CompConn/ConnConstraints.onb b/DrModelica/CompConn/ConnConstraints.onb new file mode 100644 index 00000000000..cabac36642b --- /dev/null +++ b/DrModelica/CompConn/ConnConstraints.onb @@ -0,0 +1,114 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Connection Constraints regarding Arrays, Subscripts and Constants</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Array Dimensionality Matching</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The rule that connected connectors must have equivalent type is less strict concerning arrays that are members of connectors. If matching arrays in connected connectors have the same number of elements but different dimensionality, the dimensionality of the array with the lowest number of dimensions is increased by adding one-sized dimensions to the left until both arrays have the same dimensionality.<br /></span></p></td></tr></table></body></html> + + + connector SOutPort "Simplified OutPort connector" + output Real signal; +end SOutPort; + {SOutPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector InPort "InPort connector" + parameter Integer n = 1; + input Real signal[n]; +end InPort; + {InPort,SOutPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The connectors </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ip</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">op</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> do not have the same dimensionality, but the connect statement is still correct. This works since the dimensionality of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">op.signal</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is increased by one to become</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> op.signal[1]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> before the connect statement is expanded to conventional equations. One-sized dimensions are added to the left in the list of dimensions, e.g. an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">array x[2,3]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> could be converted to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x[1,1,2,3]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span><span style=" font-family:'Times New Roman'; font-size:11pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + + + class ConnectArray + SOutPort op; + InPort ip; +equation + connect(ip, op); +end ConnectArray; + {ConnectArray,InPort,SOutPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Constant Subscript Constraints</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In order to simplify the analysis of connections and making the generation of connection equations possible at compile time, the following constraint applies:<br />Subscripts in a connector reference must be constant expressions. </span></p></td></tr></table></body></html> + + + class ConnectTest + Pin x[3]; + Pin y[3]; + Integer i = 2; +equation + connect(x[2], y[2]); // Ok, constant subscripts. + connect(x[i], y[2]); // Error, non-constant subscript. +end ConnectTest; + {ConnectTest,ConnectArray,InPort,SOutPort} + + + + + diff --git a/DrModelica/CompConn/ConnEq.onb b/DrModelica/CompConn/ConnEq.onb new file mode 100644 index 00000000000..889fbb857ee --- /dev/null +++ b/DrModelica/CompConn/ConnEq.onb @@ -0,0 +1,180 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Generation of Connection Equations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">By generating connection equations we mean the conversion of connect statements to the two different forms of equations to be used for non-flow and flow variables respectively. The process of converting </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> statements can be divided into two steps: Building </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">connections sets</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> statements and Generating </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">connection equations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for the complete model. </span><span style=" font-family:'Times New Roman'; font-size:11pt; color:#000000;">Connections sets are needed to generate the connection equations of a model.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ResistorCircuit</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A practical way to generate these sets is to first create a small connection set from each connect statement consisting of its two arguments. If any of these connector arguments are members of other connections sets, the corresponding connection sets are merged.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="382" height="102" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorCircuit</span></p></td></tr></table></body></html> + Left + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model ResistorCircuit + Modelica.Electrical.Analog.Basic.Resistor R1, R2, R3; +equation + connect(R1.p, R2.p); + connect(R2.p, R3.p); +end ResistorCircuit; + {ResistorCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ECircuit</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/2.png" width="650" height="77" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ECircuit</span></p></td></tr></table></body></html> + Left + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The situation is somewhat different regarding the ECircuit model below since it contains a structured c</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">omponent E1 that contains both inside and outside connectors.</span></p></td></tr></table></body></html> + + + class E + Modelica.Electrical.Analog.Basic.Resistor R2, R3; + Modelica.Electrical.Analog.Basic.Pin p, n; +equation + connect(p, R2.p); + connect(R2.n, R3.p); + connect(R3.n, n); +end E; + {E} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model ECircuit + Modelica.Electrical.Analog.Basic.Resistor R1, R4; + E E1; +equation + connect(R1.n, E1.p); + connect(E1.n, R4.p); +end ECircuit; + {ECircuit} + + + + + diff --git a/DrModelica/CompConn/Connections.onb b/DrModelica/CompConn/Connections.onb new file mode 100644 index 00000000000..2a043d6b2b8 --- /dev/null +++ b/DrModelica/CompConn/Connections.onb @@ -0,0 +1,218 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Connections</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Connections</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> between components can be established between </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">connectors</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">equivalent type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The names must be identical. And corresponding types of declared </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">variable members</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the classes of the connectors must be equivalent, but the ordering between the member declarations in the connector classes need not be the same. It is important to note that connections can only be established between connectors (instances of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connector</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> classes). Instances of the restricted classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">record, block, model, function</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">package</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are not allowed in connections.<br /><br />In connectors there are two kinds of variables, either non-flow variables that represent som kind of potential enegy level (ex. Voltage) or flow variables, with the prefix flow, that represent some kind of flow (ex. electric current). </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connect Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Connections between connectors are realized as equations in Modelica. Note that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equations are regarded as </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">equations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> despite the fact that the syntax is different from normal equations. The reason is that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equations are eventually expanded into normal equations. The general form of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equation is as follows:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                    connect(connector1, connector2)</span></p></td></tr></table></body></html> + Left + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The two arguments of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equation must be references to connectors, each of which either has to be declared within the same class where the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equation occurs, or has to be a member of one of the declared variables in that class.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Connections</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now we connect the two connectors </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> using a connect statement. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ConnectedPins</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> connects the two pins so that they form one node. This produces two equations, namely: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">pin1.v = pin2.v and pin1.i + pin2.i = 0</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The first says that the voltages at the connected wire ends are the same (</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">equality coupling</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">). The second equation corresponds to Kirchhoff's current law saying that the currents </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">sum to zero</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> at a node .<br /></span></p></td></tr></table></body></html> + + + class ConnectedPins + Modelica.Electrical.Analog.Interfaces.Pin pin1; + Modelica.Electrical.Analog.Interfaces.Pin pin2; +equation + connect(pin1, pin2); +end ConnectedPins; + {ConnectedPins} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="501" height="84" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Connecting two electrical pins. The connected voltages are equal, and the sum of the corrents is zero.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Mechanical Connections</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">filled</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">non-filled</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> squares of a component represent </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">mechanical flanges</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. We connect these flanges using a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> statement so that they form one node:</span></p></td></tr></table></body></html> + + + class ConnectedFlanges + Modelica.Mechanics.Translational.Interfaces.Flange_a flange1,flange2; +equation + connect (flange1, flange2); +end ConnectedFlanges; + {ConnectedFlanges} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Which connects the two flanges so that they form one node. This produces two equations, namely: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flange1.s = flange2.s</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flange1.f + flange2.f = 0</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /> </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/2.png" width="501" height="84" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Connecting two mechanical flanges. The positions at the connection point are identical and the sum of the forces are zero.</span></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/CompConn/Connectors.onb b/DrModelica/CompConn/Connectors.onb new file mode 100644 index 00000000000..0a456f12e1b --- /dev/null +++ b/DrModelica/CompConn/Connectors.onb @@ -0,0 +1,346 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Connectors and Connector Classes</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Pin</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The by now well-known class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a connector class that can be used to specify the external interface for electrical components that have pins as interaction points.</span></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; // From Modelica.Electrical.Analog.Interfaces + {Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class PinInst + Pin pin; // An instance of class Pin +end PinInst; + {PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Another way to use the connector </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is to refer to it from the library using the full path. This method can be used to create instances of all classes that belong to the Modelica library, instead of writing the whole classes every time.</span></p></td></tr></table></body></html> + + + class PinInst + Modelica.Electrical.Analog.Interfaces.Pin pin; +end PinInst; + {PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="233" height="70" /></p></td></tr></table></body></html> + Left + AAAAAYlQTkcNChoKAAAADUlIRFIAAADpAAAARggDAAAAHqND6gAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAAwMDA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXxqxmgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAXpJREFUaIHtmYsOgjAMRcf+/6M1gmjjgl0ft2PrTYwsMk6PjDGx1FVSoguAJU3nS5rOl6dpeduWqbVDTMuer80DXVifNBs/R6Z77aP3/ERVfNfOHQq/2swG/UKjTBUkUQ7TnazDr2Fa6KBhccFZ75y+NnT0NNXvbJLTtPKvMSMuOkGmIZle8EyazpdFTD9zL5yLJ6apNxdPTFNvLp6YptbZSisgeP1a9/qTtlagPytQnDT935M+4pNXIO/ax1GY0ndxBbrufE6sKXDutTE9Xv3T9k1NBU8yb2JKZyTR3NRj2rzzd0R9TmGmyqQpo2ea9vGXMb3DysGsAhQnTUH4O1ynNnigaTsgej5HQnDxxDT15uKJTszrw0b+++9w5NHiVtFwqoyChGNtNNX+eviPGRzKVcSxnJFMeXOv/egd9S4jquuy00ymo91PXUcv9IgMYprSvey54KxjWj3XSKNlDgtOgkzJitGsUa8aUeeULI0FDZbcEKb4pOl8eQBqJnfpeypIJgAAAABJRU5ErkJggg== + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A component with an electrical pin connector.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flange</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Flange</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> connector class below, analogous to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, is used to describe interfaces for one-dimensional interaction in the mechanical domain by specifying the position s and force f at a point of interaction.</span></p></td></tr></table></body></html> + + + connector Flange + Position s; + flow Force f; +end Flange; // From Modelica.Mechanical.Translational.Interfaces + {Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class FlangeInst + Flange flange; // An instance of class Flange +end FlangeInst; + {FlangeInst,Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/2.png" width="231" height="71" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAADnAAAARwgDAAAAyzag/AAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAAwMDA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXxqxmgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAaBJREFUeJztmduywiAMRbH//9E6tRdikRRodgJkPzhlRllZcvNwwjJHgnYBoLjnWHHPseKeYsRv4mfJxiZo0DM83vi8RAiYJwhEkOFAo/jankAoOtG8hULROTzXFYqDohN5zrM+J/DEnisgjgUqPu45VhQ2BTiRnitAqALSPQWhCkj3FIQqIN1TEKqAhEBDOgj0UQIE8krFPSVKgEBKPKNp/eDUtuiZemzjo/Yh90wWRR7JrXp0d7+c9+4svwPP3Wa/kjxeQvTE8W16xiN4VkqMr09Z/ur55xR/Mm3rk+y+lzHevxTWUz6N63PhxpPld+CZn62Def7M29S2xJXQbsGn+Vy57Dn0XLkhYc/zfq8lHXTpWfz/IIvr81aH9ybr+fZOPUv5k9wn+P2QLFQB6Z6CUAWkBDTfp4Kn1PmpYMJFpiR7ouxfqHXTzJxo2VoquEIQrLk83PqsLjfzQYP7bfXA5D5k0LO2JubLq+qzJUKe5s5PqfGE98kj3XN7gwQUnVk85c5Pc1ERIT+ZUo3weEPDk/w2rGl04qkR9xwrs3i+AXX7d4TOzqQhAAAAAElFTkSuQmCC + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A component with a mechanical flange connector.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">InPort</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The connector class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">InPort</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> when instantiated as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">inPort</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a signal </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">input</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> port that can be connected to receive signals.</span></p></td></tr></table></body></html> + + + connector InPort + parameter Integer n = 1; + input Real signal[n]; +end InPort; // From Modelica.Blocks.Interfaces + {InPort,FlangeInst,Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class InPortInst + InPort inPort[n]; // An instance inPort with one signal (n = 1) +end InPortInst; + {InPortInst,InPort,FlangeInst,Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/3.png" width="235" height="71" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAADrAAAARwgDAAAA0QpAcgAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZ3bsYwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAfhJREFUeJztme22hCAIRfH9X/qumckEzMJuHczgT1rmYQ9+DVF6j5G3A0AL1jktWOe0ipUO6T8tiHg7WRvWTvj4Y63vDW8+rLQYL99eKaz53toqM60DlLfIhdLrGdaK+1QlmSpUWCuKL25i/KLFUpEPe1i7ml9hmjUXSqxaJTEE0mysv+sUrOvG0WQlNoefzprUCJ13DK8uvIC1uQ4neX8G1vb+mgrndfP1IoA+21Hd818/cwhUv236eByqeVgTO2Y1XhPPj1oPYsPNnNskyYvVf39FCjtIBitA2EEyWAHCDpLBChD2UJ1I5chArEOcIWFx7RWSv45Mkta9W70A2Im/uKoD4pfNZ8c+IOcrz+P1dkDtF22dwdZhEheTe0v2Q2RLWNYkp0R2hnbVH3Yd3guPfiWnvFguqE6L2ScHnHUdzea4ipJOc7GEl6U/+P5qDYVmFV+hqucGF76sBDAmaZxhm3Etv9Yj4pqM6algzfV+VvD+upRth6g262YyvteL+4xU8X+sfH9NHYdtpz0Hotr2AqKiD1BAg5+b8hUPO/J5+HIXoKziRAGRFS4gWfWuATYcK+lNAyKrJJ1W/2C9WTJYbxd+kaqPBeuc9pqZE+swRthBMlgBwg6SwQoQdpAMVoAwXjPOTRBh/hELU/FiFV/wjJWnsnrE9Q+H2jyFwnmMBwAAAABJRU5ErkJggg== + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A component with an inPort connector for signals.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connector Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Connector classes often use special types for standard physical quantities represented by </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> values, e.g. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Voltage</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The types </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Voltage, Current, Position, Force</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Distance</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> shown below are just five of the classes available in the Modelica Standard library </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Modelica.SIunits</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. <br /></span></p></td></tr></table></body></html> + + + type Voltage = Real(final quantity = "ElectricPotential", + final unit = "V"); + {Voltage,InPortInst,InPort,FlangeInst,Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Current = Real(final quantity = "ElectricCurrent", + final unit = "A"); + {Current,Voltage,InPortInst,InPort,FlangeInst,Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Position = Real(final quantity = "Length", final unit = "m"); + {Position,Current,Voltage,InPortInst,InPort,FlangeInst,Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Force = Real(final quantity = "Force", final unit = "N"); + {Force,Position,Current,Voltage,InPortInst,InPort,FlangeInst,Flange,PinInst,Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Distance = Position(min = 0); + {Distance,Force,Position,Current,Voltage,InPortInst,InPort,FlangeInst,Flange,PinInst,Pin} + + + + + diff --git a/DrModelica/CompConn/Exercise1.onb b/DrModelica/CompConn/Exercise1.onb new file mode 100644 index 00000000000..4ff9ae1eb1e --- /dev/null +++ b/DrModelica/CompConn/Exercise1.onb @@ -0,0 +1,149 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 1</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">How can connections between components can be established in Modelica?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Connections between components can be established between </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">connectors</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">equivalent type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What are the requirements for connections?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The names of the connector classes that are to be connected together must be identical. The corresponding types of declared </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">variable members</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the classes of the connectors must be equivalent, but the ordering between the member declarations in the connector classes need not be the same. <br /><br />It is important to note that connections can only be established between connectors (instances of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">connector</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> classes). Instances of the restricted classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">record, block, model, function</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">package</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are not allowed in connections.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">How many connectors can you connect?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">There is no limit.</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/CompConn/In-Output.onb b/DrModelica/CompConn/In-Output.onb new file mode 100644 index 00000000000..75ad6a3355d --- /dev/null +++ b/DrModelica/CompConn/In-Output.onb @@ -0,0 +1,212 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Connection Restrictions on Input and Output Connectors</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The introduction of structured components with inside and outside connectors introduces some additional complexity in the rules for connecting connectors with input or output causality, i.e. connectors declared with the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">input</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">output</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> type prefix. Examples are instances of the connector classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">InPort</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">OutPort</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Normally the following rules apply:<br />*    Two acausal connectors can be connected to each other.<br />*    An input connector can be connected to an output connector or vice versa.<br />*    An input or output connector can be connected to an acausal connector, i.e. a connector without input/output prefixes.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="616" height="149" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAJoAAAAlQgDAAAA26L2lQAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAAwMDA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXxqxmgAAAAlwSFlzAAALEwAACxMBAJqcGAAACOlJREFUeJztnY2W4yYMhWXe/6HbTWwsbMAIsJAy955umrggfSMuP45nTyk4Fr2k30ZbA0sqGd+pTzAc1jCaVtRQM9o7GX2VHUZ7IyyM9k5Yw2haUYeN9m8npPbmooYyyXCbd3A1o61B64t6jnozxKDR6JM1xFdxynkS4R5/5oSdEWMRWlfUc9Tbh33MaHR7laacJyGuMaOtQuuJylipGWKG0ZqbCxvKJMQ1aTRZzrVG29/CaI9NzBrN+hmN+DsY7amJrZuBVXOgJyrxNzDaUxMYrTfqaTTB9+9/9magayZ26ndvBrRWNL54OjAaw20+XSgZLd2GbBstYe01GlsJm0LEpbP9GebMh529uO1rfvfD2RG01gyzSklCWNa+fdSTm9VAG0m9KhVNtNo/XOmKWgqVHzeizqlhGO0eaZs37CVY7rWP0WLOZIHsmD2lPhQk699Dji3yjuFS5h7qG3Z/FfPqoUnJMim+rAdsetqXRSrC7gFjqy3mvDWunOcEGeOZbsrpZ4u8L+Ges1DIq4c2Pmt31u3FYWcTjRnt9Pf8jHy+PMR4VsTdOnA/HqB9B6KjD+070j6Z+elF9Et3dtEy2kaGff95j52qAMtj3IzGftxs757yXBbmIfGpKMal+DPHxvzDpBXNIlqRdfuEPke+HTYyFWFj82RFS5sWe/eU54WtM06ZMVx29ZzK3Qd6NbR5GwPxDDJYbrQ8bGCwh9GSIyxVemcyPpYntdug7vcus3G7T9y0rxCvo4nJSqwxS8LbBttmNDZr2Y3um0abspyFL26SXYC7H6L3SRt3heNjOE4dnbQjlXwZrcYqN1rEOpDzsLzzx2jJp/0kVOqdy/hUnjD1ezQawG3N0NfVMNo90jnqn+GJfybC8q5poGluuKacGJiyb2dqoLK5tzM1c76y97OCllNccrxmtD8X1jCaVtQ0LIz2TljDaFpRYTSNsIbRtKLCaBphDaNpRYXRNMIaRtOKCqNphDWMphUVRtMIaxhNKyqMphHWMJpWVBhNI6xhNK2oMJpGWMNoWlFhNI2whtG0ov6S0V7Sb6OtgSWVjG8ZGHIjWABSEYwGqQhGg1QEo0EqgtEgFcFokIpgNEhFMBqkIhgNUhGMBqkIRoNUBKNBKoLRIBXBaJCKYDRIRTAapCIYDVIRjAapCEaDVASjQSqC0SAVwWiQimA0SEUwGqQiGA1SEYwGqQhGg1QEo0EqgtEgFcFokIpgNEhFMBqkIhgNUhGMBqkIRoNUBKNBKoLRIBXBaJCKYDRIRTAapCIYDVKRE6O99r90+QmtHp0WuYB0g7lGLorjAtIN5hq5KI4LSDeYa+SiOC4g3WCukYviuIB0g7lGLorjAtIN5hq5KI4LSAuY/FuE4/16qo+MYNTlAtIGZnTaYTMrX2AZwajLBaQNzKvRbFAFMxh1uYC0gUmBkn/boApmMOpyAWkDE0YbkQtIG5j0xaAAo3XIBaQNTBhtRC4gbWB+XbZ7LV4xICMYdbmAtIEJo43IBaQNTEpfgg2qYAajrhTS7G/m5SNo4u7/geK7+je2qmjyeqqwJlwXow0il36SlyKYxdVFu18serI96ARZNFpsUSgRjFYJe7143h638fwlo6Vt6fJ5xGj/fPu40cnDzogxC03FaBG2vT6jRjvr05hwpdE+4Y6YjRxKRpuG9g1E4ftPHJ/97fdyzcpNk+KADaFvVsiNdtZnntFiPeKXCJcK9Rottakpo81DO6sWmMP4h+EVjcFSc33GjJak7MlYbPGdiJRMyNEVretkoGk0Ycpmo8XWuX1UzMqb6BqttXVrw7MklH78G0YbPqPpGe1hdSzG/UtGGxpNoTTnwHc72F/3TWEv23Fmq1pZMupPpi3GtWG071GWLt+FsgrBaJVmo7wiowm+ojNotM4IraNZWxW7ws6IkUK5MBrJ8s0wWmWZecrYpV6jpbuvqTNaugsZN1oCq2O0x4PTU8YudRstsONK15LfKSnaSNjRZ8lN3Rljp9H4TylKKShPXymyYGLcnry9vGvQZE82z07x7SBUQ4qP0bZt2l/rKT2ppK5ZR1uMxkZwS66mp1RpgvKD1T7e99Eogyb8+nzvdA57si12mrZQR2LW+j9jzDlWHrqcO8Lx4bj1FkULnIzSi7er4Z76KRuFUp9jwRbizkN7qOS1lF1/z3QvbjZN5XCVZW2p4260Pedwylp5xGMXye5G+/K+ajT51JiG9lzJpJRsE2wHPmFfNtpex2i0ja37gpRND3N5JSTKgaW4t4ekPPUjLe+TfbAqw2VooYRWfsI9Ukk5b0iLy3Jn8zbV8dqH1TExGpXLU0y5Z+CN+YfaPHwWr8VtNPfge/UzqXP1udAmfc6Fs482WSTKaLeNo8D2VEnelTp4I+ylZvm8ddZvp1ufpI7EN6j6yLWkJHb1XBL5qVNei9zWGafMmeqauqlA6eW0QELaRrQzTZ2tWsncGa1rnydWiXwZ2+t465OwZm8G+lPWyjPxZuC0wmtGk98LtKFNMNoVbd9y5LB0TfKC0Sj2obM6cqOF4+iwb9dxxlF86a1EuN6B3y6G+IA0l7p0tjhpA+9z0oY+2jY0KtaitZL3zvlz1CMs34aPg1spb5X1qOO1T9KZeMb6yPVVP4TOShw/zg6WuZh1/gT10a5D6yzu+baf5yEFi5zOkNfK09ct95byDWaqez5NiPGUorTryiMN9peluCYxNnJPEczi6qKN5oLRniKYxYXRbnFhtHfCwmgwWmcy/RitYWG0eWFhtEpYGG1eWBitEhZGmxcWRquEhdHmhYXRKmFhtHlhYbRKWBhtXlgYrRIWRpsXFkarhPVotJc0l9k+ri7asNE0YN9y82Q5wVwjF8VxAekGc41cFMcFpBvMNXJRHBeQbjDXyEVxXEC6wVwjF8VxAekGc41cFMcFpBvMNXJRHBeQbjDXyEVxXEC6wVwjF8VxAekGc41cFMcFpBvMNXJRHBeQbjDXyEVxXEC6wVwjF8VxAekGc41cFMcFpBvMNXJRHBeQbjDXyEVxXEC++Lt5P6HVo9MiF5CQf/0HZQOiGOIhqAEAAAAASUVORK5CYII= + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Two essentially equivalent example circuits of four connected components with connectors of input or output causality. Within</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> the lower circuit two components have been embeded in the structured component M1. </span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + Left + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Inside Connectors</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">There are certain rules for how to connect connectors with input or output causality. It is not possible to connect two inputs or two outputs, unless outside connectors are involved. The following example illustrates the upper circuit above.</span></p></td></tr></table></body></html> + + + class C + SInPort inPort; // Input connector + SOutPort outPort; // Output connector +end C; + {C} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class CInst + C C1, C2, C3, C4; // Instances of C +equation + connect(C1.outPort, C2.inPort); + connect(C2.outPort, C3.inPort); + connect(C3.outPort, C4.inPort); +end CInst; + {CInst} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector SInPort "Simplified InPort connector" + input Real signal; +end SInPort; + {SInPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector SOutPort "Simplified OutPort connector" + output Real signal; +end SOutPort; + {SOutPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Outside Connectors</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following example illustrates the lower circuit above.</span></p></td></tr></table></body></html> + + + class M "Structured class M" + SInPort inport; // Outside input connector + SOutPort outport; // Outside output connector + C C2; + C C3; +end M; + {M} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent.</span></p></td></tr></table></body></html> + + + class MInst + M M1; // Instance of M +equation + connect(C1.outPort, M1.inPort); // Normal connection of outPort to inPort + connect(M1.inPort, C2.inPort); // Outside inPort connected to inside inPort + connect(C2.outPort, C3.inPort); // Inside outPort connected to inside inPort + connect(C3.outPort, M1.outPort); // Inside outPort connected to outside outPort + connect(M1.outPort, C4.inPort); // Normal connection of outPort to inPort +end MInst; + + {MInst} + + + + + diff --git a/DrModelica/CompConn/MechTrans.onb b/DrModelica/CompConn/MechTrans.onb new file mode 100644 index 00000000000..3379a0b2ddd --- /dev/null +++ b/DrModelica/CompConn/MechTrans.onb @@ -0,0 +1,231 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Mechanical Translational Coordinate Systems and Components</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Each mechanical component has an associated coordinate system, called </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">frame</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This is true also for components in a simple domain like the 1D mechanical translational domain. Even the flanges in the 1D mechanical translational domain have their own coordinate systems. The connector classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Flange_a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Flange_b</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used for flanges in the 1D translational mechanical domain are identical but have slightly different roles, somewhat analogous to the roles of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PositivePin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">NegativePin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the electrical domain. <br /><br />A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flange_a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> connector is used at the &quot;left&quot; side of a component, whereas a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flange_b</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> connector is used at the &quot;right&quot; side of the component, represented by the empty square. Each flange has an internal coordinate system characterized by the unit vector n from left to right.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connectors</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The connector classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PositivePin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">NegativePin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are identical to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Pin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and can be used in electrical components to help distinguish positive and negative pins.</span></p></td></tr></table></body></html> + + + // Current p.i flowing into positive pin +connector PositivePin = Modelica.Electrical.Analog.Interfaces.Pin; + {PositivePin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + // Current n.i flowing into negative pin +connector NegativePin = Modelica.Electrical.Analog.Interfaces.Pin; + {NegativePin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Components</span></p></td></tr></table></body></html> + + + partial model TwoPin "Component with two electrical pins p and n and current i from p to n" + Voltage v "Voltage drop between the two pins (= p.v - n.v)"; + Current i "Current flowing from pin p to pin n"; + PositivePin p; + NegativePin n; +equation + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end TwoPin; // Same as OnePort in Modelica.Electrical.Analog.Interfaces + {TwoPin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In the idealized </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class below, the &quot;coordinate system&quot; (the direction of current flow in the resistor) is from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">p</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">n</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> as inherited from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoPin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span></p></td></tr></table></body></html> + + + model Resistor + extends TwoPin; + parameter Real R(unit = "Ohm") "Resistance"; +equation + v = R * i; // Resistor equation +end Resistor; + {Resistor} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Mechanical Connectors</span></p></td></tr></table></body></html> + + + // "Left" flange class +connector Flange_a = Modelica.Mechanics.Translational.Interfaces.Flange_a; + {Flange_a} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + // "right" flange class +connector Flange_b = Modelica.Mechanics.Translational.Interfaces.Flange_b; + {Flange_b} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Mechanical Components</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The partial base class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Compliant</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below is extended by classes for compliant flexible mechanical components with two flanges. It can be regarded as a 1D mechanical analogue of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoPin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> base class from the electrical domain.</span><span style=" font-family:'Times New Roman'; font-size:11pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flange_a </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">connector is used at the &quot;left&quot; side of a component, where as a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flange_b connector </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">is used at the &quot;right&quot; side of the component. <br /></span></p></td></tr></table></body></html> + + + partial model Compliant "Compliant coupling of 2 translational 1D flanges" + Flange_a flange_a "Driving flange"; + Flange_b flange_b "Driven flange"; + Modelica.SIunits.Distance s_rel "Relative distance between flange_a and flange_b"; + flow Modelica.SIunits.Force f "Force between flanges, positive in direction of N"; +equation + s_rel = flange_b.s - flange_a.s; + 0 = flange_b.f + flange_a.f; + f = flange_b.f; +end Compliant; // From Modelica.Mechanics.Interfaces + {Compliant} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Spring</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class below iherits all equations apart from the constitutive spring equation from its base </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class Compliant</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model Spring "Linear 1D translational spring" + extends Compliant; + parameter Modelica.SIunits.Distance s_rel0 = 0 "Unstretched spring length"; + parameter Real c(unit = "N/m") = 1 "Spring constant"; +equation + f = c*(s_rel - s_rel0); // Spring equation +end Spring; + {Spring} + + + loadModel(Modelica); + [done] + + + simulate(Spring) + record SimulationResult + messages = "Simulation failed for model: Spring +Error: Internal error Found Equation without time dependent variables flange_b.f = 0.0 + +Error: Internal error Optimisation Module removeSimpleEquations failed. +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelites failed! +" +end SimulationResult; + + + + + diff --git a/DrModelica/CompConn/MultDCmotor.onb b/DrModelica/CompConn/MultDCmotor.onb new file mode 100644 index 00000000000..f2ea949e668 --- /dev/null +++ b/DrModelica/CompConn/MultDCmotor.onb @@ -0,0 +1,652 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">A DC-Motor by Connecting Components from Multiple Domains</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">So far most of the presented models have been of the single domain type being constructed of components from a single application domain. However, one of the main advantages with Modelica is the ease of constructing multi-domain models simply by connecting components from different domains. A DC (direct current) motor is one of the simplest examples illustrating this capability. <br /> <br />This particular model contains components from the three domains: mechanical components such as inertia1,the electrical components resistor1, inductor1, signalVoltage1 and ground1 as well as pure signal components such as step1. <br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/8.png" width="491" height="230" /></p></td></tr></table></body></html> + Center + Model1 + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A multi-domain DC-MotorCircuit model with mechanical, electrical and signal block components</span></p></td></tr></table></body></html> + Center + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">NOTE</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">: In order to simulate the DCMotorCircuit model below, you first need to evaluate the declarations in sections 2-7 below. This is easily done by selecting these cells (to the right) and pushing shift-return as usual.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Types from Modelica.SIunits</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following are different types from the library </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Modelica.SIunits</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used by the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DCMotorCircuit</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical units</span></p></td></tr></table></body></html> + + + type ElectricPotential = Real; +type ElectricCurrent = Real(quantity = "ElectricCurrent", unit = "A"); +type Resistance = Real(quantity = "Resistance", unit = "Ohm", min = 0); +type Inductance = Real(quantity = "Inductance", unit = "H", min = 0); +type Voltage = ElectricPotential; +type Current = ElectricCurrent; + {ElectricPotential,ElectricCurrent,Resistance,Inductance,Voltage,Current} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Mechanical units</span></p></td></tr></table></body></html> + + + type Force = Real(quantity = "Force", unit = "N"); +type Angle = Real(quantity = "Angle", unit = "rad", displayUnit = "deg"); +type Torque = Real(quantity = "Torque", unit = "N.m"); +type AngularVelocity = Real(quantity = "AngularVelocity", unit = "rad/s", displayUnit = "rev/min"); +type AngularAcceleration = Real(quantity = "AngularAcceleration", unit = "rad/s2"); +type MomentOfInertia = Real(quantity = "MomentOfInertia", unit = "kg.m2"); + {Force,Angle,Torque,AngularVelocity,AngularAcceleration,MomentOfInertia} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Other units</span></p></td></tr></table></body></html> + + + type Length = Real(quantity = "Length", unit = "m"); +type Time = Real(quantity = "Time", unit = "s"); +type Distance = Length(min = 0); +type Position = Length; + {Length,Time,Distance,Position} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + {Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector PositivePin "Positive pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end PositivePin; //From Modelica.Electrical.Analog.Interfaces + {PositivePin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector NegativePin "Negative pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end NegativePin; //From Modelica.Electrical.Analog.Interfaces + {NegativePin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;"> Mechanical Connectors</span></p></td></tr></table></body></html> + + + connector RotFlange_a "1D rotational flange (filled square)" + Angle phi "Absolute rotational angle of flange"; + flow Torque tau "Torque in the flange"; +end RotFlange_a; //From Modelica.Mechanics.Rotational.Interfaces + {RotFlange_a} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector RotFlange_b "1D rotational flange (filled square)" + Angle phi(fixed=true) "Absolute rotational angle of flange"; + flow Torque tau "Torque in the flange"; +end RotFlange_b; //From Modelica.Mechanics.Rotational.Interfaces + {RotFlange_b} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Block Signal Connectors</span></p></td></tr></table></body></html> + + + connector InPort "Connector with input signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + input Real signal[n] "Real input signals"; +end InPort; // From Modelica.Blocks.Interfaces + {InPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector OutPort "Connector with output signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + output Real signal[n] "Real output signals"; +end OutPort; // From Modelica.Blocks.Interfaces + {OutPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Components</span></p></td></tr></table></body></html> + + + partial model TwoPin // Same as OnePort in Modelica.Electrical.Analog.Interfaces + "Component with two electrical pins p and n and current i from p to n" + Voltage v "Voltage drop between the two pins (= p.v - n.v)"; + Current i(fixed=true) "Current flowing from pin p to pin n"; + PositivePin p; + NegativePin n; +equation + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end TwoPin; + {TwoPin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Resistor "Ideal linear electrical Resistor" + extends TwoPin; // Same as OnePort + parameter Real R(unit = "Ohm") "Resistance"; +equation + R*i = v; +end Resistor; // From Modelica.Electrical.Analog.Basic + {Resistor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Inductor "Ideal linear electrical Inductor" + extends TwoPin; // Same as OnePort + parameter Real L(unit = "H") "Inductance"; +equation + v = L*der(i); +end Inductor; // From Modelica.Electrical.Analog.Basic + {Inductor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Ground "Ground node" + Pin p; +equation + p.v = 0; +end Ground; // From Modelica.Electrical.Analog.Basic + {Ground} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model SignalVoltage "Generic Voltage source using the input signal as source Voltage" + extends TwoPin; // Same as OnePort + InPort inPort(n=1); +equation + inPort.signal[1] = v; +end SignalVoltage; // From Modelica.Electrical.Analog.Sources + {SignalVoltage} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Mechanical Components</span></p></td></tr></table></body></html> + + + partial model Rigid // Rotational class Rigid + "Base class for the rigid connection of two rotational 1D flanges" + Angle phi "Absolute rotation angle of component"; + RotFlange_a rotFlange_a "(left) driving flange (axis directed into plane)"; + RotFlange_b rotFlange_b "(right) driven flange (axis directed out of plane)"; +equation + rotFlange_a.phi = phi; + rotFlange_b.phi = phi; +end Rigid; // From Modelica.Mechanics.Rotational.Interfaces + + {Rigid} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model Inertia "1D rotational component with inertia" + extends Rigid; + parameter MomentOfInertia J = 1 "Moment of inertia"; + AngularVelocity w(fixed=true) "Absolute angular velocity of component"; + AngularAcceleration a "Absolute angular acceleration of component"; +equation + w = der(phi); + a = der(w); + J*a = rotFlange_a.tau + rotFlange_b.tau; +end Inertia; //From Modelica.Mechanics.Rotational + {Inertia} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electromechanical Components</span></p></td></tr></table></body></html> + + + model EMF "Electromotoric force (electric/mechanic transformer)" + extends TwoPin; + parameter Real k(unit = "N.m/A") = 1 "Transformation coefficient"; + AngularVelocity w "Angular velocity of rotFlange_b"; + RotFlange_b rotFlange_b; // Rotational Flange_b +equation + w = der(rotFlange_b.phi); + v = k*w; + rotFlange_b.tau = - k*i; +end EMF; // From Modelica.Electrical.Analog.Basic + {EMF} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Signal Block Components</span></p></td></tr></table></body></html> + + + partial block MO "Multiple Output continuous control block" + parameter Integer nout = 1 "Number of outputs"; + OutPort outPort(n = nout) "Connector of Real output signals"; +protected + Real n[nout] = outPort.signal; +end MO; // From Modelica.Blocks.Interfaces + {MO} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + block Step "Generate step signals of type Real" + extends MO(nout = 1); + parameter Real height = 1 "Height of steps"; + parameter Real offset = 0 "Offset of output signals"; + parameter Time startTime = 0 "Output = offset for time < startTime"; +equation + outPort.signal[1] = offset + (if time < startTime then 0 else height); +end Step; // Version simplified from Step in Modelica.Blocks.Sources + {Step} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">DCMotor</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> DC</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (direct current) </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">motor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model contains component from three domains: mechanical, electrical and signal components. </span></p></td></tr></table></body></html> + + + loadModel(Modelica); + [done] + + + model DCMotorCircuit + Resistor resistor1(R=10); + Inductor inductor1(L=0.2); + Ground ground1; + Inertia inertia1(J=1); + EMF emf1; + Step step1; + SignalVoltage signalVoltage1; +equation + connect(step1.outPort, signalVoltage1.inPort); + connect(signalVoltage1.p, resistor1.p); + connect(resistor1.n, inductor1.p); + connect(inductor1.n, emf1.p); + connect(emf1.rotFlange_b, inertia1.rotFlange_a); + connect(signalVoltage1.n, ground1.p); + connect(ground1.p, emf1.n); +end DCMotorCircuit; + {DCMotorCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of DCMotorCircuit </span></p></td></tr></table></body></html> + + + simulate( DCMotorCircuit, stopTime=150 ) + record SimulationResult + resultFile = "DCMotorCircuit_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( inertia1.w ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/CompConn/MultToSingle.onb b/DrModelica/CompConn/MultToSingle.onb new file mode 100644 index 00000000000..ecb40cc5e0a --- /dev/null +++ b/DrModelica/CompConn/MultToSingle.onb @@ -0,0 +1,79 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Multiple Connections to a Single Connector</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In almost all previous examples we only connected two connectors. In fact, there is in general no limitation to the number of connections that can be made to a single connector, apart from connector classes that very specifically limits the cardinality of the connections. In the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> three resistors are connected at one node.<br /></span></p></td></tr></table></body></html> + + + model ResistorCircuit + Modelica.Electrical.Analog.Basic.Resistor R1(R = 100); + Modelica.Electrical.Analog.Basic.Resistor R2(R = 200); + Modelica.Electrical.Analog.Basic.Resistor R3(R = 300); +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end ResistorCircuit; + {ResistorCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />As usual the special operator </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">connect</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> produces equations by taking into account what kind of variables , </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flow</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">non-flow</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, that are involved. The generated equations, based on equal potential at a connection point and Kirchhoff's current law, are as follows for this particular example:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                    R1.p.v = R2.p.v;<br />                    R1.p.v = R3.p.v;<br /><br />                    R1.p.i + R2.p.i + R3.p.i = 0;</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TripleSprings</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has three connected springs.</span></p></td></tr></table></body></html> + + + model TripleSprings + Modelica.Mechanics.Rotational.Spring spring1(c = 1, s_rel0 = 0.1); + Modelica.Mechanics.Rotational.Spring spring2(c = 1, s_rel0 = 0.1); + Modelica.Mechanics.Rotational.Spring spring3(c = 1, s_rel0 = 0.1); +equation + connect(spring1.flange_a, spring2.flange_a); + connect(spring1.flange_a, spring3.flange_a); +end TripleSprings; + {TripleSprings} + + + + diff --git a/DrModelica/CompConn/Oscillator.onb b/DrModelica/CompConn/Oscillator.onb new file mode 100644 index 00000000000..acbd8e6ea18 --- /dev/null +++ b/DrModelica/CompConn/Oscillator.onb @@ -0,0 +1,260 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">An Oscillating Mass Connected to a Spring</span></p></td></tr></table></body></html> + + + loadModel(Modelica) // If not already loaded, you need to load it + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">NOTE: Before simulating the Oscillator model below, you need to introduce some declarations needed, such as the types Mass, Spring, and Fixed. This is done by evaluating the declarations in the Components section below: select the cell marker to the right and push shift-return as usual.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + partial model Compliant "Compliant coupling of 2 translational 1D flanges" + Modelica.Mechanics.Translational.Interfaces.Flange_a flange_a "Driving flange"; + Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b "Driven flange"; + Modelica.SIunits.Distance s_rel "Relative distance between flange_a and flange_b"; + flow Modelica.SIunits.Force f "Force between flanges, positive in direction of N"; +equation + s_rel = flange_b.s - flange_a.s; + 0 = flange_b.f + flange_a.f; + f = flange_b.f; +end Compliant; + {Compliant} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model Spring "Linear 1D translational spring" + extends Compliant; + parameter Modelica.SIunits.Distance s_rel0 = 0 "Unstretched spring length"; + parameter Real c(unit = "N/m") = 1 "Spring constant"; +equation + f = c*(s_rel - s_rel0); // Spring equation +end Spring; + {Spring} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model Mass "Hanging mass object" + extends Rigid; + parameter Real m = 1 "Mass of the hanging mass"; + constant Real g = 9.81 "Gravitational acceleration"; + Real v(fixed=true) "Absolute velocity of component"; + Real a "Absolute acceleration of component"; +equation + v = der(s); + a = der(v); + flange_b.f = m*a - m*g; +end Mass; + {Mass} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + partial model Rigid "Rigid connection of two translational 1D flanges" + Real s(fixed=true) "Absolute position s of center of component"+ + "(s = flange_a.s + L/2 = flange_b.s - L/2)"; + parameter Real L = 0 "Length L of component from left to right flange"+ + "(L = flange_b.s - flange_a.s)"; + Modelica.Mechanics.Translational.Interfaces.Flange_a flange_a; + Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b; +equation + flange_a.s = s - L/2; + flange_b.s = s + L/2; +end Rigid; // From Modelica.Mechanics.Translational.Interfaces + {Rigid} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model Fixed "Fixed flange at a housing" + parameter Real s0 = 0 "Fixed offset position of housing"; + Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b; +equation + flange_b.s = s0; +end Fixed; // From Modelica.Mechanics.Translational + {Fixed} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Oscillator</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following model gives rise to some dynamic movement when simulated. A mass is connected to a spring which is connected to a fixed housing. The mass </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">mass1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is subject to the gravitational force </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">-mg</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the force from the spring. It is given an initial position </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">s</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">=</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">-0.5</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which is offset from the equilibrium position and therefore starts an oscillating movement up-and-down.<br /></span></p></td></tr></table></body></html> + + + model Oscillator + Mass mass1(L = 1, s(start = -0.5)); + Spring spring1(s_rel0 = 2, c = 10000); + Fixed fixed1(s0 = 1.0); +equation + connect(spring1.flange_b, fixed1.flange_b); + connect(mass1.flange_b, spring1.flange_a); +end Oscillator; + {Oscillator} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Oscillator</span></p></td></tr></table></body></html> + + + simulate( Oscillator,stopTime=0.5 ) + record SimulationResult + resultFile = "Oscillator_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( mass1.s) //plot( mass1.s, xrange={0,0.5} ) ??Error xrange not yet implemented + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">            Diagram 1:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Plot of the absolute position mass1.s(t) of the center of the haning mass.<br /><br /></span></p></td></tr></table></body></html> + + + + + + plot( mass1.v ) //plot( mass1.v, xrange={0,0.5} ) ??Error xrange not yet implemented + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">            Diagram 2:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Plot of the absolute velocity mass1.v(t) of the center of the hanging mass.</span></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/CompConn/PartDCmotor.onb b/DrModelica/CompConn/PartDCmotor.onb new file mode 100644 index 00000000000..562e704ad20 --- /dev/null +++ b/DrModelica/CompConn/PartDCmotor.onb @@ -0,0 +1,656 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Hierarchically Structured Components with Inside and Outside Connectors</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/7.png" width="536" height="273" /></p></td></tr></table></body></html> + Center + Model1 + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">NOTE: In order to simulate the PartialDCMotor. model below, you first need to evaluate the declarations in sections 1-5 below. This is easily done by selecting these cells (to the right) and pushing shift-return as usual.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + Left + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Types from Modelica.SIunits</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following are different types from the library </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Modelica.SIunits</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used by the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PartDCMotorCircuit</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical units</span></p></td></tr></table></body></html> + + + type ElectricPotential = Real; +type ElectricCurrent = Real(quantity = "ElectricCurrent", unit = "A"); +type Resistance = Real(quantity = "Resistance", unit = "Ohm", min = 0); +type Inductance = Real(quantity = "Inductance", unit = "H", min = 0); +type Voltage = ElectricPotential; +type Current = ElectricCurrent; + {ElectricPotential,ElectricCurrent,Resistance,Inductance,Voltage,Current} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Mechanical units</span></p></td></tr></table></body></html> + + + type Force = Real(quantity = "Force", unit = "N"); +type Angle = Real(quantity = "Angle", unit = "rad", displayUnit = "deg"); +type Torque = Real(quantity = "Torque", unit = "N.m"); +type AngularVelocity = Real(quantity = "AngularVelocity", unit = "rad/s", displayUnit = "rev/min"); +type AngularAcceleration = Real(quantity = "AngularAcceleration", unit = "rad/s2"); +type MomentOfInertia = Real(quantity = "MomentOfInertia", unit = "kg.m2"); + {Force,Angle,Torque,AngularVelocity,AngularAcceleration,MomentOfInertia} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Other units</span></p></td></tr></table></body></html> + + + type Length = Real(quantity = "Length", unit = "m"); +type Time = Real(quantity = "Time", unit = "s"); +type Distance = Length(min = 0); +type Position = Length; + {Length,Time,Distance,Position} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + {Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector PositivePin "Positive pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end PositivePin; //From Modelica.Electrical.Analog.Interfaces + {PositivePin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector NegativePin "Negative pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end NegativePin; //From Modelica.Electrical.Analog.Interfaces + {NegativePin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Mechanical Connectors</span></p></td></tr></table></body></html> + + + connector RotFlange_a "1D rotational flange (filled square)" + Angle phi "Absolute rotational angle of flange"; + flow Torque tau "Torque in the flange"; +end RotFlange_a; //From Modelica.Mechanics.Rotational.Interfaces + {RotFlange_a} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector RotFlange_b "1D rotational flange (filled square)" + Angle phi "Absolute rotational angle of flange"; + flow Torque tau "Torque in the flange"; +end RotFlange_b; //From Modelica.Mechanics.Rotational.Interfaces + {RotFlange_b} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Block Signal Connectors</span></p></td></tr></table></body></html> + + + connector InPort "Connector with input signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + input Real signal[n] "Real input signals"; +end InPort; // From Modelica.Blocks.Interfaces + {InPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector OutPort "Connector with output signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + output Real signal[n] "Real output signals"; +end OutPort; // From Modelica.Blocks.Interfaces + {OutPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Components</span></p></td></tr></table></body></html> + + + partial model TwoPin // Same as OnePort in Modelica.Electrical.Analog.Interfaces + "Component with two electrical pins p and n and current i from p to n" + Voltage v "Voltage drop between the two pins (= p.v - n.v)"; + Current i(fixed=true) "Current flowing from pin p to pin n"; + PositivePin p; + NegativePin n; +equation + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end TwoPin; + {TwoPin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Resistor "Ideal linear electrical Resistor" + extends TwoPin; // Same as OnePort + parameter Real R(unit = "Ohm") "Resistance"; +equation + R*i = v; +end Resistor; // From Modelica.Electrical.Analog.Basic + {Resistor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Inductor "Ideal linear electrical Inductor" + extends TwoPin; // Same as OnePort + parameter Real L(unit = "H") "Inductance"; +equation + v = L*der(i); +end Inductor; // From Modelica.Electrical.Analog.Basic + {Inductor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Ground "Ground node" + Pin p; +equation + p.v = 0; +end Ground; // From Modelica.Electrical.Analog.Basic + {Ground} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model SignalVoltage "Generic Voltage source using the input signal as source Voltage" + extends TwoPin; // Same as OnePort + InPort inPort(n=1); +equation + inPort.signal[1] = v; +end SignalVoltage; // From Modelica.Electrical.Analog.Sources + {SignalVoltage} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Mechanical Components</span></p></td></tr></table></body></html> + + + partial model Rigid // Rotational class Rigid + "Base class for the rigid connection of two rotational 1D flanges" + Angle phi(fixed=true) "Absolute rotation angle of component"; + RotFlange_a rotFlange_a "(left) driving flange (axis directed into plane)"; + RotFlange_b rotFlange_b "(right) driven flange (axis directed out of plane)"; +equation + rotFlange_a.phi = phi; + rotFlange_b.phi = phi; +end Rigid; // From Modelica.Mechanics.Rotational.Interfaces + + {Rigid} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model Inertia "1D rotational component with inertia" + extends Rigid; + parameter MomentOfInertia J = 1 "Moment of inertia"; + AngularVelocity w(fixed=true) "Absolute angular velocity of component"; + AngularAcceleration a "Absolute angular acceleration of component"; +equation + w = der(phi); + a = der(w); + J*a = rotFlange_a.tau + rotFlange_b.tau; +end Inertia; //From Modelica.Mechanics.Rotational + {Inertia} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electromechanical Components</span></p></td></tr></table></body></html> + + + model EMF "Electromotoric force (electric/mechanic transformer)" + extends TwoPin; + parameter Real k(unit = "N.m/A") = 1 "Transformation coefficient"; + AngularVelocity w "Angular velocity of rotFlange_b"; + RotFlange_b rotFlange_b; // Rotational Flange_b +equation + w = der(rotFlange_b.phi); + v = k*w; + rotFlange_b.tau = - k*i; +end EMF; // From Modelica.Electrical.Analog.Basic + {EMF} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Signal Block Components</span></p></td></tr></table></body></html> + + + partial block MO "Multiple Output continuous control block" + parameter Integer nout = 1 "Number of outputs"; + OutPort outPort(n = nout) "Connector of Real output signals"; +protected + Real n[nout] = outPort.signal; +end MO; // From Modelica.Blocks.Interfaces + {MO} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + block Step "Generate step signals of type Real" + extends MO(nout = 1); + parameter Real height = 1 "Height of steps"; + parameter Real offset = 0 "Offset of output signals"; + parameter Time startTime = 0 "Output = offset for time < startTime"; +equation + outPort.signal[1] = offset + (if time < startTime then 0 else height); +end Step; // Version simplified from Step in Modelica.Blocks.Sources + {Step} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Partial DC Motor</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Complex systems are naturally described as hierachical structures often many levels deep. We would like to create a structured library component class that captures most of the essentials of DC motor circuit. This is done in the incomplete </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PartialDCMotor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model PartialDCMotor + InPort inPort; // Outside signal connector + RotFlange_b rotFlange_b; // Outside rotational flange connector + Inductor inductor1(L=0.2); + Resistor resistor1(R=10); + Ground ground1; + EMF emf1; + SignalVoltage signalVoltage1; +equation + connect(inPort, signalVoltage1.inPort); + connect(signalVoltage1.p, resistor1.p); + connect(resistor1.n, inductor1.p); + connect(signalVoltage1.n, ground1.p); + connect(ground1.p, emf1.n); + connect(inductor1.n, emf1.p); + connect(emf1.rotFlange_b, rotFlange_b); +end PartialDCMotor; + {PartialDCMotor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model PartDCMotorCircuit + Step step1; + PartialDCMotor partialDCMotor1; + Inertia inertia1(J=1); +equation + connect(step1.outPort, partialDCMotor1.inPort); + connect(partialDCMotor1.rotFlange_b, inertia1.rotFlange_a); +end PartDCMotorCircuit; + {PartDCMotorCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of PartDCMotorCircuit </span></p></td></tr></table></body></html> + + + simulate( PartDCMotorCircuit, stopTime=100 ) + record SimulationResult + resultFile = "PartDCMotorCircuit_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( inertia1.w ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/CompConn/PhysicalConn.onb b/DrModelica/CompConn/PhysicalConn.onb new file mode 100644 index 00000000000..ccbf9e2eaf5 --- /dev/null +++ b/DrModelica/CompConn/PhysicalConn.onb @@ -0,0 +1,51 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Physical Connector Classes Based on Energy Flow</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />In addition to the previously presented translational <span style=" font-family:Courier New;">Flange_a</span> there is also a rotational Flange_a connector class., shown renamed below, from the library called <span style=" font-family:Courier New;">Modelica.Mechanics.Rotational.Intefaces</span> for one-dimensional rotational mechanical systems. <br /></p></body></html> + + + connector RotFlange_a "1D rotational flange" + Angle phi "Absolute rotational angle"; + flow Torque tau; +end RotFlange_a; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + type Angle = Real(final quantity = "Angle", final unit = "rad", displayUnit = "deg"); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + type Torque = Real(final quantity = "Torque", final unit = "N.m"); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />The connector class <span style=" font-family:Courier New;">Frame_b</span> below from the <span style=" font-style:italic;">Modelica multibody systems</span> (MBS) library is an example of a connector class of the kind that contains extra potential variables to get around problems caused by connections that cause higher index systems. <br /></p></body></html> + + + connector Frame_b "Frame b of a 3D mechanical element" + import Modelica.SIunits; + output SIunits.Position r0[3] "Frame origin in inertial system"; + Real S[3, 3] "Transformation matrix"; + SIunits.Velocity v[3] "Absolute velocity of frame origin"; + SIunits.AngularVelocity w[3] "Absolute angular velocity of frame a"; + SIunits.Acceleration a[3] "Absolute acceleration of frame origin"; + SIunits.AngularAcceleration z[3] "Absolute angular acceleration"; + flow SIunits.Force f[3]; + flow SIunits.Torque t[3]; +end Frame_b; // From ModelicaAdditions.MultiBody.Intefaces + + + + + diff --git a/DrModelica/CompConn/SignalBased.onb b/DrModelica/CompConn/SignalBased.onb new file mode 100644 index 00000000000..2f49da6af0a --- /dev/null +++ b/DrModelica/CompConn/SignalBased.onb @@ -0,0 +1,44 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Signal Based Connector Classes</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Signal based connector classes are very simple. All that is needed is a vector of input signals or output signals. Most application models where signal connectors are needed can be satisfied with the connector classes <span style=" font-family:Courier New;">InPort</span> and <span style=" font-family:Courier New;">OutPort</span> below, both from the library <span style=" font-family:Courier New;">Modelica.Blocks.Interfaces.<br /></span></p></body></html> + + + connector InPort "Connector with input signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + input Real signal[n] "Real input signals"; +end InPort; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + connector OutPort "Connector with output signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + output Real signal[n] "Real output signals"; +end OutPort; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />The <span style=" font-family:Courier New;">InPort</span> and <span style=" font-family:Courier New;">OutPort</span> connector classes can be specialized to different numbers of signals when instantiated,as in the class <span style=" font-family:Courier New;">MISO</span> below</p></body></html> + + + partial block MISO "Multiple Input Signal Output continuous control block" + parameter Integer nin = 1 "Number of inputs"; + InPort inPort(n = nin) "Connector of Real input signals"; + OutPort outPort(n = 1) "Connector of Real output signal"; +protected + Real u[:] = inPort.signal "Input signals"; + Real y = outPort.signal[1] "Output signal"; +end MISO; // From Modelica.Blocks.Interfaces + + + + + diff --git a/DrModelica/DiscreteHybrid/Automata.onb b/DrModelica/DiscreteHybrid/Automata.onb new file mode 100644 index 00000000000..42fbdfbb553 --- /dev/null +++ b/DrModelica/DiscreteHybrid/Automata.onb @@ -0,0 +1,63 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Finite State Automata</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Sample Signal Generator</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following is an example of a simple generator model that produces periodic sampling signals. The state transitions of the finite state automaton are hidden inside the implementation of the built-in function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model SampleSignalGenerator + parameter Real startTime = 0; + parameter Real period = 1; + output Boolean outSignal; + equation + outSignal = sample(startTime, period); +end SampleSignalGenerator; + {SampleSignalGenerator} + + + simulate(SampleSignalGenerator) + record SimulationResult + messages = "", + simulationTime = 0.17332875787735505 +end SimulationResult; + + + + + + plot(period) + [done] + + + + + diff --git a/DrModelica/DiscreteHybrid/ClassesforCPT.onb b/DrModelica/DiscreteHybrid/ClassesforCPT.onb new file mode 100644 index 00000000000..7955f1787e5 --- /dev/null +++ b/DrModelica/DiscreteHybrid/ClassesforCPT.onb @@ -0,0 +1,637 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Classes for Connectors, Places and Transitions</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Petri Nets</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Petri Nets</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are bipartite graphs that only allow connection of different kinds of nodes, places to transitions or transitions to places. The Modelica type system can ensure that only legal connections are made if we define two different connector classes, one class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PTPort</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for for places to transitions-with class prefix and variable suffixes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PT</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and another class TP</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Port</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for transitions for places - with class prefix and variable suffixes TP. Since variable names are different, the connector types are different in the Modelica type system, even though the connector classes in both cases represent the same kind of variables:state and firing information. <br /><br />In order to have slightly different connector icons for the input version (filled triangle) and the output version (unfilled triangle), we also define otherwise identical input and output versions of these connector classes, see below. There is also a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ConditionPort</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> connector class for specifying an optional input condition to a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Transition</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span></p></td></tr></table></body></html> + + + connector PTPort "Connecting Places to Transitions" + Boolean sPT "state information"; + Boolean fPT "firing information"; +end PTPort; + {PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector PTPortIn = PTPort; // Input version of PTPort + {PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector PTPortOut = PTPort; // Output version of PTPort + {PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector TPPort "Connecting Transitions to Places" + Boolean sTP "state information"; + Boolean fTP "firing information"; +end TPPort; + {TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector TPPortIn = TPPort; // Input version of PTPort + {TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector TPPortOut = TPPort; // Output version of PTPort + {TPPortOut,TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector ConditionPort "Optional condition to a Transition" + Boolean c(start=true); +end ConditionPort; + {ConditionPort,TPPortOut,TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We now define </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Place</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Transition</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> classes.<br /></span></p></td></tr></table></body></html> + + + class Place + parameter Integer nIn = 1 "Number of input transition ports"; + parameter Integer nOut = 1 "Number of output transition ports"; + TPPortIn inTrans[nIn] "Vector of input transition connectors"; + PTPortOut outTrans[nOut] "Vector of output transition connectors"; + Boolean state; + Boolean ostate; + Boolean d1, d2; // Dummy variables + equation + ostate = pre(state); // ostate is the current state + // Report state to input transitions, vector equation + cat(1,inTrans.sTP,{d1}) = cat(1,{ostate},inTrans.sTP or inTrans.fTP); + // Report state to output transitions, column matrix equation + [outTrans.sPT;{d2}] = [{ostate}; outTrans.sPT and not outTrans.fPT]; + // Compute new state for next Petri net iteration + state = (ostate and not anyTrue(outTrans.sPT)) or (anyTrue(inTrans.sTP)); +end Place; + {Place,ConditionPort,TPPortOut,TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class Transition + ConditionPort condition "Optional condition"; + parameter Integer nIn = 1; + parameter Integer nOut = 1; + PTPortIn inPlaces[nIn] "Vector of input place connectors"; + TPPortOut outPlaces[nOut] "Vector of output place connectors"; + Boolean fire; + equation + fire = condition.c and allTrue(inPlaces.sPT) and not anyTrue(outPlaces.sTP); + // Report firing info to input places, vector equation + inPlaces.fPT = fill(fire,nIn); + // Report firing info to output places, vector equation + outPlaces.fTP = fill(fire,nOut); +end Transition; + {Transition,Place,ConditionPort,TPPortOut,TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We also need utility </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Boolean</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> reduction functions </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">anyTrue</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">allTrue</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + function anyTrue "True, if at least one element is true in a vector" + input Boolean inp[:]; + output Boolean result; + algorithm + result := false; + for i in 1:size(inp,1) loop + result := result or inp[i]; + end for; +end anyTrue; + {anyTrue,Transition,Place,ConditionPort,TPPortOut,TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + function allTrue "True, if all elements are true in a vector" + input Boolean inp[:]; + output Boolean result; + algorithm + result := true; + for i in 1:size(inp,1) loop + result := result and inp[i]; + end for; +end allTrue; + {allTrue,anyTrue,Transition,Place,ConditionPort,TPPortOut,TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />All classes and functions are collected into a package called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">NormalPetriNet</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">:<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">encapsulated package NormalPetriNet<br /> connector PTPort ...;<br /> connector PTPortIn ...;<br /> connector PTPortOut ...;<br /> connector TPPort ...;<br /> connector TPPortIn ...;<br /> connector TPPortOut ...;<br /> connector ConditionPort ...;<br /> class Place ...;<br /> class Transition ...;<br /> function anyTrue ...;<br /> function allTrue ...; <br />end NormalPetriNet;</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">A Modelica Petri Net Model and Simulation of a Job Shop System</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We now return to our job shop system example. Its Petri net graph is shown once more below in Figure 1, with the difference that the token has advanced, representing the condition C3 that a job is currently being processed.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/3.png" width="560" height="212" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Figure 1:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> The job shop system Petri Net graph once more. The job is in the stage of being processed.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We would now like to build a Modelica Petri net model of the job shop system, using our recently developed </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">NormalPetriNet</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> package. We need modified instances of the general </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Place</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Transition</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> classes in order to reflect the different numbers of input and output ports.The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">JobShopSystem</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model follows below, containing these modified instances of places and transitions, as well as connection equations.<br /></span></p></td></tr></table></body></html> + + + model JobShopSystem + import ModelicaAdditions.PetriNets.*; + + Transition arrival(nIn = 0, nOut = 1); // E1 + Place inwait(nIn = 1, nOut = 1); // C2 + Transition synchronize(nIn = 2, nOut = 1); // E2 + Place processing(nIn = 1, nOut = 1); // C3 + Transition parallel(nIn = 1, nOut = 2); // E3 + Place idle(nIn = 1, nOut = 1); // C1 + Place outwait(nIn = 1, nOut = 1); // C4 + Transition delivery(nIn = 1, nOut = 0); // E4 + equation + connect(arrival.outPlaces, inwait.inTrans); + connect(inwait.outTrans[1], synchronize.inPlaces[1]); + connect(idle.outTrans[1], synchronize.inPlaces[2]); + connect(synchronize.outPlaces[1], processing.inTrans[1]); + connect(processing.outTrans[1], parallel.inPlaces[1]); + connect(parallel.outPlaces[1], outwait.inTrans[1]); + connect(parallel.outPlaces[2], idle.inTrans[1]); + connect(outwait.outTrans[1], delivery.inPlaces[1]); +end JobShopSystem; + {JobShopSystem,allTrue,anyTrue,Transition,Place,ConditionPort,TPPortOut,TPPortIn,TPPort,PTPortOut,PTPortIn,PTPort} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of JobShopSystem</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Finally we simulate the job shop system model using the above default settings, for a job that passes through the system and is processed.</span></p></td></tr></table></body></html> + + + loadModel(Modelica); + [done] + + + simulate( JobShopSystem, stopTime = 1 ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: JobShopSystem +[<interactive>:1:1-3:18:writable] Warning: Connector .ConditionPort is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .TPPortOut is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .TPPortIn is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .PTPortOut is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:18:writable] Warning: Connector .ConditionPort is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .PTPortIn is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .TPPortOut is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .TPPortIn is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .PTPortOut is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:18:writable] Warning: Connector .ConditionPort is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .PTPortIn is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .TPPortOut is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .TPPortIn is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .PTPortOut is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .TPPortIn is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .PTPortOut is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:18:writable] Warning: Connector .ConditionPort is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-4:11:writable] Warning: Connector .PTPortIn is not balanced: The number of potential variables (2) is not equal to the number of flow variables (0). +Error: Too few equations, under-determined system. The model has 28 equation(s) and 32 variable(s). +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed! +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + plot( inWait.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + plot( process.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + plot( idle.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + plot( outWait.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Job Shop System Using ModelicaAdditions.PetriNets</span></p></td></tr></table></body></html> + + + model JobShopSystemWorking +import ModelicaAdditions.PetriNets.*; +import Modelica.Blocks.Sources.*; + +SampleTrigger trig2(period={0.2},startTime={0.5}); +SampleTrigger trig1(period={0.2},startTime={0.4}); +Place01 arrivalPlace(initialState=true); +Place10 deliveryPlace; + +Transition arrival; +Place11 inWait; +Synchronize synchronize; +Place11 process; +Place11 idle(initialState=true); +Parallel parallell; +Place11 outWait; +Transition delivery; + +equation +connect(parallell.inTransition,process.outTransition); +connect(synchronize.outTransition,process.inTransition); +connect(parallell.outTransition1,idle.inTransition); +connect(outWait.inTransition,parallell.outTransition2); +connect(outWait.outTransition,delivery.inTransition); +connect(synchronize.inTransition1,idle.outTransition); +connect(synchronize.inTransition2,inWait.outTransition); +connect(inWait.inTransition,arrival.outTransition); +connect(deliveryPlace.inTransition,delivery.outTransition); +connect(arrival.inTransition,arrivalPlace.outTransition); +connect(trig2.outPort,synchronize.conditionPort); +connect(trig2.outPort,delivery.conditionPort); +connect(trig1.outPort,arrival.conditionPort); +connect(parallell.conditionPort,trig1.outPort); + +end JobShopSystemWorking; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of JobShopSystemWorking</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Finally we simulate the job shop system model using the above default settings, for a job that passes through the system and is processed.</span></p></td></tr></table></body></html> + + + simulate( JobShopSystemWorking, stopTime = 1 ); //??Error not yet implemented + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + plot( inWait.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/4.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + plot( process.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/5.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + plot( idle.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/6.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + plot( outWait.state ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/7.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + + + + diff --git a/DrModelica/DiscreteHybrid/CoupledPipeline.onb b/DrModelica/DiscreteHybrid/CoupledPipeline.onb new file mode 100644 index 00000000000..e6d5c4bc879 --- /dev/null +++ b/DrModelica/DiscreteHybrid/CoupledPipeline.onb @@ -0,0 +1,259 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A Coupled Pipelined DEVS Model (p. 400)</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The Random Package</p></body></html> + + + package Random + + True + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + import Modelica.Math; + + True + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + constant Real NV_MAGICCONST=4*exp(-0.5)/sqrt(2.0); + + True + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + type Seed=Integer[3]; + + True + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />DymolaBUG: for some strange reason Dymola crashes when the following statement is initialized<br />type Seed=Integer[3](min=zeros(3),max=ones(3)*255);<br />this will also cause MathModelica to loop forever in the evaluation of the model.<br />The follwing statement should be used instead<br />type Seed;<br /></p><p style="-qt-paragraph-type:empty; 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;"></p><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;">??Error - not yet implemented.</p></body></html> + + + function random "input random number generator with external storage of the seed" + input Seed si "input random seed"; + output Real x "uniform random variate between 0 and 1"; + output Seed so "output random seed"; +algorithm + so[1] := rem((171 * si[1]),30269); + so[2] := rem((172 * si[2]),30307); + so[3] := rem((170 * si[3]),30323); + // zero is a poor Seed, therfore substitute 1; + if so[1] == 0 then + so[1] := 1; + end if; + if so[2] == 0 then + so[2] := 1; + end if; + if so[3] == 0 then + so[3] := 1; + end if; + x := rem((so[1]/30269.0 +so[2]/30307.0 + so[3]/30323.0),1.0); +end random; + + True + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + function normalvariate "normally distributed random variable" + input Real mu "mean value"; + input Real sigma "standard deviation"; + input Seed si "input random seed"; + output Real x "gaussian random variate"; + output Seed so "output random seed"; +protected + Seed s1, s2; + Real z, zz, u1, u2; + Boolean break=false; +algorithm + s1 := si; + u2 := 1; + while not break loop + (u1,s2) := random(s1); + (u2,s1) := random(s2); + z := NV_MAGICCONST*(u1-0.5)/u2; + zz := z*z/4.0; + break := zz <= (- Math.log(u2)); + end while; + x := mu + z*sigma; + so := s1; +end normalvariate; + + True + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + connector discreteConnector + discrete Boolean dcon; +end discreteConnector; + + True + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + end Random; + + True + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">SimpleDEVSServer</p></body></html> + + + connector EventPort + Boolean signal; +end EventPort; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + model SimpleDEVSServer + import Modelica.Constants.inf; // ?? check if import specified constant + extends BasicDEVSTwoPort; + Boolean internalEvent; + Boolean externalEvent; + parameter Real mean = 2.0 "mean of job service time"; + parameter Real stdev = 0.5; + discrete Real servTime; // time needed to service current job + discrete Random.Seed randomSeed(start={23,87,187}); + +equation + internalEvent = pre(tNextEvent)<=time; + externalEvent = inp.signal; + //outp.signal = internalEvent; + when {externalEvent,internalEvent} then + (servTime,randomSeed) = Random.normalvariate(mean,stdev, pre(randomSeed)); + if edge(externalEvent) and not pre(DEVSactive) then + DEVSactive = true; + tNextEvent = time + abs(servTime); + elseif edge(externalEvent) and pre(DEVSactive) then + DEVSactive = true; + tNextEvent = pre(tNextEvent); + else + DEVSactive = false; + tNextEvent = pre(tNextEvent); + end if; + end when; + + outp.signal = if pre(DEVSactive) and edge(internalEvent) then true else false; +end SimpleDEVSServer; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + model SignalView "Increase width of sample trigger signals" // ?? update + EventPort inp; + EventPort outp; + parameter Real width=0.001; + discrete Real T0; +equation + when inp.signal then + T0=time; + end when; + outp.signal=(time>=T0) and (time<T0+width); +end TriggerSignalView; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Conn1 +equation + connect(simpleDEVSServer.outp, viewSignal2.inp); +end Conn1; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Conn2 +equation + connect(generateJobEvents.outp, viewSignal1.inp); +end Conn2; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">ThreeServerPipeline Model</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Several basic DEVS model components can be connected together to form a coupled model, which itself is a DEVS model. This is illustrated by the Modelica realization of a simple DEVS coupled model by placing three simple servers in series to form a three server pipeline, see Figure ?? In the further down the job generator has been attached to the three server pipeline. The generator outputs events that are considered to be jobs that need some time to be processed by the server.Inside the basic server model only the time needed to complete a job is represented,not the detailed manner in which the processing is done.When a server receives a job it goes into busy mode (<span style=" font-family:Courier New;">DEVSactive = true</span>). Since the server has no buffering capabilities,if it is already busy,it ignores incoming jobs.When a server has finished processing a job, a job completed event is emitted and the server returns to passive mode (<span style=" font-family:Courier New;">DEVSactive = false</span>).</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/43.png" width="440" height="137" /></span></p></body></html> + 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 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New; font-weight:600;">Figure ??:</span><span style=" font-family:Courier New;"> Coupled model consisting of three servers S1, S2, and S3, connected in a pipeline.</span></p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The coupled pipelined DEVS model class represented in Modelica can be described as follows:</p></body></html> + + + model ThreeServerPipeline + input EventPort extInSignal; + output EventPort outSignal; + SimpleDEVSServer S1(mean=2.0); + SimpleDEVSServer S2(mean=2.5); + SimpleDEVSServer S3(mean=1.5); +equation + connect(extInSignal, S1.inp); + connect(S1.outp, S2.inp); + connect(S2.outp, S3.inp); + connect(S3.outp, outSignal); +end ThreeServerPipeline; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + model testPipeline + ThreeServerPipeline pipeLine; + GenerateJobEvents jobgenerator(period=4); +equation + connect(jobgenerator.outp, pipeLine.extInput); +end testPipeline; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Simulate</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New; font-weight:600;">Diagram ??:</span><span style=" font-family:Courier New;"> Signals for the testPipeline model including a ThreeServerPipeline containing the servers S1, S2, and S3.</span></p></body></html> + + + + + + diff --git a/DrModelica/DiscreteHybrid/DCMotorwithBacklash.onb b/DrModelica/DiscreteHybrid/DCMotorwithBacklash.onb new file mode 100644 index 00000000000..127ab287230 --- /dev/null +++ b/DrModelica/DiscreteHybrid/DCMotorwithBacklash.onb @@ -0,0 +1,527 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">DC Motor with Backlash</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/12.png" width="460" height="169" /></p></td></tr></table></body></html> + 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 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Standard Modelica Library Components</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/13.png" width="398" height="171" /></p></td></tr></table></body></html> + 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 + + + model DCMotorCircuit + Modelica.Mechanics.Rotational.Components.Inertia inertia1(J = 1.0, w(fixed = true), phi(fixed = true)); + Modelica.Electrical.Analog.Basic.Inductor inductor1(L = 1.0, i(fixed = true)); + Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 1.0); + Modelica.Electrical.Analog.Basic.Ground ground1; + Modelica.Electrical.Analog.Basic.EMF emf1(k = 1.0); + Modelica.Blocks.Sources.Step step1; + Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage1; +equation + connect(step1.y, signalVoltage1.v); + connect(signalVoltage1.n, resistor1.p); + connect(resistor1.n, inductor1.p); + connect(signalVoltage1.p, ground1.p); + connect(ground1.p, emf1.n); + connect(inductor1.n, emf1.p); + connect(emf1.flange, inertia1.flange_a); +end DCMotorCircuit; + {DCMotorCircuit} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DCMotorCircuit</span></p></td></tr></table></body></html> + + + loadModel(Modelica); + [done] + + + simulate( DCMotorCircuit, stopTime=10 ) + record SimulationResult + resultFile = "DCMotorCircuit_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( inertia1.w ) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modelica.Mechanics.Rotational.ElastoBacklash</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This element consists of a backlash element connected in series to a spring and damper element which are connected in parallel. The spring constant shall be non-zero, otherwise the component cannot be used. <br />In combination with components IdealGear, the ElastoBacklash model can be used to model a gear box with backlash, elasticity and damping.<br />The parameters are: </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Name Default Description</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">b 0 Total backlash [rad]</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">c 1.e5S pring constant (c &gt; 0 required) [N.m/rad]</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">phi_rel0 0 Unstretched spring angle [rad]</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">d 0 Damping constant [N.m.s/rad]</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/14.png" width="460" height="169" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAHMAAAAqQgGAAAAppUN2wAAAARzQklUCAgICHwIZIgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAzESURBVHic7d3PjuTEAQfgarQSJw4cQkBw4TFASTggQd6FhFOUPEMQN7TvEpA4kKyYC3kIiCAKcGBv3JzDyjser8su/ym7yv4+abXT3W673FNTP1e52r41TdMEAGDUS0cXAABqIDABIIHArNjtdhv8t8V6t1hmD0vLsbb8pew/sJ9HRxeAdYZOQd9ut8Hn16wT4Or0MC8g1vsce35smfbnqeViy+bS3dbQ9saen3pcw/4Deelhnly/t9k+jj2f8t7++6fWtbbHO0esXP2f16yv5P0H8hGYlRtq/Jc0zinvWdro7xkWqfuxpMdXw/4D+QjMyqX0ZGKh2n1+6H0pywBchcA8kaGh1vb52PKtWNgaWgR4xqSfi5kzCcVElYd8HnBtepgn0+9lxoZVtxiS7U+CGVvX0cbOW6a+VvP+A+vdXEsWAKYZkgWABAITABIITABIYNLPyRw5kdPZcODMBOYJHRFcvnEBnJ3A5PS6Yd4/mIi9tuQ9wLkJTE7tdnsxCNvHsdeGng8h/prQhGsQmBUZGvYsubHOUd456xwKszb0ht43FIjd58deGytDanmBsglMsooNc8akX36ue43beWVaohu0Q8Zee/beW9KyS7j2COzDlX4yynft0fFfWUmTfvphMWWqOtbWY8s9hOuC+LAfPczMtmzMUsKipK+V3A99Ns8fX7FtN4MYzkFgktX2w4/bri+32soLxAnMitTW+NZWXoAxLo0HAAkEJgAkMCR7QiaZAGxPYJ6M84YAeRiSBYAEephwMrELRdx/H3b4Ygf954fWk/I+OCuBCSc0fcWk6XBMXQ9chSFZYBE9S65GYMIFNU3zvHe4NPiEJVdjSBZOKPX845z1CEiuTmDCCW0VbkIS7hmSBYAEAhMuqj2PeVQvMscM24c36p63fjN+mWJIFk5oq3OYNZuzv8JyXzkO1Ia+KpWyjTnn6QUmnMzUH3339djPKeuZu9yYtnFrG6/+OmONWv99/edi3zWdWgf1Sw3LOSErMDPo/t21P1/s4J7MzljHuo1V7Oepx3OuYtQ+vlrPuzQ5DpaGfh5ax9zfvcDMpGmeNWTt/8C4pcGV8j6hWLajDpbmEpgbu/8y+PBrOf9wY0doc7cdG9KiRNf4/WwxXGrItVwlHCyltHePaqxDpbbh90FzX8Znf6SGfmCNtX87qdfOpTwlHSw9CqHcABpSSz1P6WF2e4RDQwtzx/SH1jW03ZT1xC6bNnY+YWz7se3AXGtHPoRlXfY4WEqtUy98D/Puyd2qwvHsAKT97JumGTwgaX9Bsdl5sde7z6+Z2Te1nqEJEbH3jO3LVuXloYd1rK6D3rnaetP+W3IHle46HLTVa237sSYsQ4hcuEBoLtP/ww4h7Zc79MuK/QKP/GM3uYItzflKS/egK2W5ua/FnuNYuQ+Wugf99+123INJP4JyvYc9snxf0J0qQ66JO0uO8PQqga65B0tT65h6nPJziuil8YTnfHsEQ3+Ic09Lt919j6N4oFauJVuANechY3J/LSS27al90dsEanULoXnQpt49uQvv/O6d40o0ofuVjRLFJs+0r82ZJbv1+8bKOvS+oVm6Y9seen5sO6xX+t8DnIkLF2ysfw4z9trQ49TlUsfjp8JpavtTEyNSzwUISVgn9So25CUwDzLWE63NmfaFMuQauq+5bl4tHEusA9kCc6udra2C9He7+7i7K7Xt15gz7Qv7OzIIag4h8wGWKfZasrVWxCXautvd5f75paFlgGFvvvnmpuv7/vvvN13fXvpzCrpyT+7bU2w/cteDOZ+fIdmV5oRgu4zgZK1u23nWiT9vvP7GpuurNTCvrqR6IDBXWNpQdYPzjA0d+cQOtmJD/zV76623Nl3fN//+ZtP1sY+S6oHAhApMjUqMnQqo1dtvv310EbKLnYeMzVAfGj4cG649g5LqgcBcaItGqWnO07iRz9w6Uku96t9UIISHjfxrv3ltt22XdI3mlMk8/TIvWUcppn4Xe9SD2J2h+gTmAls2RrU0bhxjzbB/6fVqqnF6/bevH7btI+W8FnSJaqoHArPjjOeBoFavvvrq0UWgACXVA4EZMTa5YuswraE3wP7W1olS6tXS4cFXXnll45IsL0spvbzY+crSrSlzKfWgaZo6A3PPRsBXQKjdvLYhz+SRj/78UQghhMefPQ4hhPDhBx9Gl/38i89DCCG8/PLLq7c7JGXbsWshL1XbpJwcV+9q60AIZdeDsTpQZWC2R87tz3uo8KAOnvvrX/42ucwnn/49hDAvLFLD5PFnjx80mB//6ePosm2D9dJLeW6mlLLtEIYnJcWkBMpQYIytb+z85R5h27+xwpiUZfp1IIQy60G3DvRVGZjPtLObcm+n3KNASPXeH96bXOaTT+9/3jIsbrfbCw3lV//8arI8uaRuO3YXoL7b7bYoMHIPraasf2p2bX8Waep6hsrSrwMh1FEPurLd3ivX7K52ODZHD3Oqfs09J5RrWa5hizrR1ukPP/jj5LKff/GPEMK8W8SllWFZMHz5xZerttv3/gfvL37vFp9Bv4eZcxZsynrHbgc4dtvApeVZqpR64BxmIkFG7Z6FYZqtez5LGtvb7RZ+/fXXTcuxtCxbmRqGLc2W9WBpHQghFFUPqgzMver80HZyzDzUuySneXWrnIr4y9Nfji7CZo6e4DO3l3h0ebtKqgdVBmZuBdUVLmztwVntB2I//fTT0UU4zNzeXUkBt7WS6oHA7DhxnYPiTH3V4tvvvj1s20eaE5allHmNqa+w7FkPXBovgy2HZWvvBZDX0rpWQ72amlTy4/9+PGzbR/v6X19PLvPu79/doST5HV0P3A9zB1uEZg2NGsebMyv8TBfa+O4/3x1dhFMr8UBhSEn1QGCusCY0hSVztHUl5atPZ/HDf384uggUoKR6IDBXWhKawpKl9ri2cSmePn16dBFOo9Zr0IZQVj0QmBvoDpm1j/vcCQXm+fnnn48uwqnUMgTbakO+pHogMDfSrYvdcDzTOSXYS22N+xrdnt/c/Y71Gs/y+ZW2HwIzg+75psJ+30BB1gZCaYFydnkuA7/S3ZO7o4sAAA8UGZghPAtNwQlAKZ4PyXbDaavZVFsEXruOLe6gApTnyBmchjTLUvpM3ueB2QbS3ZO7wyuRniVcy9FtDseroQ4UPelHrxK4otTL3rU9shrC5gxeuIF06WqaeVpTWamTOgb7KXbSDwCUpOgh2Vq5cAG5qWOwP4EJlYpdXQrI41EI/tjyuYUQHPYDnMEjwzhQr1JvgAxnZEgWKtWODBkhWm/qIuZrD0xS3z9UjrUHRLFt77VPZyIwM3DxdXJTx7ZXSuPfL8cVg6lUAhNgprFbcvVfax93g2+rW3rFtj22zrEe59R6l27zLGYFZn+4oPsBOQoCrqDf1vWDcOi1lGW23PbcYdgl+5S6zTNJDsyhD+MKHxBwDannD+e0eUvax7ELkKeub+45y6X7dLX2f5Mh2TlDDt0jrv5rAEeZ0xaNTRJaM9w69J7+tpbc0SPlPTn36SxWBWb7wc0dcrhaNx44j6H2rCvnqaqpbcfMHap1+m1Y8rVk21Ds/lvqqh82cC5b9P622vZW5Thyn0o3q4c55xymDxmoyZxzmN1TSrFZsf33t+3l1BDnWO8uddtj5yqH2u2l+3Q1t9Sbe01N+kkdZl0zQ6w2ufbtzJ8Z86gLsJ9dbu+liw9A7ZKHZPvd8va5rtQhB7NkAajNqnOYY69NBaGgBKAmuwzJAkDtdg9MPUsAaqSHCQAJBCYAJBCYleneNNi3cwD2436YGQ19FWc77QXvM62e4pkPAPtKvtIPZegHpN8ewD4MyQJAAoEJAAkEZmXaIdimMRwLsCeBCQAJBCYAJBCYAJBAYAJAAoEJAAkEJgAkEJgAkMC1ZAuw5HqwS97je5sAywnMAggygPIZkgWABAITABIYki3QFve4NMwLsC2BWSBhB1AeQ7IAkEBgAkACQ7IVSDmnaRgXIC+BWQFhCHA8Q7IAkEBgAkACgQkACQQmACQQmACQQGACQAKBCQAJBCYAJBCYAJBAYAJAAoEJAAkEJgAkEJgAkEBgAkACgQkACQQmACQQmACQQGACQAKBCQAJBCYAJBCYAJBAYAJAAoEJAAkEJgAkEJgAkEBgAkACgQkACQTmgW632/N/JSilHAAlenR0Aa7qdruFpmmijwEoix7mAYbCsWmaBz289uf+c0M90rHH3fUM9SBL6uEClEwPsyD9EO0G65oeaWw9/Z8BiNPDLECs57jVEG3KegwHA4wTmAVomkZgARROYAJAAoF5gP4EnxDMkgUonUk/B+mH5lRYji0/FMBLygBA3K3RrQGASYZkASCBwASABAITABL8H7PhehyOeIFeAAAAAElFTkSuQmCC + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Source Code</span></p></td></tr></table></body></html> + + + model DCMotorCircuitBacklash + Modelica.Mechanics.Rotational.Components.Inertia inertia1(J=1), + inertia2(J=6, w(fixed = true), phi(fixed = true)); + Modelica.Electrical.Analog.Basic.Inductor inductor1(L = 1.0, i(fixed = true)); + Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 1.0); + Modelica.Electrical.Analog.Basic.Ground ground1; + Modelica.Electrical.Analog.Basic.EMF emf1(k = 1.0); + Modelica.Blocks.Sources.Step step1; + Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage1; + Modelica.Mechanics.Rotational.Components.ElastoBacklash + elastoBacklash( b=3, c=10, d=0.8, w_rel(fixed = true), phi_rel(fixed = true)); + +equation + connect(step1.y, signalVoltage1.v); + connect(signalVoltage1.n, resistor1.p); + connect(resistor1.n, inductor1.p); + connect(signalVoltage1.p, ground1.p); + connect(ground1.p, emf1.n); + connect(inductor1.n, emf1.p); + + //connect(emf1.flange_b, inertia1.flange_a); + + connect(emf1.flange,inertia1.flange_a); + connect(inertia1.flange_b, elastoBacklash.flange_a); + connect(elastoBacklash.flange_b,inertia2.flange_a); + +end DCMotorCircuitBacklash; + {DCMotorCircuitBacklash} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DCMotorCircuitBackClash</span></p></td></tr></table></body></html> + + + loadModel(Modelica); + [done] + + + simulate( DCMotorCircuitBacklash, stopTime=25 ) + record SimulationResult + resultFile = "DCMotorCircuitBacklash_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( elastoBacklash.w_rel ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( elastoBacklash.phi_rel ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { inertia1.w, inertia2.w } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model DCMotorCircuitBacklash2 = + DCMotorCircuitBacklash( inertia1(J=1), inertia2(J=1), elastoBacklash( b=1, c=1e5, d=0 ) ); + {DCMotorCircuitBacklash2} + + + simulate( DCMotorCircuitBacklash2, stopTime=25 ) + record SimulationResult + resultFile = "DCMotorCircuitBacklash2_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { inertia1.w, inertia2.w } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">SimpleElastoBacklash</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Most properties of the elastic transmission with backlash, both continuous and discrete, are represented in the partial model SimpleElastoBacklash below. This is a typical hybrid mode switching model, with the finite state automaton represented by the equations for the Boolean variables backward, forward and slack and the conditional equation for the torque tau having different right hand side expressions in the three operationg modes.</span></p></td></tr></table></body></html> + + + partial model SimpleElastoBacklash + Boolean backward, slack, forward; // Mode variables + parameter Real b "Size of backlash region"; + parameter Real c = 1.e5 "Spring constant (c>0), N.m/rad"; + Flange_a flange_a "(left) driving flange - connector"; + Flange_b flange_b "(right) driven flange - connector"; + parameter Real phi_rel0 = 0 "Angle when spring exerts no torque"; + Real phi_rel "Relative rotation angle betw. flanges"; + Real phi_dev "Angle deviation from zero-torque pos"; + Real tau "Torque between flanges"; +equation + phi_rel = flange_b.phi - flange_a.phi; + phi_dev = phi_rel - phi_rel0; + backward = phi_rel < -b/2; // Backward angle gives torque tau<0 + forward = phi_rel > b/2; // Forward angle gives torque tau>0 + slack = not (backward or forward); // Slack angle gives no torque + tau = if forward then // Forward angle gives + c*(phi_dev - b/2) // positive driving torque + else (if backward then // Backward angle gives + c*(phi_dev + b/2) // negative braking torque + else // Slack gives + 0); // zero torque +end SimpleElastoBacklash; + {SimpleElastoBacklash,DCMotorCircuitBacklash2,DCMotorCircuitBacklash,ModelicaServices,Complex,Modelica,DCMotorCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model ElastoBacklash + "Backlash connected in series to linear spring and damper + (backlash is modeled with elasticity)" + extends Modelica.Mechanics.Rotational.Interfaces.PartialCompliant; + import SIunits = Modelica.SIunits; + parameter SIunits.Angle b = 0 "Backlash size parameter"; + parameter Real c = 1.e5 "Spring constant (c>0), N.m/rad"; + parameter SIunits.Angle phi_rel0 = 0 "Angle with zero spring torque"; + parameter Real d = 0 "Damping constant, N.m.s/rad"; + SIunits.Angle phi_dev "Angle deviation from zero pos"; + SIunits.AngularVelocity w_rel "Relative rotation speed + between flange_b and flange_a"; + protected + SIunits.Angle b2 = b/2 "Half backlash"; + constant SIunits.Angle b_min = 1.e-10 "minimum backlash"; +equation + w_rel = der(phi_rel); + phi_dev = phi_rel - phi_rel0; + tau = if b2 > b_min // Slack behavior enabled + then (if phi_dev > b2 // Forward angle gives + then c*(phi_dev - b2) + d*w_rel // positive torque + else (if phi_dev < -b2 // Backward angle gives + then c*(phi_dev + b2)+ d*w_rel // negative torque + else 0) // Slack gives zero torque + ) + else + c*phi_dev + d*w_rel; // Slack behavior disabled if b/2 <= b_min +end ElastoBacklash; + {ElastoBacklash} + + + loadModel(Modelica); + [done] + + + simulate(ElastoBacklash) + record SimulationResult + resultFile = "", + messages = "Failed to build model: ElastoBacklash" +end SimulationResult; +OMC-ERROR: +"Error: Internal error Found Equation without time dependent variables flange_b.tau = 0.0 + +Error: Internal error pre-optimization module removeSimpleEquations failed. +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed! +" + + + + + + diff --git a/DrModelica/DiscreteHybrid/DEVS.onb b/DrModelica/DiscreteHybrid/DEVS.onb new file mode 100644 index 00000000000..96940d9e986 --- /dev/null +++ b/DrModelica/DiscreteHybrid/DEVS.onb @@ -0,0 +1,763 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Discrete Event System Specification (DEVS)</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">The Random Package</span></p></td></tr></table></body></html> + + + package Random +import Modelica.Math; +constant Real NV_MAGICCONST = 4 * exp( -0.5 ) / sqrt( 2.0 ); +type Seed=Integer[3]; + +function random "input random number generator with external storage of the seed" + input Seed si "input random seed"; + output Real x "uniform random variate between 0 and 1"; + output Seed so "output random seed"; +algorithm + so[1] := rem((171 * si[1]),30269); + so[2] := rem((172 * si[2]),30307); + so[3] := rem((170 * si[3]),30323); + // zero is a poor Seed, therfore substitute 1; + if so[1] == 0 then + so[1] := 1; + end if; + if so[2] == 0 then + so[2] := 1; + end if; + if so[3] == 0 then + so[3] := 1; + end if; + x := rem((so[1]/30269.0 +so[2]/30307.0 + so[3]/30323.0),1.0); +end random; + +function normalvariate "normally distributed random variable" + input Real mu "mean value"; + input Real sigma "standard deviation"; + input Seed si "input random seed"; + output Real x "gaussian random variate"; + output Seed so "output random seed"; +protected + Seed s1, s2; + Real z, zz, u1, u2; +algorithm + s1 := si; + u2 := 1; + while true loop + (u1,s2) := random(s1); + (u2,s1) := random(s2); + z := NV_MAGICCONST*(u1-0.5)/u2; + zz := z*z/4.0; + if zz <= (- Math.log(u2)) then + break; + end if; + end while; + x := mu + z*sigma; + so := s1; +end normalvariate; + +connector discreteConnector + discrete Boolean dcon; +end discreteConnector; + +end Random; + {Random} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">DEVS Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We will now describe a fairly comprehensive example on how DEVS models can be represented in Modelica. One difference in Modelica is that we have a built-in time variable for absolute time rather than a local timer tlocal that is reset at the most recent event. This local timer is not really needed for modeling purposes since time is available, but is included to show the relation to traditional DEVS models. The facilities for model structuring and reuse are in general much greater in Modelica due to its object-oriented properties compared to traditional DEVS. In order to simplify comparisons this example connects model components such as servers or generators in a way that is analogous to traditional DEVS.<br /></span></p></td></tr></table></body></html> + + + connector EventPort + Boolean signal; +end EventPort; + {EventPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + partial model BasicDEVSTwoPort + + import Modelica.Constants.inf; // import constant inf + input EventPort inp; // Input port for external events + output EventPort outp; // Output port for emitted events + Boolean DEVSactive(start=false); // Start in non-active mode (phase) + Real tResidual(start=inf); // Time until internal event (sigma) + Real tlocal(start=0); // Local timer reset at events (e) + discrete Real tNextEvent(start=0.0001); // Time of next internal event + discrete Real tLastEvent(start=0); // Time of most recent event +equation + tResidual = if tNextEvent<time // tNextEvent==inf + then inf else tNextEvent-time; + tlocal = if inp.signal or tNextEvent<=time // extern or intern ev + then 0 else time - tLastEvent; + when {inp.signal, pre(tNextEvent)<=time} then + tLastEvent = time; // Note the time of this event + end when; +end BasicDEVSTwoPort; + {BasicDEVSTwoPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A simple job shop model illustrates DEVS based modeling. A generator for arriving jobs is connected to a simple DEVS based server.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/26.png" width="439" height="137" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">The testDEVSServer model connects a job generator to a simple DEVS-based server.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">testDEVSServer Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">testDEVSServer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model contains two main items: a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">generateJobEvents</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> generator component that generates arriving jobs at regular intervals, and a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">simpleDEVSServer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> server component being a very simple model of a job shop system that services arriving jobs with a normally distributed service time. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">SignalView</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class instances are needed to widen sharp peaks for plotting.<br /></span></p></td></tr></table></body></html> + + + model testDEVSServer + GenerateJobEvents generateJobEvents(period=1.5,startTime=3); + SimpleDEVSServer simpleDEVSServer; + SignalView viewSignal1; // Not shown, just for plotting + SignalView viewSignal2; // Not shown, just for plotting + equation + connect(generateJobEvents.outp, simpleDEVSServer.inp); + connect(simpleDEVSServer.outp, viewSignal2.inp); + connect(generateJobEvents.outp, viewSignal1.inp); // Just for plotting +end testDEVSServer; + {testDEVSServer} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model GenerateJobEvents "Generates Job events periodically" + output EventPort outp; // Output port + parameter Real startTime = 0; + parameter Real period = 2; +equation + outp.signal = sample(startTime,period); +end GenerateJobEvents; + {GenerateJobEvents} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">SimpleDEVSServer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">SimpleDEVSServer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class is a fairly straightforward extension of the basic DEVS class BasicDEVSTwoPort. A randomly distributed service time variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">servTime</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has been added with a normal distribution determined by parameters </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">mean</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">stdev</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The discrete </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">randomSeed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> variable is needed to store the seed between calls to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">normalvariate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which as all Modelica functions is a mathematical function whose value is completely determined by its inputs. The absolute value of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">servTime</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used to guarantee positive service times.<br /></span></p></td></tr></table></body></html> + + + model SimpleDEVSServer + import Modelica.Constants.inf; // import constant inf + extends BasicDEVSTwoPort; + Boolean internalEvent; + Boolean externalEvent; + parameter Real mean = 2.0 "mean of job service time"; + parameter Real stdev = 0.5; + discrete Real servTime; // time needed to service current job + discrete Random.Seed randomSeed(start={23,87,187}); + +equation + internalEvent = pre(tNextEvent)<=time; + externalEvent = inp.signal; + //outp.signal = internalEvent; + when {externalEvent,internalEvent} then + (servTime,randomSeed) = Random.normalvariate(mean,stdev, pre(randomSeed)); + if edge(externalEvent) and not pre(DEVSactive) then + DEVSactive = true; + tNextEvent = time + abs(servTime); + elseif edge(externalEvent) and pre(DEVSactive) then + DEVSactive = true; + tNextEvent = pre(tNextEvent); + else + DEVSactive = false; + tNextEvent = pre(tNextEvent); + end if; + end when; + + outp.signal = if pre(DEVSactive) and edge(internalEvent) then true else false; +end SimpleDEVSServer; + {SimpleDEVSServer} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model SignalView "Increase width of sample trigger signals" + EventPort inp; + EventPort outp; + parameter Real width=0.001; + discrete Real T0; +equation + when inp.signal then + T0=time; + end when; + outp.signal=(time>=T0) and (time<T0+width); +end SignalView; + {SignalView} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Remember the following two connect equations from the testDEVSServer model. When using the currently available Modelica tools it is necessary to employ some kind of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">SignalView</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> peak widening facility in order to plot sharp peaks that have zero width, i.e. have no time duration. Otherwise these peaks would not be visible in the diagram.<br /></span></p></td></tr></table></body></html> + + + class Conn1 +equation + connect(simpleDEVSServer.outp, viewSignal2.inp); +end Conn1; + {Conn1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class Conn2 +equation + connect(generateJobEvents.outp, viewSignal1.inp); +end Conn2; + {Conn2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of testDEVSServer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the testDEVSServer model to be able to view some of the input and output signals. The plot agrees with the specification of the generateJobEvents instance, where the first event is generated at time = 3 and subsequent events are generated with a periodicity 1.5 seconds.<br /></span></p></td></tr></table></body></html> + + + loadModel(Modelica); + [done] + + + simulate( testDEVSServer, stopTime=10 ) + record SimulationResult + resultFile = "C:/Users/alash325/AppData/Local/Temp/OpenModelica/testDEVSServer_res.mat", + simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'testDEVSServer', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''", + messages = "", + timeFrontend = 0.29449405836669884, + timeBackend = 0.023494134257118944, + timeSimCode = 0.007212156252142438, + timeTemplates = 0.01682897562231061, + timeCompile = 1.373207088825154, + timeSimulation = 0.2676402148835412, + timeTotal = 1.9829594844144174 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:14:writable] Warning: Connector EventPort is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +Error: Model is structurally singular, error found sorting equations 2: $PRE.simpleDEVSServer.randomSeed[2] = $_start(simpleDEVSServer.randomSeed[2]); +4: $PRE.simpleDEVSServer.randomSeed[1] = $_start(simpleDEVSServer.randomSeed[1]); + for variables simpleDEVSServer.randomSeed[3](1), simpleDEVSServer.randomSeed[2](3) +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelites failed! +Warning: No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead. +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + + + plot( { viewSignal1.outp.signal, viewSignal2.outp.signal, simpleDEVSServer.DEVSactive } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/27.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 1:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> viewSignal1.outp.signal, viewSignal2.outp.signal and DEVSactive</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + + plot( { viewSignal1.outp.signal, viewSignal2.outp.signal } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 2:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> - viewSignal1.outp.signal and viewSignal2.outp.signal</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + plot( viewSignal1.outp.signal ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 3:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> - The output signal outp of the generateJobEvents generator component in testDEVSServer.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + plot( simpleDEVSServer.tNextEvent ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 4:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> - The output signal simpleDEVSServer.tNextEvent.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + plot( viewSignal2.outp.signal ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 5:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> - A signal is emitted through simpleDEVSServer.outp when completing \\ service of a job, here Job 1 and Job 3.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + plot( simpleDEVSServer.DEVSactive ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 6:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> - The variable simpleDEVSServer.DEVSactive is true while a job is being serviced.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + plot( simpleDEVSServer.servTime ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 7:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> - The service time variable simpleDEVSServer.servTime obtains new values at events.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Plot</span></p></td></tr></table></body></html> + + + + + + plot( simpleDEVSServer.internalEvent ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 8:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> - The output signal simpleDEVSServer.internalEvent.</span></p></td></tr></table></body></html> + + + + + + + diff --git a/DrModelica/DiscreteHybrid/EventBeh.onb b/DrModelica/DiscreteHybrid/EventBeh.onb new file mode 100644 index 00000000000..322ae494d97 --- /dev/null +++ b/DrModelica/DiscreteHybrid/EventBeh.onb @@ -0,0 +1,208 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Expressing Event Behavior in Modelica</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Expressing Event Behavior in Modelica</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The conditional equations associated with an event become active when the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">condition</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of the equations switches from the value false and true. There are basically two groups of conditional equation constructs in Modelica: </span><a href="Equations/IfEq.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">if-equations</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><a href="Equations/WhenEq.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">when-equations</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. In the Diode example below different equations are specified.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Units</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + {Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector PositivePin "Positive pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end PositivePin; //From Modelica.Electrical.Analog.Interfaces + {PositivePin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector NegativePin "Negative pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end NegativePin; //From Modelica.Electrical.Analog.Interfaces + {NegativePin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Electrical Components</span></p></td></tr></table></body></html> + + + partial model TwoPin // Same as OnePort in Modelica.Electrical.Analog.Interfaces + "Component with two electrical pins p and n and current i from p to n" + Voltage v "Voltage drop between the two pins (= p.v - n.v)"; + Current i "Current flowing from pin p to pin n"; + PositivePin p; + NegativePin n; +equation + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end TwoPin; + {TwoPin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Diode</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation in the ideal </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">diode</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> example below, specifies different equations for the variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in two different operating regions: the</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> v = s</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the region </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">s and the equation v = 0 in the region s &gt;= 0.<br /></span></p></td></tr></table></body></html> + + + model Diode "Ideal diode" + extends TwoPin; + Real s; + Boolean off; +equation + off = s < 0; + if off then // conditional if-equation + v = s; + else + v = 0; + end if; + i = if off then 0 else s; // equation with conditional expression +end Diode; + {Diode} + + + simulate(Diode) + record SimulationResult + messages = "Simulation failed for model: Diode +Error: Internal error Found Equation without time dependent variables n.i = 0.0 + +Error: Internal error Optimisation Module removeSimpleEquations failed. +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelites failed! +" +end SimulationResult; + + + + + + diff --git a/DrModelica/DiscreteHybrid/EventPriority.onb b/DrModelica/DiscreteHybrid/EventPriority.onb new file mode 100644 index 00000000000..37b77b83a52 --- /dev/null +++ b/DrModelica/DiscreteHybrid/EventPriority.onb @@ -0,0 +1,189 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Using Event Priority to Avoid Erroneous Multiple Definitions</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Priority in When-Statements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Two separate </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">equations or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">statements in different algorithm sections may not define the same variable. Without this rule a conflict between the equations will occur if both conditions would become true at the same time instant. This would happen for the erroneous model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">WhenConflictX</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below if we would have the same condition, e.g. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">time &gt;= 1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, in both </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations since there are two equations: x = pre(x) + 1.5 and x = pre(x) + 1 that define the same variable x.<br /></span></p></td></tr></table></body></html> + + + model WhenConflictX // Erroneous model: two equations define x + discrete Real x; +equation + when time >= 2 then // When A: Increase x by 1.5 at time >= 2 + x = pre(x) + 1.5; + end when; + when time >= 1 then // When B: Increase x by 1 at time >= 1 + x = pre(x) + 1; + end when; +end WhenConflictX; + + {WhenConflictX} + + + simulate(WhenConflictX) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: WhenConflictX +Error: Too many equations, over-determined system. The model has 2 equation(s) and 1 variable(s). +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed! +" +end SimulationResult; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Eliminating the double definition</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The multiple assignment conflict in the above example can be avoided by giving a higher priority to one of the defining equations through the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">elsewhen</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> construct, as in the same example in converted form below. We have put both equations within the same </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">equation and ordered the conditions in </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">decreasing</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> priority.<br /></span></p></td></tr></table></body></html> + + + model WhenPriorityX + discrete Real x(fixed=true); +equation + when time >= 2 then // Higher priority + x = pre(x) + 1.5; + elsewhen time >= 1 then // Lower priority + x = pre(x) + 1; + end when; +end WhenPriorityX; + + {WhenPriorityX} + + + simulate(WhenPriorityX, stopTime=10) + record SimulationResult + resultFile = "WhenPriorityX_res.mat", + messages = "" +end SimulationResult; + + + + + + plot(x) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"><br />Eliminating the double definition conflict between equations in different when-equations in the WhenPriority model by giving the event at time = 2 higher priority than the event at <br />time = 1 through the use of elsewhen in the WhenPriorityX model.</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">However, note that multiple assignments to the same variable within an algorithm section are allowed since only </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">the last assignment to the same variable in an algorithm section is counted</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + class MultipleWhen + discrete Real x(fixed=true); +algorithm + when time >= 2 then + x := pre(x) + 0.75; // multiple assignments within the same + x := x + 0.75; // when-statement or algorithm section is allowed + elsewhen time >= 1 then + x := pre(x) + 1; + end when; +end MultipleWhen; + + {MultipleWhen} + + + simulate(MultipleWhen,stopTime=10) + record SimulationResult + resultFile = "MultipleWhen_res.mat", + messages = "" +end SimulationResult; + + + + + + plot(x) + [done] + + + + + + diff --git a/DrModelica/DiscreteHybrid/FlatTank mm.onb b/DrModelica/DiscreteHybrid/FlatTank mm.onb new file mode 100644 index 00000000000..fd69559278c --- /dev/null +++ b/DrModelica/DiscreteHybrid/FlatTank mm.onb @@ -0,0 +1,1693 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Tank Model Simulation</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flat Tank Model (without any components)</span></p></td></tr></table></body></html> + + + function LimitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; +algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end LimitValue; + {LimitValue} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model FlatTank + //tank related variables and parameters + Real act; // Connector, actuator controlling input flow + parameter Real flowVout =0.02; //[m3/s] + parameter Real area =0.5; //[m2] + parameter Real flowGain =10; //[m2/s] + Real h(start=0); //tank level [m] + Real qIn; // flow through input valve[m3/s] + Real qOut; // flow through output valve[m3/s] + + //controler related variables and parameters + parameter Real Ts=0.1;//sampling time[s] + parameter Real K=2;//gain + parameter Real T=10;//time constant[s] + parameter Real minV=0,maxV=0.02;//limits for output + Real ref=0.25; + Real error,outCtr; + Real x; //state variable of continuous controller + +equation + der(h)=(qIn-qOut)/area; //mass balance equation + qOut=if time>100 then flowVout else 0; + qIn = flowGain*act; + + error = ref-h; + act = LimitValue(minV,maxV,outCtr); + der(x) = error/T; + outCtr = K*(x+error); + +end FlatTank; + {FlatTank} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of FlatTank</span></p></td></tr></table></body></html> + + + simulate( FlatTank, stopTime=250 ) + record SimulationResult + messages = "", + simulationTime = 0.14981313091687937 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flat Tank Model second approach(without any components)</span></p></td></tr></table></body></html> + + + function LimitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; +algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end LimitValue; + {LimitValue} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model FlatTank + //tank related variables and parameters + parameter Real flowVin =0.02; //[m3/s] + parameter Real area =1; //[m2] + parameter Real flowGain =0.05; //[m2/s] + Real h(start=0); //tank level [m] + Real qIn; // flow through input valve[m3/s] + Real qOut; // flow through output valve[m3/s] + + //controler related variables and parameters + parameter Real Ts=0.1;//sampling time[s] + parameter Real K=2;//gain + parameter Real T=10;//time constant[s] + parameter Real minV=0,maxV=0.02;//limits for output + Real ref=0.25; + Real error,outCtr; + Real x; //state variable of continuous controller + +equation + der(h)=(qIn-qOut)/area; //mass balance equation + qIn=if time>150 then 3*flowVin else flowVin; + qOut=LimitValue(0,10,-flowGain*outCtr); + + error = ref-h; + der(x) = error/T; + outCtr = K*(x+error); + +end FlatTank; + {FlatTank} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + simulate( FlatTank, stopTime=250 ) + record SimulationResult + messages = "", + simulationTime = 0.16996434199131977 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank Model Componets</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connectors</span></p></td></tr></table></body></html> + + + connector ReadSignal + Real val; +end ReadSignal; + {ReadSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector ActSignal + Real act; +end ActSignal; + {ActSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector LiquidFlow + Real lflow; +end LiquidFlow; + {LiquidFlow} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Functions</span></p></td></tr></table></body></html> + + + function LimitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; +algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end LimitValue; + {LimitValue} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">PI Controllers</span></p></td></tr></table></body></html> + + + partial model PIcontroller + parameter Real Ts=0.1;//sampling time[s] + parameter Real K=2;//gain + parameter Real T=10;//time constant[s] + parameter Real minV=0,maxV=1;//limits for output + Real ref,error,outCtr; + ReadSignal cInp; + ActSignal cOut; +equation + error = ref-cInp.val; + cOut.act = LimitValue(minV,maxV,outCtr); +end PIcontroller; + {PIcontroller} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model PIcontinuousController + extends PIcontroller(K=2,T=10,maxV=0.02); + Real x; //state variable of continuous controller +equation + der(x) = error/T; + outCtr = K*(x+error); +end PIcontinuousController; + + {PIcontinuousController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model PIdiscreteController + extends PIcontroller(K=2,T=10,maxV=0.02); + discrete Real x; //state variable of discrete controller +equation + when sample(0,Ts) then + x = pre(x)+error*Ts/T; + outCtr = K*(x+error); + end when; +end PIdiscreteController; + + {PIdiscreteController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">PID Controlers</span></p></td></tr></table></body></html> + + + partial model PIDcontroller + parameter Real Ts=0.1;//sampling time[s] + parameter Real K=2;//gain + parameter Real T=10;//time constant[s] + parameter Real minV=0,maxV=1;//limits for output + Real ref,error,outCtr; + ReadSignal cInp; + ActSignal cOut; +equation + error = ref-cInp.val; + cOut.act = LimitValue(minV,maxV,outCtr); +end PIDcontroller; + {PIDcontroller} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model PIDcontinuousController + extends PIDcontroller(K=2,T=10,maxV=0.02); + Real x; //state variable of continuous controller + Real y; //state variable of continuous controller +equation + der(x) = error/T; + y=T*der(error); + outCtr = K*(x+error+y); +end PIDcontinuousController; + {PIDcontinuousController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Tank</span></p></td></tr></table></body></html> + + + model Tank + ReadSignal tOut; // Connector, reading tank level + ActSignal tInp; // Connector, actuator controlling input flow + parameter Real flowVout =0.01; //[m3/s] + parameter Real area =0.5; //[m2] + parameter Real flowGain =10; //[m2/s] + Real h(start=0); //tank level [m] + Real qIn; // flow through input valve[m3/s] + Real qOut; // flow through output valve[m3/s] +equation + der(h)=(qIn-qOut)/area; //mass balance equation + qOut=if time>100 then flowVout else 0; // interface between discrete and + // continuous part + qIn = flowGain*tInp.act; + tOut.val = h; +end Tank; + {Tank} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model TankL + ReadSignal tOut; // Connector, reading tank level + ActSignal tInp; // Connector, actuator controlling input flow + LiquidFlow qIn; // flow through input valve[m3/s] + LiquidFlow qOut; // flow through output valve[m3/s] + + + parameter Real flowVout =0.01; //[m3/s] + parameter Real area =0.5; //[m2] + parameter Real flowGain=10; //[m2/s] + Real h(start=0); //tank level [m] + +equation + der(h)=(qIn.lflow-qOut.lflow)/area; //mass balance equation + qIn.lflow = flowGain*tInp.act; + tOut.val = h; +end TankL; + {TankL} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model FlowOut + LiquidFlow qOut; + parameter Real flowVOut = 0.01; +equation + qOut.lflow=if time>100 then flowVOut else 0; +end FlowOut; + {FlowOut} + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank Model with PI discrete controler</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Old Tank Model</span></p></td></tr></table></body></html> + + + model TankApplicationDiscretePI + PIdiscreteController piDiscrete; + Tank tank(area=1,flowVout=0.02); +equation + connect(tank.tInp,piDiscrete.cOut); + connect(tank.tOut,piDiscrete.cInp); + piDiscrete.ref=0.5; +end TankApplicationDiscretePI; + {TankApplicationDiscretePI} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + simulate( TankApplicationDiscretePI, stopTime=200 ) //??warning in Simulation + record SimulationResult + messages = "", + simulationTime = 0.29732275300651345 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tank.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">New Tank Model</span></p></td></tr></table></body></html> + + + model TankApplicationDiscretePInew + PIdiscreteController piDiscrete; + TankL tankn(area=1,flowVout=0.02); + FlowOut outFlow; +equation + connect(tankn.qOut,outFlow.qOut); + connect(tankn.tInp,piDiscrete.cOut); + connect(tankn.tOut,piDiscrete.cInp); + piDiscrete.ref=0.5; +end TankApplicationDiscretePInew; + {TankApplicationDiscretePInew} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + simulate( TankApplicationDiscretePInew, stopTime=200 ) //??warning in Simulation + record SimulationResult + messages = "", + simulationTime = 0.28687208945078746 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tankn.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank Model with PI continuous controler</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Old Tank Model</span></p></td></tr></table></body></html> + + + model TankApplicationContinuousPI + PIcontinuousController piContinuous; + Tank tank(area=1,flowVout=0.02); +equation + connect(tank.tInp,piContinuous.cOut); + connect(tank.tOut,piContinuous.cInp); + piContinuous.ref=0.5; +end TankApplicationContinuousPI; + {TankApplicationContinuousPI} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + simulate( TankApplicationContinuousPI, stopTime=200 ) + record SimulationResult + messages = "", + simulationTime = 0.15081951826858847 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tank.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( tank.qIn ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">New Tank Model</span></p></td></tr></table></body></html> + + + model TankApplicationContinuousPInew + PIdiscreteController piDiscrete; + TankL tankn(area=1,flowVout=0.02); + FlowOut outFlow; +equation + connect(tankn.qOut,outFlow.qOut); + connect(tankn.tInp,piDiscrete.cOut); + connect(tankn.tOut,piDiscrete.cInp); + piDiscrete.ref=0.5; +end TankApplicationContinuousPInew; + {TankApplicationContinuousPInew} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + simulate( TankApplicationContinuousPInew, stopTime=200 ) + record SimulationResult + messages = "", + simulationTime = 0.4273322339452804 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tankn.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank Model with PID continuous controler</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Renewed Tank Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The imput flow in that case is constant and the output flow is regulated by the PI controller</span></p></td></tr></table></body></html> + + + partial model PIcontroller + parameter Real Ts=0.1;//sampling time[s] + parameter Real K=2;//gain + parameter Real T=10;//time constant[s] + parameter Real minV=-10,maxV=10;//limits for output + Real ref,error,outCtr; + ReadSignal cInp; + ActSignal cOut; +equation + error = ref-cInp.val; + cOut.act = LimitValue(minV,maxV,outCtr); +end PIcontroller; + {PIcontroller} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model PIcontinuousController + extends PIcontroller(K=2,T=10); + Real x; //state variable of continuous controller +equation + der(x) = error/T; + outCtr = K*(x+error); +end PIcontinuousController; + {PIcontinuousController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model TankModified + ReadSignal tOut; // Connector, reading tank level + ActSignal tInp; // Connector, actuator controlling input flow + parameter Real flowVin =0.005; //[m3/s] + parameter Real area =0.5; //[m2] + parameter Real flowGain =0.05; //[m2/s] + Real h(start=0.0); //tank level [m] + Real qIn; // flow through input valve[m3/s] + Real qOut; // flow through output valve[m3/s] +equation + der(h)=(qIn-qOut)/area; //mass balance equation + qIn=if time>150 then 3*flowVin else flowVin ; + qOut=LimitValue(0,10,-flowGain*tInp.act); + //qOut=0; + + tOut.val = h; +end TankModified; + {TankModified} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model TankApplicationModified + PIcontinuousController piContinuous; + TankModified tankm(area=1,flowVin=0.02); +equation + connect(tankm.tInp,piContinuous.cOut); + connect(tankm.tOut,piContinuous.cInp); + piContinuous.ref=0.25; +end TankApplicationModified; + {TankApplicationModified} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of TankApplicationModified</span></p></td></tr></table></body></html> + + + simulate( TankApplicationModified, stopTime=250 ) //??warning in Simulation + record SimulationResult + messages = "", + simulationTime = 0.13319252465007417 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tankm.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Renewed Tank Model with connector for input and output flow</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The imput flow in that case is constant and the output flow is regulated by the PI controller</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connectors</span></p></td></tr></table></body></html> + + + connector ReadSignal + Real val; +end ReadSignal; + {ReadSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector ActSignal + Real act; +end ActSignal; + {ActSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector LiquidFlow + Real lflow; +end LiquidFlow; + {LiquidFlow} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Functions</span></p></td></tr></table></body></html> + + + function LimitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; +algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end LimitValue; + {LimitValue} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + partial model Controller + parameter Real Ts=0.1;//sampling time[s] + parameter Real K=2;//gain + parameter Real T=10;//time constant[s] + parameter Real minV=-10,maxV=10;//limits for output + Real ref,error,outCtr; + ReadSignal cInp; + ActSignal cOut; +equation + error = ref-cInp.val; + cOut.act = LimitValue(minV,maxV,outCtr); +end Controller; + {Controller} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model PIcontinuousController + extends Controller(K=2,T=10); + Real x; //state variable of continuous controller +equation + der(x) = error/T; + outCtr = K*(x+error); +end PIcontinuousController; + + {PIcontinuousController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model PIDcontinuousController + extends Controller(K=2,T=10,maxV=0.02); + Real x; //state variable of continuous controller + Real y; //state variable of continuous controller +equation + der(x) = error/T; + y=T*der(error); + outCtr = K*(x+error+y); +end PIDcontinuousController; + + {PIDcontinuousController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model TankModified2 + ReadSignal tOut; // Connector, reading tank level + ActSignal tInp; // Connector, actuator controlling input flow + parameter Real area =0.5; //[m2] + parameter Real flowGain =0.05; //[m2/s] + Real h(start=0.0); //tank level [m] + Real q; + LiquidFlow qIn; // flow through input valve[m3/s] + LiquidFlow qOut; // flow through output valve[m3/s] +equation + der(h)=(q-qOut.lflow)/area; //mass balance equation + q=if time>150 then 3*qIn.lflow else qIn.lflow ; + qOut.lflow=LimitValue(0,10,-flowGain*tInp.act); + tOut.val = h; +end TankModified2; + {TankModified2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model TankApplicationModifiedPIController + PIcontinuousController piContinuous; + TankModified2 tankm(area=1); +equation + connect(tankm.tInp,piContinuous.cOut); + connect(tankm.tOut,piContinuous.cInp); + piContinuous.ref=0.25; + tankm.qIn.lflow=0.02; +end TankApplicationModifiedPIController; + {TankApplicationModifiedPIController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of TankApplicationModifiedPIController</span></p></td></tr></table></body></html> + + + simulate( TankApplicationModifiedPIController, stopTime=250 ) + record SimulationResult + messages = "", + simulationTime = 0.1652990308618122 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tankm.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model TankApplicationModifiedPIDController + PIDcontinuousController pidContinuous; + TankModified2 tankm(area=1); +equation + connect(tankm.tInp,pidContinuous.cOut); + connect(tankm.tOut,pidContinuous.cInp); + pidContinuous.ref=0.25; + tankm.qIn.lflow=0.02; +end TankApplicationModifiedPIDController; + {TankApplicationModifiedPIDController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of TankApplicationModifiedPIDController</span></p></td></tr></table></body></html> + + + simulate( TankApplicationModifiedPIDController, stopTime=250 ) + record SimulationResult + messages = "", + simulationTime = 0.2078386025990824 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tankm.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connecting Two Tanks Together</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">remove the dicontinuity from the tank model<br />q=if time&gt;150 then 3*qIn.lflow else qIn.lflow;</span></p></td></tr></table></body></html> + + + model TanksConnected + PIcontinuousController piContinuous1,piContinuous2; + TankModified2 tank1(area=1),tank2(area=1.3); +equation + connect(tank1.tInp,piContinuous1.cOut); + connect(tank1.tOut,piContinuous1.cInp); + piContinuous1.ref=0.25; + + connect(tank2.tInp,piContinuous2.cOut); + connect(tank2.tOut,piContinuous2.cInp); + piContinuous2.ref=0.4; + + tank1.qIn.lflow=0.02; + connect(tank1.qOut,tank2.qIn); +end TanksConnected; + {TanksConnected} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of TanksConnected</span></p></td></tr></table></body></html> + + + simulate( TanksConnected, stopTime=250 ) + record SimulationResult + messages = "", + simulationTime = 0.13014403254462384 +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { tank1.h, tank2.h } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { tank1.qOut.lflow, tank2.qOut.lflow } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/DiscreteHybrid/GameOfLife.onb b/DrModelica/DiscreteHybrid/GameOfLife.onb new file mode 100644 index 00000000000..2b6473c2eec --- /dev/null +++ b/DrModelica/DiscreteHybrid/GameOfLife.onb @@ -0,0 +1,242 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Game of Life</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Introduction</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Rules for the Game of Life:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /><br />Life is played on a grid of square cells--like a chess board but extending infinitely in every direction. A cell can be live or dead. A live cell is shown by putting a marker on its square. A dead cell is shown by leaving the square empty. Each cell in the grid has a neighborhood consisting of the eight cells in every direction including diagonals. To apply one step of the rules, we count the number of live neighbors for each cell. What happens next depends on this number.<br />To apply one step of the rules, we count the number of live neighbors for each cell. What happens next depends on this number.<br />- A dead cell with exactly three live neighbors becomes a live cell (birth). <br /><br /><br /></span><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/13.png" width="48" height="48" /><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/14.png" width="48" height="48" /><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A live cell with two or three live neighbors stays alive (survival). <br /><br /><br /></span><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/15.png" width="48" height="48" /><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/16.png" width="48" height="48" /><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/17.png" width="48" height="48" /><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In all other cases, a cell dies or remains dead (overcrowding or loneliness). <br /><br /><br /></span><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/18.png" width="48" height="48" /><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/19.png" width="48" height="48" /><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/20.png" width="48" height="48" /><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/21.png" width="48" height="48" /><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Note:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> The number of live neighbors is always based on the cells </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; font-style:italic; color:#0000fe;">before</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> the rule was applied. In other words, we must first find all of the cells that change before changing any of them. Sounds like a job for a computer!</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + 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 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Game of Life</span></p></td></tr></table></body></html> + + + model GameOfLife + parameter Integer n = 10; + parameter Integer initialAlive[:,2] = {{2,2},{2,1},{1,2},{3,3},{3,2}}; + discrete Integer lifeHistory[n,n](start=zeros(n,n)); + Boolean init = initial(); +equation + when {init, sample(0.1,0.1)} then + if edge(init) then + lifeHistory = firstGeneration(pre(lifeHistory), initialAlive); + else + lifeHistory = nextGeneration(pre(lifeHistory)); + end if; + end when; +end GameOfLife; + {GameOfLife} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + function firstGeneration + input Integer M[:,:]; + input Integer I[:,2]; + output Integer G[size(M,1), size(M,1)] := M; +algorithm + for i in 1:size(I,1) loop + G[I[i,1], I[i,2]] := 1; + end for; +end firstGeneration; + {firstGeneration} + + + function nextGeneration + input Integer M[:,:]; + output Integer G[size(M,1), size(M,1)]; + protected + Integer iW, iE, jN, jS, borderSum; + parameter Integer n = size(M,1); +algorithm + for i in 1:n loop + for j in 1:n loop + iW := mod(i-2+n, n) + 1; + iE := mod(i+n, n) + 1; + jN := mod(j+n, n) + 1; + jS := mod(j-2+n, n) + 1; + borderSum := M[iW,j] + M[iE,j] + M[iW,jS] + M[i,jS] + M[iE,jS] + M[iW,jN] + M[i,jN] + M[iE,jN]; + if borderSum == 3 then + G[i,j] := 1; + elseif borderSum == 2 then + G[i,j] := M[i,j]; + else G[i,j] := 0; + end if; + end for; + end for; +end nextGeneration; + {nextGeneration} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Animation of GameOfLife (to be done)</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of GameOfLife</span></p></td></tr></table></body></html> + + + simulate( GameOfLife ) + record SimulationResult + messages = "Simulation failed for model: GameOfLife +Error: Too few equations, underdetermined system. The model has 2 equation(s) and 101 variable(s) +Error: Internal error Transformation Module omc index Reduction Method dummyDerivative failed! +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + PlotGameOfLife[lifeHistory] + +OMC-ERROR: +"Error: Variable PlotGameOfLife[lifeHistory] not found in scope <global scope> +" + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Test of GameOfLife</span></p></td></tr></table></body></html> + + + model test1 + GameOfLife g(initialAlive = {{1,1},{2,2},{3,3},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9},{10,10}, + {1,10},{2,9},{3,8},{4,7},{5,6},{6,5},{7,4},{8,3},{9,2},{10,1}}); +end test1; + {test1} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of test1</span></p></td></tr></table></body></html> + + + simulate( test1 ) //??Not yet implemented + record SimulationResult + messages = "Simulation failed for model: test1 +Error: Too few equations, underdetermined system. The model has 2 equation(s) and 101 variable(s) +Error: Internal error Transformation Module omc index Reduction Method dummyDerivative failed! +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + PlotGameOfLife[g.lifeHistory +] + +OMC-ERROR: +"Error: Variable PlotGameOfLife[g.lifeHistory] not found in scope <global scope> +" + + + + + + diff --git a/DrModelica/DiscreteHybrid/HybridTank.onb b/DrModelica/DiscreteHybrid/HybridTank.onb new file mode 100644 index 00000000000..599418e194e --- /dev/null +++ b/DrModelica/DiscreteHybrid/HybridTank.onb @@ -0,0 +1,657 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">A Hybrid Tank Model with a Discrete Controller</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Now let us consider a hybrid Tank containing a Proportional-Integral (PI) controller.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/10.png" width="402" height="128" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Figure 1:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> A tank system with a tank, a source for liquid, and a controller. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank Model Componets</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connectors</span></p></td></tr></table></body></html> + + + connector ReadSignal + Real val; +end ReadSignal; + {ReadSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector ActSignal + Real act; +end ActSignal; + {ActSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector LiquidFlow + Real lflow; +end LiquidFlow; + {LiquidFlow} + + + + connector ActSignal "Signal to actuator for setting valve position" + Real act; +end ActSignal; + {ActSignal} + + + connector ReadSignal "Reading fluid level" + Real val(unit = "m"); +end ReadSignal; + {ReadSignal} + + + connector LiquidFlow "Liquid flow at inlets or outlets" + Real lflow(unit = "m3/s"); +end LiquidFlow; + {LiquidFlow} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Functions</span></p></td></tr></table></body></html> + + + function LimitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; +algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end LimitValue; + {LimitValue} + + + + function limitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; + algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end limitValue; + {limitValue} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">PI Controllers</span></p></td></tr></table></body></html> + + + partial model PIcontroller + parameter Real Ts = 0.1; // sampling time[s] + parameter Real K = 2; // gain + parameter Real T = 10; // time constant[s] + parameter Real minV = 0, maxV = 1; // limits for output + Real ref, error, outCtr; + ReadSignal cInp; + ActSignal cOut; +equation + error = ref - cInp.val; + cOut.act = LimitValue(minV, maxV, outCtr); +end PIcontroller; + {PIcontroller} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + partial model BaseController + parameter Real Ts(unit = "s") = 0.1 "Time period between discrete samples"; + parameter Real K = 2 "Gain"; + parameter Real T(unit = "s") = 10 "Time constant"; + ReadSignal cIn "Input sensor level, connector"; + ActSignal cOut "Control to actuator, connector"; + parameter Real ref "Reference level"; + Real error "Deviation from reference level"; + Real outCtr(fixed=true) "Output control signal"; +equation + error = ref - cIn.val; + cOut.act = outCtr; +end BaseController; + {BaseController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model PIcontinuousController + extends BaseController(K = 2, T = 10); + Real x(fixed=true) "State variable of continuous PI controller"; +equation + der(x) = error/T; + outCtr = K*(error + x); +end PIcontinuousController; + {PIcontinuousController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model PIdiscreteController + extends BaseController(K = 2, T = 10); + discrete Real x(fixed=true); // State variable of discrete controller +equation + when sample(0, Ts) then + x = pre(x) + error * Ts / T; + outCtr = K * (x + error); + end when; +end PIdiscreteController; + {PIdiscreteController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">PID Controlers</span></p></td></tr></table></body></html> + + + partial model PIDcontroller + parameter Real Ts = 0.1; // sampling time[s] + parameter Real K = 2; // gain + parameter Real T = 10; // time constant[s] + parameter Real minV = 0, maxV = 1; // limits for output + Real ref, error, outCtr; + ReadSignal cInp; + ActSignal cOut; +equation + error = ref - cInp.val; + cOut.act = LimitValue(minV, maxV, outCtr); +end PIDcontroller; + {PIDcontroller} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model PIDcontinuousController + extends PIDcontroller(K = 2, T = 10, maxV = 0.02); + Real x(fixed=true); //state variable of continuous controller + Real y(fixed=true); //state variable of continuous controller +equation + der(x) = error/T; + y= T*der(error); + outCtr = K * (x+error+y); +end PIDcontinuousController; + {PIDcontinuousController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model PIDdiscreteController + extends BaseController(K = 2, T = 10); + discrete Real x(fixed=true); // State variable of discrete controller + discrete Real y(fixed=true); // State variable of discrete controller +equation + when sample(0, Ts) then + x = pre(x) + error * Ts / T; + y = T*(error-pre(error)); + outCtr = K * (x + error + y); + end when; +end PIDdiscreteController; + {PIDdiscreteController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Tank</span></p></td></tr></table></body></html> + + + model Tank + ReadSignal tSensor "Connector, sensor reading tank level (m)"; + ActSignal tActuator "Connector, actuator controlling input flow"; + LiquidFlow qIn "Connector, flow (m3/s) through input valve"; + LiquidFlow qOut "Connector, flow (m3/s) through output valve"; + parameter Real area(unit = "m2") = 0.5; + parameter Real flowGain(unit = "m2/s") = 0.05; + parameter Real minV= 0, maxV = 10; // Limits for output valve flow + Real h(start = 0.0,fixed=true, unit = "m") "Tank level"; + equation + assert(minV>=0,"minV - minimum Valve level must be >= 0 "); + der(h) = (qIn.lflow - qOut.lflow)/area; // Mass balance equation + qOut.lflow = limitValue(minV, maxV, -flowGain*tActuator.act); + tSensor.val = h; +end Tank; + {Tank} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model LiquidSource + LiquidFlow qOut; + parameter Real flowLevel = 0.02; +equation + qOut.lflow = if time > 150 then 3*flowLevel else flowLevel; +end LiquidSource; + {LiquidSource} + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">TankHybridPI Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Finally we put together the hybrid tank system by simply replacing the continuous PI controller by the discrete one, called piDiscrete, as depicted in Figure 2.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/11.png" width="285" height="157" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Figure 2:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> A Hybrid Tank system consisting of a continuous tank model connected to a source for liquid and a discrete PI controller.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TankHybridPI</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model connects a discrete PI controller to a liquid source and a tank, both defined by the models above.<br /></span></p></td></tr></table></body></html> + + + model TankHybridPI + LiquidSource source(flowLevel=0.02); + PIdiscreteController piDiscrete(ref=0.25); + Tank tank(area=1); +equation + connect(source.qOut, tank.qIn); + connect(tank.tActuator, piDiscrete.cOut ); + connect(tank.tSensor, piDiscrete.cIn ); +end TankHybridPI; + {TankHybridPI} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The hybrid tank system with a discrete PI controller is simulated, see Figure ??, obtaining essentially the same result as when using the continuous PI controller (compare to Figure ?? on page ??). The response shown in the curve is the reaction of the controller to an instantaneous increase in the input flow from the source at time t=150. The only difference compared to the continuous controller case is a few small squiggles in the curve probably caused by the discrete approximation.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of TankHybridPI</span></p></td></tr></table></body></html> + + + simulate( TankHybridPI, stopTime=250 ) + record SimulationResult + resultFile = "TankHybridPI_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + + + + plot( tank.h ) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">TankHybridPID Model</span></p></td></tr></table></body></html> + + + model TankHybridPID + LiquidSource source(flowLevel=0.02); + PIDdiscreteController pidDiscrete(ref=0.25); + Tank tank(area=1); +equation + connect(source.qOut, tank.qIn); + connect(tank.tActuator, pidDiscrete.cOut ); + connect(tank.tSensor, pidDiscrete.cIn ); +end TankHybridPID; + {TankHybridPID} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of TankHybridPI</span></p></td></tr></table></body></html> + + + simulate( TankHybridPID, stopTime=250 ) + record SimulationResult + resultFile = "TankHybridPID_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( tank.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/DiscreteHybrid/ModStochProc.onb b/DrModelica/DiscreteHybrid/ModStochProc.onb new file mode 100644 index 00000000000..33e25357f62 --- /dev/null +++ b/DrModelica/DiscreteHybrid/ModStochProc.onb @@ -0,0 +1,562 @@ + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + False + False + <ModelicaIndex> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Models for Event Based Stochastic Processes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />If we generalize a finite state automaton by letting the time between two events be stochastic, and possibly also letting the choice of the next state be stochastic, we obtain a model for event based stochastic processes. Such models have many applications, of which one is queuing systems.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">The Random Package</span></p></td></tr></table></body></html> + + + package Random +import Modelica.Math; +constant Real NV_MAGICCONST=4*exp(-0.5)/sqrt(2.0); +type Seed = Integer[3]; + +function random "input random number generator with external storage of the seed" + input Seed si "input random seed"; + output Real x "uniform random variate between 0 and 1"; + output Seed so "output random seed"; +algorithm + so[1] := rem((171 * si[1]),30269); + so[2] := rem((172 * si[2]),30307); + so[3] := rem((170 * si[3]),30323); + // zero is a poor Seed, therfore substitute 1; + if so[1] == 0 then + so[1] := 1; + end if; + if so[2] == 0 then + so[2] := 1; + end if; + if so[3] == 0 then + so[3] := 1; + end if; + x := rem((so[1]/30269.0 +so[2]/30307.0 + so[3]/30323.0),1.0); +end random; + +function normalvariate "normally distributed random variable" + input Real mu "mean value"; + input Real sigma "standard deviation"; + input Seed si "input random seed"; + output Real x "gaussian random variate"; + output Seed so "output random seed"; +protected + Seed s1, s2; + Real z, zz, u1, u2; +algorithm + s1 := si; + u2 := 1; + while true loop + (u1,s2) := random(s1); + (u2,s1) := random(s2); + z := NV_MAGICCONST*(u1-0.5)/u2; + zz := z*z/4.0; + if zz <= (- Math.log(u2)) then + break; + end if; + end while; + x := mu + z*sigma; + so := s1; +end normalvariate; + +connector discreteConnector + discrete Boolean dcon; +end discreteConnector; + +end Random; + {Random} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Examples</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">As a simple example of discrete-time stochastic process simulation we can consider a simple server model with a queue. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">CustomerGeneration Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CustomerGenerator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model contains an output connector </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">outCustomer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that transmits the customer arrival events to the rest of the system. We first start by defining a model which generates customers at random points in time. The time delay until the next customer arrival is assumed to be a normally distributed stochastic variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">T</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, here computed by calling the random number function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">normalvariate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, see above, where the negative part is folded back on the positive side using </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">abs(T)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to avoid unrealistic negative service times. Since this function is side-effect free as all Modelica functions, it returns a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">randomSeed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> value to be used at the next call to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">normalvariate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, see the help functions above. <br /></span></p></td></tr></table></body></html> + + + model CustomerGeneration + Random.discreteConnector dOutput; + parameter Real mean = 0; + parameter Real stDeviation = 1; + + discrete Real normalDelta; + discrete Real nextCustomerArrivalTime(start=0); + discrete Random.Seed randomSeed(start={23,87,187}); + +equation + when pre(nextCustomerArrivalTime)<=time then + (normalDelta,randomSeed)=Random.normalvariate(mean,stDeviation,pre(randomSeed)); + nextCustomerArrivalTime = pre(nextCustomerArrivalTime) + abs(normalDelta); + end when; + + dOutput.dcon=if nextCustomerArrivalTime <> pre(nextCustomerArrivalTime) then true + else false; +end CustomerGeneration; + {CustomerGeneration} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of CustomerGeneration</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CustomerGeneration</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model for a while to observe the customer arrival times.</span></p></td></tr></table></body></html> + + + loadModel(Modelica) + true + + + simulate( CustomerGeneration, stopTime=10 ) + record SimulationResult + messages = "", + simulationTime = 0.131985539025457 +end SimulationResult; +OMC-ERROR: +"Warning: In component <NO COMPONENT>, in relation nextCustomerArrivalTime <> pre(nextCustomerArrivalTime), <> on Reals is only allowed inside functions. +Error: Model is structurally singular, error found sorting equations 2: $PRE.randomSeed[2] = $_start(randomSeed[2]); +4: $PRE.randomSeed[1] = $_start(randomSeed[1]); + for variables randomSeed[3](1), randomSeed[2](3) +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelites failed! +Warning: No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead. +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( nextCustomerArrivalTime ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Next customer arrival time for customers arriving at random points in time.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">ServerWithQueue Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We can now design a server model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ServerWithQueue</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which through its </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">inCustomer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> port will accept the arriving customers from the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CustomerGeneration</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">nrOfCustomersInQueue</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> represents the current number of customers in the queue. Other state variables of interest are </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">nrOfArrivedCustomers</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, the number of customers that have so far arrived and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">nrOfServedCustomers</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, the number of customers that have so far been served. The first </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">equation services the arrival of a new customer, whereas the second </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">equation handles the event when a customer is serviced and is ready to leave the queue.<br /> <br />The event when </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">readyCustomer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> becomes true represents completed service for the current customer. The time needed to serve a customer is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">custServeTime</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which is constant in this model but could be varying according to some formula or be randomly distributed. The variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">lastServeStart</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> represents the starting time for servicing the most recent serviced customer.<br /></span></p></td></tr></table></body></html> + + + model ServerWithQueue + Random.discreteConnector dInput; + parameter Real serveTime=0.1; + + discrete Real nrOfArrivedCustomers; + discrete Real nrOfServedCustomers; + discrete Real nrOfCustomersInQueue(start=0); + + discrete Boolean readyCustomer(start=false); + discrete Boolean serveCustomer(start=false); + + Real resetTime; + +equation + when dInput.dcon then + nrOfArrivedCustomers=pre(nrOfArrivedCustomers)+1; + end when; + + when readyCustomer then + nrOfServedCustomers=pre(nrOfServedCustomers)+1; + end when; + + when (pre(nrOfCustomersInQueue)==0 and dInput.dcon) or (pre(nrOfCustomersInQueue)>=1 and pre(readyCustomer))then + serveCustomer=true; + resetTime=time; + end when; + + readyCustomer=if (serveCustomer and (serveTime<time-resetTime)) then true else false; + + + nrOfCustomersInQueue=nrOfArrivedCustomers-nrOfServedCustomers; + +end ServerWithQueue; + {ServerWithQueue} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Test Model 1</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The simulation of the whole system can be done by defining a test model which connects the CustomerGeneration model with the ServerWithQueue model. </span></p></td></tr></table></body></html> + + + model testServer1 + CustomerGeneration customer; + ServerWithQueue server(serveTime=0.4); +equation + connect(customer.dOutput, server.dInput); +end testServer1; + {testServer1} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of testServer1</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Using the MathModelica simulation environment we simulate the model for 10 seconds with the customer service time custServeTime = 0.4 seconds.</span></p></td></tr></table></body></html> + + + loadModel(Modelica) + true + + + simulate( testServer1, stopTime=10 ) + record SimulationResult + messages = "", + simulationTime = 0.12676046527060067 +end SimulationResult; +OMC-ERROR: +"Warning: In component customer, in relation nextCustomerArrivalTime <> pre(nextCustomerArrivalTime), <> on Reals is only allowed inside functions. +Warning: In component server, in relation pre(nrOfCustomersInQueue) == 0.0, == on Reals is only allowed inside functions. +Error: Model is structurally singular, error found sorting equations 2: $PRE.customer.randomSeed[2] = $_start(customer.randomSeed[2]); +4: $PRE.customer.randomSeed[1] = $_start(customer.randomSeed[1]); + for variables customer.randomSeed[3](1), customer.randomSeed[2](3) +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelites failed! +Warning: No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead. +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + + plot( {server.nrOfArrivedCustomers, server.nrOfServedCustomers, server.nrOfCustomersInQueue }) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Number of arrived customers, number of served customers, and number of customers waiting in the queue or being serviced. Customer service time is 0.4 seconds.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Test Model 2</span></p></td></tr></table></body></html> + + + model testServer2 + CustomerGeneration customer; + ServerWithQueue server(serveTime = 1); +equation + connect(customer.dOutput, server.dInput); +end testServer2; + {testServer2} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of testServer2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We now simulate the model for 10 seconds with the customer service time custServeTime = 1 second.</span></p></td></tr></table></body></html> + + + simulate( testServer2, stopTime=10 ) + record SimulationResult + messages = "", + simulationTime = 0.1360671237934065 +end SimulationResult; +OMC-ERROR: +"Warning: In component customer, in relation nextCustomerArrivalTime <> pre(nextCustomerArrivalTime), <> on Reals is only allowed inside functions. +Warning: In component server, in relation pre(nrOfCustomersInQueue) == 0.0, == on Reals is only allowed inside functions. +Error: Model is structurally singular, error found sorting equations 2: $PRE.customer.randomSeed[2] = $_start(customer.randomSeed[2]); +4: $PRE.customer.randomSeed[1] = $_start(customer.randomSeed[1]); + for variables customer.randomSeed[3](1), customer.randomSeed[2](3) +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelites failed! +Warning: No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead. +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + + plot({ server.nrOfArrivedCustomers, server.nrOfServedCustomers, server.nrOfCustomersInQueue }) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Number of arrived customers, number of served customers, and number of customers waiting in the queue or being serviced. Customer service time is 1 second.</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/DiscreteHybrid/MultEvents.onb b/DrModelica/DiscreteHybrid/MultEvents.onb new file mode 100644 index 00000000000..f2807d5e991 --- /dev/null +++ b/DrModelica/DiscreteHybrid/MultEvents.onb @@ -0,0 +1,127 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Multiple Events at the Same Point in Time and Event Iteration</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MultipleEvents</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Multiple events may actually occur at the same point in time. Two or more independent events may just happen to be fired at the same time instant, or additional events may be fired at the time instant as a consequence of handling one of the events at that time instant. In the example below different event handlers </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A, B, C </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">D </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> occur in a special order according to the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">declaration order</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model MultipleEvents + discrete Integer x(start = 1, fixed=true); + Boolean signal(start = false, fixed=true); +algorithm + when x == 2 then // Event handler A + x := pre(x)+1; // x becomes 2 + 1 = 3 + end when; + + when x == 3 then // Event handler B + x := pre(x)+5; // x becomes 2 + 5 = 7 + end when; + + when time >= 2 then // Event handler C + x := 2; // x becomes 2 + end when; + +equation + when time >= 2 then // Event handler D + signal = true; + end when; +end MultipleEvents; + {MultipleEvents} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of MultipleEvents</span></p></td></tr></table></body></html> + + + simulate( MultipleEvents, stopTime=5 ) + record SimulationResult + resultFile = "MultipleEvents_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Since the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements in the algorithm section are sequential, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">pre(x)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> will not be updated until reaching the end of the algorithm section.</span></p></td></tr></table></body></html> + + + + + + + plot( { x, signal } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/DiscreteHybrid/SampleClock.onb b/DrModelica/DiscreteHybrid/SampleClock.onb new file mode 100644 index 00000000000..08f1c70e282 --- /dev/null +++ b/DrModelica/DiscreteHybrid/SampleClock.onb @@ -0,0 +1,121 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Generating Repeated Events Using Sample</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">SamplingClock</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">(first,interval) returns </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and can be used to trigger events at time instants </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">first + i*interval (i=0,1,...)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, where </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">first</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is the time of the first event and </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">interval</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is the time interval between the periodic events. It is typically used in models of periodically sampled systems.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/RAIN1_~1/AppData/Local/Temp/OpenModelica/10.png" width="387" height="157" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAGDAAAAnQgDAAAAYRHkfwAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZ3bsYwAAAAlwSFlzAAALEwAACxMBAJqcGAAAA9NJREFUeJztnI1yqjAUBo/v/9J3KvIjCZCE4Mp1d8ZWJV+gZ5tg6JR4CE3QByA6+AJ0wKMDHh3w6IBHBzw64NEBjw54dMCjAx4d8OiARwc8OuDRAU+tA531p7KmoYP+VDtQQnfqSho6uICqkkYo4QJ0wFNT0QglXIEOeCoKGtEgIdIXqx7i5xcdn3QQz0es3o66o/gPqV0fnOlfB3nOOniNivHbcyEdMT0dKhxT3WPxfMglTn6Pkw5eZZ6r/XrM3xYbh8Cy5qMwHZxonplT3rUcOnAcdJyLth0sNuogQ4dz8upXPTsOpqwOUrqdD5JxUHg+0EG/uSgdB7nPRc+G4woj0s9JP0mHuai45fYJ/acV6OALuMyBFKMDHh3w6IBHBzw64NEBjw54dMCjAx4d8OiARwc8OuDRAY8OeHTAowMeHfDogEcHPDrg0QGPDnh0wKMDHh3w6IBHBzw64NEBjw54dMCjAx4d8OiARwc8Bf8+WbpNGtEBT87B8F/2800PYre5nGVjHMR0n4l4a6SDC9hyMD3eb2Cngws4dnDUXM6y7yCq5qITtz69W7TrbV43z8mP0UD5OfluhfxiB83N71ZIHdw6qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+qgM+eq2D2Nqw8+648WaF/FYHsbVh791x480K+XkHRUX963roPh7jMS53p4Mp2eQgm0rHwUtAPHI3rNDBlGx0kAlm5qKh2TACxtxW8/UeGo7rltFTDtbRvXGwfLLRfL2HhuO6ZfSkg9gt6uv2CJtzkfRiz8GfgWkuWp+T5RQ5A9VrNDlFzoAOPkvOgA4+S35a18Enabj4IB9BBzw64Ol7BbZqKZENlOXT6PTqoIN4a/z+ojp6dKW/kK4O3pbUbYFiB+/R+VVBIZOrkOX6Vgdcqu+44z7E+j6cNYFYvtMSfSyW+AfJDQ8N0RjHxtc4ODMOxi+Fc1kSHZ4UdBCPxMH455L66OKe4Ae5w477cMLBa/VYHk+ixfufi7hYsjZGc0Mqkyn5aTrRZRw0nA8Wk3lVIVezWEO04Ffnjg6a56LSDtJCTt01TGNHc9E8XGJudeE1u2EvFf2lgZpzcvIB8/VTHhUyHmm0bN+5C/lH0YWj7KeBuRO5inmU5WfBqZFcRs5BcvlaB5eyMQ7SRnIZzkU8uWWEf8v8QnTAowMeHfDogEcHPDrg0QGPDnh0wPMP7MXl53XuCD0AAAAASUVORK5CYII= + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> acts as a kind of clock that returns true at periodically occurring time instants. We can use this behavior in combination with a when-equation to periodically trigger events, e.g. as below:<br /></span></p></td></tr></table></body></html> + + + class SamplingClock + parameter Modelica.SIunits.Time first = 0; + parameter Modelica.SIunits.Time interval = 1; + Boolean clock; + Real x(start=1,fixed=true); +equation + clock = sample(first,interval); + when clock then + x=-pre(x); + end when; +end SamplingClock; + {SamplingClock} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of SamplingClock</span></p></td></tr></table></body></html> + + + loadModel(Modelica) + true + + + simulate( SamplingClock, stopTime=10 ) + record SimulationResult + resultFile = "SamplingClock_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot(x) + [done] + + + + + + diff --git a/DrModelica/DiscreteHybrid/SampledSystems.onb b/DrModelica/DiscreteHybrid/SampledSystems.onb new file mode 100644 index 00000000000..2f791c4797f --- /dev/null +++ b/DrModelica/DiscreteHybrid/SampledSystems.onb @@ -0,0 +1,508 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Sampled Systems</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simple Periodic Sampler</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The following model is a </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">simple periodic sampler</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with a sampling period </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">T</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that is constant and defined as a parameter that can be changed by the model user. This model has only one kind of event, the sampling event. We use the built-in function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-condition </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sample(0, T)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to periodically generate the sampling events with a period time </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">T</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This is a simple model using the state space equations.<br /></span></p></td></tr></table></body></html> + + + model SimplePeriodicSampler + parameter Real T = 1 "Sample period"; + input Real u "Input used at sample events"; + discrete output Real y(fixed=true) "Output computed at sample events"; + replaceable function f = Modelica.Math.atan2; + replaceable function h = Modelica.Math.atan2; +protected + discrete Real x(fixed=true); // discrete state variable +equation + when sample(0, T) then + x = f(pre(x), u); // state update expression + y = h(pre(x), u); // output expression + end when; +end SimplePeriodicSampler; + {SimplePeriodicSampler} + + + loadModel(Modelica); + [done] + + + simulate(SimplePeriodicSampler, stopTime=100) + record SimulationResult + resultFile = "SimplePeriodicSampler_res.mat", + messages = "" +end SimulationResult; + + + + + + + plot({x, y}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Base Class for Sampling Models</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is possible to formulate a base class for scalar sampling models using state-space equations.The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">BaseSampler</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below can for example be specialized to either a periodic sampler or an aperiodic sampler.<br /></span></p></td></tr></table></body></html> + + + partial class BaseSampler + input Real u; + discrete output Real y; + Boolean doSample; + replaceable function f = Modelica.Math.atan2; + replaceable function h = Modelica.Math.atan2; +protected + discrete Real x; +equation + when doSample then + x = f(pre(x), u); // state update expression + x = h(pre(x), u); // output expression + end when; +end BaseSampler; + {BaseSampler} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Below the base model is extended to a periodic sampling model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PeriodicSampler</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with a fixed period time T.<br /></span></p></td></tr></table></body></html> + + + model PeriodicSampler + extends BaseSampler; + parameter Real T = 1 "sample period"; +equation + doSample = sample(0, T); +end PeriodicSampler; + {PeriodicSampler} + + + loadModel(Modelica) + true + + + simulate(SimplePeriodicSampler) + record SimulationResult + resultFile = "SimplePeriodicSampler_res.mat", + messages = "" +end SimulationResult; + + + + + + plot(x) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Aperiodic Sampler</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Besides the above periodic sampler, an aperiodic sampling model with a time-varying sample period can be obtained by specializing the base class. A variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">nextSampling</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used for the next sampling time, which is current time </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">+ periodTime</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> when the current time has reached the previous value of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">nextSampling</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. In this example we increase the period time by the logarithm of the current time just to have a time varying period time.<br /></span></p></td></tr></table></body></html> + + + model APeriodicSampler + extends BaseSampler; + discrete Real nextSampling(start = 0); + discrete Real periodTime(start = 1) "time-varying sample period"; +equation + doSample = time > nextSampling; + when doSample then + nextSampling = pre(nextSampling) + periodTime; + periodTime = pre(periodTime) + log(pre(periodTime)); + end when; +end APeriodicSampler; + {APeriodicSampler} + + + simulate(APeriodicSampler) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: APeriodicSampler +[<interactive>:6:3-6:33:writable] Error: Model is structurally singular, error found sorting equations + 1: doSample = time > nextSampling; +5: when doSample then + x := atan2(pre(x), u) +end when; +4: when doSample then + x := atan2(pre(x), u) +end when; + for variables + x(3), periodTime(1), doSample(4) +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed! +" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Discrete Scalar State Space Sampling Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A discrete first order scalar state space model with periodic sampling can be formulated as follows, essentially being a special case of the above BaseSampler model even though we do not extend that class in this particular case.<br /></span></p></td></tr></table></body></html> + + + model DiscreteScalarStateSpace + parameter Real a, b, c, d; + parameter Real T = 1; + input Real u; + discrete output Real y; +protected + discrete Real x; +equation + when sample(0, T) then + x = a * pre(x) + b * u; + y = c * pre(x) + d * u; + end when; +end DiscreteScalarStateSpace; + {DiscreteScalarStateSpace} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Alternatively, the discrete scalar state space model can be expressed by extending the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">BaseSampler</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model for periodic sampling and redeclaring the functions </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">f</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">g</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> as below. However, in this case the result is not shorter or more readable since the syntax for expressing the local functions </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">f</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">1 and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">h1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not very concise. On the other hand, if the functions </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">f</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">1 and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">h1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> instead would be used in several places, the modeling style based on replaceable functions would be preferable.<br /></span></p></td></tr></table></body></html> + + + model DiscreteScalarStateSpace2 + extends BaseSampler(redeclare function f = f1, redeclare function h = h1); + parameter Real a, b, c, d; + parameter Real T = 1 "sample period"; + function f1 + input Real x1; + input Real x2; + input Real y1; + algorithm + y1 := a * x1 + b * x2; + end f1; + function h1 + input Real x1; + input Real x2; + input Real y1; + algorithm + y1 := c * x1 + d * x2; + end h1; +equation + doSample = sample(0, T); +end DiscreteScalarStateSpace2; + {DiscreteScalarStateSpace2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Discrete Vector State Space Sampling Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Usually state space models are expressed using the more general vector form, as in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DiscreteVectorStateSpace</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> periodic sampling model below:</span></p></td></tr></table></body></html> + + + model DiscreteVectorStateSpace + parameter Integer n = 5, m = 4, p = 2; + parameter Real A[n, n] = fill(1, n, n); + parameter Real B[n, m] = fill(2, n, m); + parameter Real C[p, n] = fill(3, p, n); + parameter Real D[p, m] = fill(4, p, m); + parameter Real T = 1; + input Real u[m]; + discrete output Real y[p] (each fixed=true); +protected + discrete Real x[n] (each fixed=true);// = fill(2, n); +equation + when sample(0, T) then + x = A * pre(x) + B * u; + y = C * pre(x) + D * u; + end when; +end DiscreteVectorStateSpace; + {DiscreteVectorStateSpace} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model DVSSTest + DiscreteVectorStateSpace dvss; +equation + dvss.u= fill(time,dvss.m); +end DVSSTest; + {DVSSTest} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DVSSTest</span></p></td></tr></table></body></html> + + + simulate( DVSSTest, stopTime=200 ) + record SimulationResult + resultFile = "DVSSTest_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot({dvss.m, x, y}) + [done] + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Two Rate Sampling Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoRateSampler</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model below the slow sampler is five times slower than the fast sampler, i.e. the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">slowSample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> when-equation is evaluated at every 5th activation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">fastSample when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation. The two samplers are synchronized via equations involving the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">cyCounter</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> variable. <br /></span></p></td></tr></table></body></html> + + + model TwoRateSampler + discrete Real x(fixed=true),y(fixed=true); + Boolean fastSample; + Boolean slowSample(fixed=true); + Integer cyCounter(start=0,fixed=true); // Cyclic count 0,1,2,3,4, 0,1,2,3,4,... + equation + fastSample = sample(0,1); // Define the fast clock + when fastSample then + cyCounter = if pre(cyCounter) < 5 then pre(cyCounter)+1 else 0; + slowSample = pre(cyCounter) == 0; // Define the slow clock + + end when; + equation + when fastSample then // fast sampling + x = sin(time); + end when; + equation + when slowSample then // slow sampling (5-times slower) + y = log(time); + end when; +end TwoRateSampler; + {TwoRateSampler} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of TwoRateSampler</span></p></td></tr></table></body></html> + + + simulate( TwoRateSampler, stopTime=100 ) + record SimulationResult + resultFile = "TwoRateSampler_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { x, y } ) // , xrange={7,100} is removed + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/19.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + + + + diff --git a/DrModelica/DiscreteHybrid/Synchronization.onb b/DrModelica/DiscreteHybrid/Synchronization.onb new file mode 100644 index 00000000000..a96a93da911 --- /dev/null +++ b/DrModelica/DiscreteHybrid/Synchronization.onb @@ -0,0 +1,141 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Event Synchronization</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Event Synchronization</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Events often need to be synchronized and propagated. However, Modelica gives no guarantee that two different independent events occur at exactly the same time instant if they are not explicitly synchronized, e.g. via equations. <br /><br />To achieve guaranteed synchronization between two events, we use the synchronous principle that computation at an event takes no time. An event can instantaneously, via one or more equations, change the values of certain discrete time variables used for the synchronization, typically </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Boolean</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Integer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> variables. These changes may trigger other events without any elapsed time, which thereby are synchronized. For example, you can synchronize counters performing their counting behavior at different frequencies, e.g. as in the example below.<br /></span></p></td></tr></table></body></html> + + + model SynchCounters // Two synchronized counters + Boolean slowPulses(fixed=true); + Boolean fastPulses; + Integer count(fixed=true); + Integer slowCount(fixed=true); +equation + fastPulses = sample(0,1); + when fastPulses then // Count every second + count = pre(count)+1; + slowPulses = mod(count,2)==0; // true when count=2,4,6,... + end when; + when slowPulses then // Count every 2nd second + slowCount = pre(slowCount)+1; + end when; +end SynchCounters; + {SynchCounters} + + + simulate(SynchCounters, stopTime=200) + record SimulationResult + resultFile = "SynchCounters_res.mat", + messages = "" +end SimulationResult; + + + + + + + + + plot({count, slowPulses, fastPulses, slowCount}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A kind of &quot;deadlock&quot; between different </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">equations is present if there are mutual dependences, a so-called &quot;algebraic loop&quot;, between the equations of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">equations, as in the example below. This case should be detected by a Modelica compiler. <br /></span></p></td></tr></table></body></html> + + + model DeadLock + Boolean b1(fixed=true), b2(fixed=true); +equation + when pre(b1) then + b2 = true; + end when; + when pre(b2) then + b1 = true; + end when; +end DeadLock; + {DeadLock} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DeadLock</span></p></td></tr></table></body></html> + + + simulate( DeadLock ) + record SimulationResult + resultFile = "DeadLock_res.mat", + messages = "" +end SimulationResult; + + + + + + + plot({b1, b2}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/DiscreteHybrid/WatchDog.onb b/DrModelica/DiscreteHybrid/WatchDog.onb new file mode 100644 index 00000000000..40202965689 --- /dev/null +++ b/DrModelica/DiscreteHybrid/WatchDog.onb @@ -0,0 +1,358 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">WatchDog System</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Event Generator Model</span></p></td></tr></table></body></html> + + + connector eventPort + discrete Boolean signal; +end eventPort; + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model EventGenerator + parameter Real eventTime = 1; + eventPort dOutput; +equation + dOutput.signal = time > eventTime; +end EventGenerator; + Ok + + + + connector eventPort + discrete Boolean signal(fixed=true); +end eventPort; + {eventPort} + + + model EventGenerator + parameter Real eventTime = 1; + eventPort dOutput; +equation + dOutput.signal = time > eventTime; +end EventGenerator; + {EventGenerator,eventPort} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WatchDog 1</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The watchdog system shown in Figure 1 consists of the watchdog itself and three event generators, emitting On events, Off events and deadlineSignal events.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/RAIN1_~1/AppData/Local/Temp/OpenModelica/14.png" width="402" height="180" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">WatchDog System</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A Modelica model of the watchdog system follows below, consisting of the watchdog itself and the three event generators. The watchdog is formulated using an algorithm section since otherwise the multiple </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations would cause multiple assignments to be reported for the variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">watchdogActive.<br /><br /></span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This version of the WatchDog receives three events: two commands to switch the watchdog on and off, and a &quot;deadline&quot; event. The watchdog must emit an &quot;alarm&quot; whenewer the deadline occurs when the watchdog is on. Initially it is turned of.<br />This is the algorithmic implementation.</span></p></td></tr></table></body></html> + + + model WatchDogSystem1 + EventGenerator turnOn(eventTime = 1); + EventGenerator turnOff(eventTime = 0.25); + EventGenerator deadlineEmitter(eventTime = 1.5); + WatchDog1 watchdog; +equation + connect(turnOn.dOutput, watchdog.dOn); + connect(turnOff.dOutput, watchdog.dOff); + connect(deadlineEmitter.dOutput, watchdog.dDeadline); +end WatchDogSystem1; + {WatchDogSystem1,EventGenerator,eventPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model WatchDog1 + eventPort dOn; + eventPort dOff; + eventPort dDeadline; + eventPort dAlarm; + discrete Boolean watchdogActive(start=false,fixed=true); // Initially turned off +algorithm + when change(dOn.signal) then // Event watchdog on + watchdogActive := true; + end when; + + when change(dOff.signal) then // Event watchdog off + watchdogActive := false; + dAlarm.signal := false; + end when; + + when (change(dDeadline.signal) and watchdogActive) then // Event Alarm! + dAlarm.signal := true; + end when; +end WatchDog1; + {WatchDog1,WatchDogSystem1,EventGenerator,eventPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WatchDogSystem</span></p></td></tr></table></body></html> + + + simulate( WatchDogSystem1, stopTime=2 ) + record SimulationResult + resultFile = "WatchDogSystem1_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( watchdog.dAlarm.signal ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WatchDog 2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This version of the WatchDog receives three events: two commands to switch the watchdog on and off, and a &quot;deadline&quot; event. The watchdog must emit an &quot;alarm&quot; whenewer the deadline occurs when the watchdog is on. Initially it is turned off. This is the equation-based inplementation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">watchdog1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model WatchDog2 + eventPort dOn; + eventPort dOff; + eventPort dDeadline; + eventPort dAlarm; + + Real internalTime1(fixed=true), internalTime2(fixed=true); + +equation + when change(dOn.signal)then + internalTime1 = time; + end when; + + when change(dOff.signal)then + internalTime2 = time; + end when; + + when change(dDeadline.signal) and time>internalTime1 and internalTime1>internalTime2 then + dAlarm.signal=true; + end when; +end WatchDog2; + {WatchDog2,WatchDog1,WatchDogSystem1,EventGenerator,eventPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model WatchDogSystem2 + EventGenerator turnOn(eventTime=1); + EventGenerator turnOff(eventTime=0.25); + EventGenerator deadlineEmitter(eventTime=1.5); + WatchDog2 watchdog; +equation + connect(turnOn.dOutput,watchdog.dOn); + connect(turnOff.dOutput,watchdog.dOff); + connect(deadlineEmitter.dOutput, watchdog.dDeadline); +end WatchDogSystem2; + {WatchDogSystem2,WatchDog2,WatchDog1,WatchDogSystem1,EventGenerator,eventPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WatchDogSystem2</span></p></td></tr></table></body></html> + + + simulate( WatchDogSystem2, stopTime=4 ) + record SimulationResult + resultFile = "WatchDogSystem2_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( watchdog.dAlarm.signal ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/DiscreteHybrid/meningsfil.onb b/DrModelica/DiscreteHybrid/meningsfil.onb new file mode 100644 index 00000000000..d4d0119b5e2 --- /dev/null +++ b/DrModelica/DiscreteHybrid/meningsfil.onb @@ -0,0 +1,34 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Modeling Discrete Events and Hybrid Systems</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Events</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-size:14pt;">An event is, using everyday language, simply </span><span style=" font-size:14pt; font-style:italic;">something that happens</span><span style=" font-size:14pt;">. This is true in the real world as well as in the mathematical sense. Modelica provides a number of built-in functions and operators related to events and time. One function that can be used for generating repeated events is </span><span style=" font-size:14pt; font-weight:600;">Sample (länka till SampleClock, p. 364)</span><span style=" font-size:14pt;">. <br /><br />Events arise naturally external to a simulated system or are generated internally in the simulation model. These events should be handled, i.e. some </span><span style=" font-size:14pt; font-weight:600;">Behavior (EventBeh, p. 370)</span><span style=" font-size:14pt;"> should be executed associated with each event. We also describe how to </span><span style=" font-size:14pt; font-weight:600;">Use Event Priority to Avoid Erroneous Multiple Definitions (EventPriority, p. 373)</span><span style=" font-size:14pt;">. Events often need to be </span><span style=" font-size:14pt; font-weight:600;">Synchronized (Synchronization, p. 375)</span><span style=" font-size:14pt;"> and propagated, though Modelica gives no guarantee of exact synchronization. Also discussed are </span><span style=" font-size:14pt; font-weight:600;">Multiple Events at the Same Point in Time and Event Internation (MultEvents, p. 377)</span><span style=" font-size:14pt;">.</span></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Discrete Model Examples and Related Formalisms</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-size:14pt;">This section provides you with a number of model examples of different kinds of discrete systems, for example </span><span style=" font-size:14pt; font-weight:600;">Sampled Systems (SampledSystems, p. 379)</span><span style=" font-size:14pt;">, </span><span style=" font-size:14pt; font-weight:600;">Finite State Automata (Automata, p. 385)</span><span style=" font-size:14pt;"> and </span><span style=" font-size:14pt; font-weight:600;">Models for Event Based Stochastic Processes (ModStochProc, p. 389)</span><span style=" font-size:14pt;">. <br /><br />The Discrete Event System Specification, abbreviated DEVS, is a modeling style and mathematical formalism. Examples of how DEVS models can be represented in Modelica is shown </span><span style=" font-size:14pt; font-weight:600;">here (DEVS, p. 393)</span><span style=" font-size:14pt;">. <br /><br />Petri Nets is a widely used formalism for modeling and analyzing discrete event systems, with an associated intuitive visual representation. The nets can be thought of as a graph containing two kinds of nodes, </span><span style=" font-size:14pt; font-weight:600;">Places and Transitions (ClassesforCPT, p. 406)</span><span style=" font-size:14pt;">. This section is completed with an example of a cellular automata , </span><span style=" font-size:14pt; font-weight:600;">Game of Life (GameOfLife, p. 414)</span><span style=" font-size:14pt;">.</span></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Hybrid System Modeling and Simulation</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-size:14pt;">Hybrid Systems, systems that contain both continuous-time and discrete-time subsystems. This section describes an example of a Hybrid System, the </span><span style=" font-size:14pt; font-weight:600;">Hybrid Tank Model with a Discrete Controller (Hybrid Tank, p. 417)</span><span style=" font-size:14pt;">. We end with an example of </span><span style=" font-size:14pt; font-weight:600;">A Mode Switching Model (DCMotorwithBacklash, p. 421)</span><span style=" font-size:14pt;">.</span></p></body></html> + + + + + diff --git a/DrModelica/DrModelica.onb b/DrModelica/DrModelica.onb new file mode 100644 index 00000000000..68cb32c7462 --- /dev/null +++ b/DrModelica/DrModelica.onb @@ -0,0 +1,2389 @@ + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="right" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Version 2013-10-09</span></p></td></tr></table></body></html> + Right + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">DrModelica</span><span style=" font-family:'Arial'; font-size:24pt; font-weight:600; color:#000000; vertical-align:super;">Modelica Edition</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">Copyright: (c) Linköping University, PELAB, 2003-2009, Wiley-IEEE Press, Modelica Association.<br />Contact: OpenModelica@ida.liu.se; OpenModelica Project web site: www.openmodelica.org<br />Book web page: www.openmodelica.org; Book author: Peter.Fritzson@ida.liu.se<br /><br />DrModelica Authors: (2003 version) Susanna Monemar, Eva-Lena Lengquist Sandelin, Peter Fritzson, Peter Bunus <br />DrModelica Authors: (2005 and later updates): Peter Fritzson, Adrian Pop, Alachew Shitahun</span></p></td></tr></table></body></html> + 14 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">This DrModelica notebook has been developed to facilitate learning the Modelica language as well as providing an introduction to object-oriented modeling and simulation. It is based on and is supplementary material to the Modelica book: Peter Fritzson: &quot;Principles of Object-Oriented Modeling and Simulation with Modelica&quot; (2004), 940 pages, Wiley-IEEE Press, ISBN 0-471-471631. All of the examples and exercises in DrModelica and the page references are from that book. Most of the text in DrModelica is also based on that book.</span></p></td></tr></table></body></html> + Left + 1 + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Detailed Copyright and Acknowledgment Information</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">A number of the examples in this document (DrModelica) and in the Modelica book are reproduced from the Modelica Language specification and Users Guide, copyrighted by the Modelica Association, and are free to use under the Modelica License (www.modelica.org). A number of examples have been published in papers and contributed by researchers (gratefully acknowledged in the book) for free use in the Modelica book and supplementary teaching material such as DrModelica. The rest of the examples in DrModelica are only from the Modelica Book, (c) by Wiley-IEEE Press, and are allowed for free usage if you and/or the teacher using this material have acquired that book.<br /><br />The OMNotebook plotting uses the ptplot package in the Ptolemy II system developed and copyrighted by the University of California.<br /><br /></span><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">General notice: </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">All rights reserved. Reproduction or use of editorial or pictorial content in any manner is prohibited without expressed permission, if such content is not available by permission from another source. No patent liability is assumed with respect to the use of the information contained herein. While every precaution has been taken in the preparation of this manual, the publisher assumes no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained.</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Getting Started Using OMNotebook</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">IMPORTANT:</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> To evaluate a cell just click in the specific cell and press </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#0000ff;">shift+enter</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">. If you end a command by semicolon (;), the value of the command will not be returned in an output cell. When using or saving your own files it is useful to first change the directory to the path where your files are located. This can be done by the </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#0000ff;">cd()</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> command. For a more extensive tutorial explanation on how to use a notebook, see the notebook chapter in the OpenModelica Users Guide. A cell containing a Modelica model, class, or function has to be evaluated before it is possible to simulate it. To do this, click inside the cell or on the cell, and push </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#0000ff;">shift-enter</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">. Then you have to evaluate a simulate command, e.g. by typing &quot;simulate(modelname, startTime=0, stopTime=25 );<br /> <br />After simulating a class it is possible to plot or just look at the values of the variables in the class by using the plot command. Note that Java must be installed on your computer in order to run plot. Variable names given to the plot command refer to the most recently simulated model - you do not need to provide the modelname as a prefix. When writing Modelica code a special ModelicaInput cell must be used. New cells can be inserted from the format menu. A new ModelicaInput/Command input cell can also be created by the short-cut command </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#0000ff;">Ctrl+Shift+I</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">, whereas a new cell with the same text style as the one above can be created by the short-cut command </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#0000ff;">Alt+Enter</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">.</span></p></td></tr></table></body></html> + 14 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">To open or close (toggle) the Detailed Copyright section (above), the OpenModelica command section, other sections below, </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#0000ff;">double-click</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> on the section cell marker (vertical bracket) to the right of the corresponding cell.</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">OpenModelica commands</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Exit OMShell by pressing Ctrl-d<br /><br />up-arrow<br />    Get previously given command.<br />    <br />down-arrow<br />    Get next command.<br /><br />tab<br />    Command completion of these builtin commands.<br />    Circulate through the commands by only using tab key.<br /><br />cd()<br />    Return the current directory<br /><br />cd(dir)<br />    Change directory to the directory given as a string.<br />    Ex: cd(&quot;myModels/myLibrary&quot;)<br /><br />clear()<br />    Clear everything.<br /><br />clearVariables()<br />    Clear the variables.<br /><br />help()<br />    Print this helptext (returned as a string).<br /><br />instantiateModel(modelname)<br />    Instantiates a model/class and returns a string <br />    containing the flat class definition.<br />    Ex: instantiateModel(dcmotor)<br /><br />list()<br />    Return a string containing all class definitions.<br /><br />list(modelname)<br />    Return a string containing the class definition of<br />    the named class.<br />    Ex: list(dcmotor)<br /><br />listVariables()<br />    Return a vector of the currently defined variable <br />    names.<br /><br />loadFile(strFile)<br />    Load modelica file given as string argument.<br />    Ex: loadFile(&quot;../myLibrary/myModels.mo&quot;)<br /><br />loadModel(name)<br />    Load model, function, or package relative to $MODELICAPATH.<br />    Ex: loadModel(Modelica.Electrical)<br />    Note: if e.g. loadModel(Modelica) fails, you may have<br />    MODELICAPATH pointing at the wrong location.<br /><br />plot(var)<br />    Plot a variable from the most recently simulated model.<br />    Ex: plot(x)<br /><br />plot(vars)<br />    Plot variables from the most recently simulated model<br />    given as a vector.<br />    Ex: plot({x,y})<br /></span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:12pt; color:#000000;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> plotParametric(var1, var2)</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> Plot var2 relative to var1 from the most recently simulated </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> model.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> Ex: plotParametric(x,y)</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"><br />readFile(str)<br />    Load file given as string and return a string of the<br />    file content.<br />    Ex: readFile(&quot;myModel/myModelr.mo&quot;)<br /><br />readSimulationResultSize(strFile)<br />    Return the size of the record resulting from a simulation<br />    The size is read from the result file, given as a string<br />    Ex: readSimulationResultSize(&quot;dcmotor_res.plt&quot;);<br /><br />readSimulationResult(strFile, variables, size)<br />    Read the results of a simulation from a file named by<br />    the string argument strFile. <br />    Here size is the size of the resulting record and<br />    variables is a vector of the variables to investigate.<br />    Ex: readSimulationResult(&quot;dcmotor_res.plt&quot;, {R1.i,L1.v}, 10)<br /><br />runScript(strFile)<br />    Exectute script file (.mos) given as string argument.<br />    Ex: runScript(&quot;simulation.mos&quot;)<br /><br />saveModel(strFile,modelname)<br />    Save the model/class with name modelname in the file given <br />    by the strFile string argument.<br /><br />simulate(modelname[,startTime=][,stopTime=][,numberOfIntervals=])<br />    Translates a model and simulates it.<br />    Ex: simulate(dcmotor)<br />    Ex: simulate(dcmotor,startTime=0, stopTime=10, numberOfIntervals=1000)<br /><br />system(str)<br />    Execute str as a system(shell) command, return integer<br />    success value.<br />    Ex: system(&quot;touch myFile&quot;)<br /><br />timing(expr)<br />    Evaluates expression and returns the number of seconds <br />    the evaluation took.<br />    Ex: timing(x*4711+5)<br /><br />typeOf(variable)<br />    Returns the type of the variable as a string.<br />    Ex: typeOf(R1.v)<br /><br />quit()<br />    Leave OpenModelica and kill the process.<br /></span></p></td></tr></table></body></html> + Courier New + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">OSMC Public license </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"><br />Contact:<br />Web: www.ida.liu.se/projects/OpenModelica<br />Email OpenModelica@ida.liu.se<br /><br />This file is part of OpenModelica.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> Copyright (c) 1998-2010, Linköping University,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> Department of Computer and Information Science,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> SE-58183 Linköping, Sweden.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> All rights reserved.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> AND THIS OSMC PUBLIC LICENSE (OSMC-PL). </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> ACCEPTANCE OF THE OSMC PUBLIC LICENSE.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> The OpenModelica software and the Open Source Modelica</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> Consortium (OSMC) Public License (OSMC-PL) are obtained</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> from Linköping University, either from the above address,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> from the URLs: http://www.ida.liu.se/projects/OpenModelica or </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> http://www.openmodelica.org, and in the OpenModelica distribution. </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> This program is distributed WITHOUT ANY WARRANTY; without</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> even the implied warranty of MERCHANTABILITY or FITNESS</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> OF OSMC-PL.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> See the full OSMC Public License conditions for more details.</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">A Quick Tour of Modelica</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Getting Started - First Basic Examples</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">There is a long tradition that the first sample program in any computer language is a trivial program printing the string &quot;</span><a href="QuickTour/HelloWorld.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Hello World</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">&quot; (p. 19 in Peter Fritzson's book). Since Modelica is an equation based language, printing a string does not make much sence. Instead, our Hello World Modelica program solves a trivial differential equation. The second example shows how you can write a model that solves a </span><a href="QuickTour/DiffEq.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Differential Algebraic Equation System</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 19). In the </span><a href="Variables/VanDerPol.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Van der Pol</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 22) example declaration as well as initialization and prefix usage are shown in a slightly more complicated way.</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Classes and Instances </span></p></td></tr></table></body></html> + 14 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">In Modelica objects are created implicitly just by </span><a href="QuickTour/CreateInst.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Declaring Instances of Classes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 26). Almost anything in Modelica is a class, but there are some keywords for specific use of the class concept, called </span><a href="Classes/Restricted.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Restricted Classes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 28). The concept </span><a href="Classes/ReuseMod.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Reuse of Modeling Knowledge</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 28) is an important part of Modelica. Modelica has several built-in types (like </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">Real, Integer, Boolean</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> and </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">String</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">), which has most of the properties a class has and it is possible to change the value of them during run-time. You can read more about classes in Chapter 3 below and in Chapter 3 in Peter Fritzson's book. Note that the chapter numbering in this electronic notebook corresponds to the numbering in Peter Fritzson's book in order to make it easy to use them together.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="QuickTour/Exercise1classes.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1<br />    </span></a><a href="QuickTour/Exercise2-classes.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a><a href="QuickTour/Exercise1classes.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;"><br />    </span></a><a href="QuickTour/Exercise3-classes.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Inheritance</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="QuickTour/Inheritance.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Inheritance</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 29) is the ability to extend the behavior and properties of an existing class. This way the properties of a specific class can be reused. See Chapter 4 below and in Peter Fritzson's book for additional details concerning inheritance.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="QuickTour/Exercise1inheritance.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1<br />    </span></a><a href="QuickTour/Exercise2inheritance.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Generic Classes </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">In many situations it is advantageous to be able to express </span><a href="QuickTour/Generic.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Generic Patterns</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 30) for programs. By doing so a substanitial amount of coding and software maintenance can be avoided by directly expressing the general structure of the problem and providing the special cases as parameters. In Modelica the class construct is general enough to handle generic modeling and programming. You can learn more about generic classes in Chapter 4 below and in Chapter 4 in Peter Fritzson's book .</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">Modelica is an equation-based language. The key to the physical modeling capabilities and increased reuse potential of Modelica classes is that </span><a href="QuickTour/Equations.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 32) are more flexible than assignments, since they do not prescribe a certain data flow direction. Modelica also provides repetitive equation structures, like for-loop equations. See Chapter 8 to learn more about equations.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="QuickTour/Exercise1equations.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Partial Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="QuickTour/Partial.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Partial</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 39) is in Modelica the same as abstract in other object-oriented languages. A partial class is an incomplete class, i.e., not complete enough to be instantiated. Some more advanced examples concerning partial classes are presented in Chapter 3.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="QuickTour/Exercise1partial.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Arrays </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">An </span><a href="QuickTour/Array.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Array</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 43) is a collection of variables, all of the same type. Elements of an array are accessed through simple integer indexes, ranging from 1 to the size of the respective dimension. You can read more about arrays in Chapter 7.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="QuickTour/Exercise1arrays.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Algorithmic Constructs</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">Even though equations are eminently suitable for modeling physical systems, and for a number of other tasks, there are situations where non-declarative algorithmic constructs are needed. This is typically case for algorithms, i.e., stepwise procedural descriptions on how to carry out specific computations. In Modelica an algorithmic statement can only occur within </span><a href="QuickTour/Algorithm.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Algorithm Sections</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">, starting with the keyword </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">algorithm</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 44). Apart for the assignment statement, there are several kinds of </span><a href="QuickTour/Statement.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Algorithmic Statements</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 44) in Modelica, including </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">if-then-else</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> statements, </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">for-loops, </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">and</span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;"> while-loops</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">.</span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;"> </span><a href="QuickTour/Functions.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Functions</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 44) are a natural part of any mathematical model. You can find more about Algorithms in Chapter 9.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="QuickTour/Exercise1algorithm.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Hybrid Modeling</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">In Modelica there are two different constructs for expressing hybrid models: </span><a href="QuickTour/IfClause.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Conditional Expressions or Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 46) and </span><a href="QuickTour/WhenClause.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">When-Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> used for the Bouncing Ball (p. 46). Too read more about </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">- and </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">-equations see Chapter 8.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Hybrid/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">    </span></a><a href="QuickTour/Exercise1hybrid.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><a href="Hybrid/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;"><br />    </span></a><a href="QuickTour/Exercise2hybrid.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Packages</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="QuickTour/Packages.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Packages</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 50) in Modelica may contain definitions of constants and classes including all kinds of restricted classes, functions and subpackages. By </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">subpackage</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> we mean that the package is declared inside another package, not any implied inheritance relationship. Regarding inheritance we talk about parent packages and child packages or derived packages. To learn more about packages, see Chapter 10.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="QuickTour/Exercise1package.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Classes, Types and Declarations </span></p></td></tr></table></body></html> + Ch.3-class + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">The class concept is the most fundamental concept in Modelica. Different categories of class definitions, like </span><a href="Classes/Short.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Short Class Definitions</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 80) </span><a href="Classes/Nested.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Local Classes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 105), </span><a href="Classes/Restricted.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Restricted Classes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 28) and </span><a href="Classes/Partial.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Partial Classes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 39) are discussed in this section. </span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Classes/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Classes/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2<br />    </span></a><a href="Classes/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Classes/Exercise4.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 4</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Variables</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">A variable is a class instance, always a member of (i.e., declared in) some other class instance or function. The </span><a href="Variables/Declaration.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Declaration of a Variable</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 88) states the type, access, variability, data flow and other properties of the variable. Both class and variable declarations can contain various </span><a href="Variables/VariabilityPrefixes.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Variability Prefixes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 89), which associate certain properties with the declaration and are placed at the beginning of the declaration. A variable can be </span><a href="Variables/Initialization.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Initialized</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 94) by using the start attribute. The variables that belong to a class are also called </span><a href="Variables/FieldVar.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Fields</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 74). </span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Variables/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1<br />    </span></a><a href="Variables/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Types, Supertypes and Subtypes </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">What is a Type? A </span><a href="TypeSubtype/Type.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Type</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 100) can conceptually be viewed as a </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">set of values</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">. When we say that the variable x has the type </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> we mean that the value of x belongs to the set of values represented by the type </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">. The concepts of </span><a href="TypeSubtype/Sub-SuperType.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Subtype and Supertype</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 100) are discussed further in Peter Fritzson's book.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="TypeSubtype/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="TypeSubtype/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Access control        </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">Here </span><a href="AccessControl/AccessDemo.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Access Control</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 88) of variables are discussed. Both variables that are declared public and protected are used in the </span><a href="AccessControl/MoonLanding.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Moon Landing</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 78) example.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="AccessControl/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Inheritance, Modifications and Generics</span></p></td></tr></table></body></html> + Ch.4-inheritance + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Inheritance</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">One of the major benefits of object-orientation is </span><a href="Inheritance/Inheritance.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Inheritance</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 29), i.e., the ability to extend the behavior and properties of an existing class. A class can inherit from several classes, this is called </span><a href="Inheritance/Multiple.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Multiple Inheritance</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 113). How are </span><a href="Inheritance/ProtectedElements.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Public Respectively Protected Elements</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 117) inherited? All these concepts are used in the </span><a href="Inheritance/MoonLandingInher.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Moon Landing</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 115) example using inheritance.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Inheritance/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">    Exercise 1<br />    </span></a><a href="Inheritance/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a><a href="InherMod/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;"><br />    </span></a><a href="Inheritance/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Inheritance Through Modification    </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">There are three kinds of constructs in the Modelica language in which </span><a href="InherMod/Modification.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Modifications</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 119) can occur: variable declarations, </span><a href="InherMod/Short.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Short Class Definitions</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 120) and </span><a href="InherMod/Extend.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Extends Clauses</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 122). </span><a href="InherMod/Hierachical.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Hierarchical Modification</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 124) means that elements one or more levels down in the instantiation hierarchy are modified.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="InherMod/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1<br />    </span></a><a href="InherMod/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a><a href="InherMod/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;"><br />    </span></a><a href="InherMod/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Redeclaration</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">A more dramatic change than just changing the default value in a declaration, is to modify the type and/or the prefixes of a declared element. The original declaration is replaced by the &quot;new declaration&quot;, by using the </span><a href="Redeclaration/ReplRed.onb#Redeclare +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Prefix redeclare</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 127), merged with the modifiers of the original declaration. </span><a href="Redeclaration/Redeclaration.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Redeclarations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 125) usually require the modified element to be declared with the </span><a href="Redeclaration/ReplRed.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">replaceable Prefix</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 127), but there are also kinds of redeclarations that do </span><a href="Redeclaration/RedNotRepl.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">not need the Prefix replaceable</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 126). In order to prevent certain modifications the </span><a href="Redeclaration/Final.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">final Prefix</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 128) can be used. The rules concerning the </span><a href="Redeclaration/Replaceable.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Constraining Type of Replaceable Elements</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 129) can be found in the book. Apart from textual Modelica programming, redeclarations may also be specified through a graphical user interface (GUI) of a Modelica modeling tool, e.g. via menu choices, in order to achieve this, </span><a href="Redeclaration/Annotation.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Annotation Choices</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (s. 132) are used.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Redeclaration/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Redeclaration/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2<br />    </span></a><a href="Redeclaration/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Redeclaration/Exercise4.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 4</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Parameterized Generic Classes</span></p></td></tr></table></body></html> + ch.4.4-generic + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">By expressing generic patterns for models or programs a large amount of coding and software maintenance can be avoided. This is done using </span><a href="Generic/Parameterized.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Parameterized Generic Classes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 133). </span><a href="Generic/ParamInterfaces.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Parameterization and extension of Interfaces</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 136).</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Generic/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Extended</span></p></td></tr></table></body></html> + ch.4.4-generic + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">It is important to </span><a href="Generic/Extended.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Design a Class to be Extended</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 137), otherwise inheritance might lead to errors.</span></p></td></tr></table></body></html> + 14 + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Components, Connectors and Connections</span></p></td></tr></table></body></html> + Ch.5-component + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connectors and Connector Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">Modelica </span><a href="CompConn/Connectors.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Connectors are instances of Connector Classes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 146). Connectors specify the interface for interaction between a component and its surroundings.</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connections</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="CompConn/Connections.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Connections</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 148) between components can only be established between connectors of equivalent type. </span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connectors, Components and Coordinate Systems</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">Each </span><a href="CompConn/MechTrans.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Mechanical Component</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 153) has an associated </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">coordinate system</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">, called </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">frame</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">. It is possible to connect several connections to one connector, this is called </span><a href="CompConn/MultToSingle.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Multiple Connections to a Single Connector</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 155). The model of an </span><a href="CompConn/Oscillator.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Oscillating Mass Connected to a Spring</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 156) gives rise to some dynamic movement when simulated. </span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Detailed Connection Semantics</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">A </span><a href="CompConn/MultDCmotor.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">DC Motor Model</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 162) is one of the simplest examples illustrating the ease of constructing multi-domain models in Modelica by simply connecting components from different domains. The point of a </span><a href="CompConn/PartDCmotor.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Partial DC Motor</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 162) is to get a structured library component with inside and outside connectors that can be reused. The restrictions on how to connect </span><a href="CompConn/In-Output.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Input and Output Connectors</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 164) are also handled. </span><a href="CompConn/ConnConstraints.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Connection constraints regarding Array, Subscripts and Constants</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 166) are different from other connected connectors. By </span><a href="CompConn/ConnEq.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Generating Connection Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 169) we mean the conversion of connect equations to the two different forms of equations to be used for non-flow and flow variables respectively. The process of converting connect-equations can be divided into two steps, the first is building connections sets from connect-equations and the second is generating connection equations for the complete model. In certain cases there is a need to let the behavior of a model be dependent on the number of connections to certain connectors of the model. This can be achieved by using a built-in function </span><a href="CompConn/CardEq.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">cardinality</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 173) that returns the number of connections that have been made to a connector.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="CompConn/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Literals, Operators and Expressions</span></p></td></tr></table></body></html> + Ch.6-litopex + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">The </span><a href="LitOpExp/EvalOrder.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Order of Evaluation</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 188) (e.g. regarding variable references and function calls in expressions) is not specified, since a Modelica tool is free to solve equations, to reorder expressions, and to avoid evaluating expressions if their values do not influence the result. The rules for </span><a href="LitOpExp/VariaSubt.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Subtyping and Variability</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 194) for declaration equations and normal equations are illustrated. All declared variables are functions of the independent variable </span><a href="LitOpExp/VarTime.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">time</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">, which is a built-in variable (p. 198) available in all kinds of classes. The variable time is treated as an input variable.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="LitOpExp/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1<br /> </span></a><a href="LitOpExp/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Arrays</span></p></td></tr></table></body></html> + Ch.7-array + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Array Declarations and Types</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">An </span><a href="Arrays/Declaration.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Array Variable can be Declared</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 207) by appending dimensions within square brackets after a type name or after a variable name. An </span><a href="Arrays/FlexSize.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Unspecified Dimension Size</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 209) is stated by using a colon (:) instead of the usual integer expression for dimension size. For the purpose of </span><a href="Arrays/TypeCheck.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Type Checking</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 209) and selecting the right version of overloaded array operators and functions it is important to determine the expanded type of a variable. </span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Arrays/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Arrays/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">General Array Construction</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">An </span><a href="Arrays/Construction.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Array Constructor</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> provides a convenient way of constructing array values, giving concise and readable code (p. 210). </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Arrays/Exercise1-7-2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Array Concatenation and Construction </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Arrays/ConcatConstruct.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">General Array concatenation</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> can be done through the array concatenation operator </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">cat</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(k,A,B,C,...) that concatenates the arrays A,B,C,... along the k:th dimension (p. 213).</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Arrays/Exercise1-7-3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Array Indexing </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">The </span><a href="Arrays/Indexing.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Array Indexing</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> operator (p. 216) is used to access array elements for retrieval of their values or for updating these values. When at least one of the index expressions in an array indexing operation is a vector expression, a slice or subsection of the array is accessed rather than a single element. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Arrays/Exercise1-7-4.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Using Array Concatenation and Slices</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">The Modelica </span><a href="Arrays/ConcatSlice.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Array Concatenation and Slice Operations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 219) have been designed for multidimensional arrays and can therefore produce arrays of various dimensions, from one-dimensional vectors to matrices and multidimensional arrays. </span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Arrays/Exercise1-7-5.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Arithmetic Array Operators </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Arrays/ArithmeticOp.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Arithmetic Array Operators</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 223) on arrays and certain combinations of arrays and scalars are available through the standard arithmetic operators.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Arrays/Exercise1-7-6.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1(går ej plotta)</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Built-in Array Functions </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">A number of </span><a href="Arrays/Built-inFunc.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Built-in Functions</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 225) for array expressions are provided in Modelica. These functions are directly available and need not be imported from some package in the standard library before being used. </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Application of Scalar Functions to Arrays </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">In certain situations it is useful to be able to apply a function to array values even if it has not been defined for such arguments. Modelica functions with one scalar return value can be </span><a href="Arrays/ScalarFunc.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Applied to Arrays</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> element-wise (p. 229).</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Empty Arrays</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Arrays/Empty.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Empty Arrays</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> are sometimes used as a kind of null element (p. 231).</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Equations </span></p></td></tr></table></body></html> + Ch.8-equation + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Equations in Declarations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">That are two kinds of </span><a href="Equations/EqDeclarations.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Equations that occur as Parts of Declarations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">: (p. 239) declaration equations and modifier equations. </span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Equations in Equation Sections</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">The following kinds of equations can be present in equation sections: </span><a href="Equations/SimpleEquality.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Simple Equality Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 240), </span><a href="Equations/RepStruct.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Repetitive Equation Structures with for-Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 241), </span><a href="Equations/RepConnStruct.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">connect equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 244), </span><a href="Equations/IfEq.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Conditional Equations with if-Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 245), </span><a href="Equations/WhenEq.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Conditional Equations with when-Equations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 246) </span><a href="Equations/Assert.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Assert</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 249) and </span><a href="Equations/MoonLandingTerminate.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Terminate</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 249). Terminate is described using the Moon Landing Example. Polynomial Equations using for-Equations is shown in </span><a href="Equations/Polynomial.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">XPowers</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 242) and </span><a href="Equations/PolynomialEvaluator.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Polynomial Evaluator</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 242). The class </span><a href="Equations/Step.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Step</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 244) includes a repetitive equation structure in the form of a </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">-equation. </span><a href="QuickTour/WhenClause.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Reinit</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 249) is described in the Bouncing Ball model.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Equations/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Equations/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Equations/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Equations/Exercise4.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 4</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Algorithms and Functions</span></p></td></tr></table></body></html> + Ch.9-algfunc + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Algorithms </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">In Modelica, algorithmic statements can only occur within </span><a href="Algorithms/Sections.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Algorithm Sections</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 285), starting with the keyword </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">algorithm</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">. </span><a href="Algorithms/AssignStat.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Simple Assignment Statements</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 287) is the most common kind of statements in algorithm sections. There is a special form of assignment statement that is only used when the right hand side contains a call to a </span><a href="Algorithms/MultRes.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Function with Multiple Results</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 287). <br /><br />The </span><a href="Algorithms/ForStat.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">for-Statement</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (also called </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">-loop) is a convenient way of expressing iteration (p. 288). When using the </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">-loop for iteration we must be able to express the range of values over which the iteration variable should iterate in a clo</span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">sed</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> form as an iteration expression. For cases where this is not feasible there is also a </span><a href="Algorithms/WhileStat.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">while-loop</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> iteration construct in Modelica (p. 290). For conditional expressions the </span><a href="Algorithms/IfStat.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">if-Statement</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 292) is used. </span><a href="Algorithms/WhenStat.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">When-Statements</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 293) are used to express </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">actions at event instants</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> and are closely related to </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">-equations. The </span><a href="Algorithms/Reinit.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">reinit</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 296) statement (se also </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#0000ff;">reinit</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> equations) can be used in </span><span style=" font-family:'Courier New'; font-size:14pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">-statements</span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">to define new values for continuous-time </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">state variables</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> of a model at an event. <br /><br />The </span><a href="Algorithms/Assert.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">assert</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 298) statement provides a convenient means for specifying checks on model validity within a model. <br />The most common usage of </span><a href="Algorithms/Terminate.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">terminate</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 298) is to give more appropriate stopping criteria for terminating a simulation than a fixed point in time.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Algorithms/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Algorithms/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2<br />    </span></a><a href="Algorithms/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3<br />    </span></a><a href="Algorithms/Exercise4.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 4</span></a><a href="Algorithms/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;"><br />    </span></a><a href="Algorithms/Exercise5.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 5</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">The body of a Modelica function is a kind of algorithm section that contains procedural algorithmic code to be executed when the function is </span><a href="Functions/Call.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">called</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 300). Since a function is a restricted and enhanced kind of class, it is possible to inherit an existing function declaration in the declaration of a new function. In this way we can declare the common structure of a set of functions as a </span><a href="Functions/Extending.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Partial Base Function</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 308) which can be inherited into the functions we want to define. A function with more than one output formal parameter has </span><a href="Functions/MultipleRes.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Multiple Results</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 302). It is possible to call functions defined outside of the Modelica language, so called </span><a href="Functions/External.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">External Functions</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 311).</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Functions/Exercise1.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Functions/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Functions/Exercise3.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 3</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Packages</span></p></td></tr></table></body></html> + Ch.10-package + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">What is a </span><a href="QuickTour/Packages.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Package</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">?</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Packages as Abstract Datatypes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">The notion of a package partly originates from the notion of </span><a href="Packages/PackasADTs.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Abstract Data Type</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 333).</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Packages/Exercise1ADT.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Package Access</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">There are essentially two ways of </span><a href="Packages/PackAccess.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Accessing</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 335) the definitions of a package: direct reference by prefixing the package name to definition names or importing definitions from the package.</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Package and Library Structuring </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">A well-designed </span><a href="Packages/PackLibrStruct.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Package Structure</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 338) is one of the most important aspects that influences the complexity, understandability, and maintainability of a large software systems. </span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">    </span><a href="Packages/Exercise1LibrStruct.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Package Variants and Operations </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">In the following sections we will examine certain variants of packages that can be created through operations such as instantiation of </span><a href="Packages/Generic.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Generic Packages</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 346), </span><a href="Packages/Inherited.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Inheritance of Packages</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 347), and manual editing. In addition will examine two special types of packages: </span><a href="Packages/Local.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Local Packages</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 348) and </span><a href="Packages/Nonencapsulated.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Nonencapsulated Packages</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 349). Also Copying or </span><a href="Packages/Moving.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Moving Packages</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 350) is discussed here.</span></p></td></tr></table></body></html> + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Exercises</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Packages/Exercise2.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">    </span></a><a href="Packages/Exercise1VarOp.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 1</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"><br />    </span><a href="Packages/Exercise2VarOp.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; text-decoration: underline; color:#0000ff;">Exercise 2</span></a></p></td></tr></table></body></html> + 14 + Bold + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Annotations, Units and Quantities</span></p></td></tr></table></body></html> + Ch.11-annotation + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Annotations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="AnnUnitsQuant/Annotations.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Annotations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 11.) are attributes that are not really part of the Modelica core language but still belongs to Modelica in a broad sense, and therefore are part of the Modelica language definition. Since annotations need to have a certain </span><a href="AnnUnitsQuant/SynPlac.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Syntax and Placement</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 358) in classes, rules about this are discussed here. </span><a href="AnnUnitsQuant/Graphical.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Graphical Annotations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 361) is the most common form of annotation in typical Modelica models. </span><a href="AnnUnitsQuant/FuncAnn.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Function Annotations</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 372).</span></p></td></tr></table></body></html> + 14 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Units and Quantities</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="AnnUnitsQuant/UnitsQuant.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Units and Quantities</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 374) are constructs that are also not part of the Modelica language, but are for the same reason as Annotations part of the Modelica definition.</span></p></td></tr></table></body></html> + 14 + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">System Modeling Methodology and Continuous Model Representation</span></p></td></tr></table></body></html> + Ch.12-annunitquant + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Modeling a Tank System</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">So far we have primarily discussed, and shown examples of, the principles of object-oriented mathematical modeling, a number of Modelica language constructs to support high-level model representations and a high degree of model reuse. But in this chapter we will instead present a systematic method on how to create system models.<br /><br />To begin with, a tank system will be modeled, and there are different approaches. The </span><a href="SystemMod/FlatTank.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Traditional Methodology</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 385) for physical modeling can be roughly divided into three phases: basic structuring in terms of variables, stating equations and formulas, and converting the model to state space form. When using the </span><a href="SystemMod/PIControl.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Object Oriented Component-based</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 386) approach to modeling we first try to understand the system structure and decomposition in an hierarchical top-down manner. When the system components and interactions between these components have been roughly identified, we can apply the first two traditional modeling phases of identifying variables and equations on each of these model components.</span></p></td></tr></table></body></html> + 14 + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modeling Discrete Events and Hybrid Systems</span></p></td></tr></table></body></html> + Ch.13-eventhybrid + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Events</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">An event is simply </span><span style=" font-family:'Times New Roman'; font-size:14pt; font-style:italic; color:#000000;">something that happens</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">, using everyday language. This is true in the real world as well as in the mathematical sense. Modelica provides a number of built-in functions and operators related to events and time. One function that can be used for generating repeated events is </span><a href="DiscreteHybrid/SampleClock.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">sample</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 415). <br /><br />Events arise naturally external to a simulated system or are generated internally in the simulation model. These events should be handled, i.e. some </span><a href="DiscreteHybrid/EventBeh.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Behavior</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 421) should be executed associated with each event. We also describe how to </span><a href="DiscreteHybrid/EventPriority.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Use Event Priority to Avoid Erroneous Multiple Definitions</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 424). Events often need to be </span><a href="DiscreteHybrid/Synchronization.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Synchronized</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 425) and propagated, though Modelica gives no guarantee of exact synchronization. Also discussed are </span><a href="DiscreteHybrid/MultEvents.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Multiple Events at the Same Point in Time and Event Internation</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 427).</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Discrete Model Examples and Related Formalisms</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">This section provides you with a number of model examples of different kinds of discrete systems, for example </span><a href="DiscreteHybrid/SampledSystems.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Sampled Systems</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 429), </span><a href="DiscreteHybrid/Automata.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Finite State Automata</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 433) and </span><a href="DiscreteHybrid/ModStochProc.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Models for Event Based Stochastic Processes</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 441). The </span><a href="DiscreteHybrid/WatchDog.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">WatchDog</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> System. (p. 435).<br /><br />The Discrete Event System Specification, abbreviated DEVS, is a modeling style and mathematical formalism. Examples of how DEVS models can be represented in Modelica is shown </span><a href="DiscreteHybrid/DEVS.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">here</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 444). <br /><br />Petri Nets is a widely used formalism for modeling and analyzing discrete event systems, with an associated intuitive visual representation. The nets can be thought of as a graph containing two kinds of nodes, </span><a href="DiscreteHybrid/ClassesforCPT.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Places and Transitions</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 453). This section is completed with an example of a cellular automata</span><span style=" font-family:'Times New Roman'; font-size:14pt; font-weight:600; color:#000000;">,</span><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> </span><a href="DiscreteHybrid/GameOfLife.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Game of Life</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 438).</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Hybrid System Modeling and Simulation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">Hybrid Systems, systems that contain both continuous-time and discrete-time subsystems. This section describes an example of a Hybrid System, the </span><a href="DiscreteHybrid/HybridTank.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Hybrid Tank Model with a Discrete Controller</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 460). We end with an example of </span><a href="DiscreteHybrid/DCMotorwithBacklash.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">A Mode Switching Model</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 464).</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Basic Laws of Nature</span></p></td></tr></table></body></html> + Ch.14-nature + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="LawsOfNature/TransformerEMF.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Emf-Transformer</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;">(p. 478)</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Application Examples</span></p></td></tr></table></body></html> + Ch.15-applex + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="ApplicationEx/Mechatronic.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Mechatronic Systems - A DC Motor</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 553)</span><a href="ApplicationEx/3DDoublePendulum.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;"><br /></span></a><a href="ApplicationEx/DesignOptimization.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Design Optimization</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 582)</span><a href="ApplicationEx/3DDoublePendulum.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;"><br /></span></a><a href="ApplicationEx/FourierAnalysis.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Frequency Analysis of Simulation Data</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 578)</span><a href="ApplicationEx/3DDoublePendulum.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;"><br /></span></a><a href="ApplicationEx/PressureDynamics.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Pressure Dynamics in 1D Ducts - Solving Wave Equations by Discretized PDEs</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 587)</span><a href="ApplicationEx/3DDoublePendulum.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;"><br />A 3D Double Pendulum</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 598)<br /></span><a href="ApplicationEx/KinematicLoops.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Kinematic Loops</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 601)<br /></span><a href="ApplicationEx/InterfacingtoNonMechModComp.onb +"><span style=" font-family:'Times New Roman'; font-size:14pt; text-decoration: underline; color:#0000ff;">Interfacing to Non-Mechanical Model Components</span></a><span style=" font-family:'Times New Roman'; font-size:14pt; color:#000000;"> (p. 603)<br /></span></p></td></tr></table></body></html> + 14 + + + + + diff --git a/DrModelica/Equations/Assert.onb b/DrModelica/Equations/Assert.onb new file mode 100644 index 00000000000..369d2ae9002 --- /dev/null +++ b/DrModelica/Equations/Assert.onb @@ -0,0 +1,113 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Assert</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"><br />Assert</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> provides a convinient means for specifying checks on model validity within a model. The </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">assert-expression</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">assert</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equation should normally evaluate to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. A failed assertion, i.e. when the expression evaluates to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">false</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, should be reported back to the user in some way that is dependent on the simulation tool.<br /></span></p></td></tr></table></body></html> + + + class AssertTest + Real lowlimit = -5; + Real highlimit = 5; + Real x = 1; +equation + assert(x >= lowlimit and x <= highlimit, "Variable x out of limit"); +end AssertTest; + {AssertTest} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class AssertTestInst + AssertTest assertTest(lowlimit = -2, highlimit = 6, x = 5); +end AssertTestInst; + {AssertTestInst,AssertTest} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of AssertTest</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AssertTest</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown. The variables can then be plotted below.</span></p></td></tr></table></body></html> + + + simulate( AssertTestInst, stopTime=5 ) + record SimulationResult + resultFile = "AssertTestInst_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + plot( { assertTest.x, assertTest.highlimit, assertTest.lowlimit }) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/EqDeclarations.onb b/DrModelica/Equations/EqDeclarations.onb new file mode 100644 index 00000000000..6b38ea629f6 --- /dev/null +++ b/DrModelica/Equations/EqDeclarations.onb @@ -0,0 +1,89 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Equations in Declarations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Declaration Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Declaration equations are usually given as part of declarations of constants or parameters. Such equations are actually required for constants, but are optional for parameters. An equation always holds, which means that the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">mass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> never changes value during simulation. It is also possible to specify a declaration equation for a normal state variable, but this will make the variable bahave as a kind of constant.</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + + + class DecEq + constant Integer one = 1; // Declaration equation + parameter Real mass = 22.5; // -"- + Real speed = 72.4; // Declaration equation for a normal state variable +end DecEq; + {DecEq} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modifier Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Modifier equations occur for example in a variable declaration when there is a need to modify the default value of an attribute of the variable. A modifier equation replaces the declaration equation, if present, for an attribute of the specific type. A common usage is modifier equations for the start attribute of variables, the equations also occur in type definitions.<br /></span></p></td></tr></table></body></html> + + + class ModEq + Real speed(start = 72.4); // Modifier equation +end ModEq; + {ModEq} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Here is another example of a modifier equation:</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V", min = -220.0, max = 220.0); + {Voltage} + + + + + diff --git a/DrModelica/Equations/Exercise1.onb b/DrModelica/Equations/Exercise1.onb new file mode 100644 index 00000000000..8c4c066c93e --- /dev/null +++ b/DrModelica/Equations/Exercise1.onb @@ -0,0 +1,149 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 1</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What is specific about equations in Modelica?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Equations are more powerful than assignments, since one equation can express several different assignments.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What is a declaration equation?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A declaration equation is the equation used when declaring a variable, usually constants or parameters. Such equations are actually required for constants, but are optional for parameters. It is also possible to specify a declaration equation for a normal state variable, but this will make the variable behave as a kind of constant.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What is a modifier equation?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Modifier equations occur for example in a variable declaration when there is a need to modify the default value of an attribute of the variable. A modifier equation replaces the declaration equation, if present, for an attribute of the specific type.</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Equations/Exercise2.onb b/DrModelica/Equations/Exercise2.onb new file mode 100644 index 00000000000..0d787033e1b --- /dev/null +++ b/DrModelica/Equations/Exercise2.onb @@ -0,0 +1,424 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 2- Repetitive Equation Structures</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Using the for-Loop</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Write a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Repetitive</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, with an array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">rep</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, with 7 Integer values. The class should set all values in the array to 15, using a for-loop.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + class Repetitive + Integer rep[7]; +equation + for i in 1:7 loop + rep[i] = 15; + end for; +end Repetitive; + {Repetitive} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of Repetitive</span></p></td></tr></table></body></html> + + + simulate( Repetitive ) + record SimulationResult + resultFile = "Repetitive_res.plt" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Exercise without using the for-Loop</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Write the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">RepetitiveWithoutFor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, doing the same thing as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Repetitive</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> above, though not using a for-loop.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + class RepetitiveWithoutFor + Integer rep[7]; +equation + rep[1] = 15; + rep[2] = 15; + rep[3] = 15; + rep[4] = 15; + rep[5] = 15; + rep[6] = 15; + rep[7] = 15; +end RepetitiveWithoutFor; + {RepetitiveWithoutFor} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of RepetitiveWithoutFor</span></p></td></tr></table></body></html> + + + simulate( RepetitiveWithoutFor ) + record SimulationResult + resultFile = "RepetitiveWithoutFor_res.plt" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Another Exercise Using the for-Loop</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This time write a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Repeat</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, with an array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">repeater</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> containing 4 Real values. The values in the array shall be set to 1, 4, 7, 10, using a for-loop.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + class Repeat + Integer repeater[4]; +equation + for i in 1:4 loop + repeater[i] = i + 3; + end for; +end Repeat; + {Repeat} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of Repeat</span></p></td></tr></table></body></html> + + + simulate( Repeat ) + record SimulationResult + resultFile = "Repeat_res.plt" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Function with for-loop</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Write a function, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rapper</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which calculates the sum of the values in the array.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /> Write an instance, where the values of that array shall be set. Then simulate the instance class and plot the result.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + function Rapper + input Integer rap[:]; + output Integer sum = 0; +algorithm + for i in 1:size(rap,1) loop + sum := sum + rap[i]; + end for; +end Rapper; + {Rapper} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span></p></td></tr></table></body></html> + + + class RapperInst + Integer x; +equation + x = Rapper({1, 2, 3, 4}); +end RapperInst; + {RapperInst} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of Rapper</span></p></td></tr></table></body></html> + + + simulate( RapperInst ) //??Error in implemenation of integer vectors + record SimulationResult + resultFile = "RapperInst_res.plt" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + 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QCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAAQCQAAAAAAABAJAAAAAAAAEAkAAAAAAAA + + plot( x ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////home/stefan/Desktop/jobb/OPENMODELICA_1_4_5/OMNotebook/OMNotebookQT4/OMNoteboook_tempfiles/46.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Why is it better not to have the same name on the variable in the iteration expression as a variable inside the for-clause in an equation?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is not good from the programmers point of view. The variable inside the for-clause is hidden, which is all right, but they are by the programmer easily mixed together.</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Equations/Exercise3.onb b/DrModelica/Equations/Exercise3.onb new file mode 100644 index 00000000000..fb6e6af06bb --- /dev/null +++ b/DrModelica/Equations/Exercise3.onb @@ -0,0 +1,92 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 3</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a hybrid model?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A hybrid model is a model with mixed continuous and discrete parts.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What do hybrid models have to do with if- and when-equations?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Well, the thing is that one can use both constructs for hybrid models. The if-equations may contain continuous-time expressions and when-equations may only contain discrete-time expressions.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">But why is that?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The if-equations or if-expressions are used for conditional models with <span style=" font-style:italic;">different behavior</span> in <span style=" font-style:italic;">different operating regions</span>. Consider for example the code below (you're not able to run it). <br /><br />The if-equation in the ideal Diode Example below specifies different equations for the variable v in two different operating regions: the v = s in the region s = 0.<br /></p></body></html> + + + model Diode "Ideal diode" + extends Modelica.Electrical.Analog.Interfaces.TwoPin; + Real s; + Boolean off; +equation + off = s < 0; + if off then // conditional if-equation + v = s; + else + v = 0; + end if; + i = if off then 0 else s; // equation with conditional expression +end Diode; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />The when-equations, on the other hand, are used to express instantaneous equations that are only <span style=" font-style:italic;">valid</span> (become active) <span style=" font-style:italic;">at events</span>, e.g. at discontinuities or when certain conditions become true. Discrete-time expressions only become active at event instants.<br /><br />This model has only one kind of event, the sampling event. We use the built-in function <span style=" font-family:Courier New;">sample</span> in the <span style=" font-family:Courier New;">when</span>-condition <span style=" font-family:Courier New;">sample(0, T)</span> to periodically generate the sampling events with a period time <span style=" font-family:Courier New;">T</span>. (Read more about sampling events in chapter 13.)<br /></p></body></html> + + + model SimplePeriodicSampler + parameter Real T = 1 "Sample period"; + input Real u "Input used at sample events"; + discrete output Real y "Output computed at sample events"; +protected + discrete Real x; // discrete state variable +equation + when sample(0, T) then + x = f(pre(x), u); // state update expression + x = h(pre(x), u); // output expression + end when; +end SimplePeriodicSampler; + + + + + + + diff --git a/DrModelica/Equations/Exercise4.onb b/DrModelica/Equations/Exercise4.onb new file mode 100644 index 00000000000..e188024dcf8 --- /dev/null +++ b/DrModelica/Equations/Exercise4.onb @@ -0,0 +1,84 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Repetitive Equation Structures</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Nested for-loop</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a function, <span style=" font-family:Courier New;">MatrixAddition</span>, for adding two two-dimensional matrices.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /> Do a function call to <span style=" font-family:Courier New;">MatrixAddition</span> with two arrays. Then simulate the class with the function call and plot the result.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + function MatrixAddition + input Integer matrix1[:, :]; + input Integer matrix2[:, :]; + output Integer matrixSum[2, 2]; +algorithm + for i in 1:size(matrix1, 1) loop + for j in 1:size(matrix2, 2) loop + matrixSum[i, j] := matrix1[i, j] + matrix2[i, j]; + end for; + end for; +end MatrixAddition; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"> </p></body></html> + + + class MatrixAdditionCall + Real[2, 2] MA = MatrixAddition([1, 2; 3, 4], [1, 2; 3, 4]); +end MatrixAdditionCall; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;"> Simulation of MatrixAddition</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">We simulate the MatrixAdditionCall and then plot to see the result.</p></body></html> + + + simulate( MatrixAdditionCall ) //??Error in Integer matrix operations - not yet implemented + record + resultFile = "Simulation failed. +Too few equations, underdetermined system. The model has 4 variables and 1 equations +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + plot( { MA[1,1], MA[1,2], MA[2,1], MA[2,2] } ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/133.png" width="288" height="214" /></span></p></body></html> + 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 + + + + + + + diff --git a/DrModelica/Equations/IfEq.onb b/DrModelica/Equations/IfEq.onb new file mode 100644 index 00000000000..4683a8bdb6a --- /dev/null +++ b/DrModelica/Equations/IfEq.onb @@ -0,0 +1,127 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Conditional Equations with if-Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Modelica can be used for expressing hybrid models, i.e. models with mixed continuous and discrete parts. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-expressions are used for conditional models with different behavior in different operating regions. The conditional equations may contain continuous-time expressions. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">elseif</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-part is optional and can occur zero or more times. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-part is also optional and can occur at most once. There is a constraint regarding the number of equations in each part of an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation: </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">If-equations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for which the conditions have higher variability than </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">constant</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">parameter</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> must include an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-part. Each branch (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">then</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">elseif</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-parts) must have the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">same number of equations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /><br /><br />The model </span><a href="CompConn/CardEq.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">Cardinality Resistor</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> contains a conditional </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">equation with a </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">condition</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that is a parameter expression (the built-in function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">cardinality</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has parameter variability), i.e. the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">condition</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> does not change during simulation.<br /></span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">IfEquation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The if-equation below specifies different equations for the variable y in three different operating regions, limiting values of y such that: uMin &lt;= y &lt;= uMax.</span></p></td></tr></table></body></html> + + + class IfEquation + //Parameters need to be initialized before simulation. Otherwise, it gives + //compilation error. + parameter Real u = 4; + parameter Real uMax = 10; + parameter Real uMin = 2; + Real y; +equation + if u > uMax then + y = uMax; + elseif u < uMin then + y = uMin; + else + y = u; + end if; +end IfEquation; + {IfEquation} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of IfEquation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">IfEquation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown.</span></p></td></tr></table></body></html> + + + simulate( IfEquation ) + record SimulationResult + messages = "", + simulationTime = 0.13678047013543423 +end SimulationResult; + + + + + + + plot({u,y}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/MoonLandingTerminate.onb b/DrModelica/Equations/MoonLandingTerminate.onb new file mode 100644 index 00000000000..48b2ff8869a --- /dev/null +++ b/DrModelica/Equations/MoonLandingTerminate.onb @@ -0,0 +1,351 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Terminate</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The terminate equation successfully terminates the current simulation, i.e. no error condition is indicated. A string argument is used to indicate the reason for successful termination, which can be reported back to the user in some appropriate way by the simulation tool. Terminate is most commonly used to give a more appropriate stopping criteria for terminating a simulation than a fixed point in time.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Celestial Body</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This example illustrates a Rocket landing on the moon. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CelestialBody</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be used to store information about celestial bodies such as the earth and the moon. </span></p></td></tr></table></body></html> + + + class CelestialBody + constant Real g = 6.672e-11; + parameter Real radius; + parameter String name; + Real mass; +end CelestialBody; + Ok + + + + class CelestialBody + constant Real g = 6.672e-11; + parameter Real radius; + parameter String name; + Real mass; +end CelestialBody; + {CelestialBody} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Rocket</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rocket</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> embodies the equations of vertical motion for a rocket which is influenced by an external gravitational force field </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">gravity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and the force </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">thrust</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> from the rocket motor, acting in the opposite direction to the gravitational force.<br /></span></p></td></tr></table></body></html> + + + class Rocket + parameter String name; + Real mass(start = 1038.358,fixed=true); + Real altitude(start = 59404,fixed=true); + Real velocity(start = -2003,fixed=true); + Real acceleration; + Real thrust; // Thrust force on the rocket + Real gravity; // Gravity forcefield + parameter Real massLossRate = 0.000277; +equation + (thrust - mass*gravity)/mass = acceleration; + der(mass) = -massLossRate * abs(thrust); + der(altitude) = velocity; + der(velocity) = acceleration; +end Rocket; + {Rocket} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MoonLanding</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We can use </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">terminate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to stop the simulation when the lander touches the surface in order to avoid the lander descending into the interior of the moon. This is the case for the version of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MoonLanding</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class below.<br /></span></p></td></tr></table></body></html> + + + class MoonLanding + parameter Real force1 = 36350; + parameter Real force2 = 1308; + parameter Real thrustEndTime = 210; + parameter Real thrustDecreaseTime = 43.2; + Rocket apollo(name = "Apollo13"); + CelestialBody moon(name = "moon", mass = 7.382e22, radius = 1.738e6); +equation + apollo.thrust = if (time < thrustDecreaseTime) then force1 + else if (time < thrustEndTime) then force2 + else 0; + apollo.gravity = moon.g*moon.mass/(apollo.altitude + moon.radius) ^2; + + when apollo.altitude < 0 then // Termination condition + terminate("The moon lander touches the ground of moon"); + end when; +end MoonLanding; + {MoonLanding} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of MoonLanding</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now we simulate the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MoonLanding</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> example during the time interval {0, 230}, since the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rocket</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> reaches the surface of the moon at time 200, the simulation is terminated.</span></p></td></tr></table></body></html> + + + simulate( MoonLanding, stopTime=200 ) //??Error - not fully implemented + record + resultFile = "Simulation failed. +Too few equations, underdetermined system. The model has 6 variables and 4 equations +" +end record + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Then we plot the simulation. It is possible to plot all the different variables of Apollo</span></p></td></tr></table></body></html> + + + plot( apollo.altitude ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/9.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 1:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Altitude</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of the Apollo rocket over the lunar surface<br /></span></p></td></tr></table></body></html> + + + plot( apollo.thrust ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/10.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">                    Diagram 2:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Thrust</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> from the rocket motor, with an initial high thrust f1 followed by a lower thrust f2.<br /></span></p></td></tr></table></body></html> + + + plot( apollo.mass ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/11.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 3:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Rocket mass decreases when the fuel is consumed<br /></span></p></td></tr></table></body></html> + + + plot( apollo.gravity ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/12.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 4:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Gradually increasing </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">gravity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> when the rocket approaches the lunar surface<br /></span></p></td></tr></table></body></html> + + + plot( apollo.velocity ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/13.png" width="288" height="214" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 5:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Vertical </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">velocity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> relative to the lunar surface</span></p></td></tr></table></body></html> + + + + simulate(MoonLanding, stopTime=230) + record SimulationResult + resultFile = "MoonLanding_res.mat", + messages = "[<interactive>:15:5-15:60:writable] +stdout | info | Simulation call terminate() at time 212.101081 +| | | | Message : The moon lander touches the ground of moon +" +end SimulationResult; + + + + + + + plot( { apollo.velocity, apollo.altitude } ) + [done] + + + + diff --git a/DrModelica/Equations/Polynomial.onb b/DrModelica/Equations/Polynomial.onb new file mode 100644 index 00000000000..37929f0b723 --- /dev/null +++ b/DrModelica/Equations/Polynomial.onb @@ -0,0 +1,305 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Repetitive Equation Structures</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Xpowers1</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The polynomial equation where n = 4 can be expressed as a set of equations:</span></p></td></tr></table></body></html> + + + class Xpowers1 + parameter Real x=10; + Real a = 1; + parameter Integer n = 5; + Real xpowers[n]; + Real y; +equation + xpowers[1] = 1; + xpowers[2] = xpowers[1]*x; + xpowers[3] = xpowers[2]*x; + xpowers[4] = xpowers[3]*x; + xpowers[4 + 1] = xpowers[4]*x; + y = a * xpowers[5]; +end Xpowers1; + {Xpowers1} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Xpowers1</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">XPowers1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown. The variables can then be plotted as below.</span></p></td></tr></table></body></html> + + + simulate( Xpowers1 ) + record SimulationResult + messages = "", + simulationTime = 0.15718634387704636 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + + + plot( { xpowers[1], xpowers[2], xpowers[3], xpowers[4], xpowers[5] } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Xpowers2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The same thing can be expressed more compactly as a simple equation together with a for-clause equation:</span></p></td></tr></table></body></html> + + + class Xpowers2 + parameter Real x=10; + Real xpowers[n]; + parameter Integer i=1; + parameter Integer n = 5; +equation + xpowers[1]=1; + for i in 1:n-1 loop + xpowers[i + 1] = xpowers[i]*x; + end for; +end Xpowers2; + {Xpowers2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Xpowers2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">XPowers2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown. The variables can then be plotted as below.</span></p></td></tr></table></body></html> + + + simulate( Xpowers2 ) + record SimulationResult + messages = "", + simulationTime = 0.22743939078976844 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + + + plot( { xpowers[1], xpowers[2], xpowers[3], xpowers[4], xpowers[5] } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Xpowers3</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A very compact notation:</span></p></td></tr></table></body></html> + + + class Xpowers3 + parameter Real x=10; + Real xpowers[n+1]; + parameter Integer n = 5; +equation + xpowers[1]=1; + xpowers[2:n+1] = xpowers[1:n]*x; +end Xpowers3; + {Xpowers3} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Xpowers3</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">XPowers3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown. The variables can then be plotted as below.</span></p></td></tr></table></body></html> + + + simulate( Xpowers3 ) + record SimulationResult + messages = "", + simulationTime = 0.1946288252993386 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + + + plot( { xpowers[1], xpowers[2], xpowers[3], xpowers[4], xpowers[5] } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/PolynomialEvaluator.onb b/DrModelica/Equations/PolynomialEvaluator.onb new file mode 100644 index 00000000000..4d3a651b852 --- /dev/null +++ b/DrModelica/Equations/PolynomialEvaluator.onb @@ -0,0 +1,183 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Polynomial Equations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">PolynomialEvaluator</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PolynomialEvaluator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a restricted class of block kind since both public variables have specified causality input or output.</span></p></td></tr></table></body></html> + + + block PolynomialEvaluator + parameter Real c[:]; + input Real x; + output Real y; +protected + parameter Integer n = size(c, 1) - 1; + Real xpowers[n + 1]; +equation + xpowers[1] = 1; + for i in 1:n loop + xpowers[i + 1] = xpowers[i]*x; + end for; + y = c[1] * xpowers[n + 1]; +end PolynomialEvaluator; + {PolynomialEvaluator} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />You can for example use this class to evaluate a simple polynomial in terms of the built-in variable time, by instantiating the class with the coefficient vector <br />c = {1, 2, 3, 4}.</span></p></td></tr></table></body></html> + + + class PolyEvaluate1 + Real p; + PolynomialEvaluator polyeval(c = {1, 2, 3, 4}); +equation + polyeval.x = time; + p = polyeval.y; // p gets the result +end PolyEvaluate1; + {PolyEvaluate1,PolynomialEvaluator} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />An alternative way is to bind the inputs and the outputs using modifier equations in the declaration of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">polyeval</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> instance of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PolynomialEvaluator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class PolyEvaluate2 + Real p; + PolynomialEvaluator polyeval(c = {1, 2, 3, 4}, x = time, y = p); +end PolyEvaluate2; + {PolyEvaluate2,PolyEvaluate1,PolynomialEvaluator} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of PolynomialEvaluator </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PolyEvaluate1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown. The variables can then be plotted as below.</span></p></td></tr></table></body></html> + + + simulate( PolyEvaluate1, stopTime=10 ) + record SimulationResult + resultFile = "PolyEvaluate1_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( p ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PolyEvaluate2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown.</span></p></td></tr></table></body></html> + + + simulate( PolyEvaluate2 ) + record SimulationResult + resultFile = "PolyEvaluate2_res.mat", + messages = "" +end SimulationResult; + + + + + + plot( p ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/RepConnStruct.onb b/DrModelica/Equations/RepConnStruct.onb new file mode 100644 index 00000000000..69e1ad4888c --- /dev/null +++ b/DrModelica/Equations/RepConnStruct.onb @@ -0,0 +1,150 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Connection Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In Modelica we use </span><a href="CompConn/Connections.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">connect equations</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to establish connections between components via connectors. The two arguments of a connect equation must be references to connectors, each of which either has to be declared directly within the same class where the connect equation occurs, or has to be a member of one of the declared variables in that class. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> fulfills the locality constraint mentioned above.<br /></span></p></td></tr></table></body></html> + + + model ResistorCircuit + Modelica.Electrical.Analog.Basic.Resistor R1(R = 100); + Modelica.Electrical.Analog.Basic.Resistor R2(R = 200); + Modelica.Electrical.Analog.Basic.Resistor R3(R = 300); +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end ResistorCircuit; + {ResistorCircuit} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Repetitive Connection Structures</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">You can use </span><a href="CompConn/Connections.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">connect equations</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> together with the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation construct described previously to establish </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">repetitive connection structures</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> consisting of a number of connections between connectors belonging to array elements. This is a quite important use of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations in combination with connect equations.<br /></span></p></td></tr></table></body></html> + + + class RegComponent + parameter Integer n; + + //Modelica.Electrical.Analog.Basic.Resistor[n] r_components (each R=3) + //We can replace the next line with the previous line if we want to + //have the same resistance in all the resistors. Otherwise we can + //manually put it in a vector like the one below. + Modelica.Electrical.Analog.Basic.Resistor[n]r_components(R={1,2,3,4,5,6}); + Modelica.Electrical.Analog.Basic.Capacitor C(C = 1, v(fixed = true)); + Modelica.Electrical.Analog.Basic.Ground G; + Modelica.Electrical.Analog.Sources.SineVoltage src(V=10, freqHz = 50); +equation + for i in 1:n-1 loop + connect(r_components[i].n, r_components[i + 1].p); + end for; + connect(G.p,C.n); + connect(C.p,r_components[n].n); + connect(r_components[1].p,src.p); + connect(src.n,G.p); +end RegComponent; + {RegComponent} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model Test + RegComponent rc(n = 6); +end Test; + {Test} + + + loadModel(Modelica); + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Test</span></p></td></tr></table></body></html> + + + simulate( Test ) + record SimulationResult + resultFile = "Test_res.mat", + messages = "" +end SimulationResult; + + + + + + plot(rc.n) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/RepStruct.onb b/DrModelica/Equations/RepStruct.onb new file mode 100644 index 00000000000..75befdea69c --- /dev/null +++ b/DrModelica/Equations/RepStruct.onb @@ -0,0 +1,269 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Repetitive Equation Structures with for-equations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Gneral Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Repetitive equation structures can be expressed rather compactly with the special syntactic form of equation called a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation. Such a structured equation can be expanded to a sometimes large number of simple equations. The </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">iteration-variable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> ranges over the set of values in the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">iteration-set-expression</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which must be a </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">vector expression</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with parameter or constant variability. This expression is evaluated once in each </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation, and is evaluated in the scope immediately enclosing the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation. Such a scope can typically be the scope of an enclosing class definition or the scope of an enclosing </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation. </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">FiveEquations</span></p></td></tr></table></body></html> + + + class FiveEquations + Real[5] x; +equation + for i in 1:5 loop + x[i] = i + 1; + end for; +end FiveEquations; + {FiveEquations} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of FiveEquations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FiveEquations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown.</span></p></td></tr></table></body></html> + + + simulate( FiveEquations ) + record SimulationResult + messages = "", + simulationTime = 0.09181598307961183 +end SimulationResult; + + + + + + + plot({x[1],x[4]}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">FiveEquationsUnrolled</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FiveEquations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has the same behavior as the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FiveEquationsUnrolled</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> where the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation has been unrolled into five simple equations.</span></p></td></tr></table></body></html> + + + class FiveEquationsUnrolled + Real[5] x; +equation + x[1] = 2; + x[2] = 3; + x[3] = 4; + x[4] = 5; + x[5] = 6; +end FiveEquationsUnrolled; + {FiveEquationsUnrolled} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of FiveEquationsUnrolled</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FiveEquationsUnrolled</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown.</span></p></td></tr></table></body></html> + + + simulate( FiveEquationsUnrolled ) + record SimulationResult + messages = "", + simulationTime = 0.13107141560868413 +end SimulationResult; + + + + + + + plot({x[1], x[5]}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">HideVariable</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Since the scope of the iteration variable is the enclosing </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation, it may hide other variables with the same name, e.g. the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">constant</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">k</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> declared in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HideVariable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Note that the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">k</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used in the iteration expression </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">1:k+1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is the constant k declared in the class, whereas the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">k</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used in the equations inside the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-clause is the iteration variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">k</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. You should avoid this style of modeling, even if it is legal, since it is confusing and hard to read such code.<br /></span></p></td></tr></table></body></html> + + + class HideVariable + constant Integer k = 4; + Real x[k + 1]; +equation + for k in 1:k+1 loop // The iteration variable k gets values 1, 2, 3, 4, 5 + x[k] = k; // Uses of the iteration variable k + end for; +end HideVariable; + {HideVariable} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of HideVariable</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here we simulate </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HideVariable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + simulate( HideVariable ) + record SimulationResult + messages = "", + simulationTime = 0.11975412790085925 +end SimulationResult; + + + + + + + plot({x[1], x[3]}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/SimpleEquality.onb b/DrModelica/Equations/SimpleEquality.onb new file mode 100644 index 00000000000..2ac1d44d6cd --- /dev/null +++ b/DrModelica/Equations/SimpleEquality.onb @@ -0,0 +1,220 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Simple Equality Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Simple equality equations is the traditional kind of equation known from mathematics that expresses an equality relation between two expressions. There are two syntactic forms of such equations in Modelica. The first form is </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">equality</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equations between two expressions, whereas the second form is used when calling a function with </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">several</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> results. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Function f</span></p></td></tr></table></body></html> + + + function f + input Real a; + input Real b; + output Real c; + output Real d; + output Real e; +algorithm + c := a + b; + d := a - b; + e := a * b; +end f; + {f} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Example Call of f</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Try calling f:</span></p></td></tr></table></body></html> + + + f(2, 5) + (7.0,-3.0,10.0) + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">EqualityEquations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The first equation in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">EqualityEquations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> involving the function with two inputs and three results is correct, whereas the second equation is illegal since there are expressions in the left hand side.</span></p></td></tr></table></body></html> + + + class EqualityEquations + Real x; + Real y; + Real z; + Real u; + Real v = 2; +equation + u = v; // Equality equations between two expressions + (x, y, z) = f(1.0, 2.0); // Correct! + (x+1, 3.0, z/y) = f(1.0, 2.0); // Illegal! Not a list of variables on the left hand side +end EqualityEquations; + {EqualityEquations,f} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of EqualityEquations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Errors after simulation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">EqualityEquations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are shown below. Since it is illegal to write the code (x+1, 3.0, z/y), the simulation cannot be completed.</span></p></td></tr></table></body></html> + + + simulate( EqualityEquations ) // Should be illegal! + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: EqualityEquations +[<interactive>:10:3-10:33:writable] Error: Tuple assignment only allowed for tuple of component references in lhs (in (x + 1,3.0,z / y) = f(1.0, 2.0);). +Error: Error occurred while flattening model EqualityEquations +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;">$Failed</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">EqualityEquationsCorrect</span></p></td></tr></table></body></html> + + + class EqualityEquationsCorrect + Real x; + Real y; + Real z; + Real u; + Real v = 2; +equation + u = v; // Equality equations between two expressions + (x, y, z) = f(1.0, 2.0); // Correct! +end EqualityEquationsCorrect; + {EqualityEquationsCorrect,EqualityEquations,f} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of EqualityEquationsCorrect</span></p></td></tr></table></body></html> + + + simulate( EqualityEquationsCorrect ) + record SimulationResult + resultFile = "EqualityEquationsCorrect_res.mat", + messages = "" +end SimulationResult; + + + + + + + + plot({x, y, v}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/Step.onb b/DrModelica/Equations/Step.onb new file mode 100644 index 00000000000..e473af0cbac --- /dev/null +++ b/DrModelica/Equations/Step.onb @@ -0,0 +1,196 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Step</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Block Signal Connectors</span></p></td></tr></table></body></html> + + + connector InPort "Connector with input signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + input Real signal[n] "Real input signals"; +end InPort; // From Modelica.Blocks.Interfaces + {InPort} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector OutPort "Connector with output signals of type Real" + parameter Integer n = 1 "Dimension of signal vector"; + output Real signal[n] "Real output signals"; +end OutPort; // From Modelica.Blocks.Interfaces + {OutPort} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Time From Modelica.SIunits</span></p></td></tr></table></body></html> + + + type Time=Real(quantity="Time",unit="s"); + {Time} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Signal Block Components</span></p></td></tr></table></body></html> + + + partial block MO "Multiple Output continuous control block" + parameter Integer nout = 1 "Number of outputs"; + OutPort outPort(n = nout) "Connector of Real output signals"; +protected + Real n[nout] = outPort.signal; +end MO; // From Modelica.Blocks.Interfaces + {MO} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Step</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Step</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> includes a number of advanced features such as variable length arrays, conditional expressions in parameter declarations, and a repetitive equation structure in the form of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">for</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation defining the vector </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">outPort.signal</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> inherited from the base class MO, a Multiple Output continuous control block.<br /></span></p></td></tr></table></body></html> + + + block Step "Generate step signals of type Real" + parameter Real height[:] = {1} "Heights of steps"; + parameter Real offset[:] = {0} "Offset of output signals"; + parameter Time startTime[:] = {0} "Output = offset for time < startTime"; + + extends MO(final nout = max([size(height, 1); + size(offset, 1); + size(startTime, 1)]) ); +protected + parameter Real p_height[nout] = + (if size(height, 1) == 1 then + ones(nout)*height[1] + else + height); + parameter Real p_offset[nout] = + (if size(offset, 1) == 1 then + ones(nout)*offset[1] + else + offset); + parameter Time p_startTime[nout] = + (if size(startTime, 1) == 1 then + ones(nout)*startTime[1] + else + startTime); + +equation + for i in 1:nout loop // A regular equation structure + outPort.signal[i] = p_offset[i] + + (if time < p_startTime[i] then 0 else p_height[i]); + end for; +end Step; // From Modelica.Blocks.Sources + + {Step} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Step </span></p></td></tr></table></body></html> + + + simulate( Step ) + record SimulationResult + messages = "", + simulationTime = 0.12733552647256907 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + + plot( { outPort.n, outPort.signal[1], offset[1], nout } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Equations/WhenEq.onb b/DrModelica/Equations/WhenEq.onb new file mode 100644 index 00000000000..96ec9df85e5 --- /dev/null +++ b/DrModelica/Equations/WhenEq.onb @@ -0,0 +1,676 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Conditional Equations with when-Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WhenEquation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">When</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations are used to express instantaneous equations that are only valid at events, e.g. at discontinuities or when certain conditions become true. The conditional equations automatically contain only discrete-time expressions since they become active only at event instants. The two equations in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">whenEquation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below become active at the event instant when the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Boolean</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> expression </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">&gt;</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> becomes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model WhenEquation + Real x(start = 1); + discrete Real y1(fixed=true); + parameter Real y2 = 3; + discrete Real y3(fixed=true); +equation + x = time - y2; + when x > 2 then + y1 = sin(x); + y3 = 2*x + y1 + y2; + end when; +end WhenEquation; + {WhenEquation} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WhenEquation </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">WhenEquation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is simulated. Then as below the variables can be plotted.</span></p></td></tr></table></body></html> + + + simulate( WhenEquation, stopTime=10 ) + record SimulationResult + resultFile = "WhenEquation_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + + plot( { y1, y2, y3, x } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + plot( { y1, y3, x } ) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">WhenSet</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If we instead use a Boolean vector expression containing three elements as the conditions, then the two equations will be activated at event instants when either of the three conditions: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x &gt; 2, sample(0,2), </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">or</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> x becomes true. Sample is more explained </span><a href="DiscreteHybrid/SampleClock.onb +"><span style=" font-family:'Courier New'; font-size:12pt; text-decoration: underline; color:#0000ff;">here</span></a><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class WhenSet + Real x; + parameter Real y2 = 3; + discrete Real y1(fixed=true); + discrete Real y3(fixed=true); +equation + x = time - y2; + when {x > 2, sample(0, 2), x < 5} then + y1 = sin(x); + y3 = 2*x + y1 + y2; + end when; +end WhenSet; + {WhenSet} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of WhenSet </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">WhenSet</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is simulated.</span></p></td></tr></table></body></html> + + + simulate( WhenSet, stopTime=10 ) + record SimulationResult + resultFile = "WhenSet_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + plot( { y1, y3, x } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Activate</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Special behavior can be specified by </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations when a simulation starts and finishes by testing the built-in predicates </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">initial()</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">terminal()</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The predicate </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">initial()</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> returns true at the beginning of the simulation when time is equal to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">time.start</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the predicate </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">terminal()</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> returns true at the end of the simulation.<br /></span></p></td></tr></table></body></html> + + + class Activate + constant Real x = 4; + Real y, z(fixed=true); +equation + when initial() then + y = x + 3; // Equations to be activated at the beginning + end when; + + when terminal() then + z = x - 2; // Equations to be activated at the end of the simulation + end when; +end Activate; + + {Activate} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Activate </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Activate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is simulated.</span></p></td></tr></table></body></html> + + + simulate( Activate, stopTime=10 ) + record SimulationResult + resultFile = "Activate_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( {x, y, z } ) // X is not plotted here why?? + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Restrictions on Equations within when-Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">To make it possible both for a Modelica tool and a person to determine which variables are &quot;results&quot; from a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation, Modelica restricts the allowed equations within a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation to a form where the result variable is on the left-hand side.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">WhenNotValid</span></p></td></tr></table></body></html> + + + model WhenNotValid + Real x, y; +equation + x + y = 5; + when sample(0, 2) then + 2*x + y = 7; // Error: not valid Modelica code + end when; +end WhenNotValid; + {WhenNotValid} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of WhenNotValid</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">WhenNotValid</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is simulated. Since the code </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">2*x + y = 7; </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">is not valid Modelica code the error message</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> Illegal left hand equation in when equation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown in the failed simulation message below.<br /></span></p></td></tr></table></body></html> + + + simulate( WhenNotValid ) //Should fail! + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: WhenNotValid +[<interactive>:6:5-6:16:writable] Error: Invalid left-hand side of when-equation: 2.0 * x + y. +Error: Error occurred while flattening model WhenNotValid +" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">WhenValidResult</span></p></td></tr></table></body></html> + + + model WhenValidResult + Real x; + Real y(fixed=true); +equation + x + y = 5; // Equation to be used to compute x + when sample(0, 2) then + y = 7; // - 2*x; // Correct, y is a result variable from the when + end when; +end WhenValidResult; + {WhenValidResult} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of WhenValidResult</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">WhenValidResult</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is simulated. </span></p></td></tr></table></body></html> + + + simulate( WhenValidResult ) + record SimulationResult + resultFile = "WhenValidResult_res.mat", + messages = "" +end SimulationResult; + + + + + + + plot({x, y}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Nested When</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When-clauses are not allowed to be nested.</span></p></td></tr></table></body></html> + + + model ErrorNestedWhen + Real x, y1, y2; +equation + when x > 2 then + when x > 3 then // Error: when-clauses cannot be nested + y2 = sin(x); + end when; + end when; +end ErrorNestedWhen; + {ErrorNestedWhen} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of ErrorNestedWhen</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ErrorNestedWhen</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is simulated. Since it is not allowed to have nested when-clauses. there will be an error.</span></p></td></tr></table></body></html> + + + simulate( ErrorNestedWhen ) // Simulation should fail + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: ErrorNestedWhen +[<interactive>:4:3-8:11:writable] Error: Nested when statements are not allowed. +Error: Error occurred while flattening model ErrorNestedWhen +" +end SimulationResult; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Application of the Single-Assignment Rule on when-Clauses</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Two when-caluses may not define the same variable. Without this rule that may actually happen for the erroneous model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DoubleConflict</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below a conflict between the equations will occur if both conditions become true at the same time instant.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">DoubleWhenConflict</span></p></td></tr></table></body></html> + + + model DoubleWhenConflict + Real x; + Boolean close; // Erroneous model: close defined by two equations! +equation + + when x > 2 then + close = true; + end when; + + when x > 3 then + close = false; + end when; +end DoubleWhenConflict; + {DoubleWhenConflict} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of DoubleWhenConflict</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Since the variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">close</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> cannot be defined by two equations the model could not be translated.</span></p></td></tr></table></body></html> + + + simulate( DoubleWhenConflict ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: DoubleWhenConflict +[<interactive>:11:5-11:18:writable] Error: Model is structurally singular, error found sorting equations + 2: when x > 3.0 then + close := false +end when; +1: when x > 2.0 then + close := true +end when; + for variables + x(2), close(1) +Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed! +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">&quot;Simulate failed to translate model.&quot;</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Functions/Call.onb b/DrModelica/Functions/Call.onb new file mode 100644 index 00000000000..64d7268457c --- /dev/null +++ b/DrModelica/Functions/Call.onb @@ -0,0 +1,207 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Function Call</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Polynomial Evaluator</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">There are two basic forms a of function call in Modelica: </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">positional</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">named</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> association to formal parameters. We will as an example use the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PolynomiaEvaluator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which computes the value of a polynomial given two arguments: a coefficient vector A and a value of x.<br /></span></p></td></tr></table></body></html> + + + function PolynomialEvaluator + input Real A[:]; // Array, size defined at function call time + input Real x := 1.0; // Default value 1.0 for x + output Real sum; +protected + Real xpower; +algorithm + sum := 0; + xpower := 1; + for i in 1:size(A, 1) loop + sum := sum + A[i]*xpower; + xpower := xpower*x; + end for; +end PolynomialEvaluator; + {PolynomialEvaluator} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Positional Call </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Function calls with </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">positional association</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of actual arguments to formal parameters is the most common form of function call. The actual arguments are associated with the formal parameters according to their position in the argument list. <br /><br />Using positional association {1, 2, 3, 4} becomes the value of the coefficient vector </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and 21 becomes the value of the formal parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class PositionalCall + Real p; +equation + p = PolynomialEvaluator({1, 2, 3, 4}, 21); +end PositionalCall; + {PositionalCall,PolynomialEvaluator} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of PositionalCall </span></p></td></tr></table></body></html> + + + simulate( PositionalCall) + record SimulationResult + resultFile = "PositionalCall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + //p[0] is replaced by the following line. +val (p, 0) + 38410.0 + + + + + + plot(p) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Named Call </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The same call to the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PolynomialEvaluator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can instead be made using </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">named association</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of actual arguments to formal parameters. Here the actual argument is associated with the formal parameter through an equation in the argument list.</span></p></td></tr></table></body></html> + + + class NamedCall + Real p; +equation + p = PolynomialEvaluator(A = {1, 2, 3, 4}, x = 21); +end NamedCall; + {NamedCall,PositionalCall,PolynomialEvaluator} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of NamedCall </span></p></td></tr></table></body></html> + + + simulate( NamedCall ) + record SimulationResult + resultFile = "NamedCall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot(p) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Direct positionalcall:</span></p></td></tr></table></body></html> + + + PolynomialEvaluator({1, 2, 3, 4}, 21) + 38410.0 + + + + + diff --git a/DrModelica/Functions/Exercise1.onb b/DrModelica/Functions/Exercise1.onb new file mode 100644 index 00000000000..d8598ddc8a9 --- /dev/null +++ b/DrModelica/Functions/Exercise1.onb @@ -0,0 +1,161 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 1</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Write a function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">faculty</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, such that faculty(n) = 1*2*3*4*....*n.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Call </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">faculty</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> directly.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Write a class that contains a function call to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">faculty</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + 114 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">NFaculty</span></p></td></tr></table></body></html> + + + function NFaculty + input Integer n; + output Integer fak = 1; +algorithm + for i in 2:n loop + fak := i*fak; + end for; +end NFaculty; + Ok + + + NFaculty(3) + 114 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">NFacultyCall</span></p></td></tr></table></body></html> + + + class NFacultyCall + Real n = NFaculty(4); +end NFacultyCall; + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of NFacultyCall</span></p></td></tr></table></body></html> + + + simulate( NFacultyCall ); + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + //n[1] //Doesn't give any output. Erroneous. Replaced by the next line +val (n, 0) + + 24.0 + + + + + + + diff --git a/DrModelica/Functions/Exercise2.onb b/DrModelica/Functions/Exercise2.onb new file mode 100644 index 00000000000..78781332588 --- /dev/null +++ b/DrModelica/Functions/Exercise2.onb @@ -0,0 +1,150 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Functions</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">We want to search through an array of names and find the position of a particular name. The function should have two arguments, an array of names and the name we are looking for. The output will be the index where the name where found or an error will occur if the name was not found. </p></body></html> + + + + Error occured building AST +Syntax Error + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Write a class that tests the previous function.</p></body></html> + + + + Error occured building AST +Syntax Error + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Hint</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New;">Assert</span> can be used to check wether the result has been found or not and if it has not been found, the message in the second argument will be shown otherwise.</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">findName</p></body></html> + + + function findName + input String nameArray[:]; + input String name; + output Integer index; +protected + Integer i, length = size(nameArray, 1); +algorithm + index := -1; + i := 1; + while index == -1 and i<length loop + if nameArray[i] == name then + index := i; + end if; + i := i + 1; + end while; + assert(index<>-1, "findName: Failed"); +end findName; + Ok + + + findName({"C++", "Lisp", "Java", "Ada", "Modelica"},"Lisp") //??Error - not yet implemented + +OMC-ERROR: +"Internal error code generation of expression nameArray[i] == name failed +" + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">testFindName</p></body></html> + + + class testFindName + Integer findLisp; + String nameArray[:] = {"C++", "Lisp", "Java", "Ada", "Modelica"}; + String lisp = "Lisp"; +equation + findLisp = findName(nameArray, lisp); +end testFindName; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of testFindName</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">We see that the name "Lisp" exist in the array and is on position 2.</p></body></html> + + + simulate( testFindName ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Internal error code generation of expression nameArray[i] == name failed +Internal error Code generation of Modelica functions failed. +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;">Calling TestFindName:</p></body></html> + + + + +OMC-ERROR: +"Variable findLisp[0] not found in scope <global scope> +" + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">testFindName2</p></body></html> + + + class testFindName2 + Integer findPascal; + String nameArray[:] = {"C++", "Lisp", "Java", "Ada", "Modelica"}; + String pascal = "Pascal"; +equation + findPascal = findName(nameArray, pascal); +end testFindName2; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of testFindName2</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">When searching for a name that is not in the array, the simulation is aborted. We see in the dslog.txt that the assertion fails.</p></body></html> + + + simulate( testFindName2 ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Internal error code generation of expression nameArray[i] == name failed +Internal error Code generation of Modelica functions failed. +" +end record + + + + + + + diff --git a/DrModelica/Functions/Exercise3.onb b/DrModelica/Functions/Exercise3.onb new file mode 100644 index 00000000000..d1480aa8233 --- /dev/null +++ b/DrModelica/Functions/Exercise3.onb @@ -0,0 +1,108 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 3</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Checking Orthogonal Vectors</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a function, <span style=" font-family:Courier New;">scalarProduct</span>, that calculates the scalar product of two arbitrary vectors (u1, u2, u3, ..., un) and (v1, v2, v3, ... , vn). The result should be: u1*v1 + u2*v2 + ... + un*vn.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Two vectors (u1, u2, u3, ..., un) and (v1, v2, v3, ... , vn) are ortogonal if the scalar product: is equal to 0. <br />Write a class, <span style=" font-family:Courier New;">Orthogonal</span>, that decides if two integer vectors are orthogonal. The vectors must have the same number of elements, but the number of elements should be arbitrary. </p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Hint</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Applying the multiplication operator between two vectors gives the scalar product.</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">scalarProduct</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">First we check if the vectors are of the same size and if they are we calculate the scalar product.</p></body></html> + + + function scalarProduct + input Integer V1[:]; + input Integer V2[size(V1,1)]; + output Integer scalarProduct; +algorithm + scalarProduct := V1*V2; +end scalarProduct; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Call it:</p></body></html> + + + scalarProduct({1,2},{-3,1}) + -1 + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Orthogonal</p></body></html> + + + class Orthogonal + Integer V1[:] = {1, 2, 3}; + Integer V2[:] = {-3, 0, 1}; + Integer scalarProduct1; + Boolean orthogonal; +algorithm + scalarProduct1 := scalarProduct(V1, V2); + if scalarProduct1 == 0 then + orthogonal := true; + end if; +end Orthogonal; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Orthogonal</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Since the value in the variable orthogonal is 1 the two vectors are orthogonal. </p></body></html> + + + simulate(Orthogonal) //??Error - not yet implemented + record + resultFile = "Simulation failed. +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Check the value.</p></body></html> + + + val(orthogonal,0) + + + + + + + + diff --git a/DrModelica/Functions/Exercise4.onb b/DrModelica/Functions/Exercise4.onb new file mode 100644 index 00000000000..3bf4f696bf1 --- /dev/null +++ b/DrModelica/Functions/Exercise4.onb @@ -0,0 +1,62 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 4</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Functions with multiple results</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">??Error - exercise not yet completed</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Hint</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:12pt; font-weight:600; color:#000000;"></p></body></html> + + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:12pt; font-weight:600; color:#000000;"></p></body></html> + + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of</p></body></html> + + + simulate( ); + + + + + + + + diff --git a/DrModelica/Functions/Extending.onb b/DrModelica/Functions/Extending.onb new file mode 100644 index 00000000000..ef139a3fd75 --- /dev/null +++ b/DrModelica/Functions/Extending.onb @@ -0,0 +1,270 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Extending Base Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Since a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">function</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a restricted and enhanced kind of class, it is possible to inherit an existing function declaration into the declaration of a new function. In this way you can declare the common structure of a set of functions as a partial base function which you subsequently inherit into the functions you want to define.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Base Function</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">OneArgBaseFunction</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a partial base function with one argument and one result.</span></p></td></tr></table></body></html> + + + partial function OneArgBaseFunction + input Real x; + output Real result; +end OneArgBaseFunction; + {OneArgBaseFunction} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Extends Base Class</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The functions </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">myTan</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">addTen</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> inherits the base function. By doing so the code becomes harder to read since the formal parameter list is not available in the functions.</span></p></td></tr></table></body></html> + + + function myTan + extends OneArgBaseFunction; +algorithm + result := sin(x)/cos(x); +end myTan; + {myTan} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Call it</span></p></td></tr></table></body></html> + + + myTan(1.0) + 1.557407724654902 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + function addTen + extends OneArgBaseFunction; +algorithm + result := x + 10; +end addTen; + {addTen} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + addTen(5.0) + 15.0 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">myTan Call from a Class</span></p></td></tr></table></body></html> + + + class myTanCall + Real t; +equation + t = myTan(1.0); +end myTanCall; + {myTanCall} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Call it</span></p></td></tr></table></body></html> + + + + + simulate( myTanCall ) + record SimulationResult + resultFile = "myTanCall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot(t) + [done] + + + val(t,0) + 1.557407724654902 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">addTen Call from a Class</span></p></td></tr></table></body></html> + + + class addTenCall + Real sum; +equation + sum = addTen(5.0); +end addTenCall; + {addTenCall} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Call it:</span></p></td></tr></table></body></html> + + + + + simulate( addTenCall ) + record SimulationResult + resultFile = "addTenCall_res.mat", + messages = "" +end SimulationResult; + + + + + + plot(sum) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + val(sum,0) + 15.0 + + + + + diff --git a/DrModelica/Functions/External.onb b/DrModelica/Functions/External.onb new file mode 100644 index 00000000000..7ef2b7b4a29 --- /dev/null +++ b/DrModelica/Functions/External.onb @@ -0,0 +1,223 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">External Functions</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is possible to call functions defined outside the Modelica language. The body of an external function is marked with the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">external</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> possibly followed by any of he optional items </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">language_spec, external_function_call_spec or external_function_annotation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. If you just user the keyword external without any of the optional items a number of default rules apply, e.g. , if no external language is specified the implementation language for the function is assumed to be C.</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">(??Note- should also give examples of executable external calls)</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Default Call</span></p></td></tr></table></body></html> + + + clear() + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">log</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, the default mapping rules apply.</span></p></td></tr></table></body></html> + + + function log + input Real x; + output Real y; +external; +end log; + {log} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Specified Call</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The leastSquares function uses an external function. Here the language is specified to be Fortran 77.</span></p></td></tr></table></body></html> + + + function leastSquares "Solves a linear least squares problem" + input Real A[:,:]; + input Real B[:,:]; + + output Real Ares[size(A,1),size(A,2)] := A; + // Factorization is returned in Ares for later use + output Real x[size(A,2), size(B,2)]; + +protected + Integer lwork = min(size(A,1), size(A,2)) + + max(max(size(A,1), size(A,2)), size(B,2))*32; + Real work[lwork]; + Integer info; + String transposed = "NNNN"; // Workaround for passing character data to Fortran routine + external "FORTRAN 77" + dgels( transposed, 100, size(A,1), size(A,2), size(B,2), + Ares, size(A,1), B, size(B,1), work, lwork, info + ); +end leastSquares; + {leastSquares} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">A Large Example</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The external function interface supports a number of advanced features such as in-out parameters and declaration of temporary work variables, which are illustrated by the following rather complicated example.</span></p></td></tr></table></body></html> + + + function BilinearSampling +"Function for Discrete-time <--> continuous-time systems conversion by a bilinear transformation" + input Real alpha := 1, beta := 1; + input Real A[:, size(A, 1)], B[size(A, 1), :], C[:, size(A, 1)], + D[size(C, 1), size(B, 2)]; + input Boolean isContinuous := true; + output Real Ares[size(A, 1), size(A, 2)] := A, // Ares is in-out to the Fortran function + Bres[size(B, 1), size(B, 2)] := B, + Cres[size(C, 1), size(C, 2)] := C, + Dres[size(D, 1), size(D, 2)] := D; + output Integer info; +protected + Integer iwork[size(A, 1)]; // Work arrays + Real dwork[size(A, 1)]; + String c2dstring := if isContinuous then "C" else "D"; +external "FORTRAN 77" abo4md(c2dstring, size(A,1), size(B,2), size(C,1), + alpha, beta, Ares, size(Ares, 1), Bres, size(Bres, 1), Cres, + size(Cres, 1), Dres, size(Dres, 1), iwork, dwork, size(dwork, 1), info); +end BilinearSampling; + {BilinearSampling} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The following Modelica class contains an example call to BilinearSampling, which via the external function interface is transformed to a call to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ab04md</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class BilinearSamplingTest + parameter Real alpha = 1, beta = 1; + parameter Real A[:, :] = [0, 1; 2, 4], // Coefficients + B[:, :] = [5, 6; 7, 8], + C[:, :] = [9, 10; 11, 12], + D[:, :] = [13, 14; 15, 16]; + Real Ares [size(A, 1), size(A, 2)], + Bres [size(B, 1), size(B, 2)], + Cres [size(C, 1), size(C, 2)], + Dres [size(D, 1), size(D, 2)]; + Integer info; +equation + (Ares, Bres, Cres, Dres, info) = BilinearSampling(alpha, beta, A, B, C, D, true); +end BilinearSamplingTest; + {BilinearSamplingTest} + + + simulate(BilinearSamplingTest) + record SimulationResult + resultFile = "", + messages = "Failed to build model: BilinearSamplingTest" +end SimulationResult; +OMC-ERROR: +"Error: Error building simulator. Build log: clang -fPIC -I"/home/per/workspace/modelica/build/include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o BilinearSamplingTest.o BilinearSamplingTest.c +clang -fPIC -I"/home/per/workspace/modelica/build/include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o BilinearSamplingTest_functions.o BilinearSamplingTest_functions.c +clang -fPIC -I"/home/per/workspace/modelica/build/include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o BilinearSamplingTest_records.o BilinearSamplingTest_records.c +clang -fPIC -I"/home/per/workspace/modelica/build/include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o BilinearSamplingTest_01exo.o BilinearSamplingTest_01exo.c +clang -fPIC -I"/home/per/workspace/modelica/build/include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o BilinearSamplingTest_02nls.o BilinearSamplingTest_02nls.c +clang -fPIC -I"/home/per/workspace/modelica/build/include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o BilinearSamplingTest_03lsy.o BilinearSamplingTest_03lsy.c +clang -fPIC -I"/home/per/workspace/modelica/build/include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o BilinearSamplingTest_04set.o BilinearSamplingTest_04set.c +BilinearSamplingTest_functions.c:57:40: error: use of undeclared identifier '_Ares' + tmp6 = size_of_dimension_real_array(&_Ares, (modelica_integer) 1); + ^ +BilinearSamplingTest_functions.c:58:40: error: use of undeclared identifier '_Bres' + tmp7 = size_of_dimension_real_array(&_Bres, (modelica_integer) 1); + ^ +BilinearSamplingTest_functions.c:59:40: error: use of undeclared identifier '_Cres' + tmp8 = size_of_dimension_real_array(&_Cres, (modelica_integer) 1); + ^ +BilinearSamplingTest_functions.c:60:40: error: use of undeclared identifier '_Dres' + tmp9 = size_of_dimension_real_array(&_Dres, (modelica_integer) 1); + ^ +4 errors generated. +<builtin>: recipe for target 'BilinearSamplingTest_functions.o' failed +make: *** [BilinearSamplingTest_functions.o] Error 1 +make: *** Waiting for unfinished jobs.... + +" + + + + + diff --git a/DrModelica/Functions/MultipleRes.onb b/DrModelica/Functions/MultipleRes.onb new file mode 100644 index 00000000000..36f4a4125df --- /dev/null +++ b/DrModelica/Functions/MultipleRes.onb @@ -0,0 +1,365 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Functions with Multiple Results</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A function that has more than one output parameter has multiple results. </span></p></td></tr></table></body></html> + + + function multipleResultsFunction + input Real x; + input Real y; + output Real r1; + output Real r2; + output Real r3; +algorithm + r1 := x + y; + r2 := x * y; + r3 := x - y; +end multipleResultsFunction; + {multipleResultsFunction} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Call it directly:</span></p></td></tr></table></body></html> + + + multipleResultsFunction(2.0, 1.0) + (3.0,2.0,1.0) + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MRFcall + Real a, b, c; +equation + (a, b, c) = multipleResultsFunction(2.0, 1.0); +end MRFcall; + {MRFcall,multipleResultsFunction} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Call to MultipleResultsFunction</span></p></td></tr></table></body></html> + + + simulate( MRFcall, stopTime=10 ) + record SimulationResult + resultFile = "MRFcall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + + plot( {a,b,c} ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">PointOnCircle</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Another example of a multiple results function is the function p</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ointOnCircle</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which computes the cartesian coordinates of a point located at a certain angle on a circle with a certain radius. The cartesian coordinates are returned via the two result variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + function pointOnCircle "Computes cartesian coordinates of a point" + input Real angle "Angle in radians"; + input Real radius; + output Real x; // 1:st result formal parameter + output Real y; // 2:nd result formal parameter +algorithm + x := radius*cos(angle); + y := radius*sin(angle); +end pointOnCircle; + {pointOnCircle,MRFcall,multipleResultsFunction} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Call it:</span></p></td></tr></table></body></html> + + + pointOnCircle(1.2, 2) + (0.7247155089533472,1.8640781719344526) + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">load Modelica library</span></p></td></tr></table></body></html> + + + loadModel(Modelica) + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + function pointOnCircle2 "Computes cartesian coordinates of a point" + input Real angle "Angle in radians"; + input Real radius; + output Real x; // 1:st result formal parameter + output Real y; // 2:nd result formal parameter +algorithm + x := radius*cos(angle); + y := radius*Modelica.Math.sin(angle); +end pointOnCircle2; + {pointOnCircle2,ModelicaServices,Complex,Modelica,pointOnCircle,MRFcall,multipleResultsFunction} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Function Call on Equation Form</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When calling a multiple results functions there are two possibilities, equation form or statement form.</span></p></td></tr></table></body></html> + + + class PointOnCircleCall + Real px, py; +equation + (px, py) = pointOnCircle(1.2, 2); +end PointOnCircleCall; + {PointOnCircleCall,pointOnCircle2,ModelicaServices,Complex,Modelica,pointOnCircle,MRFcall,multipleResultsFunction} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of EquationCall </span></p></td></tr></table></body></html> + + + simulate( PointOnCircleCall ) + record SimulationResult + resultFile = "PointOnCircleCall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot( {px,py} ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Function Call on Statement Form </span></p></td></tr></table></body></html> + + + class StatementCall + Real px, py; +equation + (px, py) = pointOnCircle(1.2, 2); +end StatementCall; + {StatementCall,PointOnCircleCall,pointOnCircle2,ModelicaServices,Complex,Modelica,pointOnCircle,MRFcall,multipleResultsFunction} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of StatementCall </span></p></td></tr></table></body></html> + + + simulate( StatementCall ) + record SimulationResult + resultFile = "StatementCall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + {val(px,0), val(py,0)} + {0.7247155089533472,1.8640781719344526} + + + + + diff --git a/DrModelica/Generic/Exercise1.onb b/DrModelica/Generic/Exercise1.onb new file mode 100644 index 00000000000..c40af25bd01 --- /dev/null +++ b/DrModelica/Generic/Exercise1.onb @@ -0,0 +1,42 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a generic parameterized class?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">It is a way of expressing classes or programs as generic patterns. </p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Why is that useful</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Because instead of writing many similar pieces of code with essentially the same structure, you can directly express the general structure and providing the specific information as formal parameters.</p></body></html> + + + + + + diff --git a/DrModelica/Generic/Extended.onb b/DrModelica/Generic/Extended.onb new file mode 100644 index 00000000000..64c59f741d3 --- /dev/null +++ b/DrModelica/Generic/Extended.onb @@ -0,0 +1,304 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Designing a Class to be Extended</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />When designing a class to be extended two major design goals are to reuse data, i.e. variable declarations and to reuse behavior, i.e. equations.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Type and Connector Classes</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Components</span></p></td></tr></table></body></html> + + + partial model TwoPin + // Same as OnePort in Modelica.Electrical.Analog.Interfaces + "For Component with two electrical pins p and n and current i from p to n" + Voltage v "Voltage drop between the two pins (= p.v - n.v)"; + Current i "Current flowing from pin p to pin n"; + PositivePin p; + NegativePin n; +equation + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end TwoPin; + {TwoPin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Resistor</span></p></td></tr></table></body></html> + + + model Resistor "Electrical resistor" + Pin p,n; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance"; +equation + v = i*R; +end Resistor; + {Resistor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + model TempResistor "Temperature dependent electrical resistor" + Pin p,n; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance at reference Temp."; + parameter Real RT(unit = "Ohm/degC") = 0 "Temp. dependent Resistance."; + parameter Real Tref(unit = "degC") = 20 "Reference temperature"; + Real Temp = 20 "Actual temperature"; +equation + v = i*(R + RT*(Temp - Tref)); +end TempResistor; + {TempResistor} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Reuse of Variable Declarations from Partial Base Classes </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">One way of getting around the problems of inheriting and specializing behavior, exemplified with the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class, is to create incomplete, i.e. partial base classes that only contain the data declarations that can be reused.</span></p></td></tr></table></body></html> + + + partial model BaseResistor "Electrical resistor" + Pin p, n; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance"; +end BaseResistor; + {BaseResistor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The class is partial because it does not contain enough equations to completely specify its physical behavior. Using </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">BaseResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, to classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (equivalent to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">) can be defined to reuse all the common data in the base class.</span></p></td></tr></table></body></html> + + + model Resistor2 "Electrical resistor" + extends BaseResistor; +equation +v = R*i; +end Resistor2; + {Resistor2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + model TempResistor2 "Temperature dependent electrical resistor" + extends BaseResistor; + parameter Real RT(unit = "Ohm/degC") = 0 "Temp. dependent Resistance."; + parameter Real Tref(unit = "degC") = 20 "Reference temperature"; + Real Temp = 20 "Actual temperature"; +equation + v = i*(R + RT*(Temp - Tref)); +end TempResistor2; + {TempResistor2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The drawback of this approach is that we have given up on reuse and inheritance of behavior when part of the behavior needs to be redefined. In the next section we examine a way to get around the problem.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Extending and Redefining Behavior</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">There are two ways to indirectly associate a name with equations(s), a declaration equation named by its variable or a group of equations in a named replaceable local class.<br /><br />The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorEquation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class within the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below is an example of this technique. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has the same data fields and behavior as</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, but allows redeclaration of its equations since they are defined in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorEquation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model Resistor3 "Electrical Resistor" + Pin p, n; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance"; + + replaceable class ResistorEquation + equation + v = i*R; + end ResistorEquation; + + extends ResistorEquation; + +end Resistor3; + {Resistor3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The temperature dependent resistor class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can inherit </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, by declaring its temperature dependent equation in a redeclaration class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorEquation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that replaces the original local class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorEquation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model TempResistor3 "Temperature dependent electrical resistor" + extends Resistor3( + redeclare class ResistorEquation + equation + v = i*(R + RT*(Temp - Tref)); + end ResistorEquation); + + parameter Real RT(unit = "Ohm/degC") = 0 "Temp. dependent Resistance."; + parameter Real Tref(unit = "degC") = 20 "Reference temperature"; + Real Temp = 20 "Actual temperature"; + +end TempResistor3; + {TempResistor3} + + + + + diff --git a/DrModelica/Generic/ParamInterfaces.onb b/DrModelica/Generic/ParamInterfaces.onb new file mode 100644 index 00000000000..2dcfbfd8129 --- /dev/null +++ b/DrModelica/Generic/ParamInterfaces.onb @@ -0,0 +1,455 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Parameterization and Extension of Interfaces</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">External interfaces to component classes are defined primarily through the use of connectors. Assume that we have a definition of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Tank</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model in a model library. The model has an external interface in terms of the connectors </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">inlet</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">outlet</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, as well as a formal class parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TankStream</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which is a connector class with its default class value being the Stream connector class. (See ModelicaBook page 137)<br /> </span></p></td></tr></table></body></html> + + + connector Stream //Connector class + Real pressure; + flow Real volumeFlowRate; +end Stream; + {Stream} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model Tank + parameter Real area = 1; + replaceable connector TankStream = Stream; // Class parameterization + TankStream inlet, outlet; // The connectors + Real level(start=2); +equation + inlet.volumeFlowRate = 1; + inlet.pressure = 1; + + // Mass balance + area * der(level) = inlet.volumeFlowRate + outlet.volumeFlowRate; + + outlet.pressure = inlet.pressure; + outlet.volumeFlowRate = 2; +end Tank; + {Tank} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of Tank </span></p></td></tr></table></body></html> + + + simulate( Tank ) + record SimulationResult + messages = "Simulation failed for model: Tank +Error: Too many equations, overdetermined system. The model has 7 equation(s) and 5 variable(s) +Error: Internal error Found Equation without time dependent variables outlet.volumeFlowRate = 2.0 + +Error: Internal error Optimisation Module removeSimpleEquations failed. +" +end SimulationResult; + + + plot(level ) + false + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">HeatTank</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We would like to extend the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Tank</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model to include temperature dependent effects, analogous to how we extended a resistor to a temperature dependent resistor.</span></p></td></tr></table></body></html> + + + model HeatTank + extends Tank(redeclare connector TankStream = HeatStream); + Real level(start=2); + Real temp; +equation + inlet.temp = 25; + + // Energy balance for temperature effects + area*level*der(temp) = + inlet.volumeFlowRate*inlet.temp + + outlet.volumeFlowRate*outlet.temp; + + outlet.temp = temp; +end HeatTank; + {HeatTank} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector HeatStream + extends Stream; + Real temp; +end HeatStream; + {HeatStream} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of HeatTank</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it:</span></p></td></tr></table></body></html> + + + instantiateModel(HeatTank) + "class HeatTank + parameter Real area = 1.0; + Real inlet.pressure; + Real inlet.volumeFlowRate; + Real inlet.temp; + Real outlet.pressure; + Real outlet.volumeFlowRate; + Real outlet.temp; + Real level(start = 2.0); + Real temp; +equation + inlet.temp = 25.0; + area * level * der(temp) = inlet.volumeFlowRate * inlet.temp + outlet.volumeFlowRate * outlet.temp; + outlet.temp = temp; + inlet.volumeFlowRate = 1.0; + inlet.pressure = 1.0; + area * der(level) = inlet.volumeFlowRate + outlet.volumeFlowRate; + outlet.pressure = inlet.pressure; + outlet.volumeFlowRate = 2.0; + inlet.volumeFlowRate = 0.0; + outlet.volumeFlowRate = 0.0; +end HeatTank; +" +OMC-ERROR: +"[<interactive>:1:1-4:15:writable] Warning: Connector TankStream is not balanced: The number of potential variables (2) is not equal to the number of flow variables (1). +" + + + clear() + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it:</span></p></td></tr></table></body></html> + + + simulate(HeatTank) + record SimulationResult + messages = "Simulation failed for model: HeatTank +[<interactive>:1:1-4:15:writable] Warning: Connector TankStream is not balanced: The number of potential variables (2) is not equal to the number of flow variables (1). +Error: Too many equations, overdetermined system. The model has 10 equation(s) and 8 variable(s) +Error: Internal error Found Equation without time dependent variables outlet.volumeFlowRate = 2.0 + +Error: Internal error Optimisation Module removeSimpleEquations failed. +" +end SimulationResult; + + + plot({level,temp}) + false + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">HeatTankExpanded</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The definition of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HeatTank</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent to the definition of HeatTankExpanded</span></p></td></tr></table></body></html> + + + model HeatTankExpanded //Modelica Book version, Added start values etc. + parameter Real Area=1; // and some inlet and outlet equations + TankStream inlet, outlet; + Real level(start=2); + Real temp; + + connector TankStream + Real pressure; + flow Real volumeFlowRate; + Real temp; + end TankStream; + +equation + inlet.volumeFlowRate = 1; + inlet.pressure = 1; + inlet.temp = 25; + // Mass balance: + Area*der(level) = inlet.volumeFlowRate + outlet.volumeFlowRate; + outlet.pressure = inlet.pressure; + // Energy balance: + Area*level*der(temp) = inlet.volumeFlowRate * inlet.temp + + outlet.volumeFlowRate * outlet.temp; + + outlet.temp = temp; + outlet.volumeFlowRate = 2; +end HeatTankExpanded; + {HeatTankExpanded} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + instantiateModel(HeatTankExpanded) + "class HeatTankExpanded + parameter Real Area = 1.0; + Real inlet.pressure; + Real inlet.volumeFlowRate; + Real inlet.temp; + Real outlet.pressure; + Real outlet.volumeFlowRate; + Real outlet.temp; + Real level(start = 2.0); + Real temp; +equation + inlet.volumeFlowRate = 1.0; + inlet.pressure = 1.0; + inlet.temp = 25.0; + Area * der(level) = inlet.volumeFlowRate + outlet.volumeFlowRate; + outlet.pressure = inlet.pressure; + Area * level * der(temp) = inlet.volumeFlowRate * inlet.temp + outlet.volumeFlowRate * outlet.temp; + outlet.temp = temp; + outlet.volumeFlowRate = 2.0; + inlet.volumeFlowRate = 0.0; + outlet.volumeFlowRate = 0.0; +end HeatTankExpanded; +" +OMC-ERROR: +"[<interactive>:7:3-11:17:writable] Warning: Connector HeatTankExpanded.TankStream is not balanced: The number of potential variables (2) is not equal to the number of flow variables (1). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of HeadTankExpanded</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it:</span></p></td></tr></table></body></html> + + + simulate(HeatTankExpanded) + record SimulationResult + messages = "Simulation failed for model: HeatTankExpanded +[<interactive>:7:3-11:17:writable] Warning: Connector HeatTankExpanded.TankStream is not balanced: The number of potential variables (2) is not equal to the number of flow variables (1). +Error: Too many equations, overdetermined system. The model has 10 equation(s) and 8 variable(s) +Error: Internal error Found Equation without time dependent variables outlet.volumeFlowRate = 2.0 + +Error: Internal error Optimisation Module removeSimpleEquations failed. +" +end SimulationResult; + + + plot({level,temp}) + false + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Old Version of HeatTankExpanded with too few equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The definition of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HeatTank</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent to the definition of HeatTankExpanded</span></p></td></tr></table></body></html> + + + model HeatTankExpanded //??Old Modelica Book version, start values needed + parameter Real Area=1; // Incomplete version + TankStream inlet, outlet; + Real level; + Real temp; + + connector TankStream + Real pressure; + flow Real volumeFlowRate; + Real temp; + end TankStream; + +equation + // Mass balance: + Area*der(level) = inlet.volumeFlowRate + outlet.volumeFlowRate; + outlet.pressure = inlet.pressure; + // Energy balance: + Area*level*der(temp) = inlet.volumeFlowRate * inlet.temp + + outlet.volumeFlowRate * outlet.temp; + outlet.temp = temp; +end HeatTankExpanded; + {HeatTankExpanded} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it:</span></p></td></tr></table></body></html> + + + simulate(HeatTankExpanded) + record SimulationResult + messages = "Simulation failed for model: HeatTankExpanded +[<interactive>:7:3-11:17:writable] Warning: Connector HeatTankExpanded.TankStream is not balanced: The number of potential variables (2) is not equal to the number of flow variables (1). +Error: Too few equations, underdetermined system. The model has 6 equation(s) and 8 variable(s) +" +end SimulationResult; + + + + + diff --git a/DrModelica/Generic/Parameterized.onb b/DrModelica/Generic/Parameterized.onb new file mode 100644 index 00000000000..4d2f4ff557e --- /dev/null +++ b/DrModelica/Generic/Parameterized.onb @@ -0,0 +1,396 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Parameterized Generic Classes</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Class Parameters using Replaceable and Redeclare</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Modelica classes and packages can be parameterized in a general way, corresponding to generic classes or packages. Both classes and variables which are members of some class can be used as a kind of formal class parameter by attaching the prefix replaceable in front of their declarations. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">ResistorCircuit</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="156" height="132" /></p></td></tr></table></body></html> + Center + Model1 + AAAAAYlQTkcNChoKAAAADUlIRFIAAACcAAAAhAgGAAAAZT1CuwAAAARzQklUCAgICHwIZIgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAPHSURBVHic7d3hbqQgGEbhYbP3f8vuL9sJKwoCB9DzJE2TltEv+A5gq2PYtm37SJA/owvQuxg4oQycUAZOKAMnlIETysAJZeCEMnBCGTihDJxQBk4oAyeUgRPKwAll4IQycEIZOKH+tt5gCK23WOZpF8w/rT+bB+7zGXfQRx+cXp7Un06pQhk4oYqm1KMhdvY1U1zzTPW+sT+r13AhzNtJR7XNXO/nM3d9LfrTKVWoJmepM50dpmoJX7+Yqd5fv8PETPW1rqVJ4L6H1NGdlapl/0SLu1NWCOHT+lMxUn21Qn/eVRS4bRvfAaVmPml4Y38Wj3AzHbArK9S6Qo27FrV60iCUgROqy/9SV1uXzO5J/dk8cCutSVbwtP50ShXKwAll4IQycEIZOKEMnFAGTigDJ5SBE8rACWXghDJwQhk4oQycUAZOKAMnlIETqvCzRY6vda69XzPnns8W94X2uLe0xqr9+V136TZu3Cb4/w5qDyQRgtTBHW21/oxrK621y5QaQvj5yvld3C5uE3/P2Uf8faaRrdTI/ozb1vZjh49cTb8Dct4dqTY121k9bKP7s+UbtjhwR++yu8XkvK7ntmewQn+mXnMniFVruNQOzxbDVwvOnDZP8rb+rJpS46H5++dnr9mlOrjXcD67lfrz7na6/x3ubDF71V7/m6E/a0JbfdIQvyvPhvDaKWDfz2zTREuz9+fRGW5J/4ftSUerozdN7T35ry2hDJxQBk4oAyeUgRPKwAll4IQycEIZOKEMnFAGTigDJ5SBE8rACWXghOryrC21M/oC6NaXABq4BYy67rNH2J1ShTJwQhk4oVzDDZRaI816r06Leg2cisThKj2xMHAF+t6k/X2/aMfdFGpdi4HL1OOe1JwpanT4Wtdi4FQkDl3p+9DADTTryUFKi3r9s4hQBk4op9QFjD5xaMnATW61dd4Vp1ShDJxQBk4oAyeUgRPKwAll4IQycEIZOKEMnFAGTigDJ5SBE8rACWXghDJwQhk4obzid6CzZ9nXbvdqGzXPf615OLKBG+zogNU+DLjng4Tj2kprdUpdQAjh5yvnd3G7uM3RY8RT+4jb1obZEW5yZyNKzmiTalOynZaPXzdwgx2NWncPbs7r7mw7Ne3f2Z6BGyxnJDk7ubhawOe0uSM1Ol4xcBOJp7rvn5+9Zpc6+L2mxzs8aVjM2cnBVfvW+7/DEW4y8Sh3NiXWTqn7fkqm3dopOmwjx1e9jlOqUAZOKAMnlIETysAJZeCEMnBCGTihDJxQBk4oAyeUgRPKwAll4IT6B3PuM37XpCZzAAAAAElFTkSuQmCC + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">ResistorCircuit, which is a class consisting of three Resistors connected at one node.</span></p></td></tr></table></body></html> + Left + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model ResistorCircuit // Circuit of three Resistors connected at one node + Resistor R1(R = 100); + Resistor R2(R = 200); + Resistor R3(R = 300); +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end ResistorCircuit; + {ResistorCircuit} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Class Parameters Being Components</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has been converted into a parameterized generic class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">GenericResistorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the example below. In </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">GenericResistorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class parameters are components (instances or objects).</span></p></td></tr></table></body></html> + + + model GenericResistorCircuit // The ResistorCircuit made generic + replaceable Resistor R1(R = 100); // Formal class parameter + replaceable Resistor R2(R = 200); // Formal class parameter + replaceable Resistor R3(R = 300); // Formal class parameter +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end GenericResistorCircuit; + + {GenericResistorCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A more specialized class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TemperatureDependentResistorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is created by changing the types of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">R1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">R2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TemperatureResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which is a subtype of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model TemperatureDependentResistorCircuit = + GenericResistorCircuit( + redeclare TempResistor R1, // Actual argument + redeclare TempResistor R2); // Actual argument + {TemperatureDependentResistorCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Now we add a temperature variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Temp.</span></p></td></tr></table></body></html> + + + model TemperatureDependentResistorCircuit + Real Temp; + extends GenericResistorCircuit( + redeclare TempResistor R1(RT = 0.1, Temp = Temp), + redeclare TempResistor R2); +end TemperatureDependentResistorCircuit; + {TemperatureDependentResistorCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TemperatureDependentResistorCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent to the class below. The prefix replaceable has been lost for </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">R2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">R3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, since we did not use </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">redeclare</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model TempDepResistorCircuitInherited + Real Temp; + replaceable Resistor R1(R = 100); + TempResistor R2(R = 200, RT = 0.1, Temp = Temp); + TempResistor R3(R = 300); +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end TempDepResistorCircuitInherited; + {TempDepResistorCircuitInherited} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Generalizing Constraining Types of Class Parameters</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Sometimes it can be useful to allow a more general constraining type of a class parameter, e.g. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoPin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> instead of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for the formal class parameters and components </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">comp1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">comp2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below. This allows replacement by another kind of electrical component than a resistor in the circuit.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connectors</span></p></td></tr></table></body></html> + + + type Voltage = Real(Unit = "V"); + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + type Current = Real(Unit = "A"); + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + partial class TwoPin + "Superclass of elements with two electrical pins" + Pin p, n; + Voltage v; + Current i; +equation + v = p.v - n.v; + p.i + n.i = 0; + i = p.i; +end TwoPin; + Ok + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">GeneralSimpleCircuit</span></p></td></tr></table></body></html> + + + model GeneralSimpleCircuit + replaceable Resistor comp1(R = 100) extends TwoPin; + replaceable Resistor comp2(R = 200) extends TwoPin; + TempResistor R3(R = 300); +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end GeneralSimpleCircuit; + {GeneralSimpleCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The generalized parameterization properties of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">GeneralSimpleCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are used below when replacing the circuit components </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">comp1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">comp2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with components of the types </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Capacitor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Inductor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that are subtypes of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoPin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model RefinedSimpleCircuit + extends GeneralSimpleCircuit( + redeclare Capacitor comp1(C = 0.003), + redeclare Inductor comp2(L = 0.0002)); +end RefinedSimpleCircuit; + {RefinedSimpleCircuit} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Class Parameters Being Types</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A formal class parameter, can also be a type, which is useful for changing the type of many objects. For example, by providing a type parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorModel</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the class below it is easy to change the resistor type of all objects of type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorModel</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, e.g. from the default type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to the temperature dependent type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model GenericResistorCircuit2 + replaceable model ResistorModel = Resistor; + replaceable Resistor R1(R = 100); + replaceable Resistor R2(R = 200); + replaceable Resistor R3(R = 300); +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end GenericResistorCircuit2; + {GenericResistorCircuit2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A more specialized temperature dependent circuit </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">RefinedSimpleCircuit2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be created where the resistor type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is supplied as an actual argument to the formal class parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ResistorModel</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">: <br /></span></p></td></tr></table></body></html> + + + model RefinedSimpleCircuit2 = + ResistorCircuit(redeclare model ResistorModel = TempResistor); + {RefinedSimpleCircuit2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">RefinedSimpleCircuit2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent to the &quot;expanded&quot; class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">RefinedSimpleCircuit2expanded</span></p></td></tr></table></body></html> + + + model RefinedSimpleCircuit2expanded + model ResistorModel = TempResistor; + replaceable Resistor R1(R = 100); + replaceable Resistor R2(R = 200); + replaceable Resistor R3(R = 300); +equation + connect(R1.p, R2.p); + connect(R1.p, R3.p); +end RefinedSimpleCircuit2expanded; + {RefinedSimpleCircuit2expanded} + + + + + diff --git a/DrModelica/InherMod/Exercise1.onb b/DrModelica/InherMod/Exercise1.onb new file mode 100644 index 00000000000..f95bc3b3e8d --- /dev/null +++ b/DrModelica/InherMod/Exercise1.onb @@ -0,0 +1,275 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 1</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What does a modifier do?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A modifier modifies one or more declaration(s) from an inherited class by changing some aspect(s) of the inherited declarations.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Easy Example of Using Modifications</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Modify <br />- the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">start</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> value to 3, <br />- the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">min</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> value to -22 and <br />- the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">fixed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> value to true <br />of the variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">test</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Test</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below.<br /></span></p></td></tr></table></body></html> + + + class Test + parameter Integer test; +end Test; + {Test} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Rewrite the class here.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + class Test + parameter Integer test(start = 3, min = -22, fixed = true); +end Test; + {Test} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modifiers for Array Values</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In this exercise you should modify different values of the following variables:<br />Set fixed to true in A1.<br />Set the start value to false in truthvalues.<br />Set unit to "kV" in the position: first row and second column of A2.<br />Set the start value on the first row in A3 to the values 3, 5 and 8. In the second row of the matrix the values should be set to 3, 10 and 22.<br />Set the matrix elements to "Pippi" in A4.<br /></span></p></td></tr></table></body></html> + + + class ModArray + Integer A1[5]; + Boolean truthvalues[2]; + Real A2[2,2]; + Integer A3[2,3]; + Real A4[2,2]; +end ModArray; + {ModArray} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Hint</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Remember that each attribute has the same dimensionality as the array itself.<br />Read more about predefined Types/Classes in "Introduction to Modelica ..." by Peter Fritzson.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + class ModArray + + Integer A1[5](fixed = true); + // Modifies the fixed value for the whole array + + Boolean truthvalues[2](start = {false, false}); + // Modifies the start value for the whole array + + + Real A2[2,2](unit[1,2] = "kV"); + // Modifies the start value for a certain place in the matrix + + Integer A3[2,3](start = {{1, 0, 5}, {0,0,0}} ); + // Modifies the start value for the first row in the matrix + + String A4[2,2](start = {{"Pippi", "Pippi"}, + {"Pippi", "Pippi"}} ); + +end ModArray; + {ModArray} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modification and Access Control</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Mod</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, below, contains five variables. Are you allowed to modify all of them? Why/Why not?</span></p></td></tr></table></body></html> + + + class Mod + parameter Real x; + parameter Real y; + parameter Real z; +protected + parameter Real w; + parameter Real s; +end Mod; + {Mod} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">You are allowed to modify the variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">z</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, but not the variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">w</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">s</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, since they are protected.</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/InherMod/Exercise2.onb b/DrModelica/InherMod/Exercise2.onb new file mode 100644 index 00000000000..6050cb18d52 --- /dev/null +++ b/DrModelica/InherMod/Exercise2.onb @@ -0,0 +1,111 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Inheritance through Modification</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Declare a <span style=" font-family:Courier New;">Real</span> variable temp with the unit "degC" in the class Temperature.</p></body></html> + + + class Temperature + +end Temperature; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Use short class definition and create a new class Temp20 that modifies the variable temp in Temperature to be equal to 20.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Do the same thing as in Temp20, but this time Temp20 should inherit from Temperature.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Hint</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The variable temp must be a parameter so it can be modified in the short class definition.</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Temperature + parameter Real temp(unit = "degC"); +end Temperature; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Temp20 = Temperature(temp = 20); + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + model Temp20b + extends Temperature(temp = 20); +end Temp20b; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Flattening of Temperature, Temp20 and Temp20b</p></body></html> + + + instantiateModel( Temperature ) + "fclass Temperature +parameter Real temp(unit = "degC"); +end Temperature; +" + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + instantiateModel( Temp20 ) + "fclass Temp20 +parameter Real temp(unit = "degC") = 20; +end Temp20; +" + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + instantiateModel( Temp20b ) + "fclass Temp20b +parameter Real temp(unit = "degC") = 20; +end Temp20b; +" + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/InherMod/Exercise3.onb b/DrModelica/InherMod/Exercise3.onb new file mode 100644 index 00000000000..afd94a7e4b1 --- /dev/null +++ b/DrModelica/InherMod/Exercise3.onb @@ -0,0 +1,90 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 3</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Applying Hierarchical Modification</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Today you are going on a lunch date! To help you, several classes are created below. <br /><br />The <span style=" font-style:italic;">first</span> class is <span style=" font-family:Courier New;">DayName</span>, contains the parameter <span style=" font-family:Courier New;">nameOfDay</span>, a certain day written as a <span style=" font-family:Courier New;">String</span>. <br />The <span style=" font-style:italic;">second</span> class, <span style=" font-family:Courier New;">LunchAppointment</span>, contains the variables <span style=" font-family:Courier New;">lunchTime</span> (what time you are going to lunch) and <span style=" font-family:Courier New;">lunchDate</span> (who you are going on the lunch date with). <br />And at last the class, <span style=" font-family:Courier New;">Date</span>, with parameters <span style=" font-family:Courier New;">dayName</span> (where you can set the variable in the class <span style=" font-family:Courier New;">DayName</span>, for fun it is now Funday) as well as d<span style=" font-family:Courier New;">ate</span>, <span style=" font-family:Courier New;">month</span> and <span style=" font-family:Courier New;">year</span>.<br /></p></body></html> + + + class DayName + parameter String nameOfDay; +end DayName; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class LunchAppointment + parameter Integer lunchTime; + parameter String lunchDate; +end LunchAppointment; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Date + DayName dayName(nameOfDay = "Funday"); + parameter Integer date; + parameter String month; + parameter Integer year; +end Date; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />What you are going to do now is create a class, <span style=" font-family:Courier New;">Today</span>, in which you can modify the values in the class <span style=" font-family:Courier New;">Date</span> as well as in the class <span style=" font-family:Courier New;">LunchAppointment</span>. First, write the class using <span style=" font-style:italic;">nested notation</span>.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Now write the class, <span style=" font-family:Courier New;">Tomorrow</span>, going with another date, using <span style=" font-style:italic;">dot notation</span>.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Today + Date date(dayName(nameOfDay = "Wednesday"), + date = 2, + month = "October", + year = 2002); + LunchAppointment lunchApp(lunchTime = 12, + lunchDate = "Frederick"); +end Today; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Tomorrow + Date date(dayName.nameOfDay = "Thursday", + date = 3, + month = "October", + year = 2002); + LunchAppointment lunchApp(lunchTime = 12, + lunchDate = "Steven"); +end Tomorrow; + Ok + + + + + + diff --git a/DrModelica/InherMod/Extend.onb b/DrModelica/InherMod/Extend.onb new file mode 100644 index 00000000000..e6d4f5c569b --- /dev/null +++ b/DrModelica/InherMod/Extend.onb @@ -0,0 +1,379 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Modifiers in Extends Clauses</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">LowPassFilter with Extends Clause</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Modifiers may also occur in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">extends</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> clauses, and are applied to inherited element declarations in a similar way as modifiers in short class definitions. We inherit the contents of the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> into the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter20C</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and give the same modifiers as in the short class definition of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter20</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> above. <br /></span></p></td></tr></table></body></html> + + + model LowPassFilter1 + constant Real ystart = 1; + parameter Real T = 1; + parameter Real u = 5; + Real y(start = ystart,fixed=true); +equation + T*der(y) + y = u; +end LowPassFilter1; + {LowPassFilter1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model LowPassFilter20C + extends LowPassFilter1(ystart = 0, T = 20); +end LowPassFilter20C; + {LowPassFilter20C} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of LowPassFilter </span></p></td></tr></table></body></html> + + + simulate(LowPassFilter20C, stopTime=20 ) + record SimulationResult + resultFile = "LowPassFilter20C_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( y) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Voltage</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Another example demonstrates that modifiers in extends clauses can be applied to elements that are local classes such as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Voltage</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> within the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowVoltage</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below.</span></p></td></tr></table></body></html> + + + class LowVoltage + + type Voltage = Real(unit = "V"); // Local class + + Voltage v1; + Voltage v2; +end LowVoltage; + {LowVoltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class HighVoltage + extends LowVoltage(Voltage(unit = "kV")); +end HighVoltage; + {HighVoltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Notice that the variables</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> vhigh.v1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">vhigh.v2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have the unit &quot;kV&quot;.</span></p></td></tr></table></body></html> + + + class HighVoltageInst + HighVoltage vhigh; +end HighVoltageInst; + {HighVoltageInst} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Nested Extends Clauses</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The possibilities to apply modifiers are not limited to declared elements that are variables or local classes. It is actually possible to modify elements that are extends clauses in superclasses, so-called nested extends clauses, even though such clauses dissappear in the expanded subclass.</span></p></td></tr></table></body></html> + + + class A + parameter Real a; + parameter Real b; +end A; + {A} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class B + extends A(b = 3); +end B; + {B} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">B</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be combined and expressed as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Bexpanded</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class Bexpanded + parameter Real a; + parameter Real b = 3; +end Bexpanded; + {Bexpanded} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below modifies the nested extends clause of class B, which can be considered to be nested one level down in the inheritance chain (where </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> inherits B which inherits A). The most recent, i.e. &quot;outermost&quot;, modifiers in the inheritance chain have priority over previous modifiers.</span></p></td></tr></table></body></html> + + + class C + extends B(a = 1, b = 2); +end C; + {C} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Expand the class C:</span></p></td></tr></table></body></html> + + + instantiateModel(C) + "class C + parameter Real a = 1.0; + parameter Real b = 2.0; +end C; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A, B</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are equivalent to the single class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Cexpanded</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class Cexpanded + parameter Real a = 1; + parameter Real b = 2; +end Cexpanded; + {Cexpanded} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">The Rule of the Most Recent Modification</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below illustrates the rule that the most recently applied modifications like </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">b = 1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> overrides modifications like </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A(b = 2)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of a nested extends clause, since </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">b = 1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is further down in the modification chain. The instance bcomp has </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">bcomp.b = 1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which overrides </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">b = 2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> from the nested modifier.<br /> </span></p></td></tr></table></body></html> + + + class C2 + B bcomp(b = 1, A(b = 2)); +end C2; + {C2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Look at the expanded class:</span></p></td></tr></table></body></html> + + + instantiateModel(C2) + "" +OMC-ERROR: +"[<interactive>:2:3-2:27:writable] Error: Variable bcomp: In modifier (A(b = 2), class or component b), class or component A not found in <B>. +Error: Error occurred while flattening model C2 +" + + + + + diff --git a/DrModelica/InherMod/Hierachical.onb b/DrModelica/InherMod/Hierachical.onb new file mode 100644 index 00000000000..bc24c06b25e --- /dev/null +++ b/DrModelica/InherMod/Hierachical.onb @@ -0,0 +1,255 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Hierarchical Modification</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Hierarchical modification means that elements one or more levels down in the instantiation hierarchy are modified. Such modifiers can use nested notation, using parenthesis, or dot notation. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">LowPassFilter</span></p></td></tr></table></body></html> + + + model LowPassFilter + parameter Real T = 1; + parameter Real k = 1; + Real u, y(start = 1,fixed=true); +equation + T*der(y) + y = k*u; +end LowPassFilter; + {LowPassFilter} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Two instances of the filter with different time constants </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">T</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are put together to form the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FiltersInSeries.</span></p></td></tr></table></body></html> + + + model FiltersInSeries + LowPassFilter F1(T=2), F2(T=3); // Two instances with different T's are created +equation + F1.u = sin(time); + F2.u = F1.y; +end FiltersInSeries; + {FiltersInSeries} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Finally, two different instances </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">F12</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">F34</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FiltersInSeries are created in the class ModifiedFiltersInSeries</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with modified time constants. Both instances have identical time constants, but the first uses nested notation and the second uses dot notation for hierarchical modification.</span></p></td></tr></table></body></html> + + + model ModifiedFiltersInSeries + FiltersInSeries F12(F1(T = 6), F2(T = 11, k = 2)); // Nested notation + FiltersInSeries F34(F1.T = 6, F2.T = 11, F2.k = 2); // Dot notation +end ModifiedFiltersInSeries; + {ModifiedFiltersInSeries} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of LowPassFilter </span></p></td></tr></table></body></html> + + + simulate( ModifiedFiltersInSeries, stopTime=10 ) + record SimulationResult + resultFile = "ModifiedFiltersInSeries_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( F12.F1.u ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( F12.F2.u ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( F34.F1.u ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( F34.F2.u ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">More Usage of Nested and Dot Notation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Another example of hierarchical modification is shown for the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, where the instance </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">nested</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> uses nested syntax and the instance </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">dot</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> uses dot notation.</span></p></td></tr></table></body></html> + + + class A + Real x; +end A; + {A} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Hierarchical + A nested(x (unit = "V", DisplayUnit = "mV") = 5.0); + A dot (x.unit = "V", x.DisplayUnit = "mV", x = 5.0); +end Hierarchical; + {Hierarchical} + + + + + diff --git a/DrModelica/InherMod/Modification.onb b/DrModelica/InherMod/Modification.onb new file mode 100644 index 00000000000..c942c962c69 --- /dev/null +++ b/DrModelica/InherMod/Modification.onb @@ -0,0 +1,333 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Inheritance through Modification</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class concept with inheritance is the key to reuse of modeling knowledge in Modelica. However, in contrast to many other object-oriented languages Modelica also provides inheritance through modification via so-called </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">modifiers</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This makes reuse even easier, and can be expressed very concisely. In fact, the three operations: inheritance, specialization through modifications, and object instantiation can be expressed within a single Modelica declaration.<br /><br />A modifier modifies one or more declaration(s) from an inherited class by changing some aspect(s) of the inherited declarations. The most common kind of modifiers just changes the default value (start value) in a declaration equation.<br /></span></p></td></tr></table></body></html> + + + class Rocket + Real altitude(start = 59404); +end Rocket; + {Rocket} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modifiers in Variable Declarations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Modifiers change the type of a declared variable by modifying specified member declarations of the unmodified type. For example, the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> type of the variable A2 has its default declaration equations for its members (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">unit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">fixed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">) replaced by those given by the modifiers </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">unit = &quot;Voltage&quot;</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> fixed = true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + class Mod + Real A1; // Scalar variable + Real A2(unit = "Voltage", fixed = true); // Scalar with modifiers +end Mod; + {Mod,Rocket} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modifiers for Array Variables</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Regarding modifiers for array variables, it is important to remember that each attribute has the same dimensionality as the array itself. <br /></span></p></td></tr></table></body></html> + + + class Arr + Real A3[2,2]; // Array variable + Real A4[2,2](start = {{1, 0}, {0, 1}}); // Modifies the start value for the whole array + Real A5[2,2](unit = {{"Voltage", "Voltage"}, + {"Voltage", "Voltage"}} ); +end Arr; + {Arr,Mod,Rocket} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Modification of Protected Elements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Protected elements may not be modified or redeclared in class modifications, despite the fact the protected elements are inherited. </span></p></td></tr></table></body></html> + + + class D + parameter Real a; // a is a public element +protected + parameter Real b; // b is a protected element +end D; + {D} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class D1 = D(a = 10); // OK, since a is public + {D1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class D2 = D(a = 10, b = 20); // Illegal, since b is protected! + {D2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of D1 and D2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Flatten the class to check if the modifier is applied</span></p></td></tr></table></body></html> + + + instantiateModel( D1 ) + "class D1 + parameter Real a = 10.0; + protected parameter Real b; +end D1; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Flattening D2 fails since there is an error in the model - it is not allowed to modify a protected element.</span></p></td></tr></table></body></html> + + + instantiateModel( D2 ) + "" +OMC-ERROR: +"Error: Attempt to modify protected element b +Error: Error occurred while flattening model D2 +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Single Modification Rule</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Two arguments of a modification are not allowed to denote the same attribute of a declared element, quite self-evident, but easy to forget in the context of array fields. </span></p></td></tr></table></body></html> + + + class C1 + parameter Real x[3]; +end C1; + {C1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class C2 = C1(x = {1, 1, 1}, x[2] = 2); // Error: x[2] designated twice + Error occured building AST +Syntax Error +[<interactive>:1:30-1:37:writable] Error: Subscripted modifier is illegal. + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flattening of C2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We see in the report for the flattening of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that som error occurred. It is illegal to modify </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x[2]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> twice.</span></p></td></tr></table></body></html> + + + instantiateModel( C2 ) + "Unknown model in instantiateModel: C2 +" +OMC-ERROR: +"Error: Class C2 not found in scope <TOP>. +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/InherMod/Short.onb b/DrModelica/InherMod/Short.onb new file mode 100644 index 00000000000..fd717b2e442 --- /dev/null +++ b/DrModelica/InherMod/Short.onb @@ -0,0 +1,275 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Modifiers in Short Class Definitions</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simple Short Class Definitions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A few simple examples of short class definitions with modifiers are shown below, all being modifications of the superclass </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">: </span></p></td></tr></table></body></html> + + + class Current = Real(unit = "mA"); + {Current} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Force3 = Real[3](unit = {"N", "N", "N"}); + {Force3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V", min = -220.0, max = 220.0); + {Voltage} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">LowPassFilter</span></p></td></tr></table></body></html> + + + model LowPassFilter1 + constant Real ystart = 1; + parameter Real T = 1; + parameter Real u = 5; + Real y(start = ystart,fixed=true); +equation + T*der(y) + y = u; +end LowPassFilter1; + {LowPassFilter1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter20</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a modification of the model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, with the changed values of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ystart</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">T</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model LowPassFilter20 = LowPassFilter1(ystart = 0, T = 20); + {LowPassFilter20} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The two models </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter20</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can be replaced by the single model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">LowPassFilter20</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">B.</span></p></td></tr></table></body></html> + + + model LowPassFilter20B + constant Real ystart = 0; + parameter Real T = 20; + parameter Real u = 5; + Real y(start = ystart,fixed=true); +equation + T*der(y) + y = u; +end LowPassFilter20B; + {LowPassFilter20B} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of LowPassFilter </span></p></td></tr></table></body></html> + + + simulate( LowPassFilter1, stopTime=15 ) + record SimulationResult + resultFile = "LowPassFilter1_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( y ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + + + simulate( LowPassFilter20, stopTime=20 ) + record SimulationResult + resultFile = "LowPassFilter20_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Take a look at some values of y at time=0.0001, time=10, time=20:</span></p></td></tr></table></body></html> + + + {val(y,0.0001), val(y,10.), val(y,20.)} + {0.000024975021211052755,1.9673500814938716,3.1606070249193494} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate the second filter:</span></p></td></tr></table></body></html> + + + simulate( LowPassFilter20B, stopTime=20 ) + record SimulationResult + resultFile = "LowPassFilter20B_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( y ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Inheritance/Exercise1.onb b/DrModelica/Inheritance/Exercise1.onb new file mode 100644 index 00000000000..f8af381c91b --- /dev/null +++ b/DrModelica/Inheritance/Exercise1.onb @@ -0,0 +1,203 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 1</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Inheritance</span></p></td></tr></table></body></html> + + + class Animal + Boolean isAlive = true; + Boolean talks = false; +end Animal; + {Animal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /><br />Define a class, Bird, that inherits from the class Animal. Give the variables values.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + class Bird + extends Animal; + Integer wings = 2; + Integer legs = 2; + Boolean canFly = true; +end Bird; + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Show the flattened model:</span></p></td></tr></table></body></html> + + + instantiateModel(Bird) + "fclass Bird +Boolean isAlive; +Boolean talks; +Integer wings; +Integer legs; +Boolean CanFly; +equation + isAlive = true; + talks = false; + wings = 2; + legs = 2; + CanFly = true; +end Bird; +" + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of Animal and Bird</span></p></td></tr></table></body></html> + + + simulate( Animal ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + val(talks,1.) //??val Error - should have printed false + 0.0 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + simulate( Bird ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + {val(legs,1.),val(wings,1.)} + {2.0,2.0} + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What value has the variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">talks</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Bird</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">false</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Inheritance/Exercise2.onb b/DrModelica/Inheritance/Exercise2.onb new file mode 100644 index 00000000000..6f879d4a1e6 --- /dev/null +++ b/DrModelica/Inheritance/Exercise2.onb @@ -0,0 +1,267 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 2</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Create Subclasses and Superclasses</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In this exercise you should create a partial class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Vehicle</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with the variable speed. You should also create four classes; </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Car</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Boat</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Train</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Bicycle</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which inherit from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Vehicle</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Remember the variables for each subclass, which you can see in the picture below:<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////home/stefan/Desktop/jobb/OPENMODELICA_1_4_5/OMNotebook/OMNotebookQT4/OMNoteboook_tempfiles/6.png" width="559" height="264" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The Vehicle class and different classes inheriting from Vehicle.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Vehicle class:</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Car class:</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Boat class:</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Train class:</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Bicycle class:</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Let's write an instance of Train!</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Vehicle</span></p></td></tr></table></body></html> + + + partial class Vehicle + Real speed; +end Vehicle; + {Vehicle} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Car, Boat, Train and Bicycle</span></p></td></tr></table></body></html> + + + class Car + extends Vehicle; + Real motorEffect; +end Car; + {Car} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + class Boat + extends Vehicle; + Real boatWeight; +end Boat; + {Boat} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + class Train + extends Vehicle; + Real nrOfCarriages; +end Train; + {Train} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + class Bicycle + extends Vehicle; + Real nrOfGears; +end Bicycle; + {Bicycle} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Instance of Train</span></p></td></tr></table></body></html> + + + class SuperTrain + Train superTrain(nrOfCarriages = 55); +end SuperTrain; + {SuperTrain} + + + + + + + diff --git a/DrModelica/Inheritance/Exercise3.onb b/DrModelica/Inheritance/Exercise3.onb new file mode 100644 index 00000000000..83012db08f0 --- /dev/null +++ b/DrModelica/Inheritance/Exercise3.onb @@ -0,0 +1,205 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 3</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Using Inheritance and Access Control</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Write a class, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Person</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, with the variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">name</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">weight</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ID</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, where </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ID</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> should be protected. The next class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Employed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> should inherit from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Person</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and have a protected variable, salary. The last class, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Programmer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, contains the variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">favProgLang</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (favorite programming language) and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">drinksJoltCola</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + class Person + String name; + Real weight; +protected + Integer ID; +end Person; + {Person} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + class Employed + extends Person; +protected + Real salary; +end Employed; + {Employed} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + class Programmer + extends Employed; + String favProgLang; + Boolean drinksJoltCola; +end Programmer; + Ok + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Which protected variable(s) does the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Employed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">salary</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ID</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">A Different Exercise</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Use the same class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Person</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, but use this changed class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Employed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below:</span></p></td></tr></table></body></html> + + + class Employed +protected + extends Person; +protected + Real salary; +end Employed; + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Now which protected variable(s) does the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Employed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">name</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">weight, salary</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ID</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Inheritance/Exercise4.onb b/DrModelica/Inheritance/Exercise4.onb new file mode 100644 index 00000000000..3f501d85225 --- /dev/null +++ b/DrModelica/Inheritance/Exercise4.onb @@ -0,0 +1,129 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 4</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Using Inheritance and Access Control</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a class, <span style=" font-family:Courier New;">Person</span>, with the variables <span style=" font-family:Courier New;">name</span>, <span style=" font-family:Courier New;">weight</span> and <span style=" font-family:Courier New;">ID</span>, where <span style=" font-family:Courier New;">ID</span> should be protected. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />The next class <span style=" font-family:Courier New;">Employed</span> should inherit from <span style=" font-family:Courier New;">Person</span> and have a protected variable, salary. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />The last class, Programmer, contains the variables favProgLang(favorite programming language) and drinksJoltCola.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Person + String name; + Real weight; +protected + Integer ID; +end Person; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Employed + extends Person; +protected + Real salary; +end Employed; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class Programmer + extends Employed; + String favProgLang; + Boolean drinksJoltCola; +end Programmer; + Ok + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Which protected variable(s) does the class <span style=" font-family:Courier New;">Employed</span> have?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New;">salary</span> and <span style=" font-family:Courier New;">ID</span></p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A Different Exercise</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Use the same class <span style=" font-family:Courier New;">Person</span>, but write a new class, <span style=" font-family:Courier New;">Employed</span>, so that the variable <span style=" font-family:Courier New;">salary</span> still is protected and as well as the <span style=" font-family:Courier New;">extends clause</span>.</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Employed +protected + extends Person; +protected + Real salary; +end Employed; + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Now which protected variable(s) does the class <span style=" font-family:Courier New;">Employed</span> have?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New;">name</span>, <span style=" font-family:Courier New;">weight, salary</span> and <span style=" font-family:Courier New;">ID</span></p></body></html> + + + + + + diff --git a/DrModelica/Inheritance/Inheritance.onb b/DrModelica/Inheritance/Inheritance.onb new file mode 100644 index 00000000000..2df5b0f7d3e --- /dev/null +++ b/DrModelica/Inheritance/Inheritance.onb @@ -0,0 +1,326 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Inheritance</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Sometimes there is a need to extend the behavior and properties of an existing class. The original class, known as the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">superclass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, is extended to create a more specialized version of that class, known as the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">subclass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Inheritance of a class is achieved by using the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">extends</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The behavior and properties of the original class (field declarations, equations etc.) is reused and inherited by the subclass. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ColorData</span></p></td></tr></table></body></html> + + + type MyReal = Real; + {MyReal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + record ColorData // Superclass of Color + parameter Real red = 4; + parameter MyReal blue = 3; + Real green; +end ColorData; + {ColorData,MyReal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Color // Subclass of ColorData + extends ColorData; // Inherits from ColorData +equation + red + blue + green = 1; +end Color; + {Color,ColorData,MyReal} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ErrorColor and CorrectColor</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This is an example of extending a simple Modelica class, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ColorData</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class ErrorColor + extends ColorData(red = 2); + Real blue; // Legal, since identical to the inherited field blue + Integer red; // Illegal, since same name but different type +equation + red + blue + green = 1; +end ErrorColor; + {ErrorColor,Color,ColorData,MyReal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class CorrectColor + extends ColorData(red = 2); + parameter MyReal blue = 3; // Legal, since identical to the inherited field blue +equation + red + blue + green = 1; +end CorrectColor; + {CorrectColor,ErrorColor,Color,ColorData,MyReal} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Color, CorrectColor and ErrorColor</span></p></td></tr></table></body></html> + + + instantiateModel(Color) + "class Color + parameter Real red = 4.0; + parameter Real blue = 3.0; + Real green; +equation + red + blue + green = 1.0; +end Color; +" + + + simulate( Color ) + record SimulationResult + resultFile = "Color_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + + plot({red, blue }) + [done] + + + instantiateModel(CorrectColor) + "class CorrectColor + parameter Real red = 2.0; + parameter Real blue = 3.0; + Real green; +equation + red + blue + green = 1.0; +end CorrectColor; +" + + + simulate( CorrectColor ) + record SimulationResult + resultFile = "CorrectColor_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ErrorColor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> gives error since we try to declare a new variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">red</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, of the type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Integer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, although it alredy exists with the type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + simulate( ErrorColor ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: ErrorColor +[<interactive>:4:3-4:14:writable] Notification: From here: +[<interactive>:2:3-2:25:writable] Error: Duplicate elements (due to inherited elements) not identical: + first element is: Integer red + second element is: parameter .Real red = 4 +Error: Error occurred while flattening model ErrorColor +" +end SimulationResult; + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Inheritance of Equations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Color2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If two identical equations are locally declared in a subclass, then one of the equations are discarded. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is identical to the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, since the equation defined in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is identical to the one inherited from class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and only one of these equations are kept.</span></p></td></tr></table></body></html> + + + class Color2 + extends Color; +equation + red + blue + green = 1; +end Color2; + {Color2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Color3</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Equations that are mathematically equivalent, but not syntactically equivalent are not discarded. Since this is the case in class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, both equations are kept. This leads to an overdetermined system of equation.</span></p></td></tr></table></body></html> + + + class Color3 + extends Color; +equation + red + blue + green = 1.0; +end Color3; + {Color3} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Color3</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When simulating the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> we get too many equations.</span></p></td></tr></table></body></html> + + + simulate( Color3 ) + record SimulationResult + messages = "", + simulationTime = 0.15080233626888428 +end SimulationResult; + + + + + + + plot({red, blue }) + [done] + + + + + diff --git a/DrModelica/Inheritance/MoonLandingInher.onb b/DrModelica/Inheritance/MoonLandingInher.onb new file mode 100644 index 00000000000..8fbb37455f1 --- /dev/null +++ b/DrModelica/Inheritance/MoonLandingInher.onb @@ -0,0 +1,312 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Moon Landing using Inheritance</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Body</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MoonLanding</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> example from Chapter 3 the declaration of certain fields like </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">mass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">name</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> were repeated in each of the classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CelestialBody</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rocket</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This can be avoided by collecting those field declarations into a generic body class called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Body</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and reusing these by inheriting </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Body</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> into </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CelestialBody</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Rocket</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. <br /><br />We have replaced the general keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> by the restricted class keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">model</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> which has the same semantics as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> apart from the fact that it cannot be used in connections. The reason is that it is more common practice to use the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">model</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for modeling purposes than to use the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. <br /></span></p></td></tr></table></body></html> + + + model Body "Generic body" + Real mass; + String name; +end Body; + {Body} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Celestial Body</span></p></td></tr></table></body></html> + + + model CelestialBody "Celestial body" + extends Body; + constant Real g = 6.672e-11; + parameter Real radius; +end CelestialBody; + {CelestialBody} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Rocket</span></p></td></tr></table></body></html> + + + class Rocket + extends Body; + Real altitude(start = 59404,fixed=true); + Real velocity(start = -2003,fixed=true); + Real acceleration; + Real thrust; // Thrust force on the rocket + Real gravity; // Gravity forcefield + parameter Real massLossRate = 0.000277; +equation + (thrust - mass*gravity) / mass = acceleration; + der(mass) = -massLossRate * abs(thrust); + der(altitude) = velocity; + der(velocity) = acceleration; +end Rocket; + {Rocket} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Moon Landing</span></p></td></tr></table></body></html> + + + model MoonLanding + parameter Real force1 = 36350; + parameter Real force2 = 1308; + parameter Real thrustEndTime = 210; + parameter Real thrustDecreaseTime = 43.2; + Rocket apollo(name = "Apollo13", mass(start=1038.358,fixed=true) ); + CelestialBody moon(name = "moon", mass = 7.382e22, radius = 1.738e6); +equation + apollo.thrust = if (time < thrustDecreaseTime) then force1 + else if (time < thrustEndTime) then force2 + else 0; + apollo.gravity = moon.g*moon.mass/(apollo.altitude + moon.radius)^2; +end MoonLanding; + {MoonLanding} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Moonlanding Simulation</span></p></td></tr></table></body></html> + + + simulate( MoonLanding, stopTime=230 ) + record SimulationResult + resultFile = "MoonLanding_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( apollo.altitude ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 1:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Altitude of the Apollo rocket over the lunar surface<br /></span></p></td></tr></table></body></html> + + + + + + plot( apollo.thrust) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 2:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Thrust from the rocket motor, with an initial high thrust f1 followed by a lower thrust f2.<br /></span></p></td></tr></table></body></html> + + + + + + plot( apollo.mass ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 3:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Rocket mass decreases when the fuel is consumed<br /></span></p></td></tr></table></body></html> + + + + + + plot( apollo.gravity) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 4:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Gradually increasing gravity when the rocket approaches the lunar surface<br /></span></p></td></tr></table></body></html> + + + + + + plot( apollo.velocity ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">                        </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 5:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Vertical velocity relative to the lunar surface</span></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Inheritance/Multiple.onb b/DrModelica/Inheritance/Multiple.onb new file mode 100644 index 00000000000..56be4f82c44 --- /dev/null +++ b/DrModelica/Inheritance/Multiple.onb @@ -0,0 +1,211 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Multiple Inheritance</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Multiple inheritance (several extends statements) is useful when a class wishes to include several orthogonal kinds of behavior and data, e.g. combining geometry and color. By writing several extends statements, multiple inheritance is achieved.</span></p></td></tr></table></body></html> + + + record ColorData + parameter Real red=4; + parameter Real blue=3; + Real green; +end ColorData; + {ColorData} + + + class Color + extends ColorData; +equation + red + blue + green=1; +end Color; + {Color,ColorData} + + + class Point + public Real x; + Real y, z; +end Point; + {Point,Color,ColorData} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class ColoredPoint + extends Point; + extends Color; +end ColoredPoint; + {ColoredPoint,Point,Color,ColorData} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Show the flattened class with inheritance expanded:</span></p></td></tr></table></body></html> + + + instantiateModel(ColoredPoint) + "class ColoredPoint + Real x; + Real y; + Real z; + parameter Real red = 4.0; + parameter Real blue = 3.0; + Real green; +equation + red + blue + green = 1.0; +end ColoredPoint; +" + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Diamond Inheritance</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A special kind of multiple inheritance is diamond inheritance, which is a problem that can arise when using multiple inheritance. </span></p></td></tr></table></body></html> + + + class Point2 + parameter Real x = 2; + parameter Real y = 3; +end Point2; + {Point2,ColoredPoint,Point,Color,ColorData} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class VerticalLine + extends Point2; + parameter Real vlength = 5; +end VerticalLine; + {VerticalLine,Point2,ColoredPoint,Point,Color,ColorData} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class HorizontalLine + extends Point2; + parameter Real hlength = 7; +end HorizontalLine; + {HorizontalLine,Rectangle,VerticalLine,Point2,ColoredPoint,Point,Color,ColorData} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The potential problem is that we have diamond inheritance since the coordinate position defined by the fields </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is inherited twice. In Modelica this is not a problem, since there is a rule stating that if several identical declarations or equations are inherited, only one of them is kept.</span></p></td></tr></table></body></html> + + + class Rectangle + extends VerticalLine; + extends HorizontalLine; + Point p1(x = x - vlength, y = y - hlength); + Point p2(x = x + vlength, y = y + hlength); +end Rectangle; + {Rectangle,VerticalLine,Point2,ColoredPoint,Point,Color,ColorData} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flattened Version of Rectangle with Diamond Inheritance</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The Point2 definitions x, y, etc. are only present once despite being inherited twice, via VerticalLine and HorizontalLine.</span></p></td></tr></table></body></html> + + + instantiateModel(Rectangle) + "class Rectangle + parameter Real x = 2.0; + parameter Real y = 3.0; + parameter Real vlength = 5.0; + parameter Real hlength = 7.0; + Real p1.x = x - vlength; + Real p1.y = y - hlength; + Real p1.z; + Real p2.x = x + vlength; + Real p2.y = y + hlength; + Real p2.z; +end Rectangle; +" + + + + + diff --git a/DrModelica/Inheritance/ProtectedElements.onb b/DrModelica/Inheritance/ProtectedElements.onb new file mode 100644 index 00000000000..951c06d8f5c --- /dev/null +++ b/DrModelica/Inheritance/ProtectedElements.onb @@ -0,0 +1,197 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Inheritance of Protected Elements</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />If the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">protected</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used in front of an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">extends</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> clause, all inherited elements from the superclass become protected elements of the subclass. If an extends clause is a public element, all elements of the superclass are inherited with their original protection.<br /></span></p></td></tr></table></body></html> + + + record ColorData +protected + Real red; + parameter Real blue; + parameter Real green; +end ColorData; + {ColorData} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Color + extends ColorData(blue = 3.5, green = 5); +equation + red + blue + green = 1; +end Color; + {Color} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Point +public + parameter Real x(fixed=true); +protected + parameter Real y(fixed=true); + parameter Real z(fixed=true); +end Point; + {Point} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The color fields </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">red,</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">green</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">blue</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that are inherited from Color become protected fields of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ColoredPoint2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, since the extends clause is preceded by the protected keyword. The inherited fields from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> keep their protection status since that extends clause is preceded by public.<br /><br />The prefixes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">protected</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">public</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are not inherited. A protected element cannot be accessed via dot notation - this is the essence of being protected. Additionally, protected elements may not be modified or redeclared in class modifications.<br /></span></p></td></tr></table></body></html> + + + class ColoredPoint +protected + extends Color; // red, blue and green from ColorData become +public // protected fields + extends Point; // y and z from Point stay protected +end ColoredPoint; + {ColoredPoint} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flattening and Simulation of ColoredPoint</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Flatten it:</span></p></td></tr></table></body></html> + + + instantiateModel(ColoredPoint) + "class ColoredPoint + protected Real red; + protected parameter Real blue = 3.5; + protected parameter Real green = 5.0; + parameter Real x(fixed = true); + protected parameter Real y(fixed = true); + protected parameter Real z(fixed = true); +equation + red + blue + green = 1.0; +end ColoredPoint; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it:</span></p></td></tr></table></body></html> + + + simulate(ColoredPoint) + record SimulationResult + resultFile = "ColoredPoint_res.mat", + messages = "" +end SimulationResult; + + + + + + + + + plot({red, blue, green, x}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Look at a variable:</span></p></td></tr></table></body></html> + + + val(red,1.) + -7.5 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/LawsOfNature/TransformerEMF.onb b/DrModelica/LawsOfNature/TransformerEMF.onb new file mode 100644 index 00000000000..5e20985475b --- /dev/null +++ b/DrModelica/LawsOfNature/TransformerEMF.onb @@ -0,0 +1,70 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Models of a Transformer and Electromagnetic Force</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Here the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Transformer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model from the Modelica library is shown.</span></p></td></tr></table></body></html> + + + model Transformer "Transformer with inductance" + extends Modelica.Electrical.Analog.Interfaces.TwoPort; + parameter SIunits.Inductance L1=1 "Primary inductance"; + parameter SIunits.Inductance L2=1 "Secondary inductance"; + parameter SIunits.Inductance M=1 "Coupling inductance"; +equation + v1 = L1*der(i1) + M*der(i2); + v2 = M*der(i1) + L2*der(i2); +end Transformer; // from Modelica.Electrical.Analog.Basic.Transformer + {Transformer} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Another model that we show below is the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">EMF</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model EMF "Electromotoric force (electric/mechanic transformer)" + import Modelica.Electrical.Analog.Interfaces; + import Modelica.Mechanics.Rotational.Interfaces.Flange_b; + parameter Real k(final unit="N.m/A")=1 "Transformation coefficient"; + SIunits.Voltage v "Voltage drop between the two pins"; + SIunits.Current i "Current flowing from positive to negative pin"; + SIunits.AngularVelocity w "Angular velocity of flange_b"; + Interfaces.PositivePin p; + Interfaces.NegativePin n; + Flange_b flange_b; +equation + v = p.v-n.v; + 0 = p.i+n.i; + i = p.i; + w = der(flange_b.phi); + k*w = v; + flange_b.tau = -k*i; +end EMF; // from Modelica.Electrical.Analog.Basic.EMF + {EMF} + + + + diff --git a/DrModelica/LitOpExp/EvalOrder.onb b/DrModelica/LitOpExp/EvalOrder.onb new file mode 100644 index 00000000000..54c9e744af9 --- /dev/null +++ b/DrModelica/LitOpExp/EvalOrder.onb @@ -0,0 +1,334 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Order of evaluation</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">GuardTest</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Only constructs like </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-expressions can be used to guard expressions against evaluation since the bodies of these constructs are only evaluated if the corresponding condition is </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. <br /><br />The equation is correct since the use of an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-expression guarantees that the condition </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">(y&gt;=1 and y&lt;=n)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is always evaluated before </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">then</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-parts of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-expression.<br /></span></p></td></tr></table></body></html> + + + class GuardTest + Boolean v[n] = fill(false,n); + Boolean b; + Integer y = 4; + parameter Integer n = 5; +equation + b = if (y>=1 and y<= n) then v[y] else false; // Correct +end GuardTest; + {GuardTest} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of GuardTest</span></p></td></tr></table></body></html> + + + simulate( GuardTest ) + record SimulationResult + resultFile = "GuardTest_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">GuardTestInvalid</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Boolean operators such as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">and</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> cannot be used for evaluation protection. The equation in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">GuardTestInvalid</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below can generate an error such as index out of bounds (if y is not in the interval 1 to 5), see the simulation below. Even if the boolean expression (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y&gt;=1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">y&lt;=n)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> evaluates to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">false</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, the evaluation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v[y]</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not necessarily prevented.</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> <br /></span></p></td></tr></table></body></html> + + + class GuardTestInvalid + Boolean v[n] = fill(false,n); + Boolean b; + Integer y = 10; + parameter Integer n = 5; +equation + b = v[y] and (y>=1 and y<=n); // Invalid!! +end GuardTestInvalid; + {GuardTestInvalid} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of GuardTestInvalid</span></p></td></tr></table></body></html> + + + simulate( GuardTestInvalid ) + record SimulationResult + resultFile = "GuardTestInvalid_res.mat", + messages = "" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Guards with Continuous-Time Conditions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">One problem with the iterative zero-crossing search is that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-expressions in Modelica do not behave exactly as most people expect based on experience with conventional programming languages. During this iterative process small negative values of h can actually be supplied to the body of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-expression, e.g. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">-c*sqrt(h)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below, causing an attempt to compute the square root of a negative number, which is an error.<br /></span></p></td></tr></table></body></html> + + + class GuardContinuousVar + Real h(start = 1,fixed=true); + parameter Real c=1; +equation + der(h) = if h > 0 then -c*sqrt(h) else 0; // Incorrect!! +end GuardContinuousVar; + {GuardContinuousVar} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">NoEvent</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> operator is used to avoid events from being generated by the expression it is applied to. The operator should be used if the expression is continuous during a discrete switch.</span></p></td></tr></table></body></html> + + + class GuardContinuousVarCorrect + Real h(start = 1,fixed=true); + parameter Real c=1; +equation + der(h) = if noEvent(h > 0) then -c*sqrt(h) else 0; // Correct!! +end GuardContinuousVarCorrect; + {GuardContinuousVarCorrect} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of GuardContinuousVar</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The simulation shows that the value of h decreases and at t=2 is becomes a small negative number.</span></p></td></tr></table></body></html> + + + simulate( GuardContinuousVar, stopTime = 5, /* outputInterval=1, */ numberOfIntervals=5 ) + record SimulationResult + resultFile = "GuardContinuousVar_res.mat", + messages = "Error: Model error: Argument of sqrt(h) was -1.09244e-011 should be >= 0 +stdout | warning | Integrator attempt to handle a problem with a called assert. +" +end SimulationResult; + + + val(h,0.1) + 0.9250000000007054 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( h ) // plot( h, xrange={1,5} ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + {h[2], h[4]} + +OMC-ERROR: +"Error: Variable h[2] not found in scope <global scope>. +" + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of GuardContinuousVarCorrect</span></p></td></tr></table></body></html> + + + simulate( GuardContinuousVarCorrect, stopTime = 5, numberOfIntervals=5 ) + record SimulationResult + resultFile = "GuardContinuousVarCorrect_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + val(h,2.5) + -0.00000039510437141861433 + + + val(h,5.0) + -0.0000005748446903155132 + + + + + diff --git a/DrModelica/LitOpExp/Exercise1.onb b/DrModelica/LitOpExp/Exercise1.onb new file mode 100644 index 00000000000..bd8b417878f --- /dev/null +++ b/DrModelica/LitOpExp/Exercise1.onb @@ -0,0 +1,369 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 1 - Quiz</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What is a keyword?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A keyword is a reserved word that cannot be used as a name of some entity in a model.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What is so special about those?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Because they are reserved for constructing elements in the Modelica language, they cannot be used as identifiers, e.g., cannot be used as a variable name, class name, type name, etc..</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Name some keywords that you have come across.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">For example: end, class, and, connect, else and parameter. But there are over 40 of them, so you can find many more.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Certainly you have by now come across some of the predefined types of Modelica, if not all of them. Which are they?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Real, Integer, Boolean and String.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">What is a literal constant?</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">An unnamed constant that has different form depending on their type.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Give an example of a literal constant.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, one of the two Boolean literal values.</span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Describe what the variability of an expression means.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The freedom of the expression to change value during simulation. </span></p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Question</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Which are the degrees of expression variability? Describe the properties of the expressions having the different degrees.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The degrees of variability are </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">constant, parameter, discrete-time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">continuous-time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> variability.</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;"><br /><br />Constant expressions</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have constant variability, i.e. </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">never change value</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. In constant expressions the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">time derivative is equal to zero.<br />Parameter expressions</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> have parameter variability, </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">remain constant</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> during time-dependent simulation and have </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">time derivative equal to zero</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /><br /></span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Discrete-time expressions:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> <br />They have discrete-time variability meaning that they are piecewise constant and change their values only at event instants during simulation. <br />Time derivative is equal to zero. <br />These expressions may include constant or parameter expressions or discrete-time variables, as well as applications of operators and functions with discrete-time arguments.<br /><br /></span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">Continuous-time expressions:<br /></span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">They have continuous-time variability and may </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">change</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> their </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">values</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> at any time during simulation.<br />They may include constant, parameter and discrete-time expressions as well as continuous-time Real variables, as well as applications of operators and functions.</span></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/LitOpExp/Exercise2.onb b/DrModelica/LitOpExp/Exercise2.onb new file mode 100644 index 00000000000..dcdf20d3645 --- /dev/null +++ b/DrModelica/LitOpExp/Exercise2.onb @@ -0,0 +1,44 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Variability and Subtyping</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is wrong with this class?</p></body></html> + + + class Happy + Boolean right(fixed = true); + parameter Integer h = 15; + constant Integer m = h + 28; + parameter Real k = 32; +end Happy; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The constant m cannot be set to a non-constant value, in this case h + 28, with h having parameter variability meaning that it can be changed between simulations whereas m is always the same.</p></body></html> + + + class Happy + Boolean right(fixed = true); + parameter Integer h = 15; + constant Integer m = h + 28; + parameter Real k = 32; +end Happy; + + + + + + + diff --git a/DrModelica/LitOpExp/VarTime.onb b/DrModelica/LitOpExp/VarTime.onb new file mode 100644 index 00000000000..9f2f559a141 --- /dev/null +++ b/DrModelica/LitOpExp/VarTime.onb @@ -0,0 +1,105 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Built-in Variable Time</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The built-in variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> represents the current simulation time point, and is implictly defined as:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#aa0000;">input</span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real </span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#aa0000;">time</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">(</span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#aa0000;">final</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> quantity = </span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#808080;">&quot;Time&quot;</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#aa0000;">final</span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">unit = </span><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#808080;">&quot;s&quot;</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">);</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is only available in models and blocks, and not e.g. in functions. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> can for example be used to trigger an event at a specific point in time. In the following example we have a variable x with an initial value of 1.0. At the time point 0.5s the </span><a href="../Equations/WhenEq.onb"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">when-equation</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is triggered, and the equation x = 2.0 becomes active. Note that the event happens at the time point 0.5s, not after 0.5s of simulation (unless the simulation started at 0s).</span></p></td></tr></table></body></html> + + + model TimeEventTest + Real x(start = 1.0, fixed = true); +equation + when time >= 0.5 then + x = 2.0; + end when; +end TimeEventTest; + {TimeEventTest} + + + simulate(TimeEventTest, startTime = 0.2, stopTime = 0.6); + [done] + + + + + + + plot({x, time}) + [done] + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not available in functions since Modelica functions are mathematical functions, i.e. the same input should always give the same output. This means that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">time</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not allowed to</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> be accessed inside a function, but it can still be passed as a function argument:</span></p></td></tr></table></body></html> + + + function MySin + input Real x; + output Real y; +algorithm + y := sin(x*10); // sin(time) would be an error here. +end MySin; + +model SinTest + Real z = MySin(time); +end SinTest; + {MySin,SinTest} + + + simulate(SinTest, stopTime = 2); + [done] + + + + + + plot(z) + [done] + + + + + diff --git a/DrModelica/LitOpExp/VariaSubt.onb b/DrModelica/LitOpExp/VariaSubt.onb new file mode 100644 index 00000000000..ab07e820042 --- /dev/null +++ b/DrModelica/LitOpExp/VariaSubt.onb @@ -0,0 +1,211 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Variability and Subtyping</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The variability of an expression governs the degree of freedom with which the expression may vary during simulation. Variability is a specific property but has clear connections with the notion of data type. The example classes below illustrates the subtyping and variability rules for declaration equations and normal equations.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Constants</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This is not allowed, since p1 + 2 is not a constant expression</span></p></td></tr></table></body></html> + + + model Constants + parameter Real p1 = 1; + constant Real c1 = p1 + 2; // Not allowed - p1 has constant variability +end Constants; + {Constants} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Constants</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Below the error message is shown, after trying to simulate the Constants model. </span></p></td></tr></table></body></html> + + + simulate( Constants ) //?? Error - should have emitted variability error + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: Constants +[<interactive>:3:3-3:29:writable] Error: Component c1 of variability CONST has binding 2.0 + p1 of higher variability PARAM. +Error: Error occurred while flattening model Constants +" +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ConstantsCorrect</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This is correct, since p1 + 2 has the same variability as p1.</span></p></td></tr></table></body></html> + + + model ConstantsCorrect + parameter Real p1 = 1; + parameter Real p2 = p1 + 2; // Fine! - p1 + 2 has same variability +end ConstantsCorrect; + {ConstantsCorrect,Constants} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of ConstantsCorrect</span></p></td></tr></table></body></html> + + + simulate( ConstantsCorrect ) + record SimulationResult + resultFile = "ConstantsCorrect_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">TestEquations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The equation in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TestEquations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not correct, since b is a discrete time and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">noEvent(x &gt; 1)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a continuous time expression.</span></p></td></tr></table></body></html> + + + model TestEquations + Constants c1(p1 = 3); + Constants c2(p2 = 7); // Fine, declaration equation can be modified. + Boolean b; + Real x; +equation + b = noEvent(x > 1); +end TestEquations; + {TestEquations,ConstantsCorrect,Constants} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of TestEquations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Below the error message is shown, after trying to simulate the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TestEquations</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model. </span></p></td></tr></table></body></html> + + + simulate( TestEquations ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: TestEquations +[<interactive>:3:3-3:23:writable] Error: Variable c2: In modifier (p2 = 7), class or component p2 not found in <Constants>. +Error: Error occurred while flattening model TestEquations +" +end SimulationResult; + + + + + diff --git a/DrModelica/Packages/Exercise1ADT.onb b/DrModelica/Packages/Exercise1ADT.onb new file mode 100644 index 00000000000..ccfdffefaa6 --- /dev/null +++ b/DrModelica/Packages/Exercise1ADT.onb @@ -0,0 +1,303 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Exercise 1</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Question</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Packages are nice to use in Modelica, but what exactly is a package?</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">A package is simply a container or namespace for names of classes, functions, constants, and other allowed definitions. A package is also one or the restricted classes.</p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Question</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Why use the word encapsulated when creating packages?</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Adding the word encapsulated to the package keeps the package well structured as well as being easier to understand and maintain.</p></td></tr></table></body></html> + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Creating a Package</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Create a package that contains a constant <span style=" font-family:'Courier New';">PI</span>, a type <span style=" font-family:'Courier New';">Distance</span>, a function <span style=" font-family:'Courier New';">RectangleArea</span>, a function <span style=" font-family:'Courier New';">TriangleArea</span>, a function <span style=" font-family:'Courier New';">CirclePerimeter</span> and a function <span style=" font-family:'Courier New';">CircleArea</span>.<br /></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br /><br />Write a class, <span style=" font-family:'Courier New';">GeometryUser</span>, that uses the package and calls the functions.</p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">package Geometry</p></td></tr></table></body></html> + + + loadModel(Modelica); // Load the library if not loaded + [done] + + + package Geometry + constant Real PI = 3.1415926536; + + type Distance = Real(unit = "m"); + + function RectangleArea + input Distance B; + input Distance H; + output Distance area; + algorithm + area := B*H; + end RectangleArea; + + + function TriangleArea + input Distance B; + input Distance H; + output Distance area; + algorithm + area := RectangleArea(B, H)/2; + end TriangleArea; + + + function CirclePerimeter + input Distance radius; + output Distance perimeter; + algorithm + perimeter := 2*PI*radius; + end CirclePerimeter; + + + function CircleArea + input Distance radius; + output Distance area; + algorithm + area := PI*radius^2; + end CircleArea; + +end Geometry; + {Geometry} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">Simulation of Geometry</p></td></tr></table></body></html> + + + simulate( Geometry ) + record SimulationResult + resultFile = "Geometry_res.plt" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">GeometryUser</p></td></tr></table></body></html> + + + class GeometryUser + Geometry.Distance rectangleArea = Geometry.RectangleArea(4, 5); + Geometry.Distance triangleArea = Geometry.TriangleArea(4, 5); + Geometry.Distance circlePerimeter = Geometry.CirclePerimeter(3.5); + Geometry.Distance circleArea = Geometry.CircleArea(3.5); +end GeometryUser; + {GeometryUser} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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:12pt; font-weight:600; color:#000000;">Simulation of GeometryUser</p></td></tr></table></body></html> + + + simulate( GeometryUser ) + record SimulationResult + resultFile = "GeometryUser_res.plt" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + {val(rectangleArea,0), val(triangleArea,0), +val(circlePerimeter,0),val(circleArea,0)} + {20.0,10.0,21.9911485752,38.4845100066} + + + + + + + diff --git a/DrModelica/Packages/Exercise1LibrStruct.onb b/DrModelica/Packages/Exercise1LibrStruct.onb new file mode 100644 index 00000000000..864d28144c4 --- /dev/null +++ b/DrModelica/Packages/Exercise1LibrStruct.onb @@ -0,0 +1,61 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Exercise 1</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Question</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">What is important to consider before designing a package?</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">There are many factors to consider when designing a package, for example the <span style=" font-style:italic;">name</span> of the package or <span style=" font-style:italic;">structuring</span> the package <span style=" font-style:italic;">into subpackages</span>. Other factors that are important to consider are <span style=" font-style:italic;">reusability</span> and <span style=" font-style:italic;">encapsulation</span> of the package as well as considering <span style=" font-style:italic;">dependencies</span> on other packages. </p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/Packages/Exercise1VarOp.onb b/DrModelica/Packages/Exercise1VarOp.onb new file mode 100644 index 00000000000..99be41f2de5 --- /dev/null +++ b/DrModelica/Packages/Exercise1VarOp.onb @@ -0,0 +1,74 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">There are different kinds of packages. What is a generic package?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A generic package is a package with some kind of formal parameter, e.g. a replaceable type.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a local package?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A local package is simply a package that is declared directly inside a class that is not a package.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is there something called a nonencapsulated package? If so, explain it.</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Yes, there actually is. A nonencapsulated package is a package declared without the prefix <span style=" font-family:Courier New;">encapsulated</span>. Also large encapsulated packages, containing <span style=" font-family:Courier New;">protected</span> declarations, can be internally structured into nonencapsulated packages. <br /></p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Why might it be a problem to move packages?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">That is because used declarations may not be available in the new location for that certain subclass. When copying or moving an encapsulated package or class at most the <span style=" font-family:Courier New;">import</span> statements inside this package or class, including subpackages and local classes, need to be updated.</p></body></html> + + + + + + diff --git a/DrModelica/Packages/Exercise2VarOp.onb b/DrModelica/Packages/Exercise2VarOp.onb new file mode 100644 index 00000000000..646279d8b17 --- /dev/null +++ b/DrModelica/Packages/Exercise2VarOp.onb @@ -0,0 +1,127 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Is it really possible to inherit packages?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Yes, as a matter of fact it is!</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Inheriting packages</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Inherit the package <span style=" font-family:Courier New;">Geometry</span> into a class <span style=" font-family:Courier New;">GeometryUser</span>, which is calling functions from <span style=" font-family:Courier New;">Geometry</span>.<br /></p></body></html> + + + class GeometryUser + +end GeometryUser; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /></p></body></html> + + + package Geometry + constant Real PI = 3.1415926536; + + type Distance = Real(unit = "m"); + + function RectangleArea + input Distance B; + input Distance H; + output Distance area; + algorithm + area := B*H; + end RectangleArea; + + + function TriangleArea + input Distance B; + input Distance H; + output Distance area; + algorithm + area := RectangleArea(B, H)/2; + end TriangleArea; + + + function CirclePerimeter + input Distance radius; + output Distance perimeter; + algorithm + perimeter := 2*PI*radius; + end CirclePerimeter; + + + function CircleArea + input Distance radius; + output Distance area; + algorithm + area := PI*radius^2; + end CircleArea; + +end Geometry; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">GeometryUser</p></body></html> + + + class GeometryUser + extends Geometry; + Distance rectangleArea = RectangleArea(4, 5); + Distance triangleArea = TriangleArea(4, 5); + Distance circlePerimeter = CirclePerimeter(3.5); + Distance circleArea = CircleArea(3.5); +end GeometryUser; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of GeometryUser</p></body></html> + + + simulate( GeometryUser ) //??Error - extends should make RectangleArea available inside GemoetryUser + record + resultFile = "GeometryUser_res.plt" +end record +OMC-ERROR: +"Class Geometry.RectangleArea not found in scope global scope. +" + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + {val(rectangleArea,0), val(rectangleArea,0), + val(circlePerimeter,0), val(circleArea,0)} + + + + + + + + diff --git a/DrModelica/Packages/Generic.onb b/DrModelica/Packages/Generic.onb new file mode 100644 index 00000000000..47304a4c8a6 --- /dev/null +++ b/DrModelica/Packages/Generic.onb @@ -0,0 +1,121 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Generic Packages</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Generic packages are packages with some kind of formal parameter, e.g. a replaceable type. They are really a special case of <a href="../Generic/Parameterized.onb"><span style=" text-decoration: underline; color:#0000ff;">Parametrized Generic Classes</span></a>. Another way of regarding generic classes is as parameterized <a href="PackasADTs.onb +"><span style=" text-decoration: underline; color:#0000ff;">Abstract Data Types</span></a>, e.g. package <span style=" font-family:'Courier New';">GeneralStack</span> below, which is parameterized in terms of the type of the elements in the stack - the type parameter <span style=" font-family:'Courier New';">Element</span>. <br /></p></td></tr></table></body></html> + + + package GeneralStack + + replaceable class Element + end Element; + + record Stack + parameter Integer maxsize = 0; + Integer size = 0; + Element[maxsize] vec; + end Stack; + + function Push + input Stack si; + input Element e; + output Stack so; + algorithm + so := si; + so.size := so.size+1; + so.vec[so.size] := e; + end Push; + + function Pop + input Stack si; + output Stack so; + algorithm + so := si; + so.size := so.size-1; + end Pop; + + function Top + input Stack si; + output Element e; + algorithm + e := si.vec[si.size]; + end Top; + +end GeneralStack; + {GeneralStack} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />By "instantiating" the package <span style=" font-family:'Courier New';">GeneralStack</span> with different values of the type parameter <span style=" font-family:'Courier New';">Element</span> we can create specialized stack packages containing elements of a specified type. In this case instantiation means the creation of a more <span style=" font-style:italic;">specialized package</span>. For example, we have instantiated <span style=" font-family:'Courier New';">GeneralStack</span> below, with a type argument <span style=" font-family:'Courier New';">Integer</span> creating the specialized stack called <span style=" font-family:'Courier New';">IntegerStack</span>, and with <span style=" font-family:'Courier New';">Real</span> giving the stack <span style=" font-family:'Courier New';">RealStack</span>.<br /></p></td></tr></table></body></html> + + + package IntegerStack = GeneralStack(redeclare type Element = Integer); + {IntegerStack} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + package RealStack = GeneralStack(redeclare type Element = Real); + {RealStack} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Finally the stack <span style=" font-family:'Courier New';">IntegerStack</span> is used in the class <span style=" font-family:'Courier New';">IntStackUser</span> into which it is imported.</p></td></tr></table></body></html> + + + class IntStackUser + import IS = IntegerStack; + IS.Stack stk(maxsize = 200); + Integer item; +algorithm + stk := IS.Push(stk, 35); + stk := IS.Push(stk, 400); + stk := IS.Push(stk, 44); + item := IS.Top(stk); + stk := IS.Pop(stk); +end IntStackUser; + {IntStackUser} + + + + diff --git a/DrModelica/Packages/Inherited.onb b/DrModelica/Packages/Inherited.onb new file mode 100644 index 00000000000..045a605edf6 --- /dev/null +++ b/DrModelica/Packages/Inherited.onb @@ -0,0 +1,154 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Inherited Packages</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">General Stack Package</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Since packages are restricted and enhanced classes they can be inherited and specialized in the same way as classes in general. For example, we can create a package for a double-ended queue, also called dequeue (combines actions of a stack and a queue). For that we need to inherit all stack operations with the data structure declaration <span style=" font-family:'Courier New';">Element</span> from <span style=" font-family:'Courier New';">GeneralStack</span>.<span style=" font-family:'Courier New';"> </span>Then we add operations, as in the example <span style=" font-family:'Courier New';">DoubleEndedQueue</span> below.<br /></p></td></tr></table></body></html> + + + package GeneralStack + + replaceable class Element + end Element; + + record Stack + parameter Integer maxsize = 0; + Integer size = 0; + Element[maxsize] vec; + end Stack; + + function Push + input Stack si; + input Element e; + output Stack so; + algorithm + so := si; + so.size := so.size+1; + so.vec[so.size] := e; + end Push; + + function Pop + input Stack si; + output Stack so; + algorithm + so := si; + so.size := so.size-1; + end Pop; + + function Top + input Stack si; + output Element e; + algorithm + e := si.vec[si.size]; + end Top; + +end GeneralStack; + {GeneralStack} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">DoubleEndedQueue Package</p></td></tr></table></body></html> + + + encapsulated package DoubleEndedQueue + + extends GeneralStack; + + function AddBottom + input Stack si; + input Element e; + output Stack so; + algorithm + so.size := si.size+1; + for i in 1:si.size loop + so.vec[i+1] := si.vec[i]; + end for; + so.vec[1] := e; + end AddBottom; + + function RemoveBottom + input Stack si; + output Stack so; + algorithm + so.size := si.size-1; + for i in 1:so.size loop + so.vec[i] := si.vec[i+1]; + end for; + end RemoveBottom; + + function Bottom + input Stack si; + output Element e; + algorithm + e := si.vec[1]; + end Bottom; + +end DoubleEndedQueue; + {DoubleEndedQueue} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Below is an "instantiation" of the double-ended queue together with a small usage example. Two integers are inserted at the beginning of the queue and one at the end of the queue. Then the end element is accessed and the first element is removed.<br /></p></td></tr></table></body></html> + + + package IntDeQueue = DoubleEndedQueue(redeclare type Element = Integer); + +class DeQueueUser + import ID = IntDeQueue; + ID.Stack q(maxsize = 200); + Integer item; +algorithm + q := ID.Push(q, 65); // Insert two numbers at the beginning + q := ID.Push(q, 500); + q := ID.AddBottom(q, 455); // Insert at the end of the queue + item := ID.Bottom(q); // Get the end element, i.e. 455 + q := ID.Pop(q); // Remove the first element from the queue +end DeQueueUser; + {IntDeQueue,DeQueueUser} + + + + + diff --git a/DrModelica/Packages/Local.onb b/DrModelica/Packages/Local.onb new file mode 100644 index 00000000000..73698528139 --- /dev/null +++ b/DrModelica/Packages/Local.onb @@ -0,0 +1,71 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Local Packages</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />A local package is simply a package that is declared directly inside a <span style=" font-style:italic;">class</span> that is not a package. In the model <span style=" font-family:'Courier New';">MyCircuit</span> below we use a local specialized version of the package <span style=" font-family:'Courier New';">Electrical.Components</span> being replaced by the local type <span style=" font-family:'Courier New';">MyResistorModel</span>. Several classes from the local package <span style=" font-family:'Courier New';">MyComponents</span> are used for instantiating variables.<br /></p></td></tr></table></body></html> + + + model MyCircuit + + model MyResistorModel + extends Electrical.Interfaces.ResistorModel; + // declarations and equations + end MyResistorModel; + + encapsulated package MyComponents = + Electrical.Components(redeclare model ResistorModel = MyResistorModel); + + MyComponents.Transformer tr1; + MyComponents.Transducer td2; + +end MyCircuit; + {MyCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />The class <span style=" font-family:'Courier New';">DeQueueLocalUser</span> below uses the local package <span style=" font-family:'Courier New';">P</span> that is a version of the package <span style=" font-family:'Courier New';">DoubleEndedQueue</span> from the section <a href="Inherited.onb +"><span style=" text-decoration: underline; color:#0000ff;">Inherited Packages</span></a> parameterized by the local type <span style=" font-family:'Courier New';">VerySecret</span>.<br /></p></td></tr></table></body></html> + + + class DeQueueLocalUser + protected + type VerySecret = Integer; + package P = DoubleEndedQueue(redeclare type Element = VerySecret); + P.Stack q(maxsize = 200); + Integer item; +algorithm + q := P.Push(q, 65); // Insert two numbers at the beginning + q := P.Push(q, 500); + q := P.AddBottom(q, 455); // Insert at the end of the queue + item := P.Bottom(q); // Get the end element, i.e. 455 + q := P.Pop(q); // Remove the first element from the queue +end DeQueueLocalUser; + {DeQueueLocalUser} + + + + diff --git a/DrModelica/Packages/Moving.onb b/DrModelica/Packages/Moving.onb new file mode 100644 index 00000000000..a8d75b29a50 --- /dev/null +++ b/DrModelica/Packages/Moving.onb @@ -0,0 +1,62 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Moving Packages</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Copying or moving a <span style=" font-family:Courier New;">nonencapsulated</span> subpackage might be a bit problematic since used declarations may not be available in the new location for that subclass. When copying or moving an encapsulated package or class at most the <span style=" font-family:Courier New;">import</span> statements inside this package or class, including subpackages and local classes, need to be updated.<br /></p></body></html> + + + encapsulated package Modelica + + encapsulated package Blocks + encapsulated package Interfaces + connector InPort + end InPort; + end Interfaces; + end Blocks; + + encapsulated package Mechanics + encapsulated package Rotational + import Modelica.Blocks.Interfaces; // Import + + model Torque + Interfaces.InPort inPort; // Use + end Torque; + end Rotational; + end Mechanics; + +end Modelica; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />If you move the package <span style=" font-family:Courier New;">Rotational</span> inside <span style=" font-family:Courier New;">YourModelica</span> as below, it will continue to work without changes since its <span style=" font-family:Courier New;">import</span> statements still refers to <span style=" font-family:Courier New;">YourModelica.Blocks.Interfaces</span>. Maybe if you instead would like to refer the package <span style=" font-family:Courier New;">YourModelica.Blocks.Interfaces</span>, just update the <span style=" font-family:Courier New;">import</span> statement as we have done below.<br /></p></body></html> + + + encapsulated package YourModelica + + encapsulated package Blocks + encapsulated package Interfaces + connector InPort + end InPort; + end Interfaces; + end Blocks; + + encapsulated package Mechanics + encapsulated package Rotational + import YourModelica.Blocks.Interfaces; // Import + model Torque + Interfaces.InPort inPort; // Use + end Torque; + end Rotational; + end Mechanics; + +end YourModelica; + + + + + + diff --git a/DrModelica/Packages/Nonencapsulated.onb b/DrModelica/Packages/Nonencapsulated.onb new file mode 100644 index 00000000000..daf782bf6c2 --- /dev/null +++ b/DrModelica/Packages/Nonencapsulated.onb @@ -0,0 +1,36 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Nonencapsulated Packages</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />A nonencapsulated package is a package declared without the prefix <span style=" font-family:Courier New;">encapsulated</span>. Also large encapsulated packages, containing <span style=" font-family:Courier New;">protected</span> declarations, can be internally structured into nonencapsulated packages. <br /><br />In the example below, the encapsulated package <span style=" font-family:Courier New;">Blocks</span> has been internally structured into three nonencapsulated packages <span style=" font-family:Courier New;">Interfaces</span>, <span style=" font-family:Courier New;">Continuous</span>, and <span style=" font-family:Courier New;">Examples</span> that all can access the protected type <span style=" font-family:Courier New;">MySecret</span>.<br /></p></body></html> + + + encapsulated package Modelica + encapsulated package Blocks + + protected + type MySecret = Integer; + + public + package Interfaces + end Interfaces; + + package Continuous + MySecret x; + end Continuous; + + package Examples + end Examples; + + end Blocks; + +end Modelica; + Ok + + + + diff --git a/DrModelica/Packages/PackAccess.onb b/DrModelica/Packages/PackAccess.onb new file mode 100644 index 00000000000..39297d8012c --- /dev/null +++ b/DrModelica/Packages/PackAccess.onb @@ -0,0 +1,261 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Package Access</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">General Description</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">There are essentially two ways of accessing the definitions of a package either <span style=" font-style:italic;">direct reference</span> by prefixing the package name to the definition names or <span style=" font-style:italic;">importing definitions</span> from the package. We have already used the first method in the <a href="PackasADTs.onb#Complex Example +"><span style=" text-decoration: underline; color:#0000ff;">Complex Example</span></a>. It is usually more convenient and often necessary to use the <span style=" font-family:'Courier New';">import</span> mechanism, which is the subject for the next section.</p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Importing Definitions from a Package</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><span style=" font-family:'Courier New';">Import</span> statements in a package or class fill the two needs of either making definitions from other packages available for use in a package or class or explicit declaration of usage dependences on other packages. An <span style=" font-family:'Courier New';">import</span> statement can occur in several syntactic forms. In the examples below we want to access the <span style=" font-family:'Courier New';">Add</span> operation of the package Modelica.Math.ComplexNumbers.<br /></p></td></tr></table></body></html> + + + import Modelica.Math.ComplexNumbers; // Access by ComplexNumbers.Add + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + import Modelica.Math.ComplexNumbers.Add; // Access by Add + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + import Modelica.Math.ComplexNumbers.*; // Access by Add + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + import Co = Modelica.Math.ComplexNumbers; // Access by Co.Add + Ok + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Qualified Import</p></td></tr></table></body></html> + Qualified Import + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The<span style=" font-style:italic;"> qualified import </span>statement of the form <span style=" font-family:'Courier New';">import</span> ; imports all definitions in a package, which subsequently can be referred to by names <span style=" font-style:italic;">simplepackagename.definitionname</span>, where the <span style=" font-style:italic;">simplepackagename</span> is the <span style=" font-style:italic;">packagename</span> without its prefix. This is the most common form of <span style=" font-family:'Courier New';">import</span> <span style=" font-family:'Courier New';">(</span>see <span style=" font-family:'Courier New';">ComplexUser1) </span>that eliminates the risk for name collisions when importing from several packages.<br /></p></td></tr></table></body></html> + + + encapsulated package ComplexUser1 + import ComplexNumbers; + + class User + ComplexNumbers.Complex a(x = 1.0, y = 2.0); + ComplexNumbers.Complex b(x = 1.0, y = 2.0); + ComplexNumbers.Complex z, w; + equation + z = ComplexNumbers.Multiply(a, b); + z = ComplexNumbers.Add(a, b); + end User; + +end ComplexUser1; + {ComplexUser1} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Single Definition Import</p></td></tr></table></body></html> + Single Definition Import + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The<span style=" font-style:italic;"> single definition import </span>statement of the form <span style=" font-family:'Courier New';">import</span> <span style=" font-style:italic;">.</span>; allows you to import a single specific definition from a package and use that definition referred to by its <span style=" font-style:italic;">definitionname</span> without the package prefix. This allows you to only write <span style=" font-family:'Courier New';">Add</span> (see <span style=" font-family:'Courier New';">ComplexUser2</span> below) but still you have to write an <span style=" font-family:'Courier New';">import</span> statement for each imported definition which can be a bit cumbersome. There is no risk for name collision as long as you do not try to import two definitions with the same short name.<br /></p></td></tr></table></body></html> + + + encapsulated package ComplexUser2 + import ComplexNumbers.Complex; + import ComplexNumbers.Multiply; + import ComplexNumbers.Add; + + class User + Complex a(x = 1.0, y = 2.0); + Complex b(x = 1.0, y = 2.0); + Complex z, w; + equation + z = Multiply(a, b); + z = Add(a, b); + end User; + +end ComplexUser2; + {ComplexUser2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Unqualified Import</p></td></tr></table></body></html> + Unqualified Import + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The<span style=" font-style:italic;"> unqualified import </span>statement of the form <span style=" font-family:'Courier New';">import</span> <span style=" font-style:italic;">packagename.*</span>; imports all definitions from the package using their short names without qualification prefixes. This is shown in <span style=" font-family:'Courier New';">ComplexUser3</span> below. There is a high risk of name collisions as well as future compilation errors, but nice for the lazy programmer.<br /></p></td></tr></table></body></html> + + + class ComplexUser3 + import ComplexNumbers.*; + Complex a(x = 1.0, y = 2.0); + Complex b(x = 1.0, y = 2.0); + Complex z, w; +equation + z = Multiply(a, b); + z = Add(a, b); +end ComplexUser3; + {ComplexUser3} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Renaming Import</p></td></tr></table></body></html> + Renaming Import + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The<span style=" font-style:italic;"> renaming import </span>statement of the form <span style=" font-family:'Courier New';">import</span> <span style=" font-style:italic;"> = </span>; imports a package and renames it locally to <span style=" font-style:italic;">shortpackagename</span>. You can refer to imported definitions using <span style=" font-style:italic;">shortpackagename </span>as a presumably shorter package prefix. In the class <span style=" font-family:'Courier New';">ComplexUser4</span> below, Co is used instead of the longer name <span style=" font-family:'Courier New';">ComplexNumbers</span>.<br /></p></td></tr></table></body></html> + + + class ComplexUser4 + import Co = ComplexNumbers; + Co.Complex a(x = 1.0, y = 2.0); + Co.Complex b(x = 1.0, y = 2.0); + Co.Complex z, w; +equation + z = Co.Multiply(a, b); + z = Co.Add(a, b); +end ComplexUser4; + {ComplexUser4} + + + + + + diff --git a/DrModelica/Packages/PackLibrStruct.onb b/DrModelica/Packages/PackLibrStruct.onb new file mode 100644 index 00000000000..b123f6dafb8 --- /dev/null +++ b/DrModelica/Packages/PackLibrStruct.onb @@ -0,0 +1,76 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Package and Library Structuring</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">General Description</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A well-designed package structure is one of the most important aspects that influences the complexity, comprehension, and maintainability of large software systems. There are many factors to consider when designing a package, for example the name of the package or the structuring the package into subpackages. Other factors that are important to consider are reusability and encapsulation of the package as well as considering dependencies on other packages. </p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Subpackages and Hierarchical Libraries</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The main use of Modelica packages and subpackages is to structure hierarchical model libraries, of which the standard Modelica library is a good example. Below is a small example of a hierarchical package structure which has been extracted and adapted from the Modelica standard library. <br /><br />The example is a bit misleading since these packages are quite large, normally stored on separate files and directories, and not seen as a piece of code below. See the comments for the fully qualified names of each package or model component. <br /></p></body></html> + + + encapsulated package Modelica // Modelica + + encapsulated package Mechanics // Modelica.Mechanics + + encapsulated package Rotational // Modelica.Mechanics.Rotational + + model Inertia // Modelica.Mechanics.Rotational.Inertia + end Inertia; + + model Torque // Modelica.Mechanics.Rotational.Torque + end Torque; + + end Rotational; + + end Mechanics; + +end Modelica; + + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Public components in hierchical libraries can be accessed through their fully qualified name. See model <span style=" font-family:Courier New;">InertiaUser</span> below.</p></body></html> + + + model InertiaUser + Modelica.Mechanics.Rotational.Inertia w; + // internal code +end InertiaUser; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Encapsulated Packages and Classes</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">As emphasized before, the useage of the word "encapsulated" before a package name is good for eliminating the possibility of implicit dependences. However, sometimes it is useful to have <span style=" font-family:Courier New;">encapsulated</span> <span style=" font-style:italic;">models</span> where there is no danger of implicit dependences, e.g. application examples that are intended to be self consistent and might be sent around to other users and developers. <br /></p></body></html> + + + encapsulated model TorqueUserExample1 + import Modelica.Mechanics.Rotational; // Import package Rotational + Rotational.Torque t2; // Use Torque OK! + + Modelica.Mechanics.Rotational.Inertia w2; + // Error! No direct reference to outside an encapsulated class + // ... +end TorqueUserExample1; + Ok + + + + + + diff --git a/DrModelica/Packages/Packages.onb b/DrModelica/Packages/Packages.onb new file mode 100644 index 00000000000..c21fda0797a --- /dev/null +++ b/DrModelica/Packages/Packages.onb @@ -0,0 +1,51 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Packages</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Packages as Abstract Datatypes (s. 271)    *PackasADTs*</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">?? This notebook neds to be completed</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Complex Example</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Information Hiding</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Package Access    (s. 274)            *PackAccess*</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Importing Definitions from a Package</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Package and Library Structuring (277)    *PackLibrStruct*</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Subpackages and Hierarchical Libraries</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Package Variants and Operations (s. 286) *PackVarOp*</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Här skriva att <span style=" font-weight:600;">Generic Packages</span> inherited, local, ... packages är package varianter... (se slutet av s. 286)</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-weight:600;">Generic<br />Inherited<br />Local<br />Inherited<br />Nonencapsulated<br />Moving</span><br /></p></body></html> + + + + + diff --git a/DrModelica/Packages/PackasADTs.onb b/DrModelica/Packages/PackasADTs.onb new file mode 100644 index 00000000000..30d7dcac140 --- /dev/null +++ b/DrModelica/Packages/PackasADTs.onb @@ -0,0 +1,215 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Packages as Abstract Data Types</p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">General Description</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The notion of a package is related to the notion of abstract data types. A data type, e.g. <span style=" font-family:'Courier New';">Real</span>, is a data structure together with operations on that data structure. An abstract data type is just like an ordinary data type with definitions of data and operations. That together with a method for collecting the implementations of the operations in one place and hiding the details of those implementations. </p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">Complex Example</p></td></tr></table></body></html> + Complex Example + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">As an example, consider the package <span style=" font-family:'Courier New';">ComplexNumbers</span> below which contains a data structure declaration, the record <span style=" font-family:'Courier New';">Complex</span>, and associated operations such as<span style=" font-family:'Courier New';"> Add, Multiply, MakeComplex</span>, etc. Adding the word <span style=" font-family:'Courier New';">encapsulated</span> to the package keeps the package well structured as well as being easier to understand and maintain.<br /></p></td></tr></table></body></html> + + + encapsulated package ComplexNumbers + + record Complex + Real re; + Real im; + end Complex; + + function Add + input Complex x; + input Complex y; + output Complex z; + algorithm + z.re := x.re + y.re; + z.im := x.im + y.im; + end Add; + + function Multiply + input Complex x; + input Complex y; + output Complex z; + algorithm + z.re := x.re*y.re - x.im*y.im; + z.im := x.re*y.im + x.im*y.re; + end Multiply; + + function MakeComplex + input Real x; + input Real y; + output Complex z; + algorithm + z.re := x; + z.im := y; + end MakeComplex; + +end ComplexNumbers; + + {ComplexNumbers} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />In the <span style=" font-family:'Courier New';">ComplexUser</span> class below, both the type <span style=" font-family:'Courier New';">Complex</span> as well as the operations <span style=" font-family:'Courier New';">Multiply</span> and <span style=" font-family:'Courier New';">Add</span> are referenced by prefexing them with the package name <span style=" font-family:'Courier New';">ComplexNumbers</span>.</p></td></tr></table></body></html> + + + class ComplexUser + ComplexNumbers.Complex a(x = 1.0, y = 2.0); + ComplexNumbers.Complex b(x = 1.0, y = 2.0); + ComplexNumbers.Complex z, w; +equation + z = ComplexNumbers.Multiply(a, b); + z = ComplexNumbers.Add(a, b); +end ComplexUser; + {ComplexUser} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">What about information hiding in the package? </p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;">The type <span style=" font-family:'Courier New';">Complex</span> must be made available for allocation and initialization of variables of that type, e.g the variables <span style=" font-family:'Courier New';">a, b, z </span>and <span style=" font-family:'Courier New';">w</span> in <span style=" font-family:'Courier New';">ComplexUser</span>. It would not work if you declared x and y <span style=" font-family:'Courier New';">protected</span> in the variables <span style=" font-family:'Courier New';">Complex</span> since then these fields would not be available for the implementation of <span style=" font-family:'Courier New';">Add</span> and <span style=" font-family:'Courier New';">Multiply</span>, etc. However, by declaring the operations on <span style=" font-family:'Courier New';">Complex</span> inside the class <span style=" font-family:'Courier New';">Complex</span> itself, as in the package <span style=" font-family:'Courier New';">ComplexNumbersA</span> further below, these fields can be accessed even if they are protected. <br /><br />We can increase the degree of data abstaction by using the function <span style=" font-family:'Courier New';">MakeComplex</span> for initialization instead of modifiers, e.g. as in <span style=" font-family:'Courier New';">ComplexUser2</span> below, thus avoiding exposing the fields x and y.</p></td></tr></table></body></html> + + + class ComplexUser2 + ComplexNumbers.Complex a = MakeComplex(1.0, 2.0); + ComplexNumbers.Complex b = MakeComplex(1.0, 2.0); + ComplexNumbers.Complex z, w; +equation + z = ComplexNumbers.Multiply(a, b); + z = ComplexNumbers.Add(a, b); +end ComplexUser2; + + {ComplexUser2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />In <span style=" font-family:'Courier New';">ComplexNumbersA</span> the implementation details of the <span style=" font-family:'Courier New';">Complex</span> data structure are hidden since its data fields are protected.</p></td></tr></table></body></html> + + + encapsulated package ComplexNumbersA + + function Add = Complex.Add; + + function Multiply = Complex.Multiply; + + function MakeComplex = Complex.MakeComplex; + + + class Complex + + protected + Real re; + Real im; + + public + function Add + input Complex x; + input Complex y; + output Complex z; + algorithm + z.re:=x.re+y.re; + z.im:=x.im+y.im; + end Add; + + function Multiply + input Complex x; + input Complex y; + output Complex z; + algorithm + z.re:=x.re*y.re-x.im*y.im; + z.im:=x.re*y.im+x.im*y.re; + end Multiply; + + function MakeComplex + input Real x; + input Real y; + output Complex z; + algorithm + z.re:=x; + z.im:=y; + end MakeComplex; + + end Complex; + +end ComplexNumbersA; + {ComplexNumbersA} + + + + + diff --git a/DrModelica/QuickTour/Algorithm.onb b/DrModelica/QuickTour/Algorithm.onb new file mode 100644 index 00000000000..6d33b511f67 --- /dev/null +++ b/DrModelica/QuickTour/Algorithm.onb @@ -0,0 +1,111 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Algorithmic Constructs</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Algorithms</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Algorithm sections may also be called algorithm equations, since an algorithm section can be viewed as a group of equations involving one or more variables, and can appear among equation sections. Algorithm sections are terminated by the appearance of one of the keywords </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">equation, public, protected, algorithm,</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> or </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">end</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. An algorithm section can be embedded by equation secions, like in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AlgorithmSection</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. <br /><br />The code in the algorithm section uses the values of certain variables from outside the algorithm, so called input variables to the algorithm (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x,y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">z)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Analogously, variables assigned values by the algorithm define the outputs of the algorithm (</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x1, x2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x3)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This makes the semantics of an algorithm section quite similar to a function.<br /></span></p></td></tr></table></body></html> + + + model AlgorithmSection + Real x, z, u; + parameter Real w = 3, y = 2; + Real x1, x2, x3; +equation + x = y*2; + z = w; +algorithm + x1 := z + x; + x2 := y - 5; + x3 := x2 + y; +equation + u = x1 + x2; +end AlgorithmSection; + {AlgorithmSection,AngleInst,Angle} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of AlgorithmSection</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the model AlgorithmSection and then we can look at the values in the model.</span></p></td></tr></table></body></html> + + + simulate( AlgorithmSection ) + record SimulationResult + resultFile = "AlgorithmSection_res.mat", + messages = "" +end SimulationResult; + + + + + + + plot({x,z}) //Scalar variables plot fine + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + val(x,0) + 4.0 + + + val(z,0) + 3.0 + + + + + diff --git a/DrModelica/QuickTour/Array.onb b/DrModelica/QuickTour/Array.onb new file mode 100644 index 00000000000..471a8393ad6 --- /dev/null +++ b/DrModelica/QuickTour/Array.onb @@ -0,0 +1,178 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Arrays</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Declaring Arrays</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">An array is a collection of variables, which are all of the same type. An array variable can be declared by appending dimensions within square brackets after a class name or after a variable name.<br /></span></p></td></tr></table></body></html> + + + class ArrayDim + Real n = 1, m = 4, k = 5; + Real Voltage; + + // 3-dimensional position vector + Real[3] positionvector = {1, 2, 3}; + + // transformation matrix + Real[3,3] identitymatrix = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; + + // A 3-dimensional array + Integer[n,m,k] arr3d; + + // A boolean vector + Boolean[2] truthvalues = {false, true}; + + // A vector of voltage values + Voltage[10] voltagevector; +end ArrayDim; + {ArrayDim} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Using the alternative syntax of attaching dimensions after the variable name, the same declarations can be expressed as:</span></p></td></tr></table></body></html> + + + class ArrayDim + Real n = 1, m = 4, k = 5; + Real Voltage; + Real positionvector[3] = {1, 2, 3}; + Real identitymatrix[3,3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; + Integer arr3d[n,m,k]; + Boolean truthvalues[2] = {false, true}; + Voltage voltagevector[10]; +end ArrayDim; + {ArrayDim} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Multiplication Operator</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The multiplication operator * is scalar product when used between vectors, matrix multiplication when used between matrices and element-wise multiplication when used between an array and a scalar. In the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ElementWiseMultiplication</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">positionvector</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is multiplied by the scalar 2.</span></p></td></tr></table></body></html> + + + function ElementWiseMultiplication + input Real[3] positionvector; + output Real[3] result; + algorithm + result := positionvector*2; +end ElementWiseMultiplication; + {ElementWiseMultiplication,ArrayDim} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Calling ElementWiseMultiplication</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We see that when applying the function </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ElementWiseMultiplication</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> on </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">positionvector</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, we get the result </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">{2, 4, 6}</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + ElementWiseMultiplication({1, 2, 3}) + {2.0,4.0,6.0} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Matrix Declaration</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The common special cases of concatenation along the first and second dimensions are supported through the special syntax forms [A;B;C;...] and [A,B,C,...] respectively. Both of these forms can be mixed. Scalar and vector arguments to these special operators are promoted to become matrices before performing the concatenation. This gives the effect that a matrix can be constructed from scalar expressions by separating rows by semicolon and columns by comma. <br /></span></p></td></tr></table></body></html> + + + class Matrix + Real matrix[2, 2] = [1, 2; 3, 4]; +end Matrix; + {Matrix,ElementWiseMultiplication,ArrayDim} + + + + + diff --git a/DrModelica/QuickTour/CreateInst.onb b/DrModelica/QuickTour/CreateInst.onb new file mode 100644 index 00000000000..69863a774ae --- /dev/null +++ b/DrModelica/QuickTour/CreateInst.onb @@ -0,0 +1,222 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Creating Instances</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Point</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The declaration of a class starts with a keyword, class for instance, followed by the name of the class. A class declaration creates a type name which makes it possible to declare variables of that type, also known as an instance of the class, simply by writing: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">typename variable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. First we declare the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">., where the variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x, y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">z</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are instances of the type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + class Point "Point in a three-dimensional space" + public + parameter Real x; + parameter Real y; + parameter Real z; +end Point; + {Point} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MyPoints</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">To create new instances the &quot;new&quot; keyword is not used as is common in object-oriented programming languages, since it does not exist in Modelica. In </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPoints</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> three instances of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are created. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is created with initial values for the variables, given through modification. </span></p></td></tr></table></body></html> + + + class MyPoints + Point point1(x = 1, y = 2, z = 3); + Point point2(x = 1, y = 2, z = 3); + Point point3(x = 1, y = 2, z = 3); +end MyPoints; + + {MyPoints} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Look at Flattened Version of MyPoints</span></p></td></tr></table></body></html> + + + instantiateModel(MyPoints) + "class MyPoints + parameter Real point1.x = 1.0; + parameter Real point1.y = 2.0; + parameter Real point1.z = 3.0; + parameter Real point2.x = 1.0; + parameter Real point2.y = 2.0; + parameter Real point2.z = 3.0; + parameter Real point3.x = 1.0; + parameter Real point3.y = 2.0; + parameter Real point3.z = 3.0; +end MyPoints; +" + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Instances of MyPoints</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPointsInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> creates three new </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Points</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> by instantiating </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPoints</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. There are two different ways to give the variables initial values when creating the instance. This is shown in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPointsInst1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPointsInst2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span></p></td></tr></table></body></html> + + + class MyPointsInst1 + MyPoints pts(point1(x= 1, y = 2, z = 3)); +end MyPointsInst1; + {MyPointsInst1} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MyPointsInst2 + MyPoints pts(point1.x = 1, point1.y = 2, point1.z = 3); +end MyPointsInst2; + {MyPointsInst2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of MyPointsInst1 and MyPointsInst2</span></p></td></tr></table></body></html> + + + simulate( MyPointsInst1 ) + record SimulationResult + resultFile = "MyPointsInst1_res.mat", + messages = "" +end SimulationResult; + + + + + + plot(pts.point1.x) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + simulate( MyPointsInst2 ) + record SimulationResult + messages = "", + simulationTime = 0.184562512121431 +end SimulationResult; + + + + + + plot(pts.point1.y) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/QuickTour/DiffEq.onb b/DrModelica/QuickTour/DiffEq.onb new file mode 100644 index 00000000000..0f159d47b38 --- /dev/null +++ b/DrModelica/QuickTour/DiffEq.onb @@ -0,0 +1,105 @@ + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">A differential algebraic equation system </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">DAE example</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Our second example is only slightly more complicated, containing two equations. The second equation is of a so-called algebraic equation only involving algebraic formulas of variables but no derivatives. The first equation of this model is a differential equation as in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HelloWorld</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> example. Equation systems that contain both differential and algebraic equations are called Differential Algebraic Equation systems (DAEs). That is the reason this model is called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DAEexample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model DAEexample + Real x(start = 0.9,fixed=true); + Real y(fixed=false); + parameter Real a=2; +equation + (1 + 0.5*sin(y))*der(x) + der(y) = a*sin(time); + x-y = exp(-0.9*x)*cos(y); +end DAEexample; + {DAEexample} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of DAE example</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now we simulate the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">DAEexample</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the interval from 0 to 1.</span></p></td></tr></table></body></html> + + + simulate( DAEexample, startTime=0, stopTime=1 ) + record SimulationResult + messages = "", + simulationTime = 0.3005253322784404 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plot the results.</span></p></td></tr></table></body></html> + + + + + + + plot({x,y}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plot of a simulation of a DAE (Differential Algebraic Equation) model.</span></p></td></tr></table></body></html> + + + + diff --git a/DrModelica/QuickTour/Equations.onb b/DrModelica/QuickTour/Equations.onb new file mode 100644 index 00000000000..4c869819df7 --- /dev/null +++ b/DrModelica/QuickTour/Equations.onb @@ -0,0 +1,84 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Equations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Writing Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Equations in Modelica can be classified into three different groups: Normal equations, that occur in equation sections, declaration equations and modification equations. Equations are more powerful than assignments, since one equation can express seceral different assignments.<br /></span></p></td></tr></table></body></html> + + + class Equations + Real x(start = 2); // Modification equation + constant Integer one = 1; // Declaration equation +equation + x = 3*one; // Normal equation +end Equations; + {Equations} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Flattening and Simulation of the Equations Class</span></p></td></tr></table></body></html> + + + instantiateModel(Equations) + "class Equations + Real x(start = 2.0); + constant Integer one = 1; +equation + x = 3.0; +end Equations; +" + + + simulate(Equations) + record SimulationResult + messages = "", + simulationTime = 0.11920126030348326 +end SimulationResult; + + + + + + plot({x}) + [done] + + + + + + diff --git a/DrModelica/QuickTour/Exercise1algorithm.onb b/DrModelica/QuickTour/Exercise1algorithm.onb new file mode 100644 index 00000000000..246c40a8f80 --- /dev/null +++ b/DrModelica/QuickTour/Exercise1algorithm.onb @@ -0,0 +1,181 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Can you really put an algorithm section inside an equation section?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Yes, you didn't think so, did you?</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Writing an Algorithm Section</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create the class, <span style=" font-family:Courier New;">Average</span>, which calculates the average between two named integer parameters, using an algorithm section. <br /></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create another class and declare an instance of the Average class using modifiers to change the parameter values.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Simulate and then test the result of the instance class by using the val function to look at the values:</p></body></html> + + + //??val needed + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Average class</p></body></html> + + + class Average + parameter Real a; + parameter Real b; + Real result; +algorithm + result := (a + b) / 2; +end Average; + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">The instance</p></body></html> + + + class AverageInst + Average aver(a = 15, b = 23); +end AverageInst; + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of AverageInst</p></body></html> + + + simulate( AverageInst ); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + val(aver.result,0) //??val needed + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A harder exercise</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a class, <span style=" font-family:Courier New;">AverageExtended</span>, that calculates the average of 4 variables (a, b, c and d).<br /></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create another class and declare an instance of the AverageExtended class using modifiers to change the parameter values.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br /></p><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;">Simulate and then test the result of the instance by using the val function to look at the values at time=0..</p></body></html> + + + //??val needed {val(aver.sum,0), val(aver.aver,0)} + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">AverageExtended</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">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. </p></body></html> + + + class AverageExtended + parameter Real a; + parameter Real b; + parameter Real c; + parameter Real d; + Real sum; + Real aver; + Real nrOfVariables = 4; +equation + sum = a + b + c + d; +algorithm + aver := sum / nrOfVariables; +end AverageExtended; + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">The instance</p></body></html> + + + class AverageExtInst + AverageExtended aver(a = 15, b = 23); +end AverageExtInst; + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulate of AverageExtended</p></body></html> + + + simulate( AverageExtInst ); + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Then you can look at the values of the variables at a specific point in time by using the val function. We choose time = 0 below.</p></body></html> + + + {val(aver.sum,0), val(aver.aver,0)} + + + + + + + + diff --git a/DrModelica/QuickTour/Exercise1arrays.onb b/DrModelica/QuickTour/Exercise1arrays.onb new file mode 100644 index 00000000000..1ca0c6e249b --- /dev/null +++ b/DrModelica/QuickTour/Exercise1arrays.onb @@ -0,0 +1,49 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Constructing an array</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create a record containing several vectors and matrices:<br /> a vector contain the two B<span style=" font-family:Courier New;">oolean</span> values true and false,<br /> a vector with five <span style=" font-family:Courier New;">Integer</span> values of your choice,<br /> a matrix of three rows and four columns containing <span style=" font-family:Courier New;">Strings</span> of your choice,<br /> a matrix of one row and five columns containing different <span style=" font-family:Courier New;">Real</span> values, also these of your choice.<br /></p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + record Test + Boolean[2] truthvalues = {false, true}; + Integer[5] ints = {13, 2, 5, 4, 87}; + String[3, 4] strings = {{"blue", "Martin", "yellow", "cake"}, {"Anna", "sun", "star", "heaven"}, + {"candy", "Sofia", "sweet", "Balthasar"}}; + Real[1, 5] reals = {{4.3, 7.132, 6.5, 4.0, 2.1}}; +end Test; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Test</p></body></html> + + + //simulate( Test ) //??Error - not yet implemented all + 4 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/QuickTour/Exercise1classes.onb b/DrModelica/QuickTour/Exercise1classes.onb new file mode 100644 index 00000000000..0953c4b3cdb --- /dev/null +++ b/DrModelica/QuickTour/Exercise1classes.onb @@ -0,0 +1,76 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a class?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A class is a fundamental unit of modeling in Modelica, providing the structure for an object. Classes can contain equations, where the computations are performed.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating a Class</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create a class, <span style=" font-family:Courier New;">Add</span>, that calculates the sum of two parameters, which are <span style=" font-family:Courier New;">Integer</span> numbers with given values. </p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Since <span style=" font-family:Courier New;">x + y = sum </span>is an equation and not an assignment, the equation can also be written as sum<span style=" font-family:Courier New;"> = x + y </span>without changing the meaning of the equation.</p></body></html> + + + class Add + parameter Integer x = 1; + parameter Integer y = 2; + Real sum; +equation + sum = x + y; +end Add; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Add</p></body></html> + + + simulate(Add); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">When we have simulated the class <span style=" font-family:Courier New;">Add</span>, we can look at the values of the variables at a specific point in time by writing: <span style=" font-family:Courier New; font-size:11pt;">val(variableName,time)</span>, here with time=0;.</p></body></html> + + + {2,3} //??val needed +//{val(sum,0), val(x,0), val(y,0)} + {2,3} + + + + + + + diff --git a/DrModelica/QuickTour/Exercise1equations.onb b/DrModelica/QuickTour/Exercise1equations.onb new file mode 100644 index 00000000000..90aa0d0ec8d --- /dev/null +++ b/DrModelica/QuickTour/Exercise1equations.onb @@ -0,0 +1,98 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Declaration Equations and Normal Equations</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a class, <span style=" font-family:Courier New;">Birthyear</span>, which calculates the birthyear from this year and a persons age.<br />Point out the declaration equations and the normal equations.<br /></p></body></html> + + + class Birthyear + //... +end Birthyear; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Birthyear + parameter Integer thisYear = 2002; // Declaration equation + parameter Integer age =10; + Integer birthYear; +equation + birthYear = thisYear - age; // Normal equation +end Birthyear; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + simulate( Birthyear ); + [done] + + + plot(birthYear) + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:Courier New; font-size:11pt; color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/6.png" width="492" height="250" /></span></p></body></html> + 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 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Modification Equation</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write an instance of the class <span style=" font-family:Courier New;">Birthyear</span> above. The class, let's call it <span style=" font-family:Courier New;">MartinsBirthyear</span>, shall calculate the Martin's birthyear, call the variable <span style=" font-family:Courier New;">martinsBirthyear</span>, who is a 29-year-old. Point out the modification equation.<br /></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Check your answer by writing as below:</p></body></html> + + + //??val(martinsBirthyear.birthYear,0) + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class MartinsBirthyear + Birthyear martinsBirthyear(age = 30); // Modification equation +end MartinsBirthyear; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + simulate( MartinsBirthyear ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + //??val(martinsBirthyear.birthYear,0) + + + + + + + diff --git a/DrModelica/QuickTour/Exercise1hybrid.onb b/DrModelica/QuickTour/Exercise1hybrid.onb new file mode 100644 index 00000000000..3957fd575c2 --- /dev/null +++ b/DrModelica/QuickTour/Exercise1hybrid.onb @@ -0,0 +1,57 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">If-Equation</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a class <span style=" font-family:Courier New;">Lights</span> that sets the variable switch (integer) to one if the lights are on and zero if the lights are off.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Lights + Integer switch; + Boolean off = true; +equation + if off then + switch = 0; + else + switch = 1; + end if; +end Lights; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Lights</p></body></html> + + + simulate( Lights ); + [done] + + + plot(switch) + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/7.png" width="492" height="250" /></p></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAHsAAAA+ggGAAAAY9J0UgAAAAlwSFlzAAAOxAAADsQBlSsOGwAACiRJREFUeJzt3eGSojgYBVDZmvcaH515suyPWXsZhmCiqLn0OVVd02IIn+h4TQB7KqWUCwAwtH8+XQAAcJ/ABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAA/Pl0A38s0TZvLSyl/tVkua+17b51H+23Z7trR2+ixrGerjnv3P7Ktnn7W67zqeYGzMcJmCLUgf9f6R2/3U/WsresYpa6lUoqwhgZG2HzE1oj6ntrIcLm8dbS21a51WWs9yxH/sp97Ne6NgLf62eurV0ufLfu4p7Zafy37oXUbcAZG2EQ4cqS4FfDPWIdFa5Btbbv1cba0q9XR8kGhpb5nartnr4+W/QZnJLD5iGmavn5a2t7cG/22Tq/u9bMcIa/bHqFldmD5OPaO+7fUtn48e21a6lu32eqn9TG09LG27NvImu/ElDhD6AnZ9XTwo9t6tp9XbbulplcFVUt9Rz2G3ppeuQ1IILD5CCOj93jVse5Pqx3LhzMT2MS4ncR1xBnlR77Rry8nuzf1fG/brwjVnhP77tX37sfgMjD4TWAzvGU4tF5j3Hpm8rrtbVst/dTq2quvZ9stfR2lZR/fe7zLNs88hr0+loys+W6cdEaEe2di9wTaOoSOrKtnee2Eqta+Wi2PObe0a62l57H3Poa9Wmr3CXDObirmleAPr7y+2X834FFG2FAhXIGRCGxYMK0KjMqUOAAEMMIGgADDXtZlahKAy8X5JDfDBvblcszf6h3liVZL3Uj1qGWbWupGqueMtRi8/c+UOAAEENgAEEBgA0CAUwf2PM+fLuGLWupGqkct29RSN1I9ajm3Uwc2AJyFwAbg21qehd5yRnr3WevTtP3zgO7Lunr+MELttP5X/HEFAOiVlEFdX026DuC96+xqf52otY+tTzGOiQCc2/V6/WvZI3/f/l7W3G4v/93qY739dfu7EVobTT/yQaF0WDevrX5bvnV/bx/PmOf56T6Oopa6kepRyza11I1UzxlruZcFtUy5lzVb7Vp/r91XKXD75wEvOYZdgqYYADiPW/6UxSh4PSru/Ra2ddtPZdzQX00KAHuWQXy7fVYCG4Boy5Ae6fvUL5fLY8eqK1zWBUCsvcusbqPv9TR5b6CP8gdIjLABiHX0lPgt0Jf9jjJi7wrsvR3T+qnlOx1vAOD19nLk3gljy9stJ5d98gS07hF2rbiWB3ZvOQCwzTFsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIMCP3hWmafr6vZTyULvlfff6AQAul6l0pOU0TX+E6/p2a7vaeus+1uZ5bi0VgEDX6/WvZQZ1/ykd1s1rq++1a91kZ2mb5nl+uo+jqKVupHrUsk0tdSPVc8ZajsiCs+ieEj9C67Q6APDbRwK7dE6PA8B39/azxIUzAPRzWRcABHh7YG+d/Q0A7Os6hl1KqZ4wtjwWvddu7z4AYFv3SWe1gF0v3wtiIQ0AfRzDBoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAFMppXStME1fv++tuteupY9pmnb7b7LYDgDv82ueLz9//ny6n0Oy4CR+9DRe77jajtxr19rH7b6leZ57yr08/1IB4FG/fv3qXud6vR5fyFmUDuvmtdX32j3axyPmeX66j6OopW6ketSyTS11I9VzxlqOyIKzcAwbAAIIbAAIILABIIDABoAAAhsAAnRd1lVKqV5Dvbw8a6/d3n0AwLauwL5c6gG7Xr4XxEIaAPqYEgeAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwAC/OhdYZqmr99LKQ+1W953rx8A4HKZSkdaTtP0R7iub7e2q6237mNtnufWUgEIdL1e/1pmUPef0mHdvLb6XrvWTXaWtmme56f7OIpa6kaqRy3b1FI3Uj1nrOWILDiL7inxI7ROqwMAv30ksEvn9DgAfHfVwH7VKFg4A0C/amALVgAYx9uvw946+xsA2Nd1DLuUUp0qXx6L3mu3dx8AsK37pLNawK6X7wWxkAaAPr6aFAACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIILABIIDABoAAAhsAAghsAAggsAEggMAGgAACGwACCGwACPCjd4Vpmr5+L6XcbbvVpqcPAKAzsNcBXAvk233P9gEA/PaSKXEhDADHeklgC2sAOJaTzgAgQPUYthPDAGAc1cAW0gAwDlPiABCg67KuUkp1qrz1zPC9PgCAbVMZNDG3ruOe5/n9hQDwNtfr9a9lg8bU+5VBHVHaPM8HVHIMtdSNVI9atqmlbqR6zljLwDH1do5hA0AAgQ0AAYY+hv1saSN9Rapa6kaqRy3b1FI3Uj1nrGWkx/RpRtgAEEBgA0AAgQ0AAYY+hg0Ag8bU23V909k7eYIA4H+mxAEggMAGgAACGwACCGwACCCwASCAwAaAAAIbAAIIbAAIMOwXp/RYfiva3heutLZ7Ry23tq/8gpiR9sto9fRu45XP1SP75V7bd9byyf2y9Y2IIz1P36GW23Za3u/eUcuZxQf2+oVSe+G0tntHLbf7Xmmk/TJaPb3beOVz1VvLO990E56j9bJXPVeJ++ad/7db2ryjlrMzJf4BI71YR6njZrR6RjHSa2ZtlLpG3kdnZZ+/l8D+AC/wHCO9IU3T9PUzgtFqGeV5+k7s8/eKnxLnOCO96d2CYJR6RjDSlOJy+5+uZSSllCGP1Y7ywYrnCGyGNEIYjBREo9RxM1o9oxjpWO3yw8P6gwSZBDaXy2WscBrJ8k3OPhqT56XOfjkXx7AZ6g1vpFFAKeXr53b7U0baL2TwmjmfqYzyTv2E2jGjremprXafqKW27N21jHAd6+jP097yd9Yy0n4ZrZZ3vI2l7ptX17K13U/WcmanCGwAODtT4gAQQGADQACBDQABBDYABPgXSwoAudsWC5UAAAAASUVORK5CYII= + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/QuickTour/Exercise1inheritance.onb b/DrModelica/QuickTour/Exercise1inheritance.onb new file mode 100644 index 00000000000..fcaafb7ecf1 --- /dev/null +++ b/DrModelica/QuickTour/Exercise1inheritance.onb @@ -0,0 +1,26 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What do the terms <span style=" font-family:Courier New;">partial</span>, <span style=" font-family:Courier New;">class</span> and <span style=" font-family:Courier New;">extends</span> stand for?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New; font-weight:600;">partial class</span> introduces a datatype. A partial class is incomplete, so you cannot create an instance of it. <br /></p><p style="-qt-paragraph-type:empty; 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;"></p><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;"><span style=" font-family:Courier New; font-weight:600;">class</span> introduces a variant.<br /></p><p style="-qt-paragraph-type:empty; 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;"></p><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;"><span style=" font-family:Courier New; font-weight:600;">extends</span> connects a variant to a datatype.</p></body></html> + + + + + + diff --git a/DrModelica/QuickTour/Exercise1package.onb b/DrModelica/QuickTour/Exercise1package.onb new file mode 100644 index 00000000000..e9b1971c713 --- /dev/null +++ b/DrModelica/QuickTour/Exercise1package.onb @@ -0,0 +1,107 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1 - Package</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a Package?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A package is a restricted and enhanced class that is primarily used to manage name spaces and organize Modelica code. A package has the restrictions of only containing declarations of classes, including all kinds of restricted classes, and constants. Variable declarations are not allowed. </p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating a Package</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create a package that contains a division function (that divides two <span style=" font-family:Courier New;">Real</span> numbers) and a constant k = 5.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Create a class, containing a variable x. The variable gets its value from the division function inside the package, which divides 10 by 5.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Simulate the class x and obtain the value of x by writing val(x,time), as below (let's choose time = 0):</p></body></html> + + + //??val(x,0) + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + package MyPackage + + function division + input Real a; + input Real b; + output Real result; + algorithm + result := a / b; + end division; + + constant Integer k = 5; + +end MyPackage; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class MyPackInst + Real x = MyPackage.division(10, 5); +end MyPackInst; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of MyPackage</p></body></html> + + + simulate( MyPackage ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + simulate( MyPackInst ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + False + False + + + //??val(x,0) + + + + + + + + diff --git a/DrModelica/QuickTour/Exercise1partial.onb b/DrModelica/QuickTour/Exercise1partial.onb new file mode 100644 index 00000000000..14b1dd91a06 --- /dev/null +++ b/DrModelica/QuickTour/Exercise1partial.onb @@ -0,0 +1,42 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Classes</p></body></html> + + + class Ptest + parameter Real x; + parameter Real y; + Real z; + Real w; +equation + x + y = z; +end Ptest; + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is wrong with this class? Is there something missing?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Answer</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">There are more variables than equations, which is typical for partial classes, the keyword <span style=" font-family:Courier New;">partial</span> is therefore missing.</p></body></html> + + + + + + + diff --git a/DrModelica/QuickTour/Exercise2-classes.onb b/DrModelica/QuickTour/Exercise2-classes.onb new file mode 100644 index 00000000000..483ef66f795 --- /dev/null +++ b/DrModelica/QuickTour/Exercise2-classes.onb @@ -0,0 +1,104 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2 - Instances</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is an instance?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">An instance of a class is an object created by instantiation of the class. </p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating Instances</p></body></html> + + + class Dog + constant Real legs = 4; + parameter String name = "Dummy"; +end dog; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create an instance of the class <span style=" font-family:Courier New;">Dog</span>. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Create another instance and give the dog the name "Tim".</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class DogInst + Dog d; +end DogInst; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class DogTim + Dog t(name="Tim"); +end DogTim; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Dog and DogTim</p></body></html> + + + simulate( DogInst ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Internal error generate_global_data failed +Internal error Generation of simulation code failed +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + simulate( DogTim ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Internal error generate_global_data failed +Internal error Generation of simulation code failed +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/QuickTour/Exercise2hybrid.onb b/DrModelica/QuickTour/Exercise2hybrid.onb new file mode 100644 index 00000000000..6bfeefef938 --- /dev/null +++ b/DrModelica/QuickTour/Exercise2hybrid.onb @@ -0,0 +1,78 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2 - When-Equation</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">When-Equation</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a class <span style=" font-family:Courier New;">LightSwitch</span>, that is initially off and switched on at time 5.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Tip</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New;">sample(start, interval)</span> returns true and triggers time events at time instants and <span style=" font-family:Courier New;">rem(x, y)</span> returns the integer remainder of <span style=" font-family:Courier New;">x/y</span>, such that <span style=" font-family:Courier New;">div(x,y) * y + rem(x, y) = x</span>.<br /></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">LightSwitch</p></body></html> + + + class LightSwitch + Boolean on; +equation + when sample(5, 5) then + if rem(time, 5) == 0 then + on = true; + else + on = false; + end if; + end when; +end LightSwitch; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of LightSwitch</p></body></html> + + + simulate( LightSwitch, stopTime=20 ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Too few equations, underdetermined system. The model has 1 variables and 0 equations +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + plot( on ); + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/6.png" width="288" height="214" /></span></p></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAEgAAAA1ggDAAAARuGvAgAAAwBQTFRFAAAAAAD/2dnZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqOCPfgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAvxJREFUeJzt3YtS2kAAQNHg/390p214mnBhU62Ec0YtApvInUCc7qrTB3dN//sL+OkECgIFgYJAQaAgUBAoCBQECgIFgYJAQaAgUBAoCBQECgIFgYJA4elA0/T50p49H+g8SKDjfabf7/MBM1++6LRvKw/yMJvvcnpzBC3f5XOgdz+Cru8znd/nSqdWuzf0Ij069hU5zYe3eJBbCBQECgIFgYJAQaAgUBAoCBQECgIFgYJAQaCwHOj8H/Rvb6WBQEcChfuBRgsdXsqGQIN9Pu7v86UsNtg8dbr3QA/deI9AQaAgUBAoCBQECgIFgYJAQaAgUBAoCBQECgIFgYJAQaAgUBAoCBQECrsMdDmNunXxwh4DTQuXBVoJ5Ag6u38EDS9e2PhV/SCeYuH2aXX5UaAPp/kkUBAoCBQECgIFgYJAQaAgUBAoCBQECgIFgYJAQaAgUBAoCBQECgKFtbl582KzlannmxuftfdAk4nDE3Pzwdx8WJyb9xQ7c5oPAgWBgkBBoCBQECgIFAQKAgWBgkBBoCBQECgIFAQKAgWBgkBBoCBQECgsL17Y+odU9xjoZvGCQDNTz2Ftdcc8BT241b0H+nAEnSwuXjguXxDIaT4JFAQKAgWBgkBBoCBQECgIFAQKAgWBgkBBoCBQECgIFAQKAgWBgkBheW7ez6yemHoOKzOrjqCjtdUdf/8xN7/6FLu+8Vl7DHTziwW8Bs2c5oNAQaAgUBAoCBQECgIFgYJAQaAgUBAoCBQECgIFgYJAQaAgUBAoCBQECgLduH3MPy3Q8C6HB16PPP5E/GPb/bSa4dGrD8tXP7eR/3D1p89WA/0JOR2GTS/nIsjQEfQ+pvtH1OM3vgmBggZBoPAlgaaxtXtXv15lZOD4yDv3eHqbj+x2w7jb0+zjOxzY63Txdm/T/9ro4s+NgUb2mrv8otegsc1uC7Tl0PveQEOPcR44Hmhk4HT8+BJPsfk7/ucHDw88Luf99hfpPREoCBQECgIFgYJAQaAgUBAoCBR+ARG/2zppXvAeAAAAAElFTkSuQmCC + + + + + + + diff --git a/DrModelica/QuickTour/Exercise2inheritance.onb b/DrModelica/QuickTour/Exercise2inheritance.onb new file mode 100644 index 00000000000..1895ce6dd66 --- /dev/null +++ b/DrModelica/QuickTour/Exercise2inheritance.onb @@ -0,0 +1,81 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Inheritance</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Consider the <span style=" font-family:Courier New;">Bicycle</span> class below...</p></body></html> + + + record Bicycle + Boolean has_wheels = true; + Integer nrOfWheels = 2; +end Bicycle; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Define a record, <span style=" font-family:Courier New;">ChildrensBike</span>, that inherits from the class <span style=" font-family:Courier New;">Bicycle</span> and is meant for kids. Give the variables values.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + record Bicycle + Boolean has_wheels = true; + Integer nrOfWheels = 2; +end Bicycle; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class ChildrensBike + extends Bicycle; + Boolean forKids = true; +end ChildrensBike; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Bicycle and ChildrensBike</p></body></html> + + + simulate( Bicycle ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + simulate( ChildrensBike ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + plot({nrOfWheels,forKids}) + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"><img src="file:///C:/OpenModelica1.4.3/bin/OMNoteboook_tempfiles/9.png" width="492" height="250" /></p></body></html> + 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 + + + + + + + diff --git a/DrModelica/QuickTour/Exercise3-classes.onb b/DrModelica/QuickTour/Exercise3-classes.onb new file mode 100644 index 00000000000..8a2d33c4d09 --- /dev/null +++ b/DrModelica/QuickTour/Exercise3-classes.onb @@ -0,0 +1,85 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 3</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating a Function and Making a Function Call</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Write a function, <span style=" font-family:Courier New;">average</span>, that returns the average of two <span style=" font-family:Courier New;">Real</span> values. </p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Make a function call to <span style=" font-family:Courier New;">average</span> with the input 4 and 6.</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Try your function by calling it as below. </p></body></html> + + + average(4, 6) + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + average(13.5, 19) + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + function average + input Real a; + input Real b; + output Real result; +algorithm + result := (a + b) / 2; +end average; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + class AverageTest + Real res; +equation + res = average(4, 6); +end AverageTest; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Calling average</p></body></html> + + + average(4, 6) + 5.0 + + + average(13.5, 19) + 16.25 + + + + + + + diff --git a/DrModelica/QuickTour/Functions.onb b/DrModelica/QuickTour/Functions.onb new file mode 100644 index 00000000000..0d9f8d70888 --- /dev/null +++ b/DrModelica/QuickTour/Functions.onb @@ -0,0 +1,74 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Functions</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A number of mathematical functions like </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">abs, sqrt, mod</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, etc. are predefined in the Modelica language whereas others such as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">sin, cos, exp</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, etc. are available both in the language and in the Modelica standard math library </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Modelica.Math</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The arithmetic operators +, -,*, / can be regarded as functions that are used through a convenient operator syntax. The body of a Modelica function is an algorithm section that contains procedural algorithmic code to be executed when the function is called. Formal parameters are specified using the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">input</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> keyword, whereas results are denoted using the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">output</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> keyword. This makes the syntax of function definitions quite close to Modelica block class definitions. <br /><br />Modelica functions are mathematical functions (without global side-effects and with no memory). A Modelica function always returns the same results given the same arguments. Below we show the algorithmic code for polynomial evaluation in a function named </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">polynomialEvaluator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + function polynomialEvaluator + input Real a[:]; // Array size defined at function call time + input Real x = 1.0; // Default value 1.0 for x + output Real y; +protected + Real xpower; +algorithm + y := 0; + xpower := 1; + for i in 1:size(a, 1) loop + y := y + a[i]*xpower; + xpower := xpower*x; + end for; +end polynomialEvaluator; + {polynomialEvaluator} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Calling polynomialEvaluator</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We can now call the function with the inputs and get the value of the output(s) back.</span></p></td></tr></table></body></html> + + + polynomialEvaluator({1, 2}, 2) + 5.0 + + + polynomialEvaluator({1, 2, 3, 4}, 21) + 38410.0 + + + + + diff --git a/DrModelica/QuickTour/Generic.onb b/DrModelica/QuickTour/Generic.onb new file mode 100644 index 00000000000..3fc1407d1d6 --- /dev/null +++ b/DrModelica/QuickTour/Generic.onb @@ -0,0 +1,234 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Generic Classes</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">There are essentially two cases of generic class parameterization in Modelica: </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">class parameters</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (formal parameters to the class) can either be </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">instance parameters</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, i.e. have instances as values, or be </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">type parameters</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, i.e. have types as values. <br /><br />Formal class parameters are replaceable variable or type declarations within the class (usually) marked with the prefix </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The special case of replaceable local functions is roughly equivalent to virtual methods in some object-oriented programming languages.<br />Actual arguments to classes are modifiers, which when containing whole variable declarations or types are preceded by the prefix </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">redeclare</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Class Parameters being Component Declarations</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">GreenClass and YellowClass</span></p></td></tr></table></body></html> + + + type GreenClass = Real(unit = "green"); + {GreenClass} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type YellowClass = Real(unit = "yellow"); + {YellowClass,GreenClass} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">The Class C</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here we handle the case when class parameters are component being instances or objects. The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has three class parameters, marked by the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class C + replaceable GreenClass obj1(p1=5); + replaceable YellowClass obj2; + replaceable GreenClass obj3; +end C; + {C,YellowClass,GreenClass} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is defined by providing two declarations of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">obj1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">obj2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> as actual arguments to class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, being red and green respectively, instead of the defaults green and yellow. The keyword redeclare must precede an actual argument to a class formal parameter in order to avoid accidentally changing the type of an object through a standard modifier. The type of a class component cannot be changed if it is not declared as replaceable and a redeclaration is provided.<br /></span></p></td></tr></table></body></html> + + + class C2 = C(redeclare RedClass obj1, redeclare GreenClass obj2); + {C2,C,YellowClass,GreenClass} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The definition of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2b</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class C2b + RedClass obj1(p1=5); //type + GreenClass obj2; + GreenClass obj3; +end C2b; + {C2b,C2,C,YellowClass,GreenClass} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Class Parameters being Types</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">BlueClass</span></p></td></tr></table></body></html> + + + type BlueClass = Real(unit = "blue"); + {BlueClass,C2b,C2,C,YellowClass,GreenClass} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">The Class C</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A class parameter can also be a type, for example in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below it is easy to change the color of all objects of the type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ColoredClass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class C + replaceable class ColoredClass = GreenClass; //type parameter + ColoredClass obj1(p1 = 5); + replaceable YellowClass obj2; + ColoredClass obj3; +end C; + {BlueClass,C2b,C2,C,YellowClass,GreenClass} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> the type parameter of</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> ColoredClass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are redeclared as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">BlueClass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class C2 = C(redeclare class ColoredClass = BlueClass); + {BlueClass,C2b,C2,C,YellowClass,GreenClass} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The definition of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C2b</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class C2b + BlueClass obj1(p1=5); + YellowClass obj2; + BlueClass obj3; +end C2b; + {BlueClass,C2b,C2,C,YellowClass,GreenClass} + + + + + + diff --git a/DrModelica/QuickTour/HelloWorld.onb b/DrModelica/QuickTour/HelloWorld.onb new file mode 100644 index 00000000000..52cc8fdfa06 --- /dev/null +++ b/DrModelica/QuickTour/HelloWorld.onb @@ -0,0 +1,82 @@ + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">First Basic Class</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">HelloWorld</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The program contains a declaration of a class called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HelloWorld</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with two fields and one equation. The first field is the variable x which is initialized to a start value 2 at the time when the simulation starts. The second field is the variable a, which is a constant that is initialized to 2 at the beginning of the simulation. Such a constant is prefixed by the keyword parameter in order to indicate that it is constant during simulation but is a model parameter that can be changed between simulations.<br /><br />The Modelica program solves a trivial differential equation:    </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x' = - a * x. </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The variable x is a state variable that can change value over time. The x ' is the time derivative of x.<br /></span></p></td></tr></table></body></html> + + + class HelloWorld + Real x(start = 1,fixed=true); + parameter Real a = 1; +equation + der(x) = - a * x; +end HelloWorld; + {HelloWorld} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of HelloWorld </span></p></td></tr></table></body></html> + + + simulate( HelloWorld, startTime=0, stopTime=4 ) + record SimulationResult + resultFile = "HelloWorld_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plot the results.</span></p></td></tr></table></body></html> + + + + + + plot( x ) + [done] + + + + diff --git a/DrModelica/QuickTour/HelloWorldmod.onb b/DrModelica/QuickTour/HelloWorldmod.onb new file mode 100644 index 00000000000..4306a8a4842 --- /dev/null +++ b/DrModelica/QuickTour/HelloWorldmod.onb @@ -0,0 +1,98 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">First Basic Class</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">HelloWorld</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The program contains a declaration of a class called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">HelloWorld</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with two fields and one equation. The first field is the variable x which is initialized to a start value 2 at the time when the simulation starts. The second field is the variable a, which is a constant that is initialized to 2 at the beginning of the simulation. Such a constant is prefixed by the keyword parameter in order to indicate that it is constant during simulation but is a model parameter that can be changed between simulations.<br /><br />The Modelica program solves a trivial differential equation:    </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x' = - a * x. </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The variable x is a state variable that can change value over time. The x ' is the time derivative of x.<br /></span></p></td></tr></table></body></html> + + + class HelloWorld + Real x(start = 2); + parameter Real a = 5; +equation + der(x) = a * x; +end HelloWorld; + {HelloWorld} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of HelloWorld </span></p></td></tr></table></body></html> + + + simulate( HelloWorld, stopTime=4 ) + record SimulationResult + messages = "", + simulationTime = 0.26517333755683115 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( x ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/QuickTour/IfClause.onb b/DrModelica/QuickTour/IfClause.onb new file mode 100644 index 00000000000..20471bd26ac --- /dev/null +++ b/DrModelica/QuickTour/IfClause.onb @@ -0,0 +1,221 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">If-Equation</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical units</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Components</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">TwoPin is a partial class, which means that it is not possible to make instances of it but it can be extended.</span></p></td></tr></table></body></html> + + + partial class TwoPin "Superclass of elements with two electrical pins" + Pin p, n; + Voltage v; + Current i; +equation + v = p.v - n.v; + p.i + n.i = 0; + i = p.i; +end TwoPin; + {TwoPin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Diode</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Conditional expressions or equations describe discontinuous and conditional models. When writing conditional expressions no </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">end if</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is needed. If the condition has more than two options then it is not enough with an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statement to express this, so we have to add one or more </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">elseif</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-statements. <br /></span></p></td></tr></table></body></html> + + + model Diode "Ideal diode" + extends TwoPin; + Real s; + Boolean off; +equation + off = s < 0; + if off then + v = s; + else + v = 0; // Conditional equations + end if; + i = if off then 0 else s; // Conditional expression +end Diode; + {Diode} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Load the Modelica Standard Library in order to be able to import as below.</span></p></td></tr></table></body></html> + + + loadModel(Modelica); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We construct a circuit with a diode.</span></p></td></tr></table></body></html> + + + model Circuit + import Modelica.Electrical.Analog.Basic.*; + import Modelica.Electrical.Analog.Sources.*; + Diode d(s(start = 0)); + Resistor R1 (R = 2.0); + Ground G; + SineVoltage src (V = 3.0, freqHz = 5.0); +equation + connect(G.p,src.n); + connect(src.p,R1.n); + connect(R1.p,d.n); + connect(d.p,src.n); +end Circuit; + {Circuit} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of circuit</span></p></td></tr></table></body></html> + + + simulate( Circuit, stopTime=10 ) + record SimulationResult + resultFile = "Circuit_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + diff --git a/DrModelica/QuickTour/Inheritance.onb b/DrModelica/QuickTour/Inheritance.onb new file mode 100644 index 00000000000..484239ee1d8 --- /dev/null +++ b/DrModelica/QuickTour/Inheritance.onb @@ -0,0 +1,156 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Inheritance</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A major advantage with object-orientation is the ability to extend the bahavior and properties of an existing class. The original class (base class or superclass), is extended to create a more specialized version (subclass). By doing this the field declarations, equations and other contents are inherited by the subclass, and can be reused.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ColorData</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">This is an example of extending a simple Modelica class, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ColorData</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> inherits the data fields (red, blue and green) from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ColorData</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + type MyReal = Real; + {MyReal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + record ColorData // Superclass of Color + parameter Real red; + parameter Real blue; + Real green; +end ColorData; + {ColorData,MyReal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Color // Subclass of ColorData + extends ColorData; // Inherits from ColorData +equation + red + blue + green = 1; +end Color; + {Color,ColorData,MyReal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class Point + public Real x; + Real y, z; +end Point; + {Point,Color,ColorData,MyReal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ColoredPoint</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> inherits from multiple classes, both </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Point</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class ColoredPoint + extends Point; + extends Color; +end ColoredPoint; + {ColoredPoint,Point,Color,ColorData,MyReal} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flattening of Color</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Make a call to flatten the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Color</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + instantiateModel(Color) + "class Color + parameter Real red; + parameter Real blue; + Real green; +equation + red + blue + green = 1.0; +end Color; +" + + + + + diff --git a/DrModelica/QuickTour/Local.onb b/DrModelica/QuickTour/Local.onb new file mode 100644 index 00000000000..093c6715fbe --- /dev/null +++ b/DrModelica/QuickTour/Local.onb @@ -0,0 +1,84 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Local Classes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In Modelica it is possible to define local classes nested inside a class. </span></p></td></tr></table></body></html> + + + class C1 + class Lpin // Local class + Real p; + end Lpin; + + class Voltage = Real(unit="kV"); // Local class + + Voltage v1 = 5, v2 = 1; + Lpin pn(p = 2); +end C1; + {C1} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of C1</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + simulate( C1 ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +Error occured while flattening model C1 +" +end record + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + simulate(C1) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: C1 +[<interactive>:6:3-6:34:writable] Error: Class specialization violation: .Real is a Real, not a class. +Error: Error occurred while flattening model C1 +" +end SimulationResult; + + + + diff --git a/DrModelica/QuickTour/Packages.onb b/DrModelica/QuickTour/Packages.onb new file mode 100644 index 00000000000..11980149eb0 --- /dev/null +++ b/DrModelica/QuickTour/Packages.onb @@ -0,0 +1,62 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<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;">Packages</p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Name conflicts is a major problem when developing reusable code, for example libraries of reusable Modelica classes and functions for various application domains. A package is simply a container or namespace for names of classes, functions, constants, and other allowed definitions. The package name is prefixed to all definitions in the package using standard dot notation. An import language construct is provided for Modelica packages. <span style=" font-family:'Courier New';">An import</span> statement occur in one of the following four syntactic forms <a href="../Packages/PackAccess.onb"><span style=" text-decoration: underline; color:#0000ff;">qualified import</span></a>, <a href="../Packages/PackAccess.onb"><span style=" text-decoration: underline; color:#0000ff;">single definition import</span></a>, <a href="../Packages/PackAccess.onb"><span style=" text-decoration: underline; color:#0000ff;">unqualified import</span></a> or <a href="../Packages/PackAccess.onb"><span style=" text-decoration: underline; color:#0000ff;">renaming import</span></a>.<br /><br />The type name <span style=" font-family:'Courier New';">Voltage</span> together with all other definitions in Modelica.SIunits is imported in the example below, which makes it possible to use it without prefix for declaration of the variable v. By contrast, the declaration of the variable i uses the fully qualified name <span style=" font-family:'Courier New';">Modelica.SIunits.Ampere</span> of the type <span style=" font-family:'Courier New';">Ampere</span>, even though the short version also would have been possible. The fully qualified long name for <span style=" font-family:'Courier New';">Ampere</span> can be used since it is found using the standard nested lookup of the Modelica standard library placed in a conceptual top level package.<br /></p></td></tr></table></body></html> + + + package MyPack + import Modelica.SIunits.*; + +class Foo + Voltage v; + Modelica.SIunits.Ampere i; +end Foo; + +end MyPack; + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<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;"><br />Importing definitions from one package into another package as in the above example has the drawback that the introduction of new definitions into a package may cause name clashes with definitions in packages using that package. Instead, a well-designed package should state all its dependences explicitly through import statements which are easy to find. <br /><br />Such a package is created by adding the prefix <span style=" font-family:'Courier New';">encapsulated</span> in front of the package keyword. This prevents nested lookup outside the package boundary, insuring that all dependences on other packages outside the current package have to be explicitly stated as import statements.<br /></p></td></tr></table></body></html> + + + encapsulated package MyPack + import SI = Modelica.SIunits; + import Modelica; + +class Foo + SI.Voltage v; + Modelica.SIunits.Ampere i; +end Foo; + +end MyPack; + Ok + + + + diff --git a/DrModelica/QuickTour/Partial.onb b/DrModelica/QuickTour/Partial.onb new file mode 100644 index 00000000000..b2608d48eb1 --- /dev/null +++ b/DrModelica/QuickTour/Partial.onb @@ -0,0 +1,42 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Partial Classes</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />TwoPin is a partial model of components that has two pins. Since most electrical components have two pins, this information is collected into a base class. A partial class is incomplete and can not be simulated alone. In <span style=" font-family:Courier New;">TwoPin</span> there are six variables (p.v, p.i, n.i, n.v, v, i) and only three equations, which makes the system unsolvable (no unique solution can be found).<br /></p></body></html> + + + partial class TwoPin "Superclass of elements with two electrical pins" + Pin p, n; + Voltage v; + Current i; +equation + v = p.v - n.v; + p.i + n.i = 0; + i = p.i; +end TwoPin; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Reuse of Partial Classes</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Now that we have the partial class TwoPin we can use that to create a Resistor, by adding the constitutive equation: <span style=" font-family:Courier New;">R*i = v, which </span>describes the specific physical characteristics of the relation between voltage and current for resistors.<br /></p></body></html> + + + class Resistor "Ideal linear electrical Resistor" + extends TwoPin; + parameter Real R(unit = "Ohm") "Resistance"; +equation + R*i = v; +end Resistor; // From Modelica.Electrical.Analog.Basic + Ok + + + + + diff --git a/DrModelica/QuickTour/ReuseMod.onb b/DrModelica/QuickTour/ReuseMod.onb new file mode 100644 index 00000000000..1eb91727151 --- /dev/null +++ b/DrModelica/QuickTour/ReuseMod.onb @@ -0,0 +1,187 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Reuse of Modified Classes</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">LowPassFilter</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class concept is the key to reusing modeling knowledge in Modelica. Assume that we would like to connect two filter models in series. Instead of creating two separate filter classes it is better to define a common filter class and create two instances of this class, which are connected. </span></p></td></tr></table></body></html> + + + model LowPassFilter + parameter Real T = 1; + Real u, y(start=1); +equation + T*der(y) + y = u; +end LowPassFilter; + {LowPassFilter} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">LowPass FiltersInSeries</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The LowPassFilter class can be used to create two separate instances of the filter and connect them by using the equation </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">F2.u = F1.y</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + model FiltersInSeries + LowPassFilter F1(T=2), F2(T=3); +equation + F1.u = sin(time); + F2.u = F1.y; +end FiltersInSeries; + {FiltersInSeries} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of FiltersInSeries </span></p></td></tr></table></body></html> + + + simulate( FiltersInSeries ) + record SimulationResult + messages = "", + simulationTime = 0.2794089449431129 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + plot({F1.u, F2.u}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">ModifiedFiltersInSeries</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">FiltersInSeries can be used to declare variables at a higher hierarchical level.</span></p></td></tr></table></body></html> + + + model ModifiedFiltersInSeries + FiltersInSeries F12(F1(T=6), F2.T=11); +end ModifiedFiltersInSeries; + {ModifiedFiltersInSeries} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of ModifiedFiltersInSeries</span></p></td></tr></table></body></html> + + + simulate( ModifiedFiltersInSeries ) + record SimulationResult + messages = "", + simulationTime = 0.29635719646267394 +end SimulationResult; + + + + + + + plot({F12.F1.T, F12.F2.T}) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/QuickTour/SimpleCircuit.onb b/DrModelica/QuickTour/SimpleCircuit.onb new file mode 100644 index 00000000000..c1f271b0018 --- /dev/null +++ b/DrModelica/QuickTour/SimpleCircuit.onb @@ -0,0 +1,235 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Acausal Physical Modeling - Simple Circuit </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/alash325/AppData/Local/Temp/OpenModelica/1.png" width="407" height="318" /></p></td></tr></table></body></html> + Center + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;">Diagram 1:</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> Connection diagram of the acausal simple circuit model.</span></p></td></tr></table></body></html> + Center + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span></p></td></tr></table></body></html> + Center + Model1 + + + loadModel(Modelica) // Load if not already loaded + true + + + model SimpleCircuit + Modelica.Electrical.Analog.Basic.Resistor Resistor1; + Modelica.Electrical.Analog.Basic.Inductor Inductor1; + Modelica.Electrical.Analog.Basic.Ground Ground1; + Modelica.Electrical.Analog.Basic.Resistor Resistor2; + Modelica.Electrical.Analog.Basic.Capacitor Capacitor1; + Modelica.Electrical.Analog.Sources.SineVoltage SineVoltage1; + +equation + connect(SineVoltage1.p, Resistor2.p); + connect(Resistor1.n, Inductor1.p); + connect(Resistor2.n, Capacitor1.p); + connect(Inductor1.n, Ground1.p); + connect(Capacitor1.n, Ground1.p); + connect(Resistor1.p, Resistor2.p); + connect(SineVoltage1.n, Ground1.p); +end SimpleCircuit; + {SimpleCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Flatten the model before simulation. (This command is not really needed since flattening is part of the compilation of the model performed by the simulate command).</span></p></td></tr></table></body></html> + + + instantiateModel(SimpleCircuit) // Take a look at the flattened model - not needed + "class SimpleCircuit + Real Resistor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Resistor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Resistor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Resistor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Boolean Resistor1.useHeatPort = false \"=true, if HeatPort is enabled\"; + Real Resistor1.LossPower(quantity = \"Power\", unit = \"W\") \"Loss power leaving component via HeatPort\"; + Real Resistor1.T_heatPort(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) \"Temperature of HeatPort\"; + parameter Real Resistor1.R(quantity = \"Resistance\", unit = \"Ohm\", start = 1.0) \"Resistance at temperature T_ref\"; + parameter Real Resistor1.T_ref(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = 300.15 \"Reference temperature\"; + parameter Real Resistor1.alpha(quantity = \"LinearTemperatureCoefficient\", unit = \"1/K\") = 0.0 \"Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))\"; + Real Resistor1.R_actual(quantity = \"Resistance\", unit = \"Ohm\") \"Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))\"; + parameter Real Resistor1.T(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = Resistor1.T_ref \"Fixed device temperature if useHeatPort = false\"; + Real Inductor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Inductor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Inductor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Inductor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Inductor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Inductor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real Inductor1.L(quantity = \"Inductance\", unit = \"H\", start = 1.0) \"Inductance\"; + parameter Real Inductor1.IC(quantity = \"ElectricCurrent\", unit = \"A\") = 0.0 \"Initial Value\"; + parameter Boolean Inductor1.UIC = false; + Real Ground1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Ground1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Resistor2.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Resistor2.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Resistor2.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor2.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Resistor2.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Resistor2.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Boolean Resistor2.useHeatPort = false \"=true, if HeatPort is enabled\"; + Real Resistor2.LossPower(quantity = \"Power\", unit = \"W\") \"Loss power leaving component via HeatPort\"; + Real Resistor2.T_heatPort(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) \"Temperature of HeatPort\"; + parameter Real Resistor2.R(quantity = \"Resistance\", unit = \"Ohm\", start = 1.0) \"Resistance at temperature T_ref\"; + parameter Real Resistor2.T_ref(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = 300.15 \"Reference temperature\"; + parameter Real Resistor2.alpha(quantity = \"LinearTemperatureCoefficient\", unit = \"1/K\") = 0.0 \"Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))\"; + Real Resistor2.R_actual(quantity = \"Resistance\", unit = \"Ohm\") \"Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))\"; + parameter Real Resistor2.T(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 6000.0, start = 288.15, nominal = 300.0) = Resistor2.T_ref \"Fixed device temperature if useHeatPort = false\"; + Real Capacitor1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real Capacitor1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real Capacitor1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Capacitor1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real Capacitor1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real Capacitor1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real Capacitor1.C(quantity = \"Capacitance\", unit = \"F\", min = 0.0, start = 1.0) \"Capacitance\"; + parameter Real Capacitor1.IC(quantity = \"ElectricPotential\", unit = \"V\") = 0.0 \"Initial Value\"; + parameter Boolean Capacitor1.UIC = false; + Real SineVoltage1.v(quantity = \"ElectricPotential\", unit = \"V\") \"Voltage drop between the two pins (= p.v - n.v)\"; + Real SineVoltage1.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing from pin p to pin n\"; + Real SineVoltage1.p.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real SineVoltage1.p.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + Real SineVoltage1.n.v(quantity = \"ElectricPotential\", unit = \"V\") \"Potential at the pin\"; + Real SineVoltage1.n.i(quantity = \"ElectricCurrent\", unit = \"A\") \"Current flowing into the pin\"; + parameter Real SineVoltage1.offset(quantity = \"ElectricPotential\", unit = \"V\") = 0.0 \"Voltage offset\"; + parameter Real SineVoltage1.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Time offset\"; + parameter Real SineVoltage1.V(quantity = \"ElectricPotential\", unit = \"V\", start = 1.0) \"Amplitude of sine wave\"; + parameter Real SineVoltage1.phase(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") = 0.0 \"Phase of sine wave\"; + parameter Real SineVoltage1.freqHz(quantity = \"Frequency\", unit = \"Hz\", start = 1.0) \"Frequency of sine wave\"; + output Real SineVoltage1.signalSource.y \"Connector of Real output signal\"; + parameter Real SineVoltage1.signalSource.amplitude = SineVoltage1.V \"Amplitude of sine wave\"; + parameter Real SineVoltage1.signalSource.freqHz(quantity = \"Frequency\", unit = \"Hz\", start = 1.0) = SineVoltage1.freqHz \"Frequency of sine wave\"; + parameter Real SineVoltage1.signalSource.phase(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") = SineVoltage1.phase \"Phase of sine wave\"; + parameter Real SineVoltage1.signalSource.offset = SineVoltage1.offset \"Offset of output signal\"; + parameter Real SineVoltage1.signalSource.startTime(quantity = \"Time\", unit = \"s\") = SineVoltage1.startTime \"Output = offset for time < startTime\"; + protected constant Real SineVoltage1.signalSource.pi = 3.141592653589793; +equation + assert(1.0 + Resistor1.alpha * (Resistor1.T_heatPort - Resistor1.T_ref) >= 0.000000000000001,\"Temperature outside scope of model!\"); + Resistor1.R_actual = Resistor1.R * (1.0 + Resistor1.alpha * (Resistor1.T_heatPort - Resistor1.T_ref)); + Resistor1.v = Resistor1.R_actual * Resistor1.i; + Resistor1.LossPower = Resistor1.v * Resistor1.i; + Resistor1.v = Resistor1.p.v - Resistor1.n.v; + 0.0 = Resistor1.p.i + Resistor1.n.i; + Resistor1.i = Resistor1.p.i; + Resistor1.T_heatPort = Resistor1.T; + Inductor1.L * der(Inductor1.i) = Inductor1.v; + Inductor1.v = Inductor1.p.v - Inductor1.n.v; + 0.0 = Inductor1.p.i + Inductor1.n.i; + Inductor1.i = Inductor1.p.i; + Ground1.p.v = 0.0; + assert(1.0 + Resistor2.alpha * (Resistor2.T_heatPort - Resistor2.T_ref) >= 0.000000000000001,\"Temperature outside scope of model!\"); + Resistor2.R_actual = Resistor2.R * (1.0 + Resistor2.alpha * (Resistor2.T_heatPort - Resistor2.T_ref)); + Resistor2.v = Resistor2.R_actual * Resistor2.i; + Resistor2.LossPower = Resistor2.v * Resistor2.i; + Resistor2.v = Resistor2.p.v - Resistor2.n.v; + 0.0 = Resistor2.p.i + Resistor2.n.i; + Resistor2.i = Resistor2.p.i; + Resistor2.T_heatPort = Resistor2.T; + Capacitor1.i = Capacitor1.C * der(Capacitor1.v); + Capacitor1.v = Capacitor1.p.v - Capacitor1.n.v; + 0.0 = Capacitor1.p.i + Capacitor1.n.i; + Capacitor1.i = Capacitor1.p.i; + SineVoltage1.signalSource.y = SineVoltage1.signalSource.offset + (if time < SineVoltage1.signalSource.startTime then 0.0 else SineVoltage1.signalSource.amplitude * sin(6.283185307179586 * SineVoltage1.signalSource.freqHz * (time - SineVoltage1.signalSource.startTime) + SineVoltage1.signalSource.phase)); + SineVoltage1.v = SineVoltage1.signalSource.y; + SineVoltage1.v = SineVoltage1.p.v - SineVoltage1.n.v; + 0.0 = SineVoltage1.p.i + SineVoltage1.n.i; + SineVoltage1.i = SineVoltage1.p.i; + Resistor1.p.i + Resistor2.p.i + SineVoltage1.p.i = 0.0; + Resistor1.n.i + Inductor1.p.i = 0.0; + Inductor1.n.i + Ground1.p.i + Capacitor1.n.i + SineVoltage1.n.i = 0.0; + Resistor2.n.i + Capacitor1.p.i = 0.0; + Resistor1.p.v = Resistor2.p.v; + Resistor1.p.v = SineVoltage1.p.v; + Inductor1.p.v = Resistor1.n.v; + Capacitor1.p.v = Resistor2.n.v; + Capacitor1.n.v = Ground1.p.v; + Capacitor1.n.v = Inductor1.n.v; + Capacitor1.n.v = SineVoltage1.n.v; +end SimpleCircuit; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Simulate it:</span></p></td></tr></table></body></html> + + + simulate(SimpleCircuit, startTime=0, stopTime=5) + record SimulationResult + messages = "", + simulationTime = 0.32052168997106245 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Plot it:</span></p></td></tr></table></body></html> + + + + + + + plot({Resistor1.i,Resistor2.i}) + [done] + + + + diff --git a/DrModelica/QuickTour/Statement.onb b/DrModelica/QuickTour/Statement.onb new file mode 100644 index 00000000000..4d603b32825 --- /dev/null +++ b/DrModelica/QuickTour/Statement.onb @@ -0,0 +1,203 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Statements</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Summation</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The summation below uses both a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">while</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-loop and an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">if-</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">statement, where </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">size(a,1)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> returns the size of the first dimension of array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in other words the number of rows in array </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> (in this case 1). The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">elseif</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">else</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> parts of if statements are optional. <br /></span></p></td></tr></table></body></html> + + + class Summation + Real sum(start = 0); + Integer n(start = size(a, 1)); + Real a[5] = {1, 3, 6, 9, 12}; +algorithm + while n > 0 loop + if a[n] > 0 then + sum := sum + a[n]; + elseif a[n] > -1 then + sum := sum - a[n] - 1; + else + sum := sum - a[n]; + end if; + n := n - 1; + end while; +end Summation; + {Summation} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Summation</span></p></td></tr></table></body></html> + + + simulate( Summation ) + record SimulationResult + messages = "", + simulationTime = 0.1660030202298205 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + val(sum,1) + 0.0 + + + + + + + plot({sum,a[1]}) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">XPowers</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />When using equations to model the computation of the polynomial it was necessary to introduce an auxliliary vector </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">xpowers</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for storing the different powers of x. Alternatively, the same computation can be expressed as an algorithm including a for loop as below. This can be done without the need for an extra vector, it is enough to use a scalar variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">xpower</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for the most recently computed power of x.<br /></span></p></td></tr></table></body></html> + + + class Xpowers + parameter Real x=10; + Real xpowers[n]; + parameter Integer i=1; + parameter Integer n = 5; +equation + xpowers[1]=1; + for i in 1:n-1 loop + xpowers[i + 1] = xpowers[i]*x; + end for; +end Xpowers; + {Xpowers} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Xpowers</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here the simulation of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">XPowers</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is shown.</span></p></td></tr></table></body></html> + + + simulate( Xpowers ) + record SimulationResult + messages = "", + simulationTime = 0.2638136652384306 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:11pt; color:#000000;">Value at time=0:</span></p></td></tr></table></body></html> + + + val(xpowers[1],0) + 1.0 + + + val(xpowers[2],0) + 10.0 + + + val(xpowers[3],0) + 100.0 + + + val(xpowers[4],0) + 1000.0 + + + val(xpowers[5],0) + 10000.0 + + + + + + + plot({xpowers[1],xpowers[4]}) + [done] + + + + + diff --git a/DrModelica/QuickTour/WhenClause.onb b/DrModelica/QuickTour/WhenClause.onb new file mode 100644 index 00000000000..d237c2910ac --- /dev/null +++ b/DrModelica/QuickTour/WhenClause.onb @@ -0,0 +1,236 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">When-Equations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">When</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations have been introduced in Modelica to express instantaneous equations (equations that are valid only at certain points when specific conditions become </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">). Then equations in the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equation are activated when at least one of the conditions become </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">true</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Bouncing Ball</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A bouncing ball is a good example of a hybrid system for which the when-equation is appropriate when modeled. The motion of the ball is characterized by the variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">height</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> above the ground and the vertical </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">velocity</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">reinit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> equation is a special from of equation that can be used in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">when</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">-equations to define new values for continuous-time state variables of a model at an </span><a href="../DiscreteHybrid/SampleClock.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">event</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + model BouncingBall "The bouncing ball model" + constant Real g = 9.81; // Gravitational acceleration + parameter Real c = 0.9; // Elasticity constant of ball + parameter Real radius = 0.1; // Radius of the ball + Real height(start = 1,fixed=true); // height above ground of ball center + Real velocity(start = 0,fixed=true); // Velocity of the ball +equation + der(height) = velocity; + der(velocity) = -g; + when height <= radius then + reinit(velocity, -c*pre(velocity)); + end when; +end BouncingBall; + {BouncingBall} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:///C:/Users/RAIN1_~1/AppData/Local/Temp/OpenModelica/2.png" width="307" height="176" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A bouncing ball</span></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation 1 of Bouncing Ball </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When we simulate the BouncingBall model from 0 to 8 we see how it bounces </span></p></td></tr></table></body></html> + + + simulate( BouncingBall, stopTime=8 ) + record SimulationResult + resultFile = "BouncingBall_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { height, velocity } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation 2 of Bouncing Ball </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When we Simulate BouncingBall a little further then it bounces faster and faster. Then the simulation fails and it looks like the ball bounces under the floor. This is called the Zeno effect.</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-weight:600; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">An execution of a hybrid system is called Zeno, if it takes infinitely many discrete transitions in a finite time interval. <br /></span></p></td></tr></table></body></html> + + + simulate( BouncingBall, stopTime=20 ) + record SimulationResult + resultFile = "BouncingBall_res.mat", + messages = "stdout | info | Chattering detected around time 8.09896836874..8.13847997633 (100 state events in a row with a total time delta less than the step size 0.04). This can be a performance bottleneck. Use -lv LOG_EVENTS for more information. The zero-crossing was: height <= radius +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + plot( { height, velocity } ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Redeclaration/Annotation.onb b/DrModelica/Redeclaration/Annotation.onb new file mode 100644 index 00000000000..029372dd4cd --- /dev/null +++ b/DrModelica/Redeclaration/Annotation.onb @@ -0,0 +1,389 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Redeclarations of Annotation Choices</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The user interface can suggest reasonable redeclarations, where the string comment in the choice declaration can be used as a textual explanation of a choice. Based on the interactions with the user, the GUI then generates the appropriate Modelica code. The annotation can also be used as a hint to the user doing textual Modelica programming. In order to support this mode of operation, an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">annotation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">choices</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> containing choice elements is predefined to be recognized with certain semantics in Modelica, including recognition of redeclaration statements in the annotation. </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Resistor</span></p></td></tr></table></body></html> + + + class Resistor "Ideal linear electrical Resistor" + extends TwoPin; // Same as OnePort + parameter Real R(unit = "Ohm") "Resistance"; +equation + R*i = v; +end Resistor; // From Modelica.Electrical.Analog.Basic + Ok + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MyResistor</span></p></td></tr></table></body></html> + + + model ReplResistor +replaceable model MyResistor = Resistor + annotation(choices( + choice(redeclare model MyResistor = lib2.Resistor(a={2})), + choice(redeclare model MyResistor = lib2.Resistor) + ) + ); +end ReplResistor; + {ReplResistor} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">If the user would choose the first alternative, the following code might be produced if </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is part of the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the chosen name of the instantiated component is x:</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg'; font-size:12pt; color:#000000;">            MyCircuit x(redeclare MyResistor=lib2.Resistor(a={2}))</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Additional examples of replaceable class declarations with redeclaration choices are shown below.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of ReplResistor</span></p></td></tr></table></body></html> + + + simulate( ReplResistor ) + record SimulationResult + messages = "", + simulationTime = 0.19135014685033438 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Connectors</span></p></td></tr></table></body></html> + + + connector Pin "Pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end Pin; //From Modelica.Electrical.Analog.Interfaces + {Pin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector PositivePin "Positive pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end PositivePin; //From Modelica.Electrical.Analog.Interfaces + {PositivePin} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector NegativePin "Negative pin of an electrical component" + Voltage v "Potential at the pin"; + flow Current i "Current flowing into the pin"; +end NegativePin; //From Modelica.Electrical.Analog.Interfaces + {NegativePin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Components</span></p></td></tr></table></body></html> + + + partial model TwoPin // Same as OnePort in Modelica.Electrical.Analog.Interfaces + "Component with two electrical pins p and n and current i from p to n" + Voltage v "Voltage drop between the two pins (= p.v - n.v)"; + Current i "Current flowing from pin p to pin n"; + PositivePin p; + NegativePin n; +equation + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end TwoPin; + {TwoPin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Replaceable Resistor</span></p></td></tr></table></body></html> + + + model R +replaceable Resistor Load(R=2) + extends TwoPin; + annotation(choices( + choice(redeclare lib2.Resistor Load(a = {2}) ), + choice(redeclare Capacitor Load(L = 3) ))); +end R; + {R} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Friction</span></p></td></tr></table></body></html> + + + model Friction + // ... +end Friction; + {Friction} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model FF +replaceable FrictionFunction a(func = exp) + extends Friction; + annotation(choices( + choice(redeclare ConstantFriction a(c = 1) ), + choice(redeclare TableFriction a(table = "a") ), + choice(redeclare FunctionFriction a(func = exp) ))); +end FF; + {FF} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">KindOfController</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">choices annotation</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not restricted to replaceable elements. It is also applicable to nonreplaceable elements, simple variables and types used for enummerations. For example, consider the following Integer type called </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">KindOfController</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> used to represent a choice of controller in the modeling process out of the following enumeration of three recommended alternatives.<br /></span></p></td></tr></table></body></html> + + + type KindOfController = Integer(min=1, max=3) + annotation(choices( + choice = 1 "P", + choice = 2 "PI", + choice = 3 "PID")); + {KindOfController} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Assume that </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">KindOfController</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used in a model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">KindOfControllerInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> as below:</span></p></td></tr></table></body></html> + + + model KindOfControllerInst + KindOfController x; // Instance of KindOfController +end KindOfControllerInst; + {KindOfControllerInst} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />An interactive choice of the third alternative from a menu containing the alternatives {&quot;P&quot;, &quot;PI&quot;, &quot;PID&quot;} would result in the default value 3 for the instatiated variable x in the following code for an instance a2 of the model A.</span></p></td></tr></table></body></html> + + + class KOCInst + KindOfControllerInst a2(x = 3 "PID"); +end KOCInst; + {KOCInst} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of KindOfController</span></p></td></tr></table></body></html> + + + simulate( KOCInst ) + record SimulationResult + messages = "", + simulationTime = 0.1589437187981993 +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Redeclaration/Exercise1.onb b/DrModelica/Redeclaration/Exercise1.onb new file mode 100644 index 00000000000..00972bad481 --- /dev/null +++ b/DrModelica/Redeclaration/Exercise1.onb @@ -0,0 +1,163 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Using replaceable and redeclare on class Point</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New;">Point</span> is a built-in type in Modelica.</p></body></html> + + + class Point + parameter Real x; + parameter Real y; + parameter Real z; +end Point; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Create a class <span style=" font-family:Courier New;">Redeclaration</span>, containing a Point <span style=" font-family:Courier New;">P</span> as a variable. You should set the values of x, y and z as well.</p></body></html> + + + class Redeclaration + //... +end Redeclaration; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />In the class below you should redeclare <span style=" font-family:Courier New;">P</span> as the type <span style=" font-family:Courier New;">myPoint</span>, which is a subtype of <span style=" font-family:Courier New;">Point</span> (you can write <span style=" font-family:Courier New;">myPoint</span> further below).</p></body></html> + + + class PointRed + +end PointRed; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />You can declare the class <span style=" font-family:Courier New;">myPoint</span> here, below.</p></body></html> + + + + Error occured building AST +Syntax Error + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Hint</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The variable <span style=" font-family:Courier New;">P</span> must be declared replaceable in class <span style=" font-family:Courier New;">Redeclaration</span>.</p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">class Point</p></body></html> + + + class Point + parameter Real x; + parameter Real y; + parameter Real z; +end Point; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">class Redeclaration</p></body></html> + + + class Redeclaration + replaceable Point P(x = 1, y = 2, z = 3); +end Redeclaration; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">class MyPoint</p></body></html> + + + class MyPoint + extends Point(z = 4); +end MyPoint; + Ok + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">class PointRed</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><span style=" font-family:Courier New;">myPoint</span> is a subtype of Point, it changes type and prefix of P</p></body></html> + + + class PointRed + Redeclaration myPoint(redeclare MyPoint P); +end PointRed; + Ok + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Redeclaration and PointRed</p></body></html> + + + simulate( Redeclaration ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; 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;"></p></body></html> + + + simulate( PointRed ); + [done] + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">If you instead had a class MyPoint with z as an Integer. Would that work?</p></body></html> + + + class MyPoint + parameter Real x; + parameter Real y; + parameter Integer z = 4; +end MyPoint; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">No, because then MyPoint would not be a subclass of Point.</p></body></html> + + + + + + diff --git a/DrModelica/Redeclaration/Exercise2.onb b/DrModelica/Redeclaration/Exercise2.onb new file mode 100644 index 00000000000..8e5e2ccf009 --- /dev/null +++ b/DrModelica/Redeclaration/Exercise2.onb @@ -0,0 +1,240 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 2</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Using the Extends Clause in Redeclarations</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The next exercise will test if you know how to use an </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">extends clause</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> when redeclaring.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />First write a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> parameter salt.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /><br />We also need a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Asub</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> , extending </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and having two </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Real</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> parameters: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">pepper</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">basil</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The parameter </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">salt</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> shall be set to 20.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /><br />Then we need a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, containing a variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, which is an instance of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, in which you should set </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">salt</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to 100.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /><br />Write a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AIred</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, extending </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Also, change the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of the component </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AIsub</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and set the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">pepper</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> parameter to 200.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /><br />Write a similar class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AIred</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">2 that instead of extending </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, declares a component of type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. As above, the </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of component </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> should be changed to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AIsub</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Class A</span></p></td></tr></table></body></html> + + + class A + parameter Real salt; +end A; + {A} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Class Asub</span></p></td></tr></table></body></html> + + + class Asub // A2 is a subtype of A + extends A(salt = 20); + parameter Real pepper; + parameter Real basil; +end Asub; + {Asub} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Class AInst</span></p></td></tr></table></body></html> + + + class AInst + replaceable A a(salt = 100); +end AInst; + {AInst} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Class AIred</span></p></td></tr></table></body></html> + + + class AIred + extends AInst(redeclare Asub a(pepper = 200)); // The result after redeclaration is // Asub a(salt = 1, pepper = 200) +end AIred; + {AIred} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Class AIred2</span></p></td></tr></table></body></html> + + + class AIred2 + AInst t(redeclare Asub a(pepper = 200)); +end AIred2; + {AIred2} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of AIred</span></p></td></tr></table></body></html> + + + simulate( AIred ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + + + diff --git a/DrModelica/Redeclaration/Exercise3.onb b/DrModelica/Redeclaration/Exercise3.onb new file mode 100644 index 00000000000..d57326c30c2 --- /dev/null +++ b/DrModelica/Redeclaration/Exercise3.onb @@ -0,0 +1,166 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 3</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">More on redeclaration</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Write a class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MoreRed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that declares two variables </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> being vectors and one variable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> being an </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Integer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Set x to a value.</span></p></td></tr></table></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /><br />Use the class above to redeclare the dimension sizes of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v1 and</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">v2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the type of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">x</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Hint</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">In the redeclaration-statement of the variables, you have to include the term "parameter" so that they, as parameters, can be modified.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Answer - MoreRed</span></p></td></tr></table></body></html> + + + class MoreRed + parameter Real v1[3]; + parameter Real v2[:]; + Integer x = 2; +end MoreRed; + Ok + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Answer MoreRed2</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Notice that you don't need the keyword </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for v1 and v2.</span></p></td></tr></table></body></html> + + + class MoreRed2 = MoreRed(redeclare parameter Integer x, + redeclare parameter Real v1[5], + redeclare parameter Real v2[12]); + Ok + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of MoreRed2</span></p></td></tr></table></body></html> + + + simulate( MoreRed2 ); + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"></p></td></tr></table></body></html> + + + + + + + diff --git a/DrModelica/Redeclaration/Exercise4.onb b/DrModelica/Redeclaration/Exercise4.onb new file mode 100644 index 00000000000..9cb05d5adb2 --- /dev/null +++ b/DrModelica/Redeclaration/Exercise4.onb @@ -0,0 +1,147 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Exercise 4</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Prefix Final</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We have a type Banana. Imagine that you want to make two instances of this banana, lightBanana and swedishBanana.</span></p></td></tr></table></body></html> + + + type Banana = Real(unit = "kg", + final fixed = false); + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Is this allowed? Why / Why not?</span></p></td></tr></table></body></html> + + + class Bananas + Banana lightBanana(unit = "hg"); + Banana swedishBanana(fixed = true); +end Bananas; + Ok + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Hint</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">"fixed" is declared final.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Answer</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class is not correct, since the value of fixed in the type Banana is already set to final.</span></p></td></tr></table></body></html> + + + class Bananas + Banana lightBanana(unit = "hg"); // Correct + Banana swedishBanana(fixed = true); // Error, since fixed is declared final +end Bananas; + Ok + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; 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;"></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:12pt; font-weight:600; color:#000000;">Simulation of Bananas</span></p></td></tr></table></body></html> + + + simulate( Bananas ) + record + resultFile = "Simulation failed. +Too few equations, underdetermined system. The model has 2 variables and 0 equations +" +end record + + + + + + + diff --git a/DrModelica/Redeclaration/Final.onb b/DrModelica/Redeclaration/Final.onb new file mode 100644 index 00000000000..b70dc7836c9 --- /dev/null +++ b/DrModelica/Redeclaration/Final.onb @@ -0,0 +1,321 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Modification Prevention Prefix Final</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simple Example</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A variable declared as final in a member modification cannot be further modified by another modification. All members of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">final</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> member are also </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">final</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, e.g. the fields of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">final</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> member that is a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">record</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">final</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. <br /></span></p></td></tr></table></body></html> + + + type Angle = Real(final quantity = "Angle", + final unit = "rad", + displayUnit = "deg"); + {Angle} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class AngleInst + parameter Angle a1(unit = "deg",fixed=true); // Error, since unit declared as final + parameter Angle a2(displayUnit = "rad", fixed=true); // Fine +end AngleInst; + {AngleInst,Angle} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Angle</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">When we simulate the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">AngleInst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> we see that there is an error, since we try to modify the unit which is declared as final. We also get a warning because </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> do not have any default values.</span></p></td></tr></table></body></html> + + + simulate( AngleInst ) + record SimulationResult + resultFile = "AngleInst_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">More Advanced Example</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here is another, slightly more advanced, example of the use of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">final</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This example invovles a model that is used as a transfer function within a PI controller. </span></p></td></tr></table></body></html> + + + block TransferBlock // Works like a transfer function + parameter Real a[:] = {1, 1} "denominator coefficient vector"; + parameter Real b[:] = {1} "numerator coefficient vector"; +protected + parameter Integer nb(max = na) = size(b, 1); + parameter Integer na = size(a, 1); + parameter Integer n = na - 1; + parameter Real[n] x "State vector"; + parameter Real[na] b0 = cat(1, zeros(na - nb), b); +end TransferBlock; + {TransferBlock} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model PI "PI controller" + parameter Real k = 1 "gain"; + parameter Real T = 1 "time constant"; + TransferBlock tf(final a = {T, 0}, final b = {T, 1}); +end PI; + {PI,TransferBlock} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model Test + PI c1(k = 2, T = 3); // Fine + PI c2(tf.b = {1}); // Error: b is declared as final +end Test; + {Test,PI,TransferBlock} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model Test2 + PI c1(k = 2, T = 3); // Fine +end Test2; + {Test2,Test,PI,TransferBlock} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of PI</span></p></td></tr></table></body></html> + + + simulate( TransferBlock ) + record SimulationResult + resultFile = "TransferBlock_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"Warning: Assuming fixed start value for the following 1 variables: + x[1]:VARIABLE(protected = true ) "State vector".TransferBlock, .Real type: Real [1] +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + simulate( PI ) + record SimulationResult + resultFile = "PI_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"Warning: Assuming fixed start value for the following 1 variables: + tf.x[1]:VARIABLE(protected = true ) "State vector".PI, .TransferBlock, .Real type: Real [1] +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + simulate( Test2 ) + record SimulationResult + resultFile = "Test2_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"Warning: Assuming fixed start value for the following 1 variables: + c1.tf.x[1]:VARIABLE(protected = true ) "State vector".Test2, .PI, .TransferBlock, .Real type: Real [1] +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We see in the simulation of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Test</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> that an error occurs because we try to modify b, which is declared as final.</span></p></td></tr></table></body></html> + + + simulate( Test ) + record SimulationResult + resultFile = "Test_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"Warning: Assuming fixed start value for the following 2 variables: + c1.tf.x[1]:VARIABLE(protected = true ) "State vector".Test, .PI, .TransferBlock, .Real type: Real [1] + c2.tf.x[1]:VARIABLE(protected = true ) "State vector".Test, .PI, .TransferBlock, .Real type: Real [1] +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Redeclaration/RedNotRepl.onb b/DrModelica/Redeclaration/RedNotRepl.onb new file mode 100644 index 00000000000..da5484b2767 --- /dev/null +++ b/DrModelica/Redeclaration/RedNotRepl.onb @@ -0,0 +1,104 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Redeclaration of Elements not Declared Replaceable</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />There are only two kinds of redeclarations that do not require the modified element to be declared replaceable: restricting the variability of a declared variable, e.g. from parameter to constant or restricting array dimension sizes, e.g. from (:) to a specified size. The following examples demonstrates these kinds of redeclarations.<br /></span></p></td></tr></table></body></html> + + + class C3 + Real x1; + parameter Real vec[:]; +end C3; + {C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + class C4 = C3(redeclare parameter Real x1, redeclare parameter Real vec[20]); + {C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br /></span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C4</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is equivalent to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">C4expanded</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below.</span></p></td></tr></table></body></html> + + + class C4Expanded + parameter Real x1; + parameter Real vec[20]; +end C4Expanded; + {C4Expanded,C4,C3} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of C4</span></p></td></tr></table></body></html> + + + simulate( C4 ) + record SimulationResult + resultFile = "", + messages = "Simulation failed for model: C4 +[<interactive>:1:1-1:76:writable] Notification: From here: +[<interactive>:2:3-2:10:writable] Error: Trying to redeclare component x1 but component not declared as replaceable. +Error: Error occurred while flattening model C4 +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/Redeclaration/Redeclaration.onb b/DrModelica/Redeclaration/Redeclaration.onb new file mode 100644 index 00000000000..bffc8357298 --- /dev/null +++ b/DrModelica/Redeclaration/Redeclaration.onb @@ -0,0 +1,292 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Redeclaration</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />By using the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">redeclare</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> it is possible to modify the type and/or the prefixes and possibly the dimension sizes of a declared element. This kind of modification is called a redeclaration. In most cases a declaration that can be redeclared must include the prefix </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /><br />The element in a redeclaration must have a type that is either a subtype of the replaceable element in the modified class or a subtype of a constraining type. An example is shown below with the concepts of redeclaration.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connector Classes</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin,Current,Voltage,C4Expanded,C4,C3} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Resistor and TempResistor</span></p></td></tr></table></body></html> + + + model Resistor + Pin p, n "Positive and Negative Pins"; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance"; +equation + v = R*i; +end Resistor; + {Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model TempResistor "Temperature dependent Resistor" + Pin p, n "Positive and Negative Pins"; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance at reference Temperature"; + parameter Real RT(unit = "Ohm/degC") = 0 "Temperature dependent Resistance"; + parameter Real Tref(unit = "degC") = 20 "Reference Temperature"; + Real Temp = 20 "Actual Temperature"; +equation + v = i*(R + RT*(Temp - Tref)); +end TempResistor; + {TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MiniCircuit</span></p></td></tr></table></body></html> + + + class MiniCircuit + replaceable discrete Resistor R1; +end MiniCircuit; + {MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The redeclaration of the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">R1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> element changes its type from </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResisto</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">r and its prefix from discrete to parameter. </span></p></td></tr></table></body></html> + + + class MiniCircuitRed + MiniCircuit tempcircuit(redeclare parameter TempResistor R1); +end MiniCircuitRed; + {MiniCircuitRed,MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The MiniCircuitRed class can be rewritten as the MiniCircuit2</span></p></td></tr></table></body></html> + + + class MiniCircuit2 + parameter TempResistor R1; +end MiniCircuit2; + {MiniCircuit2,MiniCircuitRed,MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Redeclaration with Extends Clause</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The next example illustrates a redeclaration used in an </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">extends clause</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class RedA + parameter Real x; +end RedA; + {RedA,MiniCircuit2,MiniCircuitRed,MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class RedA2 // A2 is a subtype of A + parameter Real x = 3.14; + parameter Real y; +end RedA2; + {RedA2,RedA,MiniCircuit2,MiniCircuitRed,MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class RedB + replaceable RedA a(x = 1); +end RedB; + {RedB,RedA2,RedA,MiniCircuit2,MiniCircuitRed,MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The redeclaration </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">redeclare RedA2 a(y=2)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used in an extends clause to replace the original declaration Red</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A a(x=1)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> from class RedB, but merging the original nested modifier </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">(x=1)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with the modifiers in the redeclaration to effectively get Red</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">A2 a(x=1,y=2)</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. The type of the redeclared field </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">a</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in class RedB is changed from RedA to RedA2 in class RedB2 which is correct since RedA2 is a subtype of RedA.<br /></span></p></td></tr></table></body></html> + + + class RedB2 + extends RedB(redeclare RedA2 a(y = 2)); // The result after redeclaration is RedA2 a(x = 1, y = 2) +end RedB2; + {RedB2,RedB,RedA2,RedA,MiniCircuit2,MiniCircuitRed,MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The class RedB, is equivalent to the class B2expanded below.</span></p></td></tr></table></body></html> + + + class B2expanded + RedA2 a(x = 1, y = 2); +end B2expanded; + {B2expanded,RedB2,RedB,RedA2,RedA,MiniCircuit2,MiniCircuitRed,MiniCircuit,TempResistor,Resistor,Pin,Current,Voltage,C4Expanded,C4,C3} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Flattening RedB, B2expanded</span></p></td></tr></table></body></html> + + + instantiateModel(RedB2) + "class RedB2 + parameter Real a.x = 1.0; + parameter Real a.y = 2.0; +end RedB2; +" + + + instantiateModel(B2expanded) + "class B2expanded + parameter Real a.x = 1.0; + parameter Real a.y = 2.0; +end B2expanded; +" + + + + + + diff --git a/DrModelica/Redeclaration/ReplRed.onb b/DrModelica/Redeclaration/ReplRed.onb new file mode 100644 index 00000000000..5981a6de95e --- /dev/null +++ b/DrModelica/Redeclaration/ReplRed.onb @@ -0,0 +1,331 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Modification Prefix Replaceable and Redeclare</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Replaceable</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A declared element of a class must have the prefix replaceable in order to be redeclared, apart from redeclarations that only change the attribute value and/or restricts the variability and possibly the dimension sizes. The main motivation for this rule is that a class needs to be </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">designed</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for inheritance that includes redeclaration. Otherwise unexpected errors may occur. <br /></span></p></td></tr></table></body></html> + + + class MicroCircuit + replaceable Resistor R1 (R = 4.0); +end MicroCircuit; + {MicroCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connector Classes</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current,Voltage,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin,Current,Voltage,MicroCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Resistor and TempResistor</span></p></td></tr></table></body></html> + + + model Resistor + Pin p, n "Positive and Negative Pins"; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance"; +equation + v = R*i; +end Resistor; + {Resistor,Pin,Current,Voltage,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model TempResistor "Temperature dependent Resistor" + Pin p, n "Positive and Negative Pins"; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance at reference Temperature"; + parameter Real RT(unit = "Ohm/degC") = 0 "Temperature dependent Resistance"; + parameter Real Tref(unit = "degC") = 20 "Reference Temperature"; + Real Temp = 20 "Actual Temperature"; +equation + v = i*(R + RT*(Temp - Tref)); +end TempResistor; + {TempResistor,Resistor,Pin,Current,Voltage,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + model SuperTempResistor "Temperature dependent Resistor" + Pin p, n "Positive and Negative Pins"; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance at reference Temperature"; + parameter Real RT(unit = "Ohm/degC") = 0 "Temperature dependent Resistance"; + parameter Real Tref(unit = "degC") = 20 "Reference Temperature"; + Real Temp = 20 "Actual Temperature"; + parameter Boolean Super = true; +equation + v = i*(R + RT*(Temp - Tref)); +end SuperTempResistor; + {SuperTempResistor,TempResistor,Resistor,Pin,Current,Voltage,MicroCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Redeclare</span></p></td></tr></table></body></html> + Redeclare + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">redeclare</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> prefix is used at the front of a modifier containing a new variable or type declaration</span><span style=" font-family:'TimesNewRoman'; font-size:12pt; color:#000000;"> t</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">hat </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">replaces</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> the original variable or type declaration element in the modified class.The reason for requiring a special keyword like </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">redeclare</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is to reduce the risk for accidental programming errors that otherwise might occur when whole declarations are replaced by declarations of different types. <br /></span></p></td></tr></table></body></html> + + + class TempMicroCiruit = MicroCircuit(redeclare TempResistor R1); + {TempMicroCiruit,SuperTempResistor,TempResistor,Resistor,Pin,Current,Voltage,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In order to allow further redeclaration of a redeclared element the replaceable prefix should be present also in the modifier.</span></p></td></tr></table></body></html> + + + class TempMicroCiruit2 = MicroCircuit(redeclare replaceable TempResistor R1); + {TempMicroCiruit2,TempMicroCiruit,SuperTempResistor,TempResistor,Resistor,Pin,Current,Voltage,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">SuperTempMicroCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is left out, which means that no further redeclaration is possible.</span></p></td></tr></table></body></html> + + + class SuperTempMicroCiruit = TempMicroCiruit2(redeclare SuperTempResistor R1); + {SuperTempMicroCiruit,TempMicroCiruit2,TempMicroCiruit,SuperTempResistor,TempResistor,Resistor,Pin,Current,Voltage,MicroCircuit} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Flattening of MicroCircuit, TempMicroCiruit2</span></p></td></tr></table></body></html> + + + + instantiateModel(MicroCircuit) + "class MicroCircuit + Real R1.p.v(unit = \"V\"); + Real R1.p.i(unit = \"A\"); + Real R1.n.v(unit = \"V\"); + Real R1.n.i(unit = \"A\"); + Real R1.v(unit = \"V\"); + Real R1.i(unit = \"A\"); + parameter Real R1.R(unit = \"Ohm\") = 4.0 \"Resistance\"; +equation + R1.v = R1.R * R1.i; + R1.p.i = 0.0; + R1.n.i = 0.0; +end MicroCircuit; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + False + False + + + + + instantiateModel(TempMicroCiruit2) + "class TempMicroCiruit2 + Real R1.p.v(unit = \"V\"); + Real R1.p.i(unit = \"A\"); + Real R1.n.v(unit = \"V\"); + Real R1.n.i(unit = \"A\"); + Real R1.v(unit = \"V\"); + Real R1.i(unit = \"A\"); + parameter Real R1.R(unit = \"Ohm\") = 4.0 \"Resistance at reference Temperature\"; + parameter Real R1.RT(unit = \"Ohm/degC\") = 0.0 \"Temperature dependent Resistance\"; + parameter Real R1.Tref(unit = \"degC\") = 20.0 \"Reference Temperature\"; + Real R1.Temp = 20.0 \"Actual Temperature\"; +equation + R1.v = R1.i * (R1.R + R1.RT * (R1.Temp - R1.Tref)); + R1.p.i = 0.0; + R1.n.i = 0.0; +end TempMicroCiruit2; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + False + False + + + + + instantiateModel(SuperTempMicroCiruit) + "class SuperTempMicroCiruit + Real R1.p.v(unit = \"V\"); + Real R1.p.i(unit = \"A\"); + Real R1.n.v(unit = \"V\"); + Real R1.n.i(unit = \"A\"); + Real R1.v(unit = \"V\"); + Real R1.i(unit = \"A\"); + parameter Real R1.R(unit = \"Ohm\") = 4.0 \"Resistance at reference Temperature\"; + parameter Real R1.RT(unit = \"Ohm/degC\") = 0.0 \"Temperature dependent Resistance\"; + parameter Real R1.Tref(unit = \"degC\") = 20.0 \"Reference Temperature\"; + Real R1.Temp = 20.0 \"Actual Temperature\"; + parameter Boolean R1.Super = true; +equation + R1.v = R1.i * (R1.R + R1.RT * (R1.Temp - R1.Tref)); + R1.p.i = 0.0; + R1.n.i = 0.0; +end SuperTempMicroCiruit; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + False + False + + + + + + + diff --git a/DrModelica/Redeclaration/Replaceable.onb b/DrModelica/Redeclaration/Replaceable.onb new file mode 100644 index 00000000000..d2988df3541 --- /dev/null +++ b/DrModelica/Redeclaration/Replaceable.onb @@ -0,0 +1,332 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Constraining Type of Replaceable Elements </span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">General Description</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A declaration of a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> element of a class can represent either a variable (as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">comp1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MicroCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">) or a local class declaration (as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">type CompType = Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in Gen</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MicroCircuit2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">). The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">extends</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> keyword in the second form has nothing to do with inheritance, it is just a reuse of the keyword for a different purpose. It is however recommended to avoid modifiers in the constraining type (the expression after the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">extends</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> keyword).</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MicroCircuit</span></p></td></tr></table></body></html> + + + class MicroCircuit + replaceable Resistor comp1; +end MicroCircuit; + {MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempMicroCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> the instance </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">comp1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is modified to have the type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> instead of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class TempMicroCircuit = MicroCircuit(redeclare TempResistor comp1); + {TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A more generic circuit expressing the same thing as </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempMicroCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class GenMicroCircuit + replaceable type CompType = Resistor; + replaceable CompType comp1; +end GenMicroCircuit; + {GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Type Error, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Inductor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is not subtype of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. By extending </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CompType = Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoPin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> the redeclaration can be successfully done.</span></p></td></tr></table></body></html> + + + class InductorMicroCircuit = + GenMicroCircuit(redeclare type CompType = Inductor); + + {InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Electrical Units</span></p></td></tr></table></body></html> + + + type Voltage = Real(Unit = "V"); + {Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + type Current = Real(Unit = "A"); + {Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connectors</span></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Component TwoPin</span></p></td></tr></table></body></html> + + + partial class TwoPin + "Superclass of elements with two electrical pins" + Pin p, n; + Voltage v; + Current i; +equation + v = p.v - n.v; + p.i + n.i = 0; + i = p.i; +end TwoPin; + {TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Generic MicroCircuit</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">After changing the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">GenMicroCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class there is no problem to define a more specific circuit, e.g. using the component type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Capacitor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + class GenMicroCircuit2 + replaceable type CompType = Resistor extends TwoPin; // No inheritance! + replaceable CompType comp1; +end GenMicroCircuit2; + {GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class CapacitorMicroCircuit = + GenMicroCircuit2(redeclare type CompType = Capacitor); + {CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CapacitorMicroCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has no replaceable </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CompType</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> declaration left since the original replaceable declaration was replaced. Therefore we need to perform a redeclaration with </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">redeclare replaceable</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to be able to perform further modifications. <br /></span></p></td></tr></table></body></html> + + + class GenCapacitorMicroCircuit = + GenMicroCircuit2(redeclare replaceable type CompType = TempCapacitor); + {GenCapacitorMicroCircuit,CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The constraining type of a replaceable redeclaration must be a subtype of the constraining type of the declaration it redeclares. This condition is fulfilled for </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">GenCapacitorMicroCircuit</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> above, since the constraining type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">GenCapacitor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a subtype of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TwoPin</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. Thus the modifier </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">R = 20</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in the definition of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MicroCircuit3</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is propagated to both the declaration and the constraining type, which is apparent in the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MicroCircuit3expanded</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.<br /></span></p></td></tr></table></body></html> + + + class MicroCircuit2 + replaceable TempResistor R1 extends Resistor; +end MicroCircuit2; + {MicroCircuit2,GenCapacitorMicroCircuit,CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MicroCircuit3 = MicroCircuit2(R1 (R = 20)); + {MicroCircuit3,MicroCircuit2,GenCapacitorMicroCircuit,CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MicroCircuit3expanded + replaceable TempResistor R1(R = 20) extends Resistor(R = 20); +end MicroCircuit3expanded; + {MicroCircuit3expanded,MicroCircuit3,MicroCircuit2,GenCapacitorMicroCircuit,CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In an element redeclaration of a replaceable element the modifiers of the replaced constraining type are merged to both the new declaration and to the new constraining type. The modifier </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">R=30</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for the constraining type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below is propagated to the new type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor2</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the new constraining type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">2.<br /></span></p></td></tr></table></body></html> + + + class MicroCircuit4 + replaceable TempResistor R1 extends Resistor(R=30); +end MicroCircuit4; + {MicroCircuit4,MicroCircuit3expanded,MicroCircuit3,MicroCircuit2,GenCapacitorMicroCircuit,CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MicroCircuit5 = + MicroCircuit4(redeclare replaceable TempResistor2 R1 extends Resistor2); + {MicroCircuit5,MicroCircuit4,MicroCircuit3expanded,MicroCircuit3,MicroCircuit2,GenCapacitorMicroCircuit,CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MicroCircuit5expanded + replaceable TempResistor2 R1(R = 30) extends Restistor2(R=30); +end MicroCircuit5expanded; + {MicroCircuit5expanded,MicroCircuit5,MicroCircuit4,MicroCircuit3expanded,MicroCircuit3,MicroCircuit2,GenCapacitorMicroCircuit,CapacitorMicroCircuit,GenMicroCircuit2,TwoPin,Pin,Current,Voltage,InductorMicroCircuit,GenMicroCircuit,TempMicroCircuit,MicroCircuit} + + + + + diff --git a/DrModelica/SystemMod/FlatTank.onb b/DrModelica/SystemMod/FlatTank.onb new file mode 100644 index 00000000000..399b84b3436 --- /dev/null +++ b/DrModelica/SystemMod/FlatTank.onb @@ -0,0 +1,273 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Using the Traditional Approach</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Below, we show how to model a tank system using the traditional approach.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/17.png" width="402" height="128" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAGSAAAAgAgDAAAAFjUf7AAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAAwMDA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXxqxmgAAAAlwSFlzAAALEwAACxMBAJqcGAAABkxJREFUeJztnIuSpCAMRbP8/0dv7XYjSXgIIWigc6ucnlaMkSNcRGcguIwJ3k7AxeVIzMmRmJMjMSdHYk6OxJwciTk5EnNyJObkSMzJkZiTIzEnR2JOjsScHIk5ORJzciTmBNk3jcU1IVaBoKF3zuQYZUjCdBtxJHPiSBT6LUcyJ+YlMOcH8I3hmlDWSuRM3N91VPMSaSz3kmlVvUQaLHqJj9KkMuIljiSp7SXfyzdexvEHfNjRjdM+5Pqo6SXYHK4NQO9eEqsZL3EkSU0vAfRBkJQ2XmUcyZzaXgKASZSRYHeGa8WgsTuSpNv7kmLHhfaExr79CTiSpNv7kn4kMi9pIGkEugYWB7K89RKOBNiKWS+RIzm1ffV4CRrnAqR2wDeGxGw4gTqST/irFACZrCaF/g/O43ecGmw18XbrJWOhVL0E9ZWxFO46qYt9eJGtqTFvBKTDSwZjaXsJY0DdLFY19zi2erPOreklkmDKXhIHyhEJ4I4sUiFrIa1OOS1TFnr4mrwJib1EvOi3ks8XYnLFQoA2EUJDGQ1pOZJ5HqUsOxKQIIGs0EokdMQAqH2Ga8oP9a6o3PCR+IHDNA99JPmPAhLItmoiYSFpPbEceDnBofBXDQkSqCKhE834WgzoVpGsDfyS1kISQgY/v2wYEvmh3lMDiSWNImHDEMGh3tOhSOhukkO9J0dSOdR7kiF5PG1u72ide0mQjWNmxQfBIQ0k+BADWLnRI6nkOyEBktdzXqvXT28YyV5ziAK9fn6DSI4HsgLJYMQykkoQg0D0U9oKyS8AsYqkeKYWm8geQRe1EotA1qS0CZLfAfIgktoMcReSHwLyEJLWjH2HlzzYRBY/iejLYXXEu7RvW8mjfVbfsVBKLyAZ305q874+K0gMX6HkuDsh6a2yCpI/HXoFCTurRTn8f2Z/1SB6HIZnl/FTsuZUJ/TjiLEKvZ1VJJ3TDLM5fN6vQDPOaNIfULmQ3jqsPxAY7VC2aiX5qS1rJbT6G0ho2QxJenowlMA2SBR26AvJkMQuKTWaEP0Wlc2e98fmcRiSm7HFI0hSpeNDJk8JhfW4t9JAYshLapk8iKTlJZ9fyqhSRBUJkQhqCKpfPmtsIIG6l5DLumTvofifcUbfonwQyc3+BpB8Lfqq8ss0Yt/EHKcUMavj0rrmMoAEEO7B0V7Kt24N7yDRj0h5CP6jVD+S2KzSx3i+9I6LbT4BCbveZW9+P4skHI5kxkPGvcSRdEWUe8i9l/BbA2Uk+Y3HGUjkHnLt224aKPdlreQkJFMeEpduJPTNUOmI63AkMx5y7yV5pekmz389A4nCX6E6Et2Ik31W6PYSdZ2KZJpH8I5LNd7MOCstjkQtGpARjHvJZA7VNcVNhWLk3u1aerMQeEln9AGdhSS9ThEUmLyFxOTdO8TU4kaIXxkSMhOOnyoqMOmfUNFVoTqMIPn2QBFJ7JAIElzhBE6JRylzyL71eEm5wWipUB3VAXNlhxU5hEAYQCgjSXuzN3hDgckNkgEveRqJ9g6SkJ8qST0X0K9kx2JNF5h8d4ds/usqwBdHwtYUjIEXriMptRPS9FDbI82oy0sciQRJy0toN1jtuxwJX5Pqm/zoRVLzEtT9QcRd3Me9JF9zDSlwXcq9JJXGSFpMHIlqxDsvQZ/uJU+ErHrJp0eqIHnaSyr7Houk4CXfQTBvJbFj5IsjUY1YZNKRxlovSV1nvDmKK9nUw5j2QFJuJx15LPUSfgA82KDd55A2QTLMIyay1Evo+A74tZOyGIyqrvVeIloWIrlujiD2WzN/M70HEh0mXW8vDOWVxhO8leBCo2c7usMbIXWevaundb2CF67H0eTiicmPRlXLb2FImOYRYMWZxphpJH51ZFmZ4aCasuol6mn16VAkKkzU06plylYNx1DJZHFIq15SzJVTORWJUS+ppDv3X2p2QbKZlyAqhyLZxkt40pLj7oFkIy/JdCoSrTbSdwuvK8HZasuol6hn1SNJ69wDyZ48/kn2l47qWSyIuCsTQb+1C5JNmYiOvAuSTZlItAcSFSbvSNJKZsZrlZDa+q37kgUy6iWORDvifL+lnlafDkWys78fisS9ZE7uJUSnjrh+yUsWJLrCSzRuEF7SmUi2liMxJ0diTha6WEdiTo7EnByJOf0Fj0hwlaIiwFoAAAAASUVORK5CYII= + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A tank system with a tank, a source for liquid, and a controller.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">FlatTank Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FlatTank</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model is a &quot;flat&quot; model of the tank system with no internal hierarchical &quot;system structure&quot; visible, i.e., just a collection of variables and equations that model the system dynamics. The internal system structure consisting of components, interfaces, couplings between the components, etc. is not reflected by this model.<br /></span></p></td></tr></table></body></html> + + + model FlatTank + // Tank related variables and parameters + parameter Real flowLevel(unit = "m3/s") = 0.02; + parameter Real area(unit = "m2") = 1; + parameter Real flowGain(unit = "m2/s") = 0.05; + Real h(start = 0, fixed=true,unit = "m") "Tank level"; + Real qInflow(unit = "m3/s") "Flow through input valve"; + Real qOutflow(unit = "m3/s") "Flow through output valve"; + + // Controller related variables and parameters + parameter Real K = 2 "Gain"; + parameter Real T(unit = "s") = 10 "Time constant"; + parameter Real minV = 0, maxV = 10; // Limits for flow output + Real ref = 0.25 "Reference level for control"; + Real error "Deviation from reference level"; + Real outCtr "Control signal without limiter"; + Real x(fixed=true) "State variable for controller"; + +equation + assert(minV>=0, "minV must be greater or equal to zero"); + der(h) = (qInflow - qOutflow)/area; // Mass balance equation + qInflow = if time > 150 then 3*flowLevel else flowLevel; + qOutflow = limitValue(minV, maxV, -flowGain*outCtr); + error = ref - h; + der(x) = error/T; + outCtr = K*(error + x); +end FlatTank; + {FlatTank} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">The limitValue Function</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">limiter function</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is needed in the model to reflect minimum and maximum flows through the output valve:</span></p></td></tr></table></body></html> + + + function limitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; + algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end limitValue; + {limitValue} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Examples of Calling limitValue</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Three calls. a) 6 is between 4 and 10; b) 3 is less than 4 which is returned; c) 12 is greater than 10 which is returned.</span></p></td></tr></table></body></html> + + + limitValue(4, 10, 6) + 6.0 + + + limitValue(4, 10, 3) + 4.0 + + + limitValue(1, 10, 12) + 10.0 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Take a Look at the Flattened FlatTank Class</span></p></td></tr></table></body></html> + + + instantiateModel(FlatTank) + "fclass FlatTank +parameter Real flowLevel(unit = "m3/s") = 0.02; +parameter Real area(unit = "m2") = 1; +parameter Real flowGain(unit = "m2/s") = 0.05; +Real h(unit = "m", start = 0.0) "Tank level"; +Real qInflow(unit = "m3/s") "Flow through input valve"; +Real qOutflow(unit = "m3/s") "Flow through output valve"; +parameter Real K = 2 "Gain"; +parameter Real T(unit = "s") = 10 "Time constant"; +parameter Real minV = 0; +parameter Real maxV = 10; +Real ref = 0.25 "Reference level for control"; +Real error "Deviation from reference level"; +Real outCtr "Control signal without limiter"; +Real x "State variable for controller"; +equation +assert(minV >= 0.0,"minV must be greater or equal to zero"); + der(h) = (qInflow - qOutflow) / area; + qInflow = if time > 150.0 then 3.0 * flowLevel else flowLevel; + qOutflow = limitValue(minV,maxV,(-flowGain) * outCtr); + error = ref - h; + der(x) = error / T; + outCtr = K * (error + x); +end FlatTank; +" + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of FlatTank</span></p></td></tr></table></body></html> + + + simulate( FlatTank, stopTime=250 ) + record SimulationResult + resultFile = "FlatTank_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + + plot( h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:12pt; font-weight:600; color:#000000;">Diagram 1:</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;"> Simulation of the FlatTank model with plot of the tank level.<br /></span></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/SystemMod/PIControl.onb b/DrModelica/SystemMod/PIControl.onb new file mode 100644 index 00000000000..76948a6a919 --- /dev/null +++ b/DrModelica/SystemMod/PIControl.onb @@ -0,0 +1,704 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Using the Object Oriented Component-Based Approach</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank System with a Continuous PI Controller</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Now we show the tank model using the object oriented component-based approach. The structure of the tank system model using this approach is clearly visible in Figure 1 below.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/14.png" width="265" height="141" /></p></td></tr></table></body></html> + AAAAAYlQTkcNChoKAAAADUlIRFIAAAEJAAAAjQgDAAAAk+B/LAAAAANzQklUCAgI2+FP4AAAAwBQTFRFAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZ3bsYwAAAAlwSFlzAAALEwAACxMBAJqcGAAABHpJREFUeJztnI2SqyAMhcP7v/SdveVAglgBiag9Z6ZbTTGBT/4UXQnUR7I6A7cRSUAkAZEERBKQBKE+Yq2IIgmIJCCSgEgCIgmIJCCSgJaQSHOZ2i86Rdy6JlNLSPwVsD7TR7EjBWXxz9Sa1rFXvt8l8an8/2f9Eu2S9n6JhKChqMJHIuggfoREiJ0kPmFb/l8hEeuCIlG2iR8hoSkkAmlHp/TP0RoSuRGoGyW5t1SzjXfPJ24pkoBIAiIJiCQgkoBIAiIJiCQgkoBIAiIJiCQgkoBIAppNYilXeyujMysFic6nUGr+1kls/JMkeiPrXYneLrvNtA2dcXRnYh4JSbfo7bnpq2ZDVTKHViTW1YkcviDRl6GR8LrkJHEvEvXW0ZehkfBYGYBRt5YOd2MkKs0195hlNn2kh4nUVeusXNNj1ku6GU2+Dbjj2uk1TzrdkJC0JpPOrmQ7gn/PQlOiM5nu89t0IjYkUuH1Tmk4JiGeTaSfRAOLWp1AiAILfJYk9sf7O5E4ZFHrJ+xAZEm0ZeY6EmNTsbrTg9ahh6cnt46BOqF7zDg8GcMje8yhfmJiZm5Doi3RtJnVaKImU7/fXk28Kh9MNUCiJ1WzlpMw3Q8esmpy/jYSQRc9DlTS5PuVJPCdhvAW1+8koSYgeSCfEr5Zs+/o9mdYtp87tA4HNZKQV5NonHQEzGXtVP+k3+7MupKobN3W7ztIzHD/AhKTGskIieah5QoS07qLIRL9Cd1IDGnH6bNJhIHW8VoSoX9lo259AYnhw63Vk4THDOi83wUkBlJf4XgqiY6eypmE/luPd2yI1lESsu+0Ie4EKQZfpy6uJMy0SfSLnmJWVY8upU4pB0IpJL5Xl69vzZ+UbK9UI1mI14/wm4LbHWTPSYqHupLdbGky+ZCZJEJ+67cMpk6At3LBVXPJdcKSyIfUHJ0gUboXvXEliXwyyvhXkJC8udc6uj0PSBGwWdCrup4kUt3LvVHupEJQ58hZ+vFDMa+nGxp6xXoqiUeLJCCSgEgCIgmIJCCSgEgCIgmIJCCSgEgCWkXC+U7NgJaR6Pbv7Zgkvh9IEtlKErCSBKwkAStJwEoSsJIErCQBqyOJ6sz4sxyxF7fN97kp9woSO4fEtZlhv7uOe4+2VgcS6UX3+iGyNbX5raS8PYnNi8afUFJGxCqdqCcfsBfSWnzAXt3xnPy7kbALoxJQvPLRXYOg2MvGkBiWJKZdzl/4tHIq2sbc/HXQ7E7JZW0f4L+SMKbWrzCjdexk2olEdJ7DpEquilV5vKH4EpMktbjHkMjO9RZ6Qcmo8l78oFlhD0lCsj+FhHVmO6mJgWq9n+0JR8YBRxLWNLvyyWZP9n5sczcrg6kVS/3s7I1e4wHLwGaQ6Q42jUQa8M+fnY6IJnDZ3/a6m0girCKxqRMkcRcSC1uHmaitJWEeHb+ShP3HOkE9hNnrznFmFSM8wzFJZHckAXckAXckAXckAXfuJNw0OZ/uJJ4ikoBIAiIJiCQgkoBIAiIJiCQgkoBIAhLH64Jn6R/8job/e4gQRgAAAABJRU5ErkJggg== + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> A tank system with a continuous PI controller and a source for liquid.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The three components of the tank system: the tank, the PI controller and the source of liquid are explicit in Figure 1 and in the declaration of the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TankPI</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> below. Tank instances of t</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">ank</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">source</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">piContinuous</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are connected to controllers and liquid sources through their connectors.<br /></span></p></td></tr></table></body></html> + + + model TankPI + LiquidSource source(flowLevel=0.02); + PIcontinuousController piContinuous(ref=0.25); + Tank tank(area=1); +equation + connect(source.qOut, tank.qIn); + connect(tank.tActuator, piContinuous.cOut); + connect(tank.tSensor, piContinuous.cIn); +end TankPI; + {TankPI} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The tank has four connectors: </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">qIn</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for input flow, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">qOut</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for output flow, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">tSensor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for providing fluid level measurements, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">tActuator</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> for setting the position of the valve at the outlet of the tank.<br /><br />The central equation regulating the behavior of the tank is the mass balance equation, which in the current simple form assumes constant pressure. The output flow is related to the valve position by a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">flowGain</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> parameter, and by a limiter that guarantees that the flow does not exceed what corresponds to the open/closed positions of the valve.<br /></span></p></td></tr></table></body></html> + + + model Tank + ReadSignal tSensor "Connector, sensor reading tank level (m)"; + ActSignal tActuator "Connector, actuator controlling input flow"; + LiquidFlow qIn "Connector, flow (m3/s) through input valve"; + LiquidFlow qOut "Connector, flow (m3/s) through output valve"; + parameter Real area(unit = "m2") = 0.5; + parameter Real flowGain(unit = "m2/s") = 0.05; + parameter Real minV= 0, maxV = 10; // Limits for output valve flow + Real h(start = 0.0,fixed=true, unit = "m") "Tank level"; + equation + assert(minV>=0,"minV - minimum Valve level must be >= 0 "); + der(h) = (qIn.lflow - qOut.lflow)/area; // Mass balance equation + qOut.lflow = limitValue(minV, maxV, -flowGain*tActuator.act); + tSensor.val = h; +end Tank; + {Tank} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">limitValue</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A limiter function is needed in the model to reflect minimum and maximum flows through the output valve:</span></p></td></tr></table></body></html> + + + function limitValue + input Real pMin; + input Real pMax; + input Real p; + output Real pLim; + algorithm + pLim := if p>pMax then pMax + else if p<pMin then pMin + else p; +end limitValue; + {limitValue} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Connectors</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">As already stated, the tank has four connectors. These are instances of the following three connector classes:</span></p></td></tr></table></body></html> + + + connector ReadSignal "Reading fluid level" + Real val(unit = "m"); +end ReadSignal; + {ReadSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector ActSignal "Signal to actuator for setting valve position" + Real act; +end ActSignal; + {ActSignal} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector LiquidFlow "Liquid flow at inlets or outlets" + Real lflow(unit = "m3/s"); +end LiquidFlow; + {LiquidFlow} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">LiquidSource</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The fluid entering the tank must come from somewhere. Therefore we have a liquid source component in the tank system. The flow increases sharply at time = 150 to factor of three of the previous flow level, which creates an interesting control problem that the controller of the tank has to handle.<br /></span></p></td></tr></table></body></html> + + + model LiquidSource + LiquidFlow qOut; + parameter Real flowLevel = 0.02; +equation + qOut.lflow = if time > 150 then 3*flowLevel else flowLevel; +end LiquidSource; + {LiquidSource} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">PIcontinuousController</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The controller needs to be specified. We will initially choose a PI controller but later replace this by other kinds of controllers. </span></p></td></tr></table></body></html> + + + model PIcontinuousController + extends BaseController(K = 2, T = 10); + Real x (fixed=true) "State variable of continuous PI controller"; +equation + der(x) = error/T; + outCtr = K*(error + x); +end PIcontinuousController; + {PIcontinuousController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">BaseController</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Both the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PI controller</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PID controller</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> to be defined later inherit the partial controller class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">BaseController</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, containing common parameters, state variables, and two connectors: one to read the sensor and one to control the valve actuator.<br /></span></p></td></tr></table></body></html> + + + partial model BaseController + parameter Real Ts(unit = "s") = 0.1 "Time period between discrete samples"; + parameter Real K = 2 "Gain"; + parameter Real T(unit = "s") = 10 "Time constant"; + ReadSignal cIn "Input sensor level, connector"; + ActSignal cOut "Control to actuator, connector"; + parameter Real ref "Reference level"; + Real error "Deviation from reference level"; + Real outCtr "Output control signal"; +equation + error = ref - cIn.val; + cOut.act = outCtr; +end BaseController; + {BaseController} + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of TankPI</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TankPI</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model and obtain the same response as for the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">FlatTank</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> model, which is not surprising given that both models have the same basic equations. <br /></span></p></td></tr></table></body></html> + + + simulate( TankPI, stopTime=250 ) + record SimulationResult + resultFile = "TankPI_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tank.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Tank with PID Continuous Controller</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We define a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TankPID</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> system which is the same as the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TankPI</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> system except that the PI controller has been the replaced by a PID controller. Here we see a clear advantage of the object oriented component-based approach over the traditional modeling approach, since system components can easily be replaced and changed in a plug-and-play manner.<br /></span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/15.png" width="262" height="141" /></p></td></tr></table></body></html> + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The tank system with the PI controller replaced by a PID controller.</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The Modelica class declaration for the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TankPID</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> system appears as follows:</span></p></td></tr></table></body></html> + + + model TankPID + LiquidSource source(flowLevel = 0.02); + PIDcontinuousController pidContinuous(ref = 0.25); + Tank tank(area = 1); +equation + connect(source.qOut, tank.qIn); + connect(tank.tActuator, pidContinuous.cOut); + connect(tank.tSensor, pidContinuous.cIn); +end TankPID; + {TankPID} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We create a </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">PIDcontinuousController</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> class in Modelica containing the three defining equations:</span></p></td></tr></table></body></html> + + + model PIDcontinuousController + extends BaseController(K = 2, T = 10); + Real x(fixed=true); // State variable of continuous PID controller + Real y; // State variable of continuous PID controller +equation + der(x) = error/T; + y = T*der(error); + outCtr = K*(error + x + y); +end PIDcontinuousController; + {PIDcontinuousController} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of TankPID</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">We simulate the tank model once more but now including the PID controller:</span></p></td></tr></table></body></html> + + + simulate( TankPID, stopTime=250 ) + record SimulationResult + resultFile = "TankPID_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +Warning: Iteration variables with default zero start attribute in torn nonlinearequation system: + pidContinuous.outCtr:VARIABLE() "Output control signal".TankPID, .PIDcontinuousController, .Real type: Real +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + plot( tank.h ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Two Tanks Connected Together</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src="file:////tmp/OpenModelica/16.png" width="474" height="148" /></p></td></tr></table></body></html> + False + False + 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 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Two connected tanks with PI controllers and a source for liquid connected to the first tank. </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The Modelica model </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TanksConnectedPI</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> corresponding to Figure 3 appears as follows:</span></p></td></tr></table></body></html> + + + model TanksConnectedPI + LiquidSource source(flowLevel = 0.02); + Tank tank1(area = 1); + Tank tank2(area = 1.3); + PIcontinuousController piContinuous1(ref = 0.25); + PIcontinuousController piContinuous2(ref = 0.4); + equation + connect(source.qOut,tank1.qIn); + connect(tank1.tActuator,piContinuous1.cOut); + connect(tank1.tSensor,piContinuous1.cIn); + connect(tank1.qOut,tank2.qIn); + connect(tank2.tActuator,piContinuous2.cOut); + connect(tank2.tSensor,piContinuous2.cIn); +end TanksConnectedPI; + {TanksConnectedPI} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />We simulate the connected tank system. We clearly see the tank level responses of the first and second tank to the changes in fluid flow from the source, where the response from the first tank of course appears earlier in time than the response of the second tank.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of TanksConnectedPI</span></p></td></tr></table></body></html> + + + simulate( TanksConnectedPI, stopTime=400 ) + record SimulationResult + resultFile = "TanksConnectedPI_res.mat", + messages = "" +end SimulationResult; +OMC-ERROR: +"[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .LiquidFlow is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:15:writable] Warning: Connector .ReadSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +[<interactive>:1:1-3:14:writable] Warning: Connector .ActSignal is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0). +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:11pt; color:#000000;"><br /></p></td></tr></table></body></html> + + + + + + + plot( {tank1.h,tank2.h} ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + + diff --git a/DrModelica/TypeSubtype/Exercise1.onb b/DrModelica/TypeSubtype/Exercise1.onb new file mode 100644 index 00000000000..03f011ea607 --- /dev/null +++ b/DrModelica/TypeSubtype/Exercise1.onb @@ -0,0 +1,49 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1 - Record</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Creating a Record</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br />Create a record, Dog, with the values nrOfLegs, which is an Integer and name, which is a String. Give the variables some values.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + record Dog + Integer nrOfLegs = 4; + String name = "dog"; +end Dog; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Dog</p></body></html> + + + simulate( Dog ) //??Error - not yet implemented + record + resultFile = "Simulation failed. +" +end record + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/TypeSubtype/Exercise2.onb b/DrModelica/TypeSubtype/Exercise2.onb new file mode 100644 index 00000000000..e0226f3746a --- /dev/null +++ b/DrModelica/TypeSubtype/Exercise2.onb @@ -0,0 +1,106 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2 - Subtype and Supertype</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a type?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A type can conceptually be viewed as a set of values. If x has the type Real, this means that x belongs to the set of values represented by the type Real.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a subtype?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The subtype relation between types is analogous to the subset relation between sets. If a type A1 is a subtype of A, the set of values corresponding to type A1 is a subset of the set of values corresponding to type A. </p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a supertype?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">The supertype relation is the inverse of the subtype relation.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Subtype and Supertype</p></body></html> + + + class House + Real length; + Real width; +end House; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;"><br /><br />Define a class <span style=" font-family:Courier New;">Room</span> that is a Subtype of the class House. Which also means that House is a Supertype of Room. Also give the variables some values. </p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Room + Real length = 5; + Real width = 4.3; + Real hieght = 2.1; +end Room; + Ok + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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:12pt; font-weight:600; color:#000000;">Simulation of Room</p></body></html> + + + simulate( Room ); + [done] + + + val(length,1.) + 5.0 + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Courier New; font-size:11pt; color:#000000;"></p></body></html> + + + + + + + diff --git a/DrModelica/TypeSubtype/Sub-SuperType.onb b/DrModelica/TypeSubtype/Sub-SuperType.onb new file mode 100644 index 00000000000..4851396325d --- /dev/null +++ b/DrModelica/TypeSubtype/Sub-SuperType.onb @@ -0,0 +1,142 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Subtype and Supertype</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Connector Classes</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + type Current = Real(unit = "A"); + {Current} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + connector Pin + Voltage v; + flow Current i; +end Pin; + {Pin} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Resistor</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The subtype relation between types is analogous to the subset relation between sets. If we have one type Temperature that contains all temperature values and another type Winter-Temperature that contains only negative temperature values, then we say that Temperature is a supertype of Winter-Temperature. This also implies that Winter-Temperature is a subtype of Temperature.<br /><br />The supertype relation, on the other hand, is the inverse of the subtype relation. Since </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a subtype of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, then </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Resistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is a supertype of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">TempResistor</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. <br /></span></p></td></tr></table></body></html> + + + model Resistor + Pin p, n "Positive and Negative Pins"; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance"; +equation + v = R*i; +end Resistor; + {Resistor} + + + simulate(Resistor) + record SimulationResult + messages = "Simulation failed for model: Resistor +Warning: Parameter R has neither value nor start value, and is fixed during initialization (fixed=true) +Error: Too few equations, underdetermined system. The model has 3 equation(s) and 6 variable(s) +" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + model TempResistor "Temperature dependent Resistor" + Pin p, n "Positive and Negative Pins"; + Voltage v; + Current i; + parameter Real R(unit = "Ohm") "Resistance at reference Temperature"; + parameter Real RT(unit = "Ohm/degC") = 0 "Temperature dep. Resistance"; + parameter Real Tref(unit = "degC") = 20 "Reference Temperature"; + Real Temp = 20 "Actual Temperature"; +equation + v = i*(R + RT*(Temp - Tref)); +end TempResistor; + {TempResistor} + + + simulate(TempResistor) + record SimulationResult + messages = "Simulation failed for model: TempResistor +Warning: Parameter R has neither value nor start value, and is fixed during initialization (fixed=true) +Error: Too few equations, underdetermined system. The model has 4 equation(s) and 7 variable(s) +" +end SimulationResult; + + + + + diff --git a/DrModelica/TypeSubtype/Type.onb b/DrModelica/TypeSubtype/Type.onb new file mode 100644 index 00000000000..29742d14991 --- /dev/null +++ b/DrModelica/TypeSubtype/Type.onb @@ -0,0 +1,100 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Type</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />There are several different kinds of types. Record/Class Types and Array Types are described below. Also there are function types and types of classes that contain local classes.</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Record/Class Type</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">record/class type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in Modelica is conceptually the set of all record values of that record type, where each value contains named field values for the fields of that record.</span></p></td></tr></table></body></html> + + + record Person + String name; + Real weight; + Real length; +end Person; + {Person} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Array Type</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">An array type is conceptually a set of array values, where each array value can be considered as a set of pairs (array-element-index, array-value) analogous to the set of pairs (field-name, field value) that make up a record value.<br /></span></p></td></tr></table></body></html> + + + type vector2 = Real[2]; // Vector type with specified dimension size +type vector = Real[:]; // Vector type with unspecified dimension size + {vector2,vector} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; 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;"><br /></p></td></tr></table></body></html> + + + type matrix23 = Real[2, 3]; // Matrix type with specified dimension size +type matrix = Real[:, :]; // Matrix type with unspecified dimension size + {matrix23,matrix} + + + + + diff --git a/DrModelica/Variables/Declaration.onb b/DrModelica/Variables/Declaration.onb new file mode 100644 index 00000000000..a3ceb9b138c --- /dev/null +++ b/DrModelica/Variables/Declaration.onb @@ -0,0 +1,67 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Variable Declaration Structure</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />When declaring variables you do either several single declarations or a multiple declaration. A variable specifier can be a single </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">identifier</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, or an identifier optionally followed by a </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">modifier</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and/or an array dimension descriptor, optionally followed by an </span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;">initializer </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">or</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;"> declaration equation </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">right</span><span style=" font-family:'Times New Roman'; font-size:12pt; font-style:italic; color:#000000;"> </span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">hand side. <br /></span></p></td></tr></table></body></html> + + + class Matrix + Real[2, 2] A; // Single declaration + Real[2, 2] B; // Single declaration +end Matrix; + {Matrix} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The following declaration has the same meaning as the single declaration above.</span></p></td></tr></table></body></html> + + + class Matrix + Real[2, 2] A, B; // Multiple declaration +end Matrix; + {Matrix} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Another way of writing single declarations with the same meaning is shown below. </span></p></td></tr></table></body></html> + + + class Matrix + Real A[2, 2]; + Real B[2, 2]; +end Matrix; + {Matrix} + + + + diff --git a/DrModelica/Variables/Exercise1.onb b/DrModelica/Variables/Exercise1.onb new file mode 100644 index 00000000000..233a29b4a0b --- /dev/null +++ b/DrModelica/Variables/Exercise1.onb @@ -0,0 +1,84 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 1 - Variable Declaration</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a variable?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A variable is a place to store a piece of information. Just as you might store a friend's phone number in your own memory, you can store this information in a computer's memory. Variables are your way of accessing your computer's memory. </p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Which are the two kinds of variables and what is the difference between them?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">There are two different kinds of variables, discrete-time and continuous-time variables. Discrete-time variables change value only at event instants, whereas continuous-time variables may change value both between and at events.</p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">What is a parameter?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">A 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. </p></body></html> + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Declaring Variables</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Define a class <span style=" font-family:Courier New;">Matrices</span> that declares the variables m1, m2, m3, m4 all being matrices with Integers respectively Real numbers. Make at least one of them an array. Let m1 and m2 be parameters, m3 a regular variable and m4 a constant. </p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Matrices + parameter Real m1[2,3]; // A matrix with two rows and three columns + parameter Real m2[5]; // An array with 5 elements + Real m3[1,6]; // Matrix with one row and six columns (six-element array) + constant Real[2,1] m4 = {{4}, {7}}; // Matrix with two rows and one column +end Matrices; + Ok + + + + + + diff --git a/DrModelica/Variables/Exercise2.onb b/DrModelica/Variables/Exercise2.onb new file mode 100644 index 00000000000..184f6ce2f03 --- /dev/null +++ b/DrModelica/Variables/Exercise2.onb @@ -0,0 +1,66 @@ + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Exercise 2 - Initialization of Variables</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Question</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">How can a variable be initialized?</p></body></html> + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">If nothing is specified, the default start value of all numerical variables is zero, apart from function results and function local variables where it is unspecified. In functions you can use an assignment in the declaration to set the default value.</p><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;"> Start values can be specified by setting the start attribute of instance variables using a modifier equation, see the next section.. </p><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;"> You can also set the initial value using a when-equation as below. An event is generated at the start of the simulation by initial(), which activates the initializing equation.</p></body></html> + + + when (initial()) + x_dot = -5; +end when; + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">An initial equation section is a general way of initializing variables. It can also be used for setting initial values of derivatives.</p></body></html> + + + initial equation + x_dot = -5; + der(y) = 10; + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Initializing Variables</p></body></html> + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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;">Declare the variables length1, length2 and length3 of type <span style=" font-family:Courier New;">Real</span> with different initial values. One of the variables should have the value 0. Name the class <span style=" font-family:Courier New;">Variables</span>.</p></body></html> + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><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</p></body></html> + + + class Variables + Real length1(start = 3.5); // Initial value 3.5 + Real length2(start = 2.0); // Initial value 2 + Real length3; // Initial value 0, but you could write (start = 0) if you want to +end Variables; + + + + + + + diff --git a/DrModelica/Variables/FieldVar.onb b/DrModelica/Variables/FieldVar.onb new file mode 100644 index 00000000000..87e6d388a84 --- /dev/null +++ b/DrModelica/Variables/FieldVar.onb @@ -0,0 +1,240 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Fields and Variables</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />In the class </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CelestialBody</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">radius</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">name</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">mass</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> are examples of fields/variables. Every object of the type </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">CelestialBody</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has its own instances of these fields. Changing the mass field in one object will not affect the mass in another object.<br /></span></p></td></tr></table></body></html> + + + class CelestialBody + constant Real g = 6.672e-11; + parameter Real radius; + parameter String name; + Real mass; +end CelestialBody; + {CelestialBody} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Duplicate Field Names</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Duplicate field names is not allowed in class declarations. The name of a declared element must be different from the names of all other declared elements in the class.<br /></span></p></td></tr></table></body></html> + + + class IllegalDuplicate + parameter Real duplicate = 4.0; + parameter Integer duplicate = 6; // Error! Illegal duplicate field name. +end IllegalDuplicate; + Error occured building AST +Syntax Error +[<interactive>:2:3-2:33:writable] Error: An element with name duplicate is already declared in this scope. + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Only the syntax is Ok, but not the semantics, i.e., typing and declarations have not yet been checked.</span></p></td></tr></table></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Simulation of IllegalDuplicate to Perform Checking</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">As we can see when simulating </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">IllegalDuplicate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, the class generates an error for trying to redefine the field </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">duplicate</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">.</span></p></td></tr></table></body></html> + + + simulate(IllegalDuplicate) + + record SimulationResult + messages = "Simulation Failed. Model: IllegalDuplicate does not exist! Please load it first before simulation." +end SimulationResult; + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Identical Field Names and Type Names</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Voltage</span></p></td></tr></table></body></html> + + + type Voltage = Real(unit = "V"); + {Voltage} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">IllegalTypeAsField</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">It is not allowed to have the same name of a field/variable and its type specifier.</span></p></td></tr></table></body></html> + + + class IllegalTypeAsField + Voltage Voltage; // Error! + Voltage voltage; // Legal, Voltage and voltage are two different names +end IllegalTypeAsField; + Error occured building AST +Syntax Error +[<interactive>:2:3-2:18:writable] Error: Found a component with same name when looking for type Voltage + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Checking of IllegalTypeAsField</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Semantic checking is also performed during flattening. As we can see when simulating IllegalTypeAsField we get a warning for trying to name our variable Voltage, which is the same as the type name.</span></p></td></tr></table></body></html> + + + instantiateModel( IllegalTypeAsField ); + +OMC-ERROR: +"Error: Class IllegalTypeAsField not found in scope <TOP>. +" + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:14pt; font-weight:600; color:#000000;">Fixing the Error</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">By changing the name of the first field/variable to voltage1, we fix the problem.</span></p></td></tr></table></body></html> + + + class LegalVoltage + Voltage voltage1; // Legal! + Voltage voltage; // Legal, Voltage and voltage are two different names +end LegalVoltage; + {LegalVoltage} + + + instantiateModel( LegalVoltage ) + "class LegalVoltage + Real voltage1(unit = \"V\"); + Real voltage(unit = \"V\"); +end LegalVoltage; +" + + + simulate(LegalVoltage) + record SimulationResult + messages = "Simulation failed for model: LegalVoltage +Error: Too few equations, underdetermined system. The model has 0 equation(s) and 2 variable(s) +Error: Internal error Transformation Module omc index Reduction Method dummyDerivative failed! +" +end SimulationResult; + + + + + + diff --git a/DrModelica/Variables/Initialization.onb b/DrModelica/Variables/Initialization.onb new file mode 100644 index 00000000000..f127f9a6ce0 --- /dev/null +++ b/DrModelica/Variables/Initialization.onb @@ -0,0 +1,273 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Initial Values of Variables</span></p></td></tr></table></body></html> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Point</span></p></td></tr></table></body></html> + + + class Point "Point in a three-dimensional space" + parameter Real x; + parameter Real y; + parameter Real z; +end Point; + {Point} + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">MyPoints</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">A Modelica variable is either statically allocated and instantiated or is dynamically instantiated. The </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">start</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> value of a variable is the default initial value of the variable. A start value can be specified for the </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Points</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPoints</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. On the other hand, since x, y, and z are parameters, it is not very relevant to specify start values since they are constant. However, we do that anyway.<br /> </span></p></td></tr></table></body></html> + + + class MyPoints + Point point1(x=1,y=2,z=3); + Point point2(x=1,y=2,z=3); + Point point3(x=1,y=2,z=3); +end MyPoints; + {MyPoints} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Flatten MyPoints</span></p></td></tr></table></body></html> + + + instantiateModel(MyPoints) + "class MyPoints + parameter Real point1.x = 1.0; + parameter Real point1.y = 2.0; + parameter Real point1.z = 3.0; + parameter Real point2.x = 1.0; + parameter Real point2.y = 2.0; + parameter Real point2.z = 3.0; + parameter Real point3.x = 1.0; + parameter Real point3.y = 2.0; + parameter Real point3.z = 3.0; +end MyPoints; +" + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of MyPoints</span></p></td></tr></table></body></html> + + + simulate( MyPoints ) + record SimulationResult + resultFile = "MyPoints_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Try to plot the constant parameter point1.x:</span></p></td></tr></table></body></html> + + + + plot(point1.x) + [done] + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Using Modifiers to Set Parameter Values of MyPoints</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Instead of specifying the value of parameters in </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">point1</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> in M</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">yPoints</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> this can be done using modifiers in M</span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">yPoints2Inst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. This can be done in two different ways, which is shown in the classes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPoints2Inst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">MyPoints2Inst</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">2 below.<br /></span></p></td></tr></table></body></html> + + + class MyPoints2 + Point point1; + Point point2; + Point point3; +end MyPoints2; + {MyPoints2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + class MyPoints2Inst + MyPoints2 pts(point1.x = 1, point1.y = 2, point1.z = 3); +end MyPoints2Inst; + {MyPoints2Inst} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Flatten it to observe the result:</span></p></td></tr></table></body></html> + + + instantiateModel(MyPoints2Inst) + "class MyPoints2Inst + parameter Real pts.point1.x = 1.0; + parameter Real pts.point1.y = 2.0; + parameter Real pts.point1.z = 3.0; + parameter Real pts.point2.x; + parameter Real pts.point2.y; + parameter Real pts.point2.z; + parameter Real pts.point3.x; + parameter Real pts.point3.y; + parameter Real pts.point3.z; +end MyPoints2Inst; +" + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Here is another example using nested modifiers</span></p></td></tr></table></body></html> + + + class MyPoints2Inst2 + MyPoints2 pts(point1(x = 1, y = 2, z = 3)); +end MyPoints2Inst2; + {MyPoints2Inst2} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Flatten that one too:</span></p></td></tr></table></body></html> + + + instantiateModel(MyPoints2Inst2) + "class MyPoints2Inst2 + parameter Real pts.point1.x = 1.0; + parameter Real pts.point1.y = 2.0; + parameter Real pts.point1.z = 3.0; + parameter Real pts.point2.x; + parameter Real pts.point2.y; + parameter Real pts.point2.z; + parameter Real pts.point3.x; + parameter Real pts.point3.y; + parameter Real pts.point3.z; +end MyPoints2Inst2; +" + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Arrays </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">The class Arrays below contains a few declarations with different of combinations of array dimension descriptors and modifiers.</span></p></td></tr></table></body></html> + + + class Arrays + Real A3[2,2]; // Array variable + Real A4[2,2](start = {{1,0}, {0,1}}); // Array with explicit start value +end Arrays; + {Arrays} + + + + + diff --git a/DrModelica/Variables/VanDerPol.onb b/DrModelica/Variables/VanDerPol.onb new file mode 100644 index 00000000000..8768e36ac99 --- /dev/null +++ b/DrModelica/Variables/VanDerPol.onb @@ -0,0 +1,94 @@ + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Van der Pol Model</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />This example describes a Van der Pol oscillator. Notice that here the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">model</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> is used instead of </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">class</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> with the same meaning. This example contains declarations of two state variables x and y, both of type Real and a parameter constant lambda, which is a so-called simulation parameter. The keyword parameter specifies that the variable is constant during a simulation run, but can have its value initialized before a run, or between runs. Finally, there is an equation section starting with the keyword equation, containing two mutually dependent equations that define the dynamics of the model.<br /></span></p></td></tr></table></body></html> + + + model VanDerPol "Van der Pol oscillator model" + Real x(start = 1,fixed=true); + Real y(start = 1,fixed=true); + parameter Real lambda = 0.3; +equation + der(x) = y; + der (y) = - x + lambda*(1 - x*x)*y; +end VanDerPol; + {VanDerPol} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times'; font-size:18pt; font-weight:600; color:#000000;">Simulation of Van der Pol </span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">To illustrate the behavior of the model, we give a command to simulate the Van der Pol oscillator during 25 seconds starting at time 0.</span></p></td></tr></table></body></html> + + + simulate(VanDerPol, startTime=0, stopTime=25 ) + record SimulationResult + resultFile = "VanDerPol_res.mat", + messages = "" +end SimulationResult; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">Perform a parametric plot:</span></p></td></tr></table></body></html> + + + + + + plotParametric( x, y ) + [done] + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></td></tr></table></body></html> + + + + diff --git a/DrModelica/Variables/VariabilityPrefixes.onb b/DrModelica/Variables/VariabilityPrefixes.onb new file mode 100644 index 00000000000..af00f693858 --- /dev/null +++ b/DrModelica/Variables/VariabilityPrefixes.onb @@ -0,0 +1,36 @@ + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Variability Prefixes</span></p></td></tr></table></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The prefixes </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">constant, parameter, discrete</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> of a variable declaration are called variability prefixes and define in which situations the value of a variable may change and when it is kept constant. A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">constant</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has the least variability. A </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">parameter</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> has some more variability since it can be changed between simulations. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Discrete</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> variables are variables that change value only at </span><a href="DiscreteHybrid/SampleClock.onb +"><span style=" font-family:'Times New Roman'; font-size:12pt; text-decoration: underline; color:#0000ff;">event instants</span></a><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">. </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Boolean</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">Integer</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;">, and </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">String</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> variables are discrete-time by default. <br /></span></p></td></tr></table></body></html> + + + class VariabilityPref + constant Real PI = 3.14159; + parameter Real p = 36.7; + discrete Boolean bo(start = false); +end VariabilityPref; + {VariabilityPref} + + + +