Skip to content

Commit

Permalink
Improve html code indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tobolar committed May 21, 2024
1 parent 7296373 commit 4a5969b
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 38 deletions.
94 changes: 70 additions & 24 deletions Modelica_LinearSystems2/Utilities/Import/linearize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,75 @@ public
output String stateNames[nx] = xuyName[1:nx] "Modelica names of states";
algorithm

annotation (__Dymola_interactive=true, Documentation(info="<html>
<p>This function initializes a Modelica model and then simulates the model with its default experiment options until time instant \"t_linearize\". If t_linearize=0, no simulation takes place (only initialization). At the simulation stop time, the model is linearized in such a form that </p>
<p><ul>
<li>all top-level signals with prefix \"input\" are treated as inputs <strong>u</strong>(t) of the model ,</li>
<li>all top-level signals with prefix \"output\" are treated as outputs <strong>y</strong>(t) of the model,</li>
<li>all variables that appear differentiated and that are selected as states at this time instant are treated as states <strong>x</strong> of the model.</li>
</ul></p>
<p>Formally, the non-linear hybrid differential-algebraic equation system is therefore treated as the following ordinary equation system at time instant t_linearize: </p>
<pre> der(<strong>x</strong>) = <strong>f</strong>(<strong>x</strong>,<strong>u</strong>)</pre>
<pre> <strong>y</strong> = <strong>g</strong>(<strong>x</strong>,<strong>u</strong>) </pre>
<p>Taylor series expansion (linearization) of this model around the simulation stop time t_linearize: </p>
<pre> <strong>u</strong>0 = <strong>u</strong>(t_linearize)</pre>
<pre> <strong>y</strong>0 = <strong>y</strong>(t_linearize)</pre>
<pre> <strong>x</strong>0 = <strong>x</strong>(t_linearize) </pre>
<p>and neglecting higher order terms results in the following system: </p>
<pre> der(<strong>x</strong>0+d<strong>x</strong>) = <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>f</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>f</strong>,<strong>u</strong>)*d<strong>u</strong></pre>
<pre> <strong>y</strong>0 + d<strong>y</strong> = <strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong></pre>
<p>where der(<strong>f</strong>,<strong>x</strong>) is the partial derivative of <strong>f</strong> with respect to <strong>x</strong>, and the partial derivatives are computed at the linearization point t_linearize. Re-ordering of terms gives (note <strong>der</strong>(<strong>x</strong>0) = <strong>0</strong>): </p>
<pre> der(d<strong>x</strong>) = der(<strong>f</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>f</strong>,<strong>u</strong>)*d<strong>u</strong> + <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0)</pre>
<pre> d<strong>y</strong> = der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong> + (<strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) - <strong>y</strong>0)</pre>
<p>or </p>
<pre> der(d<strong>x</strong>) = <strong>A</strong>*d<strong>x</strong> + <strong>B</strong>*d<strong>u</strong> + <strong>f</strong>0</pre>
<pre> d<strong>y</strong> = <strong>C</strong>*d<strong>x</strong> + <strong>D</strong>*d<strong>u</strong></pre>
<p>This function returns the matrices <strong>A</strong>, <strong>B</strong>, <strong>C</strong>, <strong>D</strong> and assumes that the linearization point is a steady-state point of the simulation (i.e., <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0) = 0). Additionally, the full Modelica names of all inputs, outputs and states shall be returned if possible (default is to return empty name strings).</p>
annotation (__Dymola_interactive=true, Documentation(info="<html>
<p>
This function initializes a Modelica model and then simulates the model
with its default experiment options until time instant \"t_linearize\".
If t_linearize=0, no simulation takes place (only initialization).
At the simulation stop time, the model is linearized in such a form that
</p>
<ul>
<li>
all top-level signals with prefix \"input\" are treated as inputs <strong>u</strong>(t)
of the model,
</li>
<li>
all top-level signals with prefix \"output\" are treated as outputs <strong>y</strong>(t)
of the model,
</li>
<li>
all variables that appear differentiated and that are selected as states at this time
instant are treated as states <strong>x</strong> of the model.
</li>
</ul>
<p>
Formally, the non-linear hybrid differential-algebraic equation system is therefore treated
as the following ordinary equation system at time instant t_linearize:
</p>
<blockquote><pre>
der(<strong>x</strong>) = <strong>f</strong>(<strong>x</strong>,<strong>u</strong>)
<strong>y</strong> = <strong>g</strong>(<strong>x</strong>,<strong>u</strong>)
</pre></blockquote>
<p>
Taylor series expansion (linearization) of this model around the simulation stop time t_linearize:
</p>
<blockquote><pre>
<strong>u</strong>0 = <strong>u</strong>(t_linearize)
<strong>y</strong>0 = <strong>y</strong>(t_linearize)
<strong>x</strong>0 = <strong>x</strong>(t_linearize)
</pre></blockquote>
<p>
and neglecting higher order terms results in the following system:
</p>
<blockquote><pre>
der(<strong>x</strong>0 + d<strong>x</strong>) = <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>f</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>f</strong>,<strong>u</strong>)*d<strong>u</strong>
<strong>y</strong>0 + d<strong>y</strong> = <strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong>
</pre></blockquote>
<p>
where der(<strong>f</strong>,<strong>x</strong>) is the partial derivative
of&nbsp;<strong>f</strong> with respect to&nbsp;<strong>x</strong>, and the partial
derivatives are computed at the linearization point t_linearize. Re-ordering of terms
gives (note <strong>der</strong>(<strong>x</strong>0)&nbsp;=&nbsp;<strong>0</strong>):
</p>
<blockquote><pre>
der(d<strong>x</strong>) = der(<strong>f</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>f</strong>,<strong>u</strong>)*d<strong>u</strong> + <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0)
d<strong>y</strong> = der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong> + (<strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) - <strong>y</strong>0)
</pre></blockquote>
<p>
or
</p>
<blockquote><pre>
der(d<strong>x</strong>) = <strong>A</strong>*d<strong>x</strong> + <strong>B</strong>*d<strong>u</strong> + <strong>f</strong>0
d<strong>y</strong> = <strong>C</strong>*d<strong>x</strong> + <strong>D</strong>*d<strong>u</strong>
</pre></blockquote>
<p>
This function returns the matrices&nbsp;<strong>A</strong>, <strong>B</strong>,
<strong>C</strong>, <strong>D</strong> and assumes that the linearization point is
a&nbsp;steady-state point of the simulation (i.e.,
<strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0)&nbsp;=&nbsp;0).
Additionally, the full Modelica names of all inputs, outputs and states shall be
returned if possible (default is to return empty name strings).
</p>
</html>"));
end linearize;
49 changes: 35 additions & 14 deletions Modelica_LinearSystems2/Utilities/Import/linearize2.mo
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,27 @@ If t_linearize=0, no simulation takes place (only initialization).
At the simulation stop time, the model is linearized in such a form that
</p>
<ul>
<li>all top-level signals with prefix \"input\" are treated as inputs <strong>u</strong>(t) of the model ,</li>
<li>all top-level signals with prefix \"output\" are treated as outputs <strong>y</strong>(t) of the model,</li>
<li>all variables that appear differentiated and that are selected as states at this time instant are treated as states <strong>x</strong> of the model.</li>
<li>
all top-level signals with prefix \"input\" are treated as inputs <strong>u</strong>(t)
of the model,
</li>
<li>
all top-level signals with prefix \"output\" are treated as outputs <strong>y</strong>(t)
of the model,
</li>
<li>
all variables that appear differentiated and that are selected as states at this time
instant are treated as states <strong>x</strong> of the model.
</li>
</ul>
<p>
Formally, the non-linear hybrid differential-algebraic equation system is
therefore treated as the following ordinary equation system at time
instant t_linearize:
Formally, the non-linear hybrid differential-algebraic equation system is therefore treated
as the following ordinary equation system at time instant t_linearize:
</p>
<blockquote><pre>
der(<strong>x</strong>) = <strong>f</strong>(<strong>x</strong>,<strong>u</strong>)
<strong>y</strong> = <strong>g</strong>(<strong>x</strong>,<strong>u</strong>)
<strong>y</strong> = <strong>g</strong>(<strong>x</strong>,<strong>u</strong>)
</pre></blockquote>
<p>
Taylor series expansion (linearization) of this model around the simulation stop time t_linearize:
Expand All @@ -93,25 +102,37 @@ Taylor series expansion (linearization) of this model around the simulation stop
<strong>y</strong>0 = <strong>y</strong>(t_linearize)
<strong>x</strong>0 = <strong>x</strong>(t_linearize)
</pre></blockquote>
<p>and neglecting higher order terms results in the following system: </p>
<p>
and neglecting higher order terms results in the following system:
</p>
<blockquote><pre>
der(<strong>x</strong>0+d<strong>x</strong>) = <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>f</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>f</strong>,<strong>u</strong>)*d<strong>u</strong>
<strong>y</strong>0 + d<strong>y</strong> = <strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong>
der(<strong>x</strong>0 + d<strong>x</strong>) = <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>f</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>f</strong>,<strong>u</strong>)*d<strong>u</strong>
<strong>y</strong>0 + d<strong>y</strong> = <strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) + der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong>
</pre></blockquote>
<p>where der(<strong>f</strong>,<strong>x</strong>) is the partial derivative of <strong>f</strong> with respect to <strong>x</strong>, and the partial derivatives are computed at the linearization point t_linearize. Re-ordering of terms gives (note <strong>der</strong>(<strong>x</strong>0) = <strong>0</strong>): </p>
<p>
where der(<strong>f</strong>,<strong>x</strong>) is the partial derivative
of&nbsp;<strong>f</strong> with respect to&nbsp;<strong>x</strong>, and the partial
derivatives are computed at the linearization point t_linearize. Re-ordering of terms
gives (note <strong>der</strong>(<strong>x</strong>0)&nbsp;=&nbsp;<strong>0</strong>):
</p>
<blockquote><pre>
der(d<strong>x</strong>) = der(<strong>f</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>f</strong>,<strong>u</strong>)*d<strong>u</strong> + <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0)
d<strong>y</strong> = der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong> + (<strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) - <strong>y</strong>0)
d<strong>y</strong> = der(<strong>g</strong>,<strong>x</strong>)*d<strong>x</strong> + der(<strong>g</strong>,<strong>u</strong>)*d<strong>u</strong> + (<strong>g</strong>(<strong>x</strong>0,<strong>u</strong>0) - <strong>y</strong>0)
</pre></blockquote>
<p>
or
</p>
<blockquote><pre>
der(d<strong>x</strong>) = <strong>A</strong>*d<strong>x</strong> + <strong>B</strong>*d<strong>u</strong> + <strong>f</strong>0
d<strong>y</strong> = <strong>C</strong>*d<strong>x</strong> + <strong>D</strong>*d<strong>u</strong>
d<strong>y</strong> = <strong>C</strong>*d<strong>x</strong> + <strong>D</strong>*d<strong>u</strong>
</pre></blockquote>
<p>
This function returns the matrices <strong>A</strong>, <strong>B</strong>, <strong>C</strong>, <strong>D</strong> and assumes that the linearization point is a steady-state point of the simulation (i.e., <strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0) = 0). Additionally, the full Modelica names of all inputs, outputs and states shall be returned if possible (default is to return empty name strings).
This function returns the matrices&nbsp;<strong>A</strong>, <strong>B</strong>,
<strong>C</strong>, <strong>D</strong> and assumes that the linearization point is
a&nbsp;steady-state point of the simulation (i.e.,
<strong>f</strong>(<strong>x</strong>0,<strong>u</strong>0)&nbsp;=&nbsp;0).
Additionally, the full Modelica names of all inputs, outputs and states shall be
returned if possible (default is to return empty name strings).
</p>
</html>"));
end linearize2;

0 comments on commit 4a5969b

Please sign in to comment.