Skip to content

Commit

Permalink
Fix long lines and use \ldots for ellipsis in listings
Browse files Browse the repository at this point in the history
Also trying to standardize the occasional use of '<describing text>' inside listings.
  • Loading branch information
henrikt-ma committed Jan 12, 2021
1 parent 23c6c8f commit 933314b
Show file tree
Hide file tree
Showing 22 changed files with 228 additions and 247 deletions.
26 changes: 13 additions & 13 deletions chapters/annotations.tex
Expand Up @@ -122,7 +122,7 @@ \subsection{Annotations for Figures}\label{annotations-for-figures}
\end{nonnormative}

% henrikt-ma 2020-06: Once there is Modelica URI support for referring to a figure in the collection of a class, it will be easier to explain
% the following statement...
% the following statement.
Even though a \lstinline!Figure! annotation can be shared through inheritance between classes in a class hierarchy, note that each simulated class provides
its own data to be displayed in the figure.

Expand Down Expand Up @@ -835,7 +835,7 @@ \subsection{Extends clause}\label{extends-clause}

model B
extends C annotation(DiagramMap(primitivesVisible = false));
...
$\ldots$
end B;
\end{lstlisting}
In this example the diagram of \lstinline!A! contains the graphical primitives
Expand Down Expand Up @@ -1268,7 +1268,7 @@ \section{Annotations for the Graphical User Interface}\label{annotations-for-the
\begin{example}
\begin{lstlisting}[language=modelica]
model World
...
$\ldots$
annotation(defaultComponentName = "world",
defaultComponentPrefixes = "inner replaceable",
missingInnerMessage = "The World object is missing");
Expand Down Expand Up @@ -1335,7 +1335,7 @@ \section{Annotations for the Graphical User Interface}\label{annotations-for-the
\begin{example}
\begin{lstlisting}[language=modelica]
connector Frame "Frame of a mechanical system"
...
$\ldots$
flow Modelica.Units.SI.Force f[3]
annotation(unassignedMessage =
"All Forces cannot be uniquely calculated. The reason could be that the
Expand Down Expand Up @@ -1456,7 +1456,7 @@ \section{Annotations for the Graphical User Interface}\label{annotations-for-the
parameter Real r4 "Real parameter in Tab 1 and Group 2"
annotation(Dialog(tab="Tab 1", group="Group 2"));
StepIn stepIn[nInports];
...
$\ldots$
end DialogDemo;
\end{lstlisting}
When clicking on an instance of model \lstinline!DialogDemo!, a menu pops up
Expand Down Expand Up @@ -1490,7 +1490,7 @@ \section{Annotations for the Graphical User Interface}\label{annotations-for-the
// nIn cannot be set in the parameter dialog (but maybe shown)
parameter Integer nIn=0 annotation(Dialog(connectorSizing=true));
StepIn inPorts[nIn];
...
$\ldots$
end Step;
\end{lstlisting}
If the parameter is used as dimension size of a vector of
Expand Down Expand Up @@ -1625,7 +1625,7 @@ \subsection{Version Handling}\label{version-handling}
Defines that user models using the \lstinline!VERSION-NUMBER! can be upgraded to the \lstinline!CURRENT-VERSION-NUMBER! of the current class without any changes.
\item
\lstinline!conversion(from(version = Versions, [to=VERSION-NUMBER,] Convert))!\\
where \emph{Versions} is \lstinline!VERSION-NUMBER! \textbar{} \lstinline!{VERSION-NUMBER,VERSION-NUMBER, ...}! and \lstinline!Convert! is \lstinline!script="..."! \textbar{} \lstinline!change={conversionRule(), ..., conversionRule()}!\\*[.5ex]
where \emph{Versions} is \lstinline!VERSION-NUMBER! \textbar{} \lstinline!{VERSION-NUMBER, VERSION-NUMBER, $\ldots$}! and \lstinline!Convert! is \lstinline!script="$\ldots$"! \textbar{} \lstinline!change={conversionRule(), $\ldots$, conversionRule()}!\\*[.5ex]
Defines that user models using the \lstinline!VERSION-NUMBER! or any of the given \lstinline!VERSION-NUMBER! can be upgraded to the given \lstinline!VERSION-NUMBER! (if the to-tag is missing this is the \lstinline!CURRENT-VERSION-NUMBER!) of the current class by applying the given conversion rules.
The script consists of an unordered sequence of \lstinline!conversionRule();! (and optionally Modelica comments).
The \lstinline!conversionRule! functions are defined in \cref{conversion-rules}.
Expand All @@ -1643,7 +1643,7 @@ \subsection{Version Handling}\label{version-handling}
\begin{example}
\begin{lstlisting}[language=modelica]
package Modelica
...
$\ldots$
annotation(version="3.1",
conversion(noneFromVersion="3.1 Beta 1",
noneFromVersion="3.1 Beta 2",
Expand All @@ -1654,13 +1654,13 @@ \subsection{Version Handling}\label{version-handling}
end Modelica;

model A
...
$\ldots$
annotation(version="1.0",
uses(Modelica(version="1.5")));
end A;

model B
...
$\ldots$
annotation(uses(Modelica(version="3.1 Beta 1")));
end B;
\end{lstlisting}
Expand Down Expand Up @@ -1942,7 +1942,7 @@ \subsection{Version Date and Build Information}\label{version-date-and-build-inf
\begin{example}
\begin{lstlisting}[language=modelica,mathescape=false]
package Modelica
...
$\ldots$
annotation(version = "3.0.1",
versionDate = "2008-04-10",
versionBuild = 4,
Expand Down Expand Up @@ -2159,7 +2159,7 @@ \subsection{Licensing}\label{licensing}
defined to restrict the usage of the encrypted package:
\begin{lstlisting}[language=modelica]
record Protection
...
$\ldots$
String features[:] = fill("", 0) "Required license features";
record License
String libraryKey;
Expand Down Expand Up @@ -2248,7 +2248,7 @@ \subsection{Licensing}\label{licensing}
// File MyLibrary\package.mo
package MyLibrary
annotation(Protection(License(libraryKey="15783-A39323-498222-444ckk4ll",
licenseFile="MyLibraryAuthorization_Tool.mo_lic), ...));
licenseFile="MyLibraryAuthorization_Tool.mo_lic), $\ldots$));
end MyLibrary;

// File MyLibrary\MyLibraryAuthorization_Tool.mo\
Expand Down
23 changes: 12 additions & 11 deletions chapters/arrays.tex
Expand Up @@ -85,7 +85,7 @@ \section{Array Declarations}\label{array-declarations}
It is a component whose components are \willintroduce{array elements} (see below).
For an array variable, the ordering of its components matters:
The $k$th element in the sequence of components of an array variable \lstinline!x! is the array element with index \lstinline!k!, denoted \lstinline!x[k]!.
% henrikt-ma: The following statement seems like an over-simplification; for Flat Modelica, we've spent some time trying to figure out how to deal with the fact that Modelica arrays are not homogenous in general...
% henrikt-ma: The following statement seems like an over-simplification; for Flat Modelica, we've spent some time trying to figure out how to deal with the fact that Modelica arrays are not homogenous in general.
All elements of an array have the same type.
An array element may again be an array, i.e., arrays can be nested.
An array element is hence referenced using $n$ indices in general, where $n$ is the number of dimensions of the array.
Expand All @@ -103,7 +103,8 @@ \section{Array Declarations}\label{array-declarations}
languages such as Fortran, C, C++.

\begin{lstlisting}[language=modelica]
Real[:] v1, v2 // vectors v1 and v2 have unknown sizes. The actual sizes may be different.
Real[:] v1, v2 // Vectors v1 and v2 have unknown sizes.
// The actual sizes may be different.
\end{lstlisting}
It is possible to mix the two declaration forms although it might be confusing.
\begin{lstlisting}[language=modelica]
Expand Down Expand Up @@ -621,11 +622,11 @@ \subsubsection{Reduction Expressions}\label{reduction-expressions}
\begin{example}
% No frame since the math would break it.
\begin{lstlisting}[language=modelica, frame=none]
sum(i for i in 1:10) // Gives $\sum_{i=1}^{10}i=$1+2+...+10=55
sum(i for i in 1:10) // Gives $\sum_{i=1}^{10}i$ = 1 + 2 + $\ldots$ + 10 = 55
// Read it as: compute the sum of i for i in the range 1 to 10.
sum(i^2 for i in {1,3,7,6}) // Gives $\sum_{i\in \begin{Bmatrix}1&3&7&6\end{Bmatrix}}i^2=$1+9+49+36=95
{product(j for j in 1:i) for i in 0:4} // Gives {1,1,2,6,24}
max(i^2 for i in {3,7,6}) // Gives 49
sum(i^2 for i in {1,3,7,6}) // Gives $\sum_{i\in \{1,\, 3,\, 7,\, 6\}}i^2$ = 1 + 9 + 49 + 36 = 95
{product(j for j in 1:i) for i in 0:4} // Gives {1, 1, 2, 6, 24}
max(i^2 for i in {3,7,6}) // Gives 49
\end{lstlisting}
\end{example}

Expand Down Expand Up @@ -781,10 +782,10 @@ \subsubsection{Array Constructor with One Iterator}\label{array-constructor-with
\begin{example}
\begin{lstlisting}[language=modelica]
array(i for i in 1:10)
// Gives the vector 1:10={1,2,3,...,10}
// Gives the vector 1:10 = {1, 2, 3, $\ldots$, 10}

{r for r in 1.0 : 1.5 : 5.5}
// Gives the vector 1.0:1.5:5.5={1.0, 2.5, 4.0, 5.5}
// Gives the vector 1.0:1.5:5.5 = {1.0, 2.5, 4.0, 5.5}

{i^2 for i in {1,3,7,6}}
// Gives the vector {1, 9, 49, 36}
Expand All @@ -800,8 +801,8 @@ \subsubsection{Array Constructor with Several Iterators}\label{array-constructor

\begin{example}
\begin{lstlisting}[language=modelica]
Real toeplitz[:,:]={i-j for i in 1:n, j in 1:n};
Real toeplitz2[:,:]={{i-j for i in 1:n} for j in 1:n};
Real toeplitz[:,:] = {i-j for i in 1:n, j in 1:n};
Real toeplitz2[:,:] = {{i-j for i in 1:n} for j in 1:n};
\end{lstlisting}
\end{example}

Expand Down Expand Up @@ -1366,7 +1367,7 @@ \subsection{Slice Operation}\label{slice-operation}
// size(tf[1].x1[:]) = size(tf[2].x1[:]) = $\ldots$ = size(tf[m].x1[:])
y3 = sum(tf.x1[1:2]); // Legal.
// Since x1 has at least 2 elements in all tf, and
// size(tf[1].x1[1:2]) = size(tf[2].x1[1:2]) = $\ldots$ = size(tf[m].x1[1:2]) = {2}
// size(tf[1].x1[1:2]) = $\ldots$ = size(tf[m].x1[1:2]) = {2}
\end{lstlisting}
In this example the different \lstinline!x1! vectors have different lengths,
but it is still possible to perform some operations on them.
Expand Down
31 changes: 14 additions & 17 deletions chapters/classes.tex
Expand Up @@ -252,11 +252,11 @@ \subsubsection{Prefix Rules}\label{prefix-rules}
\begin{lstlisting}[language=modelica]
block FirstOrder
input Real u;
...
$\ldots$
end FirstOrder;
model UseFirstOrder
FirstOrder firstOrder(u=time); // binding equation for u
...
$\ldots$
end UseFirstOrder;
\end{lstlisting}
\end{example}
Expand Down Expand Up @@ -398,7 +398,7 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
\begin{lstlisting}[language=modelica]
model Inertia
parameter Boolean state = true;
...
$\ldots$
equation
J*a = t1 - t2;
if state then // code which is removed during symbolic
Expand Down Expand Up @@ -477,7 +477,7 @@ \subsection{Conditional Component Declaration}\label{conditional-component-decla
// Illegal modifier on component3 since component1.J is conditional
// Even if we can see that component1 always exist if component3 exist
equation
connect(component1..., ...) "Connection to conditional component 1";
connect(component1$\ldots$, $\ldots$) "Connection to conditional component 1";
connect(component2.n, motor.n) "Connection to conditional component 2";
connect(component3.n, motor.n) "Connection to conditional component 3";
component1.u=0; // Illegal
Expand Down Expand Up @@ -533,11 +533,11 @@ \section{Class Declarations}\label{class-declarations}
class ClassName
Declaration1
Declaration2
...
$\ldots$
equation
equation1
equation2
...
$\ldots$
end ClassName;
\end{lstlisting}
\end{example}
Expand Down Expand Up @@ -617,7 +617,7 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
\begin{lstlisting}[language=modelica]
model Resistor
parameter Real R;
...
$\ldots$
end Resistor;
model A
parameter Real R;
Expand All @@ -631,8 +631,8 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
encapsulated model Load2=.Resistor(R=2); // Ok
encapsulated model LoadR=.Resistor(R=R); // Illegal
Load a,b,c;
ConstantSource ...;
...
ConstantSource $\ldots$;
$\ldots$
end A;
\end{lstlisting}
\end{example}
Expand Down Expand Up @@ -1533,7 +1533,7 @@ \subsubsection{Attributes of Enumeration Types}\label{attributes-of-enumeration-

For each enumeration:
\begin{lstlisting}[language=modelica]
type E=enumeration(e1, e2, ..., en);
type E = enumeration(e1, e2, $\ldots$, en);
\end{lstlisting}

a new simple type is conceptually defined as
Expand All @@ -1546,9 +1546,9 @@ \subsubsection{Attributes of Enumeration Types}\label{attributes-of-enumeration-
parameter EnumType start = e1; // Initial value
parameter BooleanType fixed = true, // default for parameter/constant;
= false; // default for other variables
constant EnumType e1=...;
...
constant EnumType en=...;
constant EnumType e1 = $\ldots$;
$\ldots$
constant EnumType en = $\ldots$;
equation
assert(value >= min and value <= max, "Variable value out of limit");
end E;
Expand All @@ -1562,10 +1562,7 @@ \subsubsection{Attributes of Enumeration Types}\label{attributes-of-enumeration-

\subsubsection{Type Conversion of Enumeration Values to String or Integer}\label{type-conversion-of-enumeration-values-to-string-or-integer}

The type conversion function \lstinline!Integer(<expression of enumeration type>)! returns the ordinal number of the
enumeration value \lstinline!E.enumvalue!, to which the expression is evaluated,
where \lstinline!Integer(E.e1) = 1!, \lstinline!Integer(E.en) = n!, for an enumeration type
\lstinline!E = enumeration(e1, ..., en)!.
The type conversion function \lstinline!Integer($\mbox{\emph{\textless{}expression of enumeration type\textgreater{}}}$)! returns the ordinal number of the enumeration value \lstinline!E.enumvalue!, to which the expression is evaluated, where $\text{\lstinline!Integer(E.e1)!} = 1$, $\text{\lstinline!Integer(E.en)!} = n$, for an enumeration type \lstinline!E = enumeration(e1, $\ldots$, en)!.

\lstinline!String(E.enumvalue)! gives the \lstinline!String! representation of the enumeration value.

Expand Down
10 changes: 5 additions & 5 deletions chapters/connectors.tex
Expand Up @@ -20,7 +20,7 @@ \section{Connect-Equations and Connectors}\label{connect-equations-and-connector
The connect-equation construct takes two references to connectors, each of which is either of the following forms:
\begin{itemize}
\item
$c_1.c_2...c_n$,
$c_1.c_2\ldots{}c_n$,
where $c_1$ is a connector of the class,
$n$\textgreatereq 1 and $c_{i+1}$ is a connector element of
$c_i$ for \lstinline!i=1:(n-1)!.
Expand Down Expand Up @@ -320,7 +320,7 @@ \subsection{Expandable Connectors}\label{expandable-connectors}
// Plant Side
model SparkPlug
RealInput spark_advance;
...
$\ldots$
end SparkPlug;

expandable connector EngineBus
Expand All @@ -334,7 +334,7 @@ \subsection{Expandable Connectors}\label{expandable-connectors}
model Cylinder
CylinderBus cylinder_bus;
SparkPlug spark_plug;
...
$\ldots$
equation
connect(spark_plug.spark_advance,
cylinder_bus.spark_advance);
Expand Down Expand Up @@ -796,7 +796,7 @@ \subsection{Overconstrained Equation Operators for Connection Graphs}\label{over
input Type T2;
output Real residue[ <n> ];
algorithm
residue := ...
residue := $\ldots$;
end equalityConstraint;
end Type;

Expand All @@ -807,7 +807,7 @@ \subsection{Overconstrained Equation Operators for Connection Graphs}\label{over
input Record R2;
output Real residue[ <n> ];
algorithm
residue := ...
residue := $\ldots$;
end equalityConstraint;
end Record;
\end{lstlisting}
Expand Down
4 changes: 2 additions & 2 deletions chapters/derivationofstream.tex
Expand Up @@ -147,7 +147,7 @@ \section{Rationale for the formulation of inStream}\label{rationale-for-the-form
In the general case of a connection set with \emph{n} components,
similar considerations lead to the following.
\begin{equation*}
\text{\lstinline!inStream!}(h_{\mathrm{outflow},i})=\frac{\sum_{j=1,...,n;j\neq i}\operatorname{max}(-\tilde{m}_j,0)h_{\mathrm{outflow},j}}{\sum_{j=1,...,n;j\neq i}\operatorname{max}(-\tilde{m}_j,0)}
\text{\lstinline!inStream!}(h_{\mathrm{outflow},i})=\frac{\sum_{j=1,\dotsc,n;j\neq i}\operatorname{max}(-\tilde{m}_j,0)h_{\mathrm{outflow},j}}{\sum_{j=1,\dotsc,n;j\neq i}\operatorname{max}(-\tilde{m}_j,0)}
\end{equation*}

\section{Special cases covered by inStream definition}\label{special-cases-covered-by-the-instream-operator-definition}
Expand Down Expand Up @@ -216,7 +216,7 @@ \subsection{Connection of 3 stream connectors where two mass flow rates are posi
\begin{lstlisting}[language=modelica]
model m2
Fluidport c(m_flow(min=0));
...
$\ldots$
end m2;
\end{lstlisting}

Expand Down
2 changes: 1 addition & 1 deletion chapters/equations.tex
Expand Up @@ -122,7 +122,7 @@ \subsubsection{Explicit Iteration Ranges of For-Equations}\label{explicit-iterat

\begin{example}
\begin{lstlisting}[language=modelica]
for i in 1 : 10 loop // i takes the values 1, 2, 3, ..., 10
for i in 1 : 10 loop // i takes the values 1, 2, 3, $\ldots$, 10
for r in 1.0 : 1.5 : 5.5 loop // r takes the values 1.0, 2.5, 4.0, 5.5
for i in {1, 3, 6, 7} loop // i takes the values 1, 3, 6, 7
for i in TwoEnums loop // i takes the values TwoEnums.one, TwoEnums.two
Expand Down

0 comments on commit 933314b

Please sign in to comment.