Skip to content

Commit

Permalink
Insert some whitespace in synchronous listings
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Oct 11, 2020
1 parent e9cab21 commit 7268d51
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions chapters/synchronous.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1296,15 +1296,15 @@ \subsection{Associating a Solver to a Partition}\label{associating-a-solver-to-a
\begin{example}
\begin{lstlisting}[language=modelica]
// Continuous PI controller in a clocked partition
vd = sample(x2, Clock(Clock(1,10),solverMethod="ImplicitEuler"));
e = ref-vd;
der(xd) = e/Ti;
u = k*(e + xd);
vd = sample(x2, Clock(Clock(1, 10), solverMethod="ImplicitEuler"));
e = ref - vd;
der(xd) = e / Ti;
u = k * (e + xd);

// Physical model
f = hold(u);
der(x1) = x2;
m*der(x2) = f;
m * der(x2) = f;
\end{lstlisting}
\end{example}

Expand Down Expand Up @@ -1337,19 +1337,19 @@ \subsection{Inferencing of solverMethod}\label{inferencing-of-solvermethod}
Real y "Explicitly using ImplicitEuler method";
Real z "Inferred to use ExplicitEuler";
equation
der(x)=-x+sample(1,Clock(Clock(1,10), solverMethod="ExplicitEuler"));
der(y)=subSample(x,2)+sample(1,Clock(Clock(2,10), solverMethod="ImplicitEuler"));
der(z)=subSample(x,2)+1;
der(x) = -x + sample(1, Clock(Clock(1, 10), solverMethod="ExplicitEuler"));
der(y) = subSample(x,2) + sample(1, Clock(Clock(2, 10), solverMethod="ImplicitEuler"));
der(z) = subSample(x,2) + 1;
end InferenceTest;

model IllegalInference
Real x(start=3) "Explicitly using ExplicitEuler";
Real y "Explicitly using ImplicitEuler method";
Real z;
equation
der(x)=-x+sample(1,Clock(Clock(1,10), solverMethod="ExplicitEuler"));
der(y)=subSample(x,2)+sample(1,Clock(Clock(2,10), solverMethod="ImplicitEuler"));
der(z)=subSample(x,4)+1+subSample(y);
der(x) = -x + sample(1, Clock(Clock(1, 10), solverMethod="ExplicitEuler"));
der(y) = subSample(x, 2) + sample(1, Clock(Clock(2, 10), solverMethod="ImplicitEuler"));
der(z) = subSample(x, 4) + 1 + subSample(y);
end IllegalInference;
\end{lstlisting}
Here \lstinline!z! is a continuous-time equation connected directly to both \lstinline!x! and \lstinline!y! partitions that have different \lstinline!solverMethod!.
Expand Down Expand Up @@ -1424,12 +1424,12 @@ \section{Other Operators}\label{other-operators}
protected
Real Ts = interval(u);
equation
/* Continuous PI equations: der(x) = u/T; y = k*(x + u);
Discretization equation: der(x) = (x - previous (x))/Ts;
*/
/* Continuous PI equations: der(x) = u / T; y = k * (x + u);
* Discretization equation: der(x) = (x - previous (x)) / Ts;
*/
when Clock() then
x = previous (x) + Ts/T*u;
y = k*(x + u);
x = previous (x) + Ts / T * u;
y = k * (x + u);
end when;
end ClockedPI;
\end{lstlisting}
Expand All @@ -1453,8 +1453,8 @@ \section{Other Operators}\label{other-operators}
der(xc) = uc;
/* PI controller */
z = if firstTick() then 0 else
previous(z) + Ts/T*(uc - y_meas);
y = xc + k*(xc + uc);
previous(z) + Ts / T * (uc - y_meas);
y = xc + k * (xc + uc);
yc = hold (y);
end MixedController;
\end{lstlisting}
Expand Down

0 comments on commit 7268d51

Please sign in to comment.