\section{The envelope-following method in a nutshell}
\label{sec:ef}

In transient analysis\index{transient analysis},
a nonlinear circuit's behavior can be represented
by a coupled set of nonlinear first-order
differential algebraic equations\index{differential algebraic equations}
(DAE) of the form
\begin{equation}\label{eq:dae}
   \frac{\ud}{\ud t} q(x(t)) + f(x(t)) = b(t),
\end{equation}
where $x(t)\in \mathbb{R}^N$ is the vector of circuit variables,
usually comprising node voltages and possibly branch currents,
$f(\cdot)$ is a nonlinear function that maps $x(t)$ to a vector
of $N$ entries most of
which are sums of resistive currents at a node,
$q(\cdot)$ %is also a nonlinear function that
maps $x(t)$ to a vector of $N$ entries of
capacitor charges or inductor fluxes,
and $b(t)$ contains the input source values.
For many power electronics circuits, the input
switching signal is known %as a circuit parameter
and is periodic with clock period $T$.

Assume the time inside one period $T$ has been discretised
into $M$ time steps, $0=t_0 < t_1 < t_2 < \cdots < t_M=T$, and the
$i$-th step length is $h_i = t_i-t_{i-1}$.
In practice, the discretisation is nonuniform to
control truncation error\index{truncation error} and convergence.
Then, given an initial condition $x(0)$ at $t=0$,
numerical integration is applied to find the time domain solution of
circuit state $x(t)$ at each time step till $t=T$.
%, in a consequent time series.

For those circuits whose carrier waveforms\index{carrier waveforms}
vary slowly in a large number of periods,
the envelope-following\index{envelope-following} method only integrates the
DAE in several selected periods and then jumps over to a new time point.
By repeating this ``simulate and skip'' action,
envelope-following method attains its efficiency
compared to conventional transient analysis, but still can accurately
obtain the slow varying envelope.

For example, if the clock period is $T$, and the suitable jump
interval for the envelope is $k$ periods, then the envelope step is
$kT$.  Suppose the state at time $t=mT$ is known as $x(mT)$, and the
envelope-following wants to obtain the state at the next envelope
step, $x((m+k)T)$.  If the envelope step is much larger than the clock
period ($k$ is much bigger than one), envelope-following will lead to
significant savings in simulation time.

% One simple way to estimate $x((m+k)T)$ is to use the information at
% $mT$ and $(m-1)T$, which leads to the forward-Euler method as
To estimate $x((m+k)T)$,
a forward Euler\index{Euler!forward Euler} style jumping relies only on $x(mT)$ and $x((m-1)T)$,
i.e.,
\[
   x((m+k)T)
   =
   x(mT) + k\left[ x(mT)-x((m-1)T) \right].
\]
However, this approach is inefficient due to its restriction on
envelope step $k$, since larger $k$ usually causes instability.
Instead, backward Euler\index{Euler!backward Euler} jumping,
%and the equation becomes
\[
  x((m+k)T)-x(mT) = k\left[x((m+k)T)-x((m+k-1)T)\right],
\]
allows larger envelope steps.
Here $x((m+k-1)T)$ is the unknown variable to be solved
by Newton iteration\index{iterative method!Newton iteration},
and $x((m+k)T)$ is dependent on $x((m+k-1)T)$
in each iteration.
% Forward-Euler may be used to generate the initial guess.
The Newton update equation in each iteration is thus expressed as
% x^{j+1}((m+k-1)T) = x^{j}((m+k-1)T) - A^{-1} \left[(k-1)x^j((m+k)T) - kx^j((m+k-1)T)+ x(mT)\right],
%\begin{equation} \label{eq:Newton}
%\begin{split}
\begin{multline} \label{eq:Newton}
  \Delta x((m+k-1)T)= A^{-1} \left[(k-1)x^j((m+k)T) \right. \\
   \left. - kx^j((m+k-1)T)+ x(mT)\right],
\end{multline}
%\end{split}
%\end{equation}
where the Jacobian matrix\index{Jacobian matrix} $A$ is computed as
a combination of circuit sensitivity matrix\index{sensitivity matrix}
and identity matrix, as
\begin{equation} \label{eq:A}
  A = (k-1)\frac{\ud x((m+k)T)}{\ud x((m+k-1)T)} -kI
    = (k-1)J-kI.
\end{equation}
In each Newton iteration,
$x((m+k-1)T)$ is used as initial condition to calculate
$x((m+k)T)$ by integrating the DAE in one clock period.
Meanwhile, %circuit matrices, for example,
the conductance matrix $G_i=\ud f(x(t_i))/\ud x(t_i)$
and the capacitance matrix $C_i=\ud q(x(t_i))/\ud x(t_i)$
at each time step %in this period,
are used to derive the %circuit
sensitivity matrix $J= \ud x((m+k)T) / \ud x((m+k-1)T)$.
% i.e.,
% \[
%   x((m+k)T) = \Phi(x((m+k-1)T),(m+k-1)T,(m+k)T).
% \]

Different integration rules can be applied to
the computation of sensitivity matrix.
It can be easily derived that,
%for one signal period with $M$ time steps,
if the DAE is integrated with backward Euler rule,
the sensitivity is
\[
   J = \frac{\ud x_M}{\ud x_0}
   = \prod_{i=1}^{M}
     \left( \frac{1}{h_i} C_i + G_i \right)^{-1}
     \frac{1}{h_i}C_{i-1}
%  \frac{\ud x_n}{\ud x_0}
%  = \left(\frac{1}{h_n} C_n + G_n\right)^{-1}
%    \frac{1}{h_n}C_{n-1} \frac{\ud x_{n-1}}{\ud x_0}
\]
%is the sensitivity matrix
% In the next section, we will formulate the sensitivity in
% Gear-2 scheme.
% and for trapezoidal integration,
% \[
%   \frac{\ud x_n}{\ud x_0}
%  = \left(\frac{1}{h_n} C_n + \frac{1}{2} G_n\right)^{-1}
%    \left(\frac{1}{h_n} C_{n-1} - \frac{1}{2} G_{n-1}\right)
%    \frac{\ud x_{n-1}}{\ud x_0}.
% \]

In summary, the envelope-following method is fundamentally
a boosted version of traditional transient analysis,
with certain skips over several periods and a Newton iteration
to update or correct the errors brought by the skips,
as is exhibited by Figure~\ref{fig:ef_flow}.
\begin{figure}[!tb]
\centering
\resizebox{.7\textwidth}{!}{\input{./Chapters/chapter16/figures/ef_flow.pdf_t}}
\caption{The flow of envelope-following method.}
\label{fig:ef_flow}
%\end{center}
\end{figure}



