\section{Line of Sight Depths}
\label{891_2:sec:LOS}

\begin{figure*}
  \centering
  \includegraphics[width=0.9\textwidth, trim={0 1.5cm 0 0}, clip]{891_2/figs/velocity_projection.pdf}
  \caption[Map of \GP apertures in cylindrical
    coordinates]{\fixspacing\label{891_2:fig:velocity_projection}Map
    of the physical location of average emission from each aperture,
    as determined by a velocity-based LOS depth calculation (equations
    \ref{891_2:eq:vel_LOS}). The vertical dotted lines show the
    boundaries of the \GP pointings described in \ref{chap:891_1}.}
\end{figure*}

To report our quantities of interest as a function of height and true,
galactic radius we need to deproject our measured radii into radii
defined with respect to the true center of NGC 891. This deprojection
relies on understanding the average line-of-sight (LOS) depth to the
emitting material in each \GP aperture. This LOS depth can be computed
from the measured tangential velocity in each aperture.

In the absence of any attenuating material (i.e., dust) the maximum
velocity measured in each aperture will be the tangential speed of the
galaxy at any given radius and height, which, to first order, is well
approximated by the circular speed of the galaxy.  In reality,
however, when looking through an edge-on disk with high attenuation
the measured velocity is the projected velocity of emitting material
along the entire sight-line, which will become opaque before reaching
the tangent point. Thus, by comparing the measured velocity to the
known circular velocity at a given radius we can determine the LOS
depth to the emitting material.

Under the assumption that all material in the galaxy rotates at the
circular speed the relation between measured and circular velocity
comes from simple geometry. Given a measured projected radius and
velocity, $r_{\mathrm{proj}}$ and $V_{\mathrm{obs}}$, respectively,
the effective location of the emitting material in cylindrical
coordinates centered on the galaxy is
\begin{align}
  \label{891_2:eq:vel_LOS}
  \phi &= \cos^{-1}\left(\frac{V_{\mathrm{obs}}}{V_{\mathrm{c}}}\right)\\
  r &= r_{\mathrm{proj}}\frac{V_{\mathrm{c}}}{V_{\mathrm{obs}}},
\end{align}
where $V_{\mathrm{c}}$ is the circular velocity. Due to the nearly
perfect edge-on nature of NGC 891 the projected radius,
$r_\mathrm{proj}$, can be measured directly as the on-sky distance
from the galaxy center. Measurements of $V_\mathrm{obs}$ are described
in \S\ref{891_2:sec:vel}.

To compute $V_c$ we construct a simple model rotation curve using
circular velocities derived from envelop-fitting the HI data of
\citet{Swaters97}. We also include the height-dependence on circular
speed reported by \citet{Oosterloo07}. These measurements of the
circular speed are based on collisional particles (i.e., gas) and are
therefore not perfect estimates for the circular speed of the stars,
which will lag the gas slightly due to asymmetric drift. However, in
the absence of measurements of the true, stellar circular speed the
gas velocities make an acceptable approximation. Our rotation curve
for NGC 891 is thus
\begin{multline}
  V_{\mathrm{c}}(r_{\mathrm{proj}},z) =
  (\val{-15.79}{\kms})\left(\frac{z}{\mathrm{kpc}}\right) \\
  + \left\{
    \begin{array}{ll}
      (\val{68.2}{\kms})\left(\frac{r_{\mathrm{proj}}}{\mathrm{kpc}}\right)
      & r_{\mathrm{proj}} < \val{3.3}{kpc}\\ \val{225}{\kms} &
      r_{\mathrm{proj}} \geq \val{3.3}{kpc}.\\
    \end{array}
    \right.
\end{multline}

%+++++++++++++++++++=
%% {\bf MAB: Note sentence I broke out about HI measuing circular
%%   speed. This needs a reference and also discussion up front of how
%%   you are going to use the measured variation in this speed with
%%   height from Oosterloo07. This should be noted again in the sentence
%%   starting with the sentnece ``Under the assumption...'' You can still
%%   leave your model to the end of the par. More broadly you want to
%%   discuss whether the trends in HI tangential speed with height is
%%   representative of the potential or a lagging gas halo that may not
%%   reflect the stellar tangential speed. Similarly, you should not the
%%   amplitude of the rotation and the vertical correction relative to
%%   asymmetric drift. I think the point is that the model is not perfect
%%   for stars, but seems a reasonable approach to the best
%%   approximation.
%------------------
%    You should discuss how uncertainties in the velocity
%%   model project to uncertainties in the inferred LOS depth, nothing
%%   that this is unlikely to introduce differential effects between the
%%   two halves of the galaxy.

%++++++++++++++++++=
%%   I am wondering about this sentence: ``In reality, however, when
%%   looking through an edge-on disk with high attenutation the measured
%%   velocity is the projected, LOS velocity of the emitting material at
%%   approximately 1 optical depth.'' Is this right and how to we
%%   reconcile it with the fact that we measure optical depths
%%   considerably greater than 1 in many lines of sight?

%++++++++++++++++=
%%   I would say something slightly different than `` we can determine
%%   the LOS depth to the emitting material.'' We are measuring a
%%   characteristic mean depth.
%++++++++++++++++
%%   Let me recommend that you simplify eqn 14. by specifying that r and
%%   z have units of kpc (you should go back and do the same for eqn. 11
%%   in the previous setion). Also note format of km s$^{-1}$.

%% }

Figure \ref{891_2:fig:velocity_projection} shows each aperture in its
velocity-derived cylindrical coordinate. We define the approaching
side of the galaxy ($r_\mathrm{proj} < 0$) to be at $\phi <
90^{\circ}$ and the receding side to have $\phi > 90^{\circ}$. With
this view the large-scale structure of NGC 891 becomes clear;
sight-lines to the receding side of NGC 891 probe the back of a spiral
arm, where \citet{Kamphuis07b} identifies a higher concentration of
dust, and as a result our measurements do not sample very far into the
disk. Conversely on the approaching side we see the leading edge of a
spiral arm, which has less dust due to ongoing star formation. On the
approaching side of the galaxy there is also a clear trend that we see
farther into the disk at larger heights, which is consistent with dust
occupying a disk with a surface density that decreases with height.

%+++++++++++++++++++
%% {\bf MAB: Explain your coordinate system in the sense of what $\phi$
%%   values correspond to approaching and receding sides. I think you can
%%   get away with the Kamphuis07 (a or b) ref here at least in terms of
%%   the spiral arm picture. What I am wondering about is if you want to
%%   address something about the phase-angle and pitch of the arms
%%   (qualitatively) in order to justify your picture here.
%-----------
%    Also, for the
%%   last sentence concerning height, this is very difficult to see from
%%   Fig 5. Have you tried plotting $R_{proj}/R_{LOS}$ (where I think
%%   $R_{LOS}$ is your r in eqn 13) vs z, marking for approaching vs
%%   receding? Or maybe it should be $R_{LOS}/R_{proj} - 1$ vs z. }

% \subsection{Extinction-based LOS Calculations}
% We can also estimate the LOS depth based on the measured optical depth in each
% aperture. Under the massively simplifying assumption that all of the
% attenuating material in NGC 891 occupies a doubly-exponential disk we can
% calculate the extinction coefficient at any point in the galaxy:
% \begin{equation}
%   \kappa(r,\phi,z) = \kappa_{V}\rho_0\exp\left(-\frac{r}{h_r}-\frac{|z|}{h_z}\right),
% \end{equation}
% where $r$, $\phi$, and $z$ are cylindrical coordinates, $\rho_0$ is density of
% dust at $r=z=0$, and $h_r$ and $h_z$ are the dust scale length and scale
% height, respectively. The optical depth at a given projected radius,
% $r_{\mathrm{proj}}$, and LOS depth, $y$, is then
% \begin{equation}
%   \tau_V(r_{\mathrm{proj}},y,z) = \exp\left(-\frac{|z|}{h_z}\right)\rho_0\kappa_V\int_0^y \exp\left(-\frac{\sqrt{r_{\mathrm{proj}}^2 + y'^2}}{h_r}\right) d y'.
% \end{equation}
% For our analysis we use values of $h_z=\val{0.29}{kpc}$,
% $h_r=\val{7.68}{kpc}$, and $\rho_0\kappa_V = \val{1.47}{m^{-1}}$, all taken
% from \citet{xilouris99}. {\bf NOTE: CHECK THE VALUE OF $\rho_0\kappa_V$}.

% In practice we compute the $\tau_V$ integral numerically for a grid of $y$
% values and then find the value of $y$ that matches \tauV measured from SSP
% fitting (\S\ref{891_2:sec:SSP_modeling}). Figure \ref{891_2:fig:tau_projection} shows each
% aperture in its \tauV-derived cylindirical coordinate. Note that right now
% this looks pretty messed up; at the largest heights the implication is that we
% can see through the entire galaxy. Maybe this isn't so crazy at \val{2}{kpc},
% but in that case why do we still measured $\tauV > 1$?

% \begin{figure}
%   \centering
%   \includegraphics[width=\columnwidth]{891_2/figs/tau_projection.png}
%   \caption{\label{891_2:fig:tau_projection}Map of the physical location of average
%     emission from each aperture, as determined by a \tauV-based LOS depth
%     calculation. The vertical dotted lines show the boundaries of the \GP
%     pointings shown in Figure \ref{891_2:fig:pointings}. Using the simple galaxy
%     model described in the text we find that many of the apertures show
%     measured \tauV values far above what would be expected at larger
%     heights. {\bf We need to confirm we're using the correct values. Also,
%       what about clumpiness, etc.?}}
% \end{figure}

% tau_balm vs tau_cont compared to predictions from e.g. Charlot
% projected radius map from velocity vs projected radius map from A_V


% !TEX root = ../main.tex
\newpage
\section{\mywork Emerging Network Topologies} \label{sec:EmergingNetworkTopologies}
%\textcolor{red}{TODO}: \textsl{explain in detail how the different methods \cref{eq:KempterSTDPFormulation2,eq:SongSTDPFormulation} will be implemented, using \STDP coupled with \IP.}

We will now investigate what topologies emerge from the learning procedures described in Chapter \ref{sec:HebbianLearningAndSynapticPlasticity}. Are the approaches presented in \cite{Kempter1999, Song2000, Song2017, ChrolCannon2012} plausible within the context of the Theta model? Do we obtain similar results concerning synchronisation and topology? Is there a reason for only allowing the network to make excitatory ($K_{ij} \geq 0$) connections?

\subsection{Conditions of the network}
As we saw in Chapter \ref{sec:MFRs}, the typical ranges for the coupling strength $\kappa$ and the mean excitability $\eta_0$ to alter the macroscopic state of the network drastically are fairly large. Using the Kempter method \eqref{eq:KempterSTDPFormulation2}, there is no limit on the magnitude of $K_{ij}$, though initial activity of the node degrees was observed within the interval [-100, 100].

When using the Song method \eqref{eq:SongSTDPFormulation} we will constrain $-K^{\rm max} \leq K_{ij} \leq K^{\rm max}$ to allow neurons to both exhibit exitatory and inhibitory behaviour. When testing different values of $K^{\rm max}$ no significant difference was observed in the results, except the time of reaching convergence of $\kmean$. To optimally compare the two methods we will use $K^{\rm max}$ = 100. $K_{ij}$ is initialised using a uniform distribution over $[-K^{\rm max}, K^{\rm max}]$, as to minimise influence of the initial distribution on the resulting topology.\\

The networks we will study consist of 100 Theta neurons, as the computational task of numerically solving the learning equations until convergence is a heavy one. Larger networks are more difficult to simulate, but smaller networks might be more susceptible to the stochastic behaviour of a few neurons. The networks will be initialised with $\theta_i$ equidistantly distributed over $\T$, so that $| Z(0) |$ = 0 exactly. The excitabilities $\eta_i$ are set to zero for all neurons.
When investigating \STDP + \IP, the excitability is allowed to change over the same domain as $K_{ij}$, in accordance to our comments on $\eta_i$ and $I_i$ cancelling each other out. Therefore we take $\eta_{\max} = K^{\rm max}$ and just like $K_{ij}$, $\eta_i$ is initialised using a uniform distribution over $[-\eta_{\max}, \eta_{\max}]$.

\subsection{Tuning hyperparameters for \texorpdfstring{$W_K$}{TEXT}}
We decided to scale all learning windows presented in Chapter \ref{sec:HebbianLearningAndSynapticPlasticity} to the same order of magnitude, to make for a fair comparison of the learning dynamics over time. What is left now is to tune the hyperparameters $w^{\mathrm{in}}$ and $w^{\mathrm{out}}$. Looking at Figure \ref{fig:KempterWinWout}, we can see that we cannot simply use the same magnitude as the learning window: the dynamics are disturbed by the large discrete changes induced by $w^{\mathrm{in}}$ and $w^{\mathrm{out}}$. A better solution is obtained by using $w^{\mathrm{in}}$ = 10$^{-3}$.

\begin{figure}[H]
\centering
\includegraphics[width = \textwidth]{../Figures/Learning/KempterWinWout.pdf}
\caption{Tuning of the hyperparameters $w^{\mathrm{in}}$ and $w^{\mathrm{out}} = -1.0475  w^{\mathrm{in}}$. The order parameter $Z(t)$ is given in black and the mean network degree $\kmean$ in green. $Z$ is initialised as zero and quickly becomes non-zero. When neurons start bursting we can see a big drop in synchronisation, and a large increase in $\kmean$, meaning that the \STDP method works. Left: the learning dynamics with zero weights, as a benchmark. Middle: the learning dynamics for small, non-zero weights. The mean coupling strength is higher, but the overall synchronisation is lower. This might yield an interesting topological structure. Right: the learning dynamics with the same magnitude as the learning window disturb the learning process.}
\label{fig:KempterWinWout}
\end{figure}

\subsection{Results of \STDP} \label{sec:STDPlearning} %applied to networks of theta neurons
We can now use the Kempter method and its corresponding learning window and compare it to the Song method and the bi- and triphasic learning windows. The results are shown in Figure \ref{fig:STDP}. It is remarkable how easily the different methods can be recognised, like the influence of the sign and magnitude of the correlation: using $W_C$ yields the most evidence of adaptation. Interestingly, the in- and outdegrees are remarkably similar, and this might endorse our approach of obtaining an asymmetrical adjacency matrix by using $\koutb = \permute ( \kinb )$ in Chapter \ref{sec:MFRSUndirected}. \\

In the first column of plots, we can see the overall synchronisation of the network and its mean node degree as it learns over time. The Kempter method does not seem to converge for any time period under the circumstances described before. We find the network right before larger node degrees start taking off to higher orders, and remarkably the synchronisation is very low. This might be due to the fact that the modus of $K_{ij}$ lies close to zero.

The coupling matrix does not seem to contain a lot of structure: a high number of nodes have only a low degree, and so most of the network topology disappears as grey lines. The nodes with very high or very low degrees are sparsely distributed across the matrix. When we look at the histogram underneath, a lognormal shape can be identified. Remember that no constraints are applied to $K_{ij}$, so its is remarkable a structure seems to appear. Underneath, we can see the node degrees follow a clear correlation, with a more clustered behaviour for high degrees. \\

In the second column we can see the results of using the Song method with $W_S$. The learning behaviour is more regular and we can observe that with an increasing network connectivity we obtain increased synchronisation. Convergence is near completion, and we can see the separation between two clusters of node degrees in the high-contrast image of $K_{ij}$, and in all histograms and plots. We can interpret the scatterplot of $\kin$ versus $\kout$ as a small group of nodes of varying degrees, and a large group of node degrees at the limits, as the definition of the degree vectors \eqref{eq:redefineFromK} takes only the absolute value. Most neurons see their synaptic strength decreased by the negative correlation. There is only a small fraction of oscillators that has learned to spike at the right time and manages to keep increasing its synaptic strength and eventually ends up at $K^{\rm max}$. \\%The dichotomy may also be found in the shape of the learning window: the large difference

In the third column we can see the results of using the Song method with $W_C$. Convergence to a steady-state happens much more steadily, and also the synchronisation benefits from this approach. The coupling matrix shows an even stronger partition, as even fewer neurons manage to learn to spike at the right interval. It is even more clear here how well the network is split into two distinct groups with either high or low node degrees.\\

It is useful to review our choice to define $\kin$ from the absolute value of $K_{ij}$. One can see this operation as folding the histogram of $K_{ij}$ in half at 0, and one can argue that inherently information is lost. However, when not accounting for the sign of the synaptic strength, they might cancel out and a node degree of zero might be found for even the best connected neurons. What we do lose is the ability to see positive or negative correlation, but that information can be found from the learning window, or from the mean value of the histogram of $K_{ij}$.

\subsection{Results of \STDP + \IP} \label{sec:STDPandIPlearning}
When introducing intrinsic plasticity, the expected changes to $\eta_i$ counteract $K_{ij}$ as expected: $\eta_i$ is cranked up to the largest possible value for virtually all neurons, but it does seem to have an effect on the topology. The results are shown in Figure \ref{fig:STDPandIP}.

We find the Kempter method again on the verge of exploding, where nodes with a large degree (both negative and positive) are about to take off to even larger orders of magnitude. The overall structure is similar as before, but the positive correlation between in- and out-degrees is stronger. The synchronisation is again remarkably low, as the modus of $K_{ij}$ lies close to zero again. It seems like $K_{ij}$ is more symmetric than before.

The Song method benefits from a faster convergence, which we can see in the second and third column. This is likely due to the neurons becoming less susceptible with an increased excitability. A more uniform distribution of node degrees can be found between the two extrema, as convergence has halted. For both methods the dichotomy between low and high degree nodes is more clear, especially for $W_C$.

\subsection{Interpretation of the results}
When comparing the results of \STDP with and without \IP, we can observe that including the excitability as a learnable parameter, the learning process is more stable, and convergence can be achieved using the Song method. A relation appears to exist between the in- and out-degrees of different nodes, and the degree distributions appear even more similar.

It is remarkable that in only few cases the network of Theta neurons finds an equilibrium state. These can be recognised immediately, as all learning stops and the synchronisation is 1. It appears that the changing network topology is enough to sustain a globally periodic spiking regime, though we assume individual neurons switch between the excitable and bifurcation regimes as well, due to the highly variable nature of the term $\eta_i + I_i$, which is right at the heart of our learning. \\

As speculated before, we can also interpret the convergence of the results as $\eta_i$ and $K_{ij}$ cancelling each other out. Learning only occurs when the neurons are spiking, and as this is regulated by $W$ we want the firing rates to be close to the maximum of the learning window. That would result in the largest desirable increase in $K_{ij}$, and therefore a large incoming current $I_i$. As $N$ = 100, we can easily expect $I_i$ to be around that number. With \IP however, when $\eta_i + I_i$ is close to zero, the time required to spike can be very long, as we saw in Chapter \ref{TheThetaNeuronModel}. Only nodes with the highest coupling strength are able to overcome this threshold.

\newpage
\begin{figure}[H]
\centering
\includegraphics[height = \textheight]{../Figures/Learning/STDP.pdf}
\caption{Results of the \STDP learning.}
\label{fig:STDP}
\end{figure}

\begin{figure}[H]
\centering
\includegraphics[height = \textheight]{../Figures/Learning/STDPandIP.pdf}
\caption{Results of the \STDP learning with \IP learning.}
\label{fig:STDPandIP}
\end{figure}


\section{Automated Angle-Informed Variance Reduction Methods}
\label{sec:AngleVR}

In a number of problems, the angular dependence of the flux is significant enough that
biasing in space and energy exclusively is not
sufficient. As a result, a subset of hybrid methods were developed to incorporate some
degree of the flux anisotropy in variance reduction parameters. Without explicitly
calculating the angular flux, which is memory- and storage-intensive, methods
attempted to approximate the angular flux using other information more readily
accessible to them. These approaches are broadly categorized as methods that
bias using population control methods (such as weight windows),
and methods that bias with modified
sampling methods (such as the exponential transform).
Initial approaches
to angular biasing focused on approximating the angular flux, $\psi$,
as a separable
function of the scalar flux and an angle-dependent multiplier.
These approximations of the flux were then used to generate biasing
parameters dependent on angle for highly angular-dependent problems. In this
section, methods that generate variance reduction parameters dependent on angle
or that include angular information are described.

\subsection{Angular Biasing with Population Control Methods}

\subsubsection{AVATAR}
\label{subsec:AVATAR}

The AVATAR \cite{van_riper_generation_1995, van_riper_avatarautomatic_1997}
(Automatic Variance and Time of Analysis Reduction) method generates
three-dimensional, space-, energy- and angle-dependent weight windows for Monte
Carlo. The implementation of AVATAR by the authors
uses a relatively course-mesh and few-angle deterministic calculation in
THREEDANT, approximating the angular flux as a function of the scalar flux, and
then subsequently passes those flux values through a postprocessing
code, Justine, to generate
weight windows for MCNP \cite{mcnp_manual_v1}. The AVATAR approach to
determining the angular flux uses an approximation of the angular flux based on
the maximum entropy distribution, which is briefly summarized in the next
few paragraphs.

\subsubsection*{Information Theory}

First, for a given set of discrete values $x_i, \: i=1,2, \cdots n$
that are passed to a function, $f(x)$, the expectation value of that function is given
by
\begin{equation}
  \big\langle f(x) \big\rangle = \sum_{i=1}^n p_if(x_i).
\end{equation}
For the probability distribution $p_i = p(x_i)$, $i=1,2, \cdots n$, the entropy of
$p$ is defined as
\begin{equation}
  H(p) = - K \Sigma_i p_i \ln p_i \:,
  \label{eq:entropy}
\end{equation}
where $K$ is a positive constant. A proof that this is indeed the associated
maximal entropy associated with all $p_i$ is given in
\cite{jaynes_information_1957}.
For a continuous probability density function $p(x)$ over the interval I, the
entropy of the continuous function is
\begin{equation}
  H(p) = - K \int_I\ p(x) \ln p(x) dx .
\end{equation}

To maximize either of these distributions, while also maintaining that $\Sigma
p_i = 1$, one can use Lagrangian multipliers $\lambda$ and $\mu$
\begin{equation}
  p_i = e^{-\lambda-\mu f(x_i)} .
\end{equation}
This set of equations can be solved using
\begin{subequations}
  \begin{equation}
    \big\langle f(x) \big\rangle = - \frac{\partial}{\partial \mu} \ln Z(\mu)\:,
  \end{equation}
  and
  \begin{equation}
    \lambda = \ln\big[Z(\mu)\big] \:,
  \end{equation}
  where
  \begin{equation}
    Z(\mu) = \Sigma_i e^{-\mu f(x_i)} .
  \end{equation}
\end{subequations}

Jaynes \cite{jaynes_information_1957, jaynes_information_1957-1}
showed that the maximum
entropy probability distribution function corresponding to the previous
equations is given by
\begin{equation}
  p_i= \exp \big[ - \big( \lambda_0 + \lambda_1f_1(x_1) + \cdots + \lambda_m f_m(x_i) \
    \big) \big] ,
\end{equation}
and the entropy of this distribution is given by
\begin{equation}
  S_{max} = \lambda_0 + \lambda_1 \big\langle f_1 (x) \big\rangle + \cdots + \
  \lambda_m \big\langle f_m(x) \big\rangle .
\end{equation}
In this case, the constant $K$ from Eq. \eqref{eq:entropy} has been set to 1.

The maximum entropy approach to calculating a probability distribution function
is an attractive option given limited information about that
distribution. This method's power lies in that it
deduces a function given limited information, but does not place too great of an
importance on missing or unwarranted information. Furthermore, a distribution
ascertained from this methodology will encompass all distributions with smaller
entropies that satisfy the same constraints. Thus, the method provides the most widely
applicable probability distribution function for the system that has been
defined.

Moskalev showed that by using the maximum entropy approach, a distribution function
could be reconstructed from a (truncated) Legendre expansion
\cite{moskalev_reconstruction_1993}. This is particularly
applicable to radiation transport because scattering terms are often truncated
Legendre expansions. In his application, Moskalev derived a generalized form of
reconstructing a probability distribution from a truncated expansion, where the
true function represented by a Legendre polynomial series,
\begin{equation}
  f(L,\mu) = \sum_{l=0}^L -\frac{2l+1}{2} f_l P_l(\mu)\:,
\end{equation}
could be associated with an adjusted function (obtained from maximizing the
entropy of the known values),
\begin{equation}
  \tilde{f}(L,\mu) = \exp \big( \sum_{l=0}^{L} \lambda_l P_l(\mu) \big)\:,
\end{equation}
such that
\begin{equation}
  (f,P_l) = (\tilde{f}, P_l); \quad l = 0, \cdots, L .
\end{equation}
Here, $\lambda_l$ are the Lagrange multipliers, $\tilde{f}$ and $f$ are
$\in \phi$, and are assumed to be a function of $\mu$ such that $f(\mu)
\geq 0, \mu \in [-1, 1]$.
These generalized equations were then applied to
group-to-group scattering probability distribution functions, as well as
reconstructing a $L=3$ function. The reconstruction showed agreement except near
the extrema of $\mu$.

Walters and Wareing \cite{walters_nonlinear_1994, walters_accurate_1996} showed
that the angle-dependent source definition for a discrete ordinates transport problem
could be calculated using Moskalev's approach
\cite{moskalev_reconstruction_1993}. In their method, they used this approach to
reconstruct the source distribution of particles in each cell from the source
moments. For standard methods, the source in a cell expanded in Legendre moments is
\begin{equation}
  S_m(x) = S_{m,j}\bigg[ P_0(x) + \frac{S_{m,j}^x}{S_{m,j}}P_1(x)\bigg]\:,
\end{equation}
where $S_{m,j}$ is the average source in cell $j$, direction $m$, $S_{m,j}^x$ is the
$P_1(x)$ moment of the source, and the $P_0$ and $P_1$ are the associated
Legendre polynomials. Using a normalized source distribution $s_m(x)$ where
\begin{equation*}
  S_m(x) = s_m(x) S_{m,j},
\end{equation*}
and the normalized distribution is
\begin{equation}
  s_m(x) = \big[ s_0 + s_1 P_1(x)\big]\:.
\end{equation}
In this equation,
$s_0$ and $s_1$ are the zeroth and first Legendre moments of the source,
respectively.
The source distribution derived from the maximum entropy distribution is
\begin{equation}
  \tilde{s}(x) = \frac{\lambda_{1,k}}{\sinh (\lambda_{1,j})} \
  e^{\lambda_{1,j}P_1(x)} .
\end{equation}
$\tilde{s}$ has normalized Legendre moments $s_0$ and $s_1$ that match
$s_m(x)$. Because $\tilde{s}$ satisfies the information that can be obtained
about $s_m$, it can be used to reconstruct $S_m(x)$:
\begin{equation}
  S_m(x) = \tilde{s}_m(x)S_{m,j}.
\label{eq:Walt_reconstruct}
\end{equation}
$\lambda_{1,j}$ can be found with
\begin{equation}
  s_1 = 3\bigg[ \coth(\lambda_{1,j} - \frac{1}{\lambda_{1,j}})\bigg] .
  \label{eq:WW_lambda}
\end{equation}
It should be noted that the same methodology that Walters and Wareing use to reconstruct the source
distribution from the source moments can be used to reconstruct the angular flux
in cells based on moments of the angular flux (i.e.\ the scalar flux and
current) \cite{walters_nonlinear_1994}.

In their paper, Walters and Wareing \cite{walters_accurate_1996} suggested that in place of
solving Eq.\ \eqref{eq:WW_lambda} for $\lambda_{1,j}$, that a rational polynomial
be used in its place to reduce computational time. The
suggested polynomial for $0 \leq \lambda_{1,j} \leq 5$ is:
\newcommand{\lamvar}{\dfrac{s_{1,j}}{3}}
\begin{equation}
  \lambda_{1,j} =  \dfrac{2.99821 (\lamvar) - 2.2669248 (\lamvar)^2 }{1 - 0.769332
             (\lamvar) -0.519928 (\lamvar)^2 + 0.2691594 (\lamvar)^3} \:, \\
\end{equation}
and for $\lambda \geq 5$:
\begin{equation}
  \lambda_{1,j} = \frac{1}{1-\bar\mu} \:.
\end{equation}
A full derivation of Eq. \eqref{eq:WW_lambda} and how it satisfies the maximum
entropy requirements can be found in Appendix A of Ref.\
\cite{walters_accurate_1996}.

In their application, Walters and Wareing found that this method was accurate
over a fairly course mesh for the problems analyzed, and the computed fluxes
remained positive over the solution space. When compared to other methods, this
approach performed much better on coarse meshes. However, the analysis was
limited to 1D problems. As mesh size grew finer, the method
performed similarly to other methods. Near vacuum boundary conditions,
$\lambda_{1,j} \rightarrow \infty$ at the cell boundary, causing issues in
calculating the flux in these cells.

\subsubsection*{AVATAR Implementation}

AVATAR uss a deterministically-obtained solution of the adjoint scalar flux and
adjoint currents to
reconstruct the angular flux distribution. The angular flux distribution is then
used to generate weight windows.
AVATAR built off of the methodology described by Walters and Wareing
\cite{walters_nonlinear_1994, walters_accurate_1996}, but instead of
reconstructing the source distribution inside the cell, the maximum entropy
method was used to reconstruct the angular fluxes. Thus the angular flux,
$\psi$,
was reconstructed with the scalar flux, $\phi$, and the current, $J$.

AVATAR avoided generating explicit angular fluxes with
THREEDANT by assuming
that the adjoint angular flux is symmetric about the average adjoint current vector,
$J^{\dagger}$ :
\begin{subequations}
\label{avatareqns}
\begin{equation}
  \psi^{\dagger}(\hat\Omega) = \psi^{\dagger}(\hat\Omega\cdot n) \:,
  \label{eq:Av1}
\end{equation}
where
\begin{equation}
  n = \frac{J^{\dagger}}{ \left\| J^{\dagger} \right\| }.
\end{equation}
Note that $n, J, \psi,$ and $\phi$ all have implied dependence on $(\vec{r},
E)$.
The angular flux could then be reconstructed assuming that the angular flux is a
product of the scalar flux and some angle-dependent function
\begin{equation}
  \psi^{\dagger}(\hat \Omega \cdot n) = \phi^{\dagger} f(\hat\Omega \cdot n).
  \label{eq:Av2}
\end{equation}
Note that Eq.\ \eqref{eq:Av2} takes the form of Eq.\ \eqref{eq:Walt_reconstruct}.
Thus $f$ is derived from the maximum entropy distribution:
\begin{equation}
f(\hat\Omega \cdot n) = \frac{\lambda e^{(\hat\Omega \cdot n)\lambda}}
                             {2 \sinh {\lambda} }\:,
  \label{eq:Av25}
\end{equation}
and $\lambda$ is a function of the average cosine $\bar\mu$
\begin{equation}
\begin{split}
\lambda  & = \frac{2.99821 \bar\mu - 2.2669248 {\bar\mu}^2 }{1 - 0.769332
             \bar\mu -0.519928 {\bar\mu}^2 + 0.2691594 {\bar\mu}^3} \\
         & = \frac{1}{1-\bar\mu} \\
  \label{eq:Av3}
\end{split}
\end{equation}
for $ 0 \le \bar\mu < 0.8001$ and $0.8001 \le \bar\mu < 1.0 $, respectively.
Also, $\mu$ is given by
\begin{equation}
\bar\mu(\vec{r}, E) = \frac{\left\| J^{\dagger}(\vec{r}, E)
                     \right\|}{\phi^{\dagger}(\vec{r}, E)}.
  \label{eq:Av4}
\end{equation}
\label{eq:AvEqns}
\end{subequations}
Equations \eqref{eq:Av3} and \eqref{eq:Av4} are exact in both isotropic and
streaming conditions \cite{van_riper_generation_1995}.

Using the calculation of the angular flux described in Eqs.\ \eqref{eq:Av1}
through \eqref{eq:Av4}, angle-dependent weight windows can be constructed.
AVATAR's space- energy- and angle-dependent weight window is given by
\begin{equation}
\bar {w} (\vec{r},E,\hat\Omega) = \frac{k}{\phi^{\dagger}(\vec{r},E)
                                  f(\hat\Omega \cdot n)},
\end{equation}
where $k$ is a constant that can be adjusted to match the source distribution.
In the case of AVATAR, $k$ was used as a normalization factor to ensure that
source particles are born with weights within the weight window.
AVATAR exclusively generated weight windows, and did not attempt to consistently
bias the source
distribution. Physically, the assumption behind AVATAR is that the adjoint
angular flux
is locally one-dimensional, so azimuthal symmetry is assumed.

\subsubsection*{AVATAR Results}

The authors of AVATAR showed that AVATAR's angularly-dependent
weight windows improved the FOM (from 5x to 7x) for a multiple-tally well-logging
problem compared to the MCNP weight window generator. AVATAR was also compared
to other methods in subsequent papers \cite{evans_enhanced_1998}. In an
update of the MCNP weight window generator, AVATAR was compared to variants of
the weight window generator and had a FOM of 79 while variants of the
weight window generator had FOMs ranging from 105 to 119
\cite{evans_enhanced_1998}. However, the MCNP weight window generator required
multiple iterations of Monte Carlo transport to converge on weight window values
while AVATAR did not. Total runtimes for iteratively converging on weight window
values were in the 200 to 300 minute range, while AVATAR took roughly 5
minutes to converge on weight window values for the problem. Whether these
calculations were performed in serial or parallel were not discussed.

The MCNP weight window generator has also been adapted to use weight window
values seeded by a solution from AVATAR \cite{evans_enhanced_1998}. This method
had FOMs comparable to the default MCNP weight window generator, but only
required 1 iteration to converge rather than 3. This reduced the total
transport runtime from roughly 260 minutes to 140 minutes, but still required
user experience and input to adequately set up and prepare the deterministic
input for AVATAR.

The method used by AVATAR to produce angle-dependent weight windows successfully
incorporated angular information into variance reduction parameters for Monte Carlo
with very little additional computational burden. However, because AVATAR
was not fully automated, the user had to have knowledge on the use of the $S_N$
deterministic solver in addition to the Monte Carlo methods they were trying to
optimize. As a result, the user needed to adequately prepare the deterministic
inputs, correctly specify the adjoint source for the deterministic solve, and
then pass these values to postprocessing software \cite{peplow_consistent_2012,
evans_enhanced_1998}. The FOMs reported with AVATAR did not incorporate the
additional time required for user setup and preparation of inputs. Though this
is not a customary time inclusion, the burden of time for this process may be
significant. Though more computationally efficient than the weight window generator,
this aspect of AVATAR may be too substantive of an obstacle for new-user
approachability. Further, it leaves more room for user-induced error.

The AVATAR method
\cite{van_riper_generation_1995, van_riper_avatarautomatic_1997} used an
approximation of the angular flux--without explicitly calculating it--to
generate angle-dependent weight windows. It operated with the approximation
that
the angular flux was separable and symmetric about the average current vector.
The angular flux was then calculated using
a product of a deterministically-obtained
scalar flux and an exponential function, derived from the
maximum entropy distribution, that was a function of the scalar flux and the
current. Space-, energy-, and angle-dependent weight windows for
the Monte Carlo problem were then generated from the inverse of the angular
flux. AVATAR improved the FOM for sample problems from 2 to 5 times, but did not
apply to problems where the flux was not azimuthally symmetric.

%
%----------------------------------------------------------------------------------------

\subsubsection{Simple Angular CADIS}
\label{sec:simpAngCADIS}

Simple Angular CADIS \cite{peplow_consistent_2012} is built on the theory of CADIS
and FW-CADIS, but incorporates angular information in the
methods. Simple Angular CADIS does so without explicitly using
angular flux solutions from the deterministic solution.
Instead, the method reconstructs the angular flux in the same manner employed by
AVATAR, and additionally consistently
biases the
source distribution with the weight windows using the same methodology as CADIS
and FW-CADIS. Recall that the original
implementation of AVATAR did not have consistent source biasing.
In their work, Peplow et al.\ implemented simple angular CADIS
in MAVRIC, a hybrid methods software package distributed with the SCALE
codebase \cite{SCALE6_1}. The Simple Angular CADIS method was implemented with
two different
approaches to variance reduction:
directionally-dependent weight windows with directionally-dependent source
biasing and directionally-dependent weight windows without directional source
biasing.

\subsubsection*{Theory}

The Simple Angular CADIS approach, like AVATAR, uses a reconstruction of the
angular flux derived from the maximum entropy distribution (Section
\ref{subsec:AVATAR}). In Simple Angular CADIS, the authors approximate the
adjoint angular flux such that
%
\begin{equation}
\psi^{\dagger}(\vec{r}, E, \hat \Omega) \cong \phi^{\dagger}(\vec{r}, E)
\frac{1}{2\pi} f(\hat\Omega \cdot \hat n)\:,
\label{eq:AvAngflux}
\end{equation}
where $f(\hat\Omega \cdot \hat n)$ is given by the same Eqs. \
\eqref{eq:Av25}, \eqref{eq:Av3}, \eqref{eq:Av4} as AVATAR.
Note that this differs from AVATAR's reconstruction of the angular flux,
Eq. \eqref{eq:Av1}, by a factor of $1/2\pi$. As it was only dependent on
$\mu$, AVATAR's original approach assumed azimuthal symmetry, but did not
incorporate any factor of integration into the angular flux reconstruction. By
including the azimuthal integration factor of $1/2\pi$, this version of
$\psi^{\dagger}$ satisfies
\begin{equation*}
  \phi^{\dagger}(\vec{r}, E) = \int \phi^{\dagger} \frac{1}{2\pi} f(\hat\Omega
  \cdot \hat n) d \hat\Omega .
\end{equation*}
The corresponding angle-dependent weight windows are then given by:
\begin{equation}
\bar {w} (\vec{r},E,\hat\Omega) = \frac{2 \pi k}{\phi^{\dagger}(\vec{r},E)
                                  f(\hat\Omega \cdot n)} \:.
\end{equation}

For the variant method with directionally-dependent weight windows and without
directional
source biasing, the biasing parameters are given by Eqs.\ \eqref{SA-CADIS1}.
\begin{subequations}
The biased source distribution, $\hat{q}(\vec{r},E,\hat\Omega)$,
is given by a combination of the standard CADIS
biased source, $\phi^{\dagger}(\vec{r},E)$ and the original directional
source distribution, $q(\hat\Omega \cdot \hat d)$ such that
\begin{equation}
\begin{split}
\hat{q}(\vec{r},E,\hat\Omega) & = \frac{1}{R} q(\vec{r},E) \phi^{\dagger}
                                  (\vec{r},E) \frac{1}{2 \pi} q(\hat\Omega \cdot
                                  \hat d)\\
                              & = \hat{q}(\vec{r},E) \frac{1}{2 \pi}
                              q(\hat\Omega \cdot \hat d).
\end{split}
\end{equation}
The direction $\hat d$ is sampled using the original directional source
distribution $q(\hat\Omega \cdot \hat d)$.
The birth weight matches standard CADIS with
\begin{equation}
\begin{split}
  w_0 (\vec{r},E,\hat\Omega)  & = \frac{q(\vec{r},E,\hat\Omega)}{\hat{q}(\vec{r},E,\hat\Omega)} \\
     & = \frac{R}{\phi^{+}(\vec {r} ,E)},
\end{split}
\end{equation}
and the weight window target value is given by
\begin{equation}
\begin{split}
\bar{w} (\vec{r},E,\hat\Omega)  & = \frac{R}{\phi^{\dagger}(\vec{r},E)}
                                    \frac{f(\hat{\Omega_0}\cdot n(\vec{r_0}, E_0))}
                                    {f(\hat\Omega \cdot n)} \\
                                & = \bar{w}(\vec{r},E) \frac{f(\hat{\Omega_0}\cdot
                                    n(\vec{r_0}, E_0))}{f(\hat\Omega \cdot n)}.
\end{split}
\end{equation}
\label{SA-CADIS1}
\end{subequations}
Note that the biased source distribution, $\hat{q}(\vec{r},E,\hat\Omega)$, is a
function of
the biased source distribution from standard space- energy-CADIS and of the
original
directional source distribution. This is why this method has directional weight
windows,
but not directional source biasing.
For the second method, with directionally-dependent weight windows and with
directional
source biasing, the biasing parameters are given by the equations summarized in
Eqs.\ \eqref{SA-CADIS2}.
The biased source distribution is given by a combination of the
space-energy biased source distribution, the original directional source
distribution, and a directionally-dependent biased source distribution,
$f(\hat\Omega \cdot \hat{n_0})$, such that
\begin{subequations}
\label{SA-CADIS2}
\begin{equation}
\begin{split}
\hat{q}(\vec{r},E,\hat\Omega) & = \frac{1}{Rc} q(\vec{r},E,\hat\Omega)
                                  \phi^{\dagger}(\vec{r},E,\hat\Omega) \\
                              & = \left[ \frac{1}{R}q(\vec{r},E)
                                \phi^{\dagger}(\vec{r},E)
                                  \right] \left[\frac{1}{c}\frac{1}{2 \pi}
                                    q(\hat\Omega
                                  \cdot \hat d) \frac{1}{2 \pi}
                                  f (\hat\Omega \cdot n_0)\right]  \\
                             & = \hat{q}(\vec{r},E) \left[\frac{1}{c}\frac{1}{2 \pi}
                                 q(\hat\Omega \cdot \hat d) \frac{1}{2 \pi}
                                 f(\hat\Omega \cdot n_0) \right].
\end{split}
\end{equation}
The constant $c$ is given by
\begin{equation}
c = \int{\frac{1}{2 \pi} q(\hat\Omega \cdot \hat d) \frac{1}{2 \pi}
    f (\hat\Omega \cdot n_0)} d\hat\Omega.
\end{equation}
The birth weights are also a function of direction, where
\begin{equation}
\begin{split}
  w_0 (\vec{r},E,\hat\Omega)  &= \frac{q(\vec{r},E,\hat\Omega)}{\hat{q}(\vec{r},E,\hat\Omega)} \\
     &= \frac{R}{\phi^{+}(\vec {r} ,E)} \frac{2 \pi c}{f(\hat\Omega \cdot n_0)},
\end{split}
\end{equation}
as are the target weights
\begin{equation}
\begin{split}
\bar{w} (\vec{r},E,\hat\Omega)  &= \frac{R}{\phi^{\dagger}(\vec{r},E)}
                                   \frac{2 \pi c}{f(\hat\Omega \cdot n_0)} \\
                                &= \bar{w}(\vec{r},E) \frac{2 \pi
                                    c}{f(\hat\Omega \cdot n)}.
\end{split}
\end{equation}
\end{subequations}

Details about how the aforementioned equations were practically implemented are
detailed in Ref.\ \cite{peplow_consistent_2012}. The motivated reader may explore this
reference for details on the calculation of $\lambda$, $\bar{\mu}$,
$\left\| J^{\dagger}(\vec{r}, E)\right\|$, and $f(\hat\Omega \cdot \hat{n_0})$

\subsubsection*{Results}

To test these two modifications of CADIS, the authors ran a number of test
problems and
compared them against standard implementations of CADIS and analog Monte Carlo
runs. For a spherical boat test problem, Simple Angular CADIS without
directional biasing improved the FOM by a factor of 2 to 3. Note that because
the source is monodirectional, directional source biasing was not compared.
Simple Angular CADIS with- and without- directional source biasing improved the
FOM for active interrogation sample problems and for simple duct streaming
problems. The methods did not improve the FOMs for sample problems using a neutron
porosity tool or a gamma-ray litho-density tool.

The range in performance for
angle-dependent problems was explained by the authors as a failure of the
angular flux approximation to capture the true distribution of the angular flux.
Because Simple Angular CADIS uses the same approximation in calculating the
angular flux (Eq.\ \eqref{eq:AvAngflux}) as AVATAR, it is limited in the types of anisotropy
that it can capture. As a result, the biasing parameters for a problem are
unlikely to
adequately reflect the flux distribution in problems where the flux is not
captured effectively by the P$_1$ expansion.

The authors also noted that because the weight window is dependent on
space/energy/angle, the source birth weights only matched
the weight window target values at a specific point in the weight window region.
If the weight window covered a substantial region of phase-space, this could
result in particle birth weights that do not adequately correspond to the
importance of the region that they are born into, resulting in increased runtime
and a more computationally-intensive calculation.

\subsubsection{Cooper's Weight Windows}
Cooper and Larsen, in addition to generating global isotropic weight windows
from a deterministic forward solution (as
described
in Section \ref{subsec:CooperGlobal}), also developed angle-dependent weight windows
\cite{cooper_automated_2001}. Here, the forward angular flux is calculated in a
similar
manner as the AVATAR method, where the angular flux is a product of the scalar
flux and an angle-dependent function. In this case, the adjustment factor also
includes a factor of $4\pi$,
\begin{subequations}
\label{cooperangle}
\begin{equation}
  \psi(\vec{r},\hat\Omega) \approx A(\vec{r})e^{\vec{B}(\vec{r}) \cdot \hat\Omega},
  \label{eq:cooper1}
\end{equation}
where $A(\vec{r})$ and $\vec{B}(\vec{r})$ are given by:
\begin{equation}
A(\vec{r}) = \frac{\phi(\vec{r})}{4 \pi}\frac{B(\vec{r})}{\sinh B(\vec{r})}
\end{equation}
\begin{equation}
  \vec{B}(\vec{r}) = B(\vec{r}) \frac{\vec{\lambda}(\vec{r})}{\left|
    \vec{\lambda}(\vec{r}) \right|}
\end{equation}
and
\begin{equation}
\lambda(\vec{r}) = \coth B(\vec{r}) - \frac{1}{B(\vec{r})}.
\end{equation}

If both $A(\vec{r})$ and $\vec{B}(\vec{r})$ are inserted into the equation for
$\psi(\vec{r}, \hat\Omega)$, Eq. \eqref{eq:cooper1},
the formulation will be very similar to AVATAR's
reconstruction of the angular flux. However, Cooper's method differs from
AVATAR in the calculation of $\lambda(\vec{r})$.
Cooper noted that $\lambda(\vec{r})$ could be estimated with either the scalar fluxes
and currents from a fairly low-cost quasidiffusion calculation,
\begin{equation}
  \begin{split}
    \lambda_i(\vec{r})  & = \frac{J_i(\vec{r})}{\phi(\vec{r})} \\
                        & = \frac{1}{\Sigma_{tr}(\vec{r})\phi(\vec{r})}
                       \frac{\partial}{\partial r_j} E_{ij}(\vec{r})
                       \phi(\vec{r})\:,
  \end{split}
\end{equation}
or with the scalar fluxes and
currents directly
from the Monte Carlo solution (recall that $E_{ij}(\vec{r})$ is the Eddington
factor described in Section \ref{subsec:CooperGlobal}).
Cooper noted that because Monte Carlo robustly
calculates
these values, it is the more optimal choice. After obtaining these values from
the deterministic calculation, Cooper's angle-dependent weight window could be
calculated with
\begin{equation}
ww_{i,j} (\hat\Omega)= \frac{\psi_{i,j}(\vec{r},\hat\Omega)} {max\phi_{i',j'}/4\pi}.
\end{equation}
\end{subequations}

As mentioned in Section \ref{subsec:CooperGlobal}, Cooper's method was limited in that it used an
iterative quasidiffusion / Monte Carlo solution to generate the biasing parameters for
the problem. This method was not automated; and the ideal frequency between iterations
was never explored. However, Cooper showed in two-dimensional example problems
that the angularly-dependent weight windows
significantly improved the figure of merit as compared to analog Monte Carlo.
The distributions of the FOM and the resulting tally were also much smoother
with the approach described in their work.
Further, the
angular weight windows performed slightly better than the isotropic weight windows in
evenly distributing the particles, even in problems where the anisotropy was not
significant. However, like
AVATAR, this method is limited in the types of anisotropy it can quantify due to
the approximations it uses to reconstruct the angular flux. In generating the
estimates for $\vec{\lambda}$, the authors found that using a quasidiffusion
estimate was more efficient than using Monte Carlo estimates, likely because the
estimates of the factors could be periodically updated as the solution
iteratively converged.
%
%
%----------------------------------------------------------------------------------------

\subsection{Angular Biasing Using the Exponential Transform}

\subsubsection{Early Work}

As discussed in Section \ref{subsec:MCVR}, the exponential transform is a modified
sampling method that adjusts the distance-to-collision in Monte Carlo
transport to encourage particle transport in preferential regions. This is done
by modifying the sampled cross section.
Recall from Eq.\ \eqref{eq:ExTrns} that
the exponential transform is dependent on a transform parameter $p$ and the
cosine angle $\mu$, such that $\Sigma_t^* = \Sigma_t(1-p\mu)$.
When used without angle biasing,
\begin{equation}
  \psi^{\dagger}_g (r, \Omega) \approx e^{\Sigma_t \lambda \cdot r}\:,
  \label{eq:ExTransfrm}
\end{equation}
the exponential transform can
have undesirable weight
fluctuations \cite{haghighat_monte_2003}, especially as the number of collisions
to reach a tally increases \cite{gupta_sampling_1985}. Eq.\
\eqref{eq:ExTransfrm} shows that the importance function (the adjoint flux) can
be approximated as an exponential function varying in space, dependent on the
total cross section $\Sigma_t$, distance traveled $r$, and a parameter defining the amount
and direction of biasing $\lambda$.

Dwivedi \cite{dwivedi_new_1982} showed that by adding an angle-dependent collision
biasing scheme in addition to the exponential transform, the problematic weight
fluctuations could be mitigated. The collision biasing scheme introduced with
the exponential transform takes the form
\begin{equation}
  \psi_g^{\dagger}(r, \Omega) \approx \frac{\sigma_{s,0} e^{\Sigma_t\lambda \cdot r}}
  {4 \pi \sigma_t (1 - \lambda \cdot \Omega)}.
  \label{eq:DwivediTrns}
\end{equation}
Note that the ratio of cross sections outside of the exponential function
$\sigma_{s,0} / \sigma_t$, where $\sigma_{s,0}$ is the zeroth moment of the
scattering cross section, the ratio of the cross sections
is the survival probability in an interaction event, and
the $(1 - \lambda \cdot \Omega)$ term is consistent with the weight adjustment
required for the exponential transform (Eq. \eqref{eq:ExTrnsWt}).
This was applied to a monoenergetic problem
with slab geometry and isotropic scattering, and the variance was reduced by a
factor of more than 100 when compared with other exponential transform methods.

Gupta and Dwivedi's subsequent work \cite{gupta_sampling_1985} adjusted the
factor described in the preceding paragraph by applying the
exponential transform with angle biasing to deep-penetration problems with
anisotropic scattering. The authors did not explicitly use the
true distribution for anisotropic scattering, but rather chose to approximate
the biased kernel to be a function of the isotropic angular distribution. The
authors observed a reduction in the variance by a factor of 10, but they
acknowledged that, while the combination of the biased kernel and exponential
biasing reduced weight fluctuations, it also had the potential to introduce
other weight fluctuations due to anisotropies in the flux.

Ueki and Larsen \cite{ueki_kinetic_1998}
generalized Dwivedi's importance transform and applied it to
isotropic, linearly anisotropic, and quadratically anisotropic scattering. They
observed that Dwivedi's method and the generalized Dwivedi method outperformed
non-angle-dependent exponential biasing for all types of scattering,
and that their generalized method
outperformed Dwivedi's original method in higher order scattering. The work
of Dwivedi, Gupta, Ueki and Larsen was applied and each compared with
one-dimensional sample
problems. Ueki and Larsen pointed out that their method could be extended to
three-dimensional problems using Turner and Larsen's methodology
(described in Section \ref{subsec:LIFT})
\cite{ueki_kinetic_1998}.

In 1985, Henricks and Carter \cite{hendricks_anisotropic_1985} described a
method by which
photon transport could be biased in angle with an exponential transform
adjustment factor.
In this study, the authors performed studies on three test problems with the
exponential
transform adjustment factor and with a synergistic angular bias and exponential
transform
adjustment.
In all studies, the synergistic biasing outperformed the exponential transform
adjustment
alone.
However, their method performed best in highly absorbing media.
The authors noted that this performance was due to the fact that the biasing
could be
strong without undersampling scattering in the problem.
They also pointed out that, while the weight window method was comparable in
efficiency to the
method described, their method avoided choosing importances and
weight window
values for biasing. Their method was limited to exclusively photon transport
biasing, and not
neutron transport. However,
the authors were optimistic that the method could be extended to neutron
transport with relative ease.
Both, Niemal, and Vergnaud \cite{both_automated_1990} also derived VR parameters for
the exponential transform and for collision biasing based on the adjoint
solution as a measure of importance.

\subsubsection{LIFT}
\label{subsec:LIFT}

The LIFT \cite{turner_automatic_1997, turner_automatic_1997-1} method
developed by Turner and Larsen, and like Dwivedi's exponential transform, is
a modification
of the zero variance solution (see Section \ref{sec:ContributonImportance}).
Consequently, the LIFT method uses a calculation of the adjoint flux as a measure
for importance in the problem to distribute particles according to the
contributon density in the problem.
LIFT uses a deterministic calculation to
generate biasing
parameters for the exponential transform and weight window variance reduction
techniques.

As with the form of the importance function derived by Dwivedi (Eq.\
\eqref{eq:DwivediTrns}), the LIFT method generates an angle-dependent importance
function by taking the product of a space-based exponential function and an
angle-informed collision estimator. Additionally, LIFT uses a deterministic
calculation of the adjoint scalar flux to inform the angular flux
reconstruction.
The adjoint angular flux is approximated as piecewise continuous in space
and angle with Eqs. \eqref{eq:LIFTI} through \eqref{eq:LIFTIII}:
\begin{subequations}
\begin{equation}
\psi^{\dagger}_{g,n} (r,\Omega) \approx
                \phi^{\dagger}_{g,n}V_n \left[ \beta_{g,n}
                \frac{\sigma_{s_0,g \rightarrow g,n} b_{g,n}(\Omega)}{\sigma_{t,g,n} -
                \rho_{g,n}\cdot \Omega} e^{\rho_{g,n}\cdot (r-r_n)} \right] \:,
                \label{eq:LIFTI}
\end{equation}
where the physical system is comprised of $N$ regions of volume $V_n$, and
$\psi^{\dagger}_{g,n}$ is the
approximation of the angular flux for group $g$ and region $n$. Further, $\beta$,
the normalization
factor, is given by:
\begin{equation}
\beta_{g,n} = \frac{1}{\int_{V_n} e^{\rho_{g,n} \cdot (r-r_n)} dr \int_{4\pi}
              \frac{\sigma_{s_0,g \rightarrow g,n} b_{g,n}(\Omega)}{\sigma_{t,g,n} -
              \rho_{g,n}\cdot \Omega} d\Omega}\:;
\end{equation}
$b_{g,n}$, the linearly anisotropic factor, is
\begin{equation}
b_{g,n}(\Omega) = 1 + 3\mu_{g\rightarrow g,n}\frac{\sigma_{t,g,n} -
                      \sigma_{s_0,g\rightarrow g,n}}{{\left| \rho_{g,n}
                      \right|}^2}\rho_{g,n}\cdot \Omega \:;
\end{equation}
and the biasing parameter $\rho_{g,n}$ is given by the product of the cross section and the
biasing parameter $\lambda$ seen previously in Eqs.\ \eqref{eq:ExTransfrm}
and \eqref{eq:DwivediTrns},
\begin{equation}
  \rho_{g,n} = \sigma_{t,g,n} \lambda_{g,n} .
  \label{eq:LIFTIII}
\end{equation}
\label{LIFT}
\end{subequations}
Turner showed that $\rho_{g,n}$ can be obtained from
the deterministic solution to the adjoint
equation, rather than from the cross section and $\lambda$, which requires some
assumptions on the distribution of particles. Instead, Turner showed that $\rho$
can be found in terms of the deterministic scalar fluxes, where
\begin{subequations}
\begin{equation}
  \rho_{x,g,n} = \frac{1}{\Delta x_n} \ln \bigg(
  \frac{\phi^{\dagger}_{g,i+1/2}}{\phi^{\dagger}_{g,i-1/2}} \bigg)
  \label{eq:rhox}
\end{equation}
\begin{equation}
  \rho_{y,g,n} = \frac{1}{\Delta y_n} \ln \bigg(
  \frac{\phi^{\dagger}_{g,j+1/2}}{\phi^{\dagger}_{g,j-1/2}} \bigg)
  \label{eq:rhox}
\end{equation}
and
\begin{equation}
  \rho_{z,g,n} = \frac{1}{\Delta z_n} \ln \bigg(
  \frac{\phi^{\dagger}_{g,k+1/2}}{\phi^{\dagger}_{g,k-1/2}} \bigg)
  \label{eq:rhox}
\end{equation}
are all defined using cell-edge flux values in Cartesian coordinates.
\end{subequations}

Eq.\ \eqref{eq:LIFTI} is an adjustment of the exponential transform described by
Dwivedi \cite{dwivedi_new_1982}.
However,
rather than relying upon an isotropic scattering law, like earlier
implementations of the exponential transform, the LIFT
method adjusts the transform to instead be linearly anisotropic in angle. The
derivation of this equation for both linearly anisotropic scattering and
isotropic scattering is available in \cite{turner_automatic_1997}.
To summarize: the parameters
$\beta_{g,n}$, $b_{g,n}$, and $\rho_{g,n}$ are calculated from values obtained from the
deterministic calculation and are used to calculate $\psi^{\dagger}_{g,n}$.

In addition to using the exponential transform to bias the particles in
angle, the LIFT
method also uses weight windows for particle weight adjustment. However, the
computational
cost of generating angle-dependent weight windows from the previous equations
led the authors
to choose space-energy exclusive weight windows. The weight window target values were
calculated to be inversely proportional to the adjoint solution, as with other
methods
\begin{equation}
  ww_{center,g,n} = \frac{\phi^{\dagger}_{g,src}}{\phi^{\dagger}_{g,n}} .
\end{equation}

The LIFT method \cite{turner_automatic_1997, turner_automatic_1997-1}, like
AVATAR, calculated the angular flux for a region by assuming the angular flux
was a product of the scalar flux and an exponential function. The angular flux
values were then used to generate values for the exponential transform variance
reduction
technique to bias the particles in space, energy, and angle. Like AVATAR, LIFT
also generated weight window parameters. However, generating a full
angle-dependent weight window map and running Monte Carlo transport with those
weight windows was computationally limiting, and the authors chose to only
generate space- and energy-dependent weight windows. Turner showed that LIFT
outperformed AVATAR for several example problems, but both methods performed
poorly in voids and low-density regions.

Turner compared a number of variants of LIFT \cite{turner_automatic_1997-1}
against AVATAR to
determine the efficiency of LIFT. In his investigation, Turner compared LIFT and
AVATAR using
approximations for the adjoint solution with diffusion and $S_N$ transport
calculations, and with
various methods to calculate weight window parameters, including using LIFT
combined
with AVATAR's weight window parameters. In most cases, LIFT outperformed AVATAR.
In problems
with voids and low-density regions, the efficiency of the LIFT method decreased,
but so did
AVATAR. This independently confirmed the findings of the previous study.
However, an important note that Turner mentioned was that while
increasing the
accuracy of the deterministic solution may decrease the variance, it is not
necessarily the
best for the FOM. This is a valuable lesson for all automated variance reduction
methods: an
overly accurate solution for the adjoint problem may reduce the variance but
come at such
a high computational cost such that it decreases the FOM.

More recently, Keady and Larsen showed that LIFT could be improved upon further
by using cell-averaged currents and fluxes rather than cell-edge values for
angular biasing \cite{keady_modified_2015}. By using this modified variation of
LIFT, material interfaces do not create strong flux discontinuties on cell
edges, resulting in a solution that is both smoother and more realistic.
Results were presented for a
one-dimensional monoenergetic slab problem with material interfaces. The
modified version of LIFT outperformed both the original LIFT method and
Monte Carlo
weight windows generated with forward deterministic weight windows.


\section*{Introduction}
It has been highlighted in the previous chapter that even though exact solutions of hyperbolic systems have been derived, it is not possible in general. It is indeed well known that in addition to the mathematical complexity of PDEs, physics often involves multidimensional problems in domains with complex geometries that cannot be solved analytically. Numerical strategies may then be employed in order to compute an approximate solution to such problems.

Since the early 50's, plenty of numerical methods consisting mainly of mesh-based schemes, that is methods subdividing a complex domain into elements of simple shapes in which an approximate solution is sought, have been developed (\textit{finite element \cite{Belytschko}, finite volume \cite{Leveque} etc.}). Problems involving very large deformations may lead, however, to numerical difficulties when this kind of approach is used with a material description (Lagrangian formulation) due to severe mesh distortions. Alternatively, Eulerian methods avoid mesh entanglement by building an approximate solution of a PDE system on a fixed mesh that corresponds to a discretized control volume. Nevertheless, interface tracking techniques and convection steps are required in Eulerian approaches in order to follow the boundaries and transport internal variables, which is less convenient for solid than for fluid mechanics because of history dependent constitutive behaviors.

The \textbf{Material Point Method} (MPM) \cite{Sulsky94} mixes the advantages of both Lagrangian and Eulerian methods in order to circumvent mesh entanglement.
However, the MPM suffers from numerical dissipation and oscillations that make it unable to accurately capture discontinuous waves traveling in solids.
%These limitations have been the object of research that yield significant improvements without allowing to capture discontinuities.
These limitations have been the object of research that led to significant improvements of the method.
Nevertheless, the MPM is still unable to capture discontinuities.
This is the purpose of this chapter.

In what follows, a brief historical review of developments that led to the MPM formulation is made and the original formulation is recalled in section \ref{sec:MPM}. Next, after emphasizing some shortcomings of the method, an extension of the MPM to the Discontinuous Galerkin (DG) approximation is proposed in section \ref{sec:DGMPM}. At last, the numerical analysis of the \textbf{Discontinuous Galerkin Material Point Method} (DGMPM) is performed in section \ref{sec:DGMPM_analysis} in terms of convergence and stability. These studies of the numerical scheme show that the Courant number may be set to unity in specific cases, at the cost of first-order accuracy in velocity.

\section{The material point method}
\label{sec:MPM}
\input{chapter3/MPM}

\section{Extension of the MPM to discontinuous Galerkin approximation}
\label{sec:DGMPM}
\input{chapter3/DGMPM}

\section{Numerical analysis of the DGMPM}
\label{sec:DGMPM_analysis}
\input{chapter3/numerical_analysis}

\section{Conclusion}
In this chapter, the formulation of the MPM has been recalled and some drawbacks of the method when applied to hyperbolic problems have been emphasized in section \ref{sec:MPM}.
It has been seen that the projection of the nodal velocity field to material points inherited from FLIP, though it reduces the numerical dissipation, introduces noise in the solution.
Hence, an alternative method using both the PIC mapping procedure and Discontinuous Galerkin approximation has been proposed in section \ref{sec:DGMPM} in order to avoid spurious oscillations.
% Hence, an alternative to this mapping procedure in order to avoid numerical dissipation within the MPM without introducing numerical noise has been proposed by means of the Discontinuous Galerkin approximation in section \ref{sec:DGMPM}.
The resulting DGMPM is based on the weak form of a system of conservation laws written element by element in an arbitrary computational grid in which particles can move.
Interface fluxes involved in boundary integrals of the weak form result from the solution of Riemann problems at cell interfaces computed thanks to an approximate Riemann solver (see section \ref{subsec:interface_fluxes}).
This method combines thus the strength of Finite Element and Finite Volume methods.

The numerical analysis of the scheme applied to the solution of one and two-dimensional linear scalar advection equations performed in section \ref{sec:DGMPM_analysis} led to the ability to determine the maximal Courant number ensuring stability for a given discretization.
This property allows to fully exploiting the ability of the method to, for instance, rebuild the grid by employing adaptive mesh techniques on the reference configuration in order to accurately track waves in the current one.
Indeed, after such a reconstruction, the number and positions of material points in grid cells can change and one must properly adapt the CFL number so that the scheme remains stable.
An advantage over the original MPM, for which the critical Courant number cannot be computed, is hence highlighted.
%no stability condition exists for the method.
It is however worth noticing that the MPM seems less dependent on the particle distribution so that the CFL is usually set to an arbitrary value ($0.5$ or $0.7$ for one and two-dimensional problems).
The DGMPM is on the other hand, characterized by a CFL number that can be set at one in particular cases.

In addition to the stability of the method, the convergence properties of the DGMPM have been compared to that of the original MPM on a one-dimensional elastic problem.
While the MPM, as FEM, shows a second-order accuracy in velocity and first-order in stress, the DGMPM exhibits a first-order accuracy for both fields.
The loss of accuracy has been attributed to the back-mapping used in the DGMPM and strategies to handle higher-order approximations have been proposed.
However, the purpose of this work being the accurate capturing of waves that can be non-regular, high-order accuracy goes beyond the scope of this thesis.%is not essential for it leads to more regularity in the numerical solution.

In the following, attention is paid to the capturing of waves without oscillations unlike what has been highlighted for the MPM in section \ref{sec:MPM}.
The object of the next chapter is the illustration of the DGMPM performances with one and two-dimensional simulations.

%%% Local Variables:
%%% mode: latex
%%% ispell-local-dictionary: "american"
%%% TeX-master: "../mainManuscript"
%%% End:


\subsection{Map scopes}
Maps get represented by a region labeled by \codeword{sdir.map}. A similar syntax to \codeword{affine.parallel} is being used. The region of the map has access to the \codeword{sdir.memlet} of the enclosing state and therefore can directly access them. Symbols are used for the map variables in order to ensure that they do not get edited in the map region as well as provide a way to perform simple arithmetic in a compact way. See Figure \ref{fig:map}.
\smc{map}{Map scope}


\chapter{Examples}
\label{chap:examples}
In this section, we provide some examples to show the main capabilities of \mpng{} for simulating the operation of power and natural gas networks. We have included the folder \mpngcasepath{} in the distribution, which contains the gas and interconnection cases used for testing. Moreover, the folder \mpngexamplepath{} contains the files used in the examples. In particular, we explore two examples: (1) the integrated operation of a nine-bus power system  and an eight-node natural gas grid; and (2) the single operation of a 48-node looped natural gas network.

\section{9-bus 8-node Power\&Gas System}
\label{sec:8-9_gas_power}

We analyze an interconnected system formed by a power system of nine buses  and a natural gas network of eight nodes. As shown in Figure \ref{fig:example1}, they are coupled through a gas-fired power plant and a power-driven compressor working with energy coming from the power system. This example aims aimed at showing the primary functionalities of \mpng{} as well as how to properly run a simulation.

The power system consists of the classic \matpower{} nine-bus case, with some modifications in order to meet the requirements of the interconnected network. Some of these changes are related to bus areas, line capability constraints, maximum power generation, and generation costs. For the gas system, we created an eight-node looped case with two compressors connected in series and a loop formed by three pipelines. Tables \ref{tab:ex1_power} and \ref{tab:ex1_gas} summarize the system information.

\begin{figure}[!ht]
	\centering
	\includegraphics[scale=0.8]{Figures/Example1}
	\caption{Power and gas integrated network considered in Example 1.}
	\label{fig:example1}
\end{figure}

\begin{table}[!ht]
\centering
\begin{threeparttable}
\caption{Example 1 - Power System Summary}
\label{tab:ex1_power}
\footnotesize
\begin{tabular}{ll}
\toprule
\bf{topology}	& 9-bus network	 \\
\midrule
			& 3 gens at buses 1, 2, and 3\\
\bf{generators}	& 200 MW Max $P_{g}$ for all generators\\
			& all 3 have identical quadratic generation costs \tnote{*}\\
\midrule
\bf{load}		& 90 MW at bus 5, 100 MW at bus 7, 125 MW at bus 9 \\
			& curtailable at \$5000/MWh	\\
\midrule
\bf{branches}	& 250 MW limit for all lines	\\
\bottomrule
\end{tabular}
\begin{tablenotes}
 \scriptsize
 \item [*] {Linear costs of \$95/WMh are used for the example.}
\end{tablenotes}
\end{threeparttable}
\end{table}

\begin{table}[!ht]
%\renewcommand{\arraystretch}{1.2}
\centering
\begin{threeparttable}
\caption{Example 1 - Gas System Summary}
\label{tab:ex1_gas}
\footnotesize
\begin{tabular}{ll}
\toprule
\bf{topology}	& 8-node looped network	 \\
\midrule
			& 1 well at node 1\\
\bf{well}		& 80 MMSCF Max $g^{w}$ for well\\
			& linear cost extraction cost (\$5000 / MMSCFD )\\
\midrule
			& gas demands at nodes 7 and 8\\
\bf{load}		& 2 types of gas load 	\\
			& high cost of non-supplied demand\\
\midrule
\bf{pipelines}	& no active limits for all lines	\\
			& transport cost at (\$5 / MMSCFD) for all pipelines \\
\midrule
\bf{compressors}	& no active limits for all compressors	\\
			& transport cost at (\$5 / MMSCFD) for all compressors \\
\midrule
\bf{storage}	& no storage considered	\\
\bottomrule
\end{tabular}
\begin{tablenotes}
 \scriptsize
 \item [] {}
\end{tablenotes}
\end{threeparttable}
\end{table}

Initially, for the sake of convenience and code portability, we define the column pointers (constants) for the power system\footnote{The default \matpower{} function \code{define\_constants} allows an straightforward indexing of all information via integer variables. See \cite{matpower_manual} for details.}. Similarly, we define column pointers to easily access the natural gas and interconnection cases, as follows:

\begin{Code}
>> define_constants        % power system constants
>> define_constants_gas    % natural gas system and connect struct constants
\end{Code}

We can load the \matpower{} options struct to chose the desired solver and some additional features. The current stable solver for \mpng{}  is `IPOPT'. Besides, based on the experience, we set the maximum number of iterations to 100000, as shown below:

\begin{Code}
>> mpopt = mpoption;                   % initialize option struct
>> mpopt.opf.ac.solver = `IPOPT';      % current stable solver
>> mpopt.ipopt.opts.max_iter = 1e5;    % max iterations
\end{Code}

Afterwards, we load the power and gas cases and the connection struct\footnote{All cases and connection struct are included in the folder \mpngcasepath{}. Since the data of the interconnection case mainly comprises additional information of the \matpower{}-case, we refer to the connect struct using a similar name as that used for the power system case.}. For the sake of simplicity, we name the power case as \code{mpc}, the natural gas case as \code{mgc},  and the connection struct as \code{connect}, as follows:

\begin{Code}
>> mpc = loadcase(`case9_new');    % 9 bus power system
>> mgc = ng_case8;                 % 8 node natural gas system
>> connect = connect_pg_case9;     % interconnection case
\end{Code}

As the window of analysis consist in an entire day for the gas network, we just need to define the number of periods and their corresponding length for analyzing the power system. We consider four periods of time, each of them of the same length, that is:

\begin{Code}
>> connect.power.time = [6 6 6 6];   % four periods of time
\end{Code}

The connection struct also requires the active and reactive demands in all buses for each period. Then, we take the original system's demand to produce such a temporal behavior via a factor vector as follows:

\begin{Code}
>> factors = [1 1.1 1.2 0.9];      % factors (external aid of MPNG)
>> connect.power.demands.pd = factors.*mpc.bus(:,PD);  % PD matrix
>> connect.power.demands.qd = factors.*mpc.bus(:,QD);  % QD matrix
\end{Code}

Moreover, we set the generator number two to have a maximum daily energy of 5000 MWh/d:

\begin{Code}
>> connect.power.energy = zeros(1,2);  % initialize (one gen with max energy)
>> connect.power.energy(1,GEN_ID) = 2;         % id for max energy in gen 2
>> connect.power.energy(1,MAX_ENER) = 5000;    % max energy is 1000 MWh/d
\end{Code}

For this particular example, we do not consider spinning reserve because of the small number of generators. As a consequence, the spinning reserve matrix is set to be an empty array:

\begin{Code}
>> connect.power.sr = [];                      % no spinning reserves
\end{Code}

As shown in Figure \ref{fig:example1}, both classes of compressors where included in this example. Their corresponding information, specified in the connection struct, must be consistent with the gas and power cases:

\begin{Code}
>> connect.interc.comp = zeros(1,2); % initialize (a power-driven compressor)
>> connect.interc.comp(1,COMP_ID) = 2;       % second compressor
>> connect.interc.comp(1,BUS_ID) = 5;        % connected to bus # 5
>> mgc.comp(2,TYPE_C) = COMP_P;              % concordance with gas case
\end{Code}

Additionally, a gas-fired power plant was considered, and its information must be included in the connection struct in a manner consistent with the gas and power cases:

\begin{Code}
>> connect.interc.term = zeros(1,3);       % initialize (one gas-fired plant)
>> connect.interc.term(1,GEN_ID)  = 3;     % third power plant
>> connect.interc.term(1,NODE_ID) = 7;     % connected to node # 7
>> connect.interc.term(1,EFF) = 10e-3;     % power plant eff. (MMSCFD/MWh)
\end{Code}

At this point, we have set all the inputs required to model the different aspects that we intended for the interconnected power and natural gas system. Now, we need to put all together in a single struct. We call this struct \code{mpgc}, which represents the combination between \code{mpc}, \code{mgc}, and \code{connect}, as shown below:

\begin{Code}
>> mpgc = mpc;                         % initialize MPNG case
>> mpgc.mgc = mgc;                     % adding gas case
>> mpgc.connect = connect;             % adding connection struct
\end{Code}

Finally, we can run the simulation by calling \mpng{} using the \code{mpgc} case and the \matpower{} options struct:

\begin{Code}
>> results = mpng(mpgc,mpopt);         % running simulation
\end{Code}

The optimal solution values are saved as the \code{results} struct.  See Section \ref{subsec:view_results} for more details about the simulation \code{results}. By default, the \code{results} are pretty-printed. The information related to the natural gas network after running the simulation looks like:\\

\vspace{-0.3cm}

%\begin{tiny}
%\begin{Code}
%		    >>  ================================================================================
%			|     Gas system summary                                                       |
%			================================================================================
%
%			How many?                  How much?
%			---------------------    --------------------------------
%			Nodes            8         Total Well Capacity    80.00
%			Wells            1         On-line Capacity       80.00
%			Pipelines        6         Gas Production         45.83
%			Compressors      2         Total Demand           38.63
%			  Gas Comp.      1           Supplied Demand      38.63
%			  Power Comp.    1           Non-Supplied Demand  -0.00
%			Storage Units    1         Gas Stored             0.00
%
%			Gas total extration cost =   229169.12
%			================================================================================
%			|     Nodes Data                                                               |
%			================================================================================
%			 Node   Pressure   Over      Under     Demand    Non-S       Gas        Nodal
%			  #      (psi)    Pressure  Pressure  (MMSCFD)   Demand   Extraction    Lambda
%			 ----   --------  --------  --------  --------  --------  -----------  ---------
%			   1     650.000     0.00      ---       ---       ---        45.83      5000.00
%			   2     563.146     ---       ---       ---       ---         ---       5911.35
%			   3     577.053     ---       ---       ---       ---         ---       5916.39
%			   4     612.558     ---       ---       ---       ---         ---       6083.14
%			   5     586.604     ---       ---       ---       ---         ---       6389.94
%			   6     592.410     ---       ---       ---       ---         ---       6212.97
%			   7     530.413     ---       ---      12.22     -0.00        ---       6217.97
%			   8     464.000     ---       ---      26.41      0.00        ---       8019.82
%
%			================================================================================
%			|     Pipeline Data                                                            |
%			================================================================================
%			 Pipeline    From      To      Weymouth    Max Gas       Gas       Transport
%			    #        Node     Node     Constant     Flow         Flow       Cost
%			 --------    -----    -----    --------    --------    --------    ---------
%			    1          1        2        0.141       80.00       45.83       229.17
%			    2          4        5        0.121       40.00       21.42       107.09
%			    3          4        6        0.157       40.00       24.42       122.08
%			    4          5        6        0.060       40.00       -5.00        24.99
%			    5          6        7        0.074       40.00       19.42        97.09
%			    6          5        8        0.074       40.00       26.41       132.07
%
%			================================================================================
%			|     Compressor Data                                                          |
%			================================================================================
%			 Comp.   Comp.   From    To     Comp.      Power       Gas      Comp.    Comp.
%			   #     Type    Node   Node    Flow      Consumed   Consumed   Ratio    Cost
%			 -----   -----   ----   ----   --------   --------   --------   -----   --------
%			   1       G       2      3      45.834      1.29     0.0003    1.025   229.17
%			   2       P       3      4      45.834      3.17       ---     1.062   229.17
%
%			================================================================================
%			|     Gas-fired Generators Data                                                |
%			================================================================================
%			 Unit.   Node   Plant       Daily      Gas
%			   #      #      Eff.       Energy    Consumed
%			 -----   ----  ---------   --------   --------
%			   3      7     1.00e-02     720.00      7.20
%			 -----   ----  ---------   --------   --------
%			                   Total     720.00      7.20
%\end{Code}
%\end{tiny}

\begin{small}
\begin{Code}
    >>  ================================================================================
	|     Gas system summary                                                       |
	================================================================================

	How many?                  How much?
	---------------------    --------------------------------
	Nodes            8         Total Well Capacity    80.00
	Wells            1         On-line Capacity       80.00
	Pipelines        6         Gas Production         45.83
	Compressors      2         Total Demand           38.63
	Gas Comp.        1           Supplied Demand      38.63
	Power Comp.      1           Non-Supplied Demand  -0.00
	Storage Units    1         Gas Stored              0.00

	Gas total extraction cost =   229169.12
	================================================================================
	|     Nodes Data                                                               |
	================================================================================
	Node   Pressure     Over      Under    Demand     Non-S      Gas         Nodal
	  #      (psi)    Pressure  Pressure  (MMSCFD)   Demand   Extraction    Lambda
	----   --------  --------  --------  --------  --------  -----------  ---------
	  1     650.000     0.00      ---       ---       ---        45.83      5000.00
	  2     563.146     ---       ---       ---       ---         ---       5911.35
	  3     577.053     ---       ---       ---       ---         ---       5916.39
	  4     612.558     ---       ---       ---       ---         ---       6083.14
	  5     586.604     ---       ---       ---       ---         ---       6389.94
	  6     592.410     ---       ---       ---       ---         ---       6212.97
	  7     530.413     ---       ---      12.22     -0.00        ---       6217.97
	  8     464.000     ---       ---      26.41      0.00        ---       8019.82
	================================================================================
	|     Pipeline Data                                                            |
	================================================================================
	Pipeline    From      To      Weymouth    Max Gas       Gas       Transport
	   #        Node     Node     Constant     Flow         Flow        Cost
	--------    -----    -----    --------    --------    --------    ---------
	   1          1        2        0.141       80.00       45.83       229.17
	   2          4        5        0.121       40.00       21.42       107.09
	   3          4        6        0.157       40.00       24.42       122.08
	   4          5        6        0.060       40.00       -5.00        24.99
	   5          6        7        0.074       40.00       19.42        97.09
	   6          5        8        0.074       40.00       26.41       132.07
\end{Code}
\end{small}

\begin{small}
	\begin{Code}
	================================================================================
	|     Compressor Data                                                          |
	================================================================================
	 Comp.   Comp.   From    To     Comp.      Power       Gas      Comp.    Comp.
	   #     Type    Node   Node    Flow      Consumed   Consumed   Ratio    Cost
	 -----   -----   ----   ----   --------   --------   --------   -----   --------
	   1       G       2      3      45.834      1.29     0.0003    1.025   229.17
	   2       P       3      4      45.834      3.17       ---     1.062   229.17

	================================================================================
	|     Gas-fired Generators Data                                                |
	================================================================================
	 Unit.   Node   Plant       Daily      Gas
	   #      #      Eff.       Energy    Consumed
	 -----   ----  ---------   --------   --------
	   3      7     1.00e-02     720.00      7.20
	 -----   ----  ---------   --------   --------
	                   Total     720.00      7.20
\end{Code}
\end{small}

\section{48-node Looped Natural Gas Network}
\label{sec:48_gas}

In this example, we show the capability of \mpng{} for solving looped natural gas systems. We highlight that \mpng{} is also a tool for analyzing independent natural gas networks. In particular, we can use a virtual two-bus power system as the power case just to allow \matpower{} to work properly. The information for the 48-node gas network considered in this example was provided by Cheng et al.~\cite{Chen2017}, whose topology is shown in Figure \ref{fig:ng48}.\\

\begin{figure}[H]
\centering
\includegraphics[scale=1.6]{Figures/NG48}
\caption{Natural gas network for Example 2. Source:~\cite{Chen2017}.}
\label{fig:ng48}
\end{figure}

In terms of computational and mathematical tractability, looped natural gas systems are the most complex to solve because they require nodal pressures that guarantee the gas flow in more than one pipeline~\cite{Woldeyohannes2011}. This states an interesting scenario to assess the performance of \mpng{}. In this example, we consider two case studies over the 48-node gas network: a \textit{base case} study, where elements interact properly in a normal operation with no perturbations; and a \textit{contingency case} study, where failures lead to complex decisions for the simulator.

Following Example \ref{sec:8-9_gas_power}, we start by defining all the power, gas, and connect constants. Then, we load the corresponding cases for this example: the gas case (\code{ng\_case48}), and the straightforward 2-bus power system (\code{case2}) that allows the virtual connection to the natural gas system (\code{connect\_pg\_case2}) with minimal implications in topological and computational terms. Lastly, we package the cases and the connect struct together and  run \mpng{}:

\begin{Code}
mpc = loadcase(`case2');        % 2 bus power system
mgc = ng_case48;                % 48 node looped natural gas system
connect = connect_pg_case2;     % interconnection case

%% put cases together
mpgc = mpc;                     % initialize MPNG case
mpgc.mgc = mgc;                 % adding gas case
mpgc.connect = connect;         % adding connection struct

%% run mpng
res_base = mpng(mpgc,mpopt);         % running MPNG
\end{Code}

Now, we modify the base case to obtain the \textit{contingency case}. Specifically, we reduce the maximum injection capability of one of the wells located at the network center (node 20), forcing the system to extract natural gas from somewhere else to fulfill the gas demand. Moreover, we set pipeline number 38 (the one that connects nodes 43 and 44) to be out of service, eliminating one of the gas network loops located downstream. This contingency forces the system to supply the demands of nodes 30 to 33 through only two paths, which might cause over-pressures and pipeline congestion.

To simulate these contingencies, we start again by loading the 48-node gas case. Then, we set the reduced maximum injection for well 9. For eliminating the mentioned pipeline, we remove its whole corresponding row in the field \code{mgc.pipe}. Once the contingencies are properly modeled, we put the entire system together and finally rerun the program:

\begin{Code}
%% changes due to contingencies
mgc_cont = mgc;
mgc_cont.well(9,GMAX) = 200;        % set max injection of well 9
cont_pipe = 39; 		    % id for out-of-service pipeline
mgc_cont.pipe(cont_pipe,:) = [];    % take pipeline out of service

%% putting all together
mpgc_cont = mpc;                    % initialize MPNG case
mpgc_cont.mgc = mgc_cont;           % adding gas case
mpgc_cont.connect = connect;	% adding connection struct

%% running program
res_cont = mpng(mpgc_cont,mpopt);   % running MPNG
\end{Code}

Figures \ref{fig:ex2_pressure} to \ref{fig:ex2_inj} show the results comparison between the base case and the contingency case. We mainly analyze pressures, gas flows, and well injections, since they are the most representative variables in the gas network. As seen, reducing the injection capacity in node 22 leads not only to the maximum injection in node one but also to the activation of the wells located at nodes 2 and 6 to balance the global production. As a consequence, new gas flows appear through pipelines 4-7 and 6-7 as a result of higher pressures in nodes 2 to 7; moreover, the gas flow through pipe 1-8 increases at the expense of lower pressure of node 8. Besides, compressors 1, 2, and 3 are forced to transport larger flows by increasing the difference between suction and discharge pressures, that is, their compressor ratios. On the other hand, the outage of pipeline 43-44 leads to higher pressures in the surrounding nodes because of the new radial connections of some pipes. Notice how pipelines 36-43 and 43-42 end up with gas flows in the opposite direction in the contingency case.

\begin{figure}[H]
\centering
\includegraphics[scale=0.8]{Figures/ex2_pressure}
\caption{Results Example 2 - Nodal Pressure.}
\label{fig:ex2_pressure}
\end{figure}

\begin{figure}[H]
\includegraphics[scale=0.75]{Figures/ex2_fgo}
\caption{Results Example 2 - Gas Flow Through Pipelines.}
\label{fig:ex2_fgo}
\end{figure}

\begin{figure}[H]
\centering
\includegraphics[scale=0.8]{Figures/ex2_fgc}
\caption{Results Example 2 - Gas Flow Through Compressors.}
\label{fig:ex2_fgc}
\end{figure}

\begin{figure}[H]
\centering
\includegraphics[scale=0.8]{Figures/ex2_inj}
\caption{Results Example 2 - Gas Injection in Wells.}
\label{fig:ex2_inj}
\end{figure}