\section{Sensitivity to Deterministic Parameter Choice}
\label{sec:AngleResults}

At this point in the $\Omega$-method characterization,
it has been shown how the $\Omega$-methods
behave in problems with differing geometries and materials.
However, each of the problems presented in Section \ref{sec:CharResults}
was run with the same deterministic calculation
parameters. While the angular flux may have differed in these problems due to
differences in the way the problems were constructed, it did not
vary due to deterministic
solver choices. Some deterministic solver choices will change the angular
fluxes used to calculate the $\Omega$-flux. Consequently, this may affect the
behavior of the $\Omega$-methods. This section will
explore the effects of deterministic solver
choices on the $\Omega$-method's performance.

Section \ref{sec:CharResults} showed that the $\Omega$-methods have a strong
weakness to ``thin'' materials, as CADIS and FW-CADIS do. Recall that a
``thin'' material is characterized by a low density, and thus a low macroscopic
cross section, or interaction
probability. In a pure streaming problem, the particle flux will decrease by a
factor of $r^2$ from the source and never interact.
In a thin material, a particle may stream
several centimeters before interacting. As a result, the
importance of a particle, which is related to the adjoint- or omega-flux,
may vary several orders of magnitude over a mean free
path of travel distance. At a collision, the particle then requires
several orders of
magnitude of sampling events.

The $\Omega$-method's weakness to ``thin'' materials was confirmed by
running the steel beam problem with air and concrete in the geometric location
of the steel beam. In
the ``thin'' material air version, CADIS-$\Omega$ performed poorer than CADIS.
This was a strong contrast to the same geometric configuration with a steel
beam, where CADIS-$\Omega$ outperformed CADIS.
The success of CADIS-$\Omega$ in this problem also showed that
the incorporation of the $\Omega$-flux into a problem with materials with
very different moderating properties but both with high probabilities of
interaction, improves the performance of the $\Omega$-methods beyond CADIS or
the nonbiased analog.

Due to CADIS-$\Omega$'s superior performance to CADIS
in the problem with a steel beam in concrete, this is the problem that will be
used to characterize CADIS-$\Omega$'s sensitivity to deterministic
parameter choice.
In this section, the effect of deterministic solver choices on the
performance of the $\Omega$ methods will be investigated. In particular, we are
interested in how parameters that influence the angular flux will affect the
performance of the $\Omega$-methods. By using the same problem
with differing solver options, the effect of solver options can be isolated from
the material and geometric effects. By doing so, we seek to determine how
resilient the $\Omega$-methods may be to using low-fidelity solver options, how
different the sensitivity of the $\Omega$-methods are to solution quality when
compared to CADIS, and how varying angular parameters may speed up or slow down
the time to a desired solution. By quantifying these effects, we can determine
the best parameter selection for the $\Omega$-methods for this type of problem.

\subsection{Parametric Study Description}
\label{subsec:parstudy}

The angle sensitivity parametric study will cover the subset of computational parameters
that are most likely to influence the $\Omega$ method's solution. Because the
$\Omega$-flux is calculated from an angular integration of the forward and adjoint
flux, calculation parameters that are most likely to influence the angular flux
solution are the variables that will be perturbed.
The two parameters that will be studied
are the quadrature order and the P$_N$ order.

The quadrature used in a deterministic solver is used do discretize the
problem in angle. Quadrature options are split into two separate selections: the
quadrature set or type, and the quadrature order. Because the $\Omega$-methods
require rotational symmetry, only quadrature sets that have rotational
symmetry (generally these are triangular quadrature sets)
can be used with the $\Omega$-methods. In ADVANTG/Denovo, the triangular
quadrature sets are: linear-discontinuous finite element, level-symmetric, and
quadruple range. As discussed previously, quadruple range is selected as the
ADVANTG default because it has good properties and guarantees positivity in the
flux. Different quadrature sets have separate
properties and are a realm of study unto their own. Thus, we will vary only
quadrature order and not quadrature type in this sensitivity study.

Quadrature orders specify
how fine of a resolution the quadrature set will be. As quadrature order
increases, the angular discretization becomes finer, and the
size of the angular flux matrices increases. The $\Omega$ methods use angular
flux values that are written to a file after a Denovo transport solve, which are
then read into memory to compute the $\Omega$-flux. We expect to
observe much slower deterministic recorded times in T$_{det}$--and, by
extension, T$_{hybrid}$--for high quadrature orders
because of the I/O demand to read and write the angular flux values. This I/O
demand will not be as extreme for standard CADIS, as the angular flux values are
not written in that case.
Recall that the ADVANTG
default quadrature order is 10. The quadrature orders used for the sensitivity
study aimed to choose orders surrounding this value. This resulted in quadrature
orders 5, 7, 10, 12, 15, 17, and 20 being chosen for variations in this
parameter.

The P$_N$ order determines the fidelity of the scattering expansion. The
availability of P$_N$ orders is dependent on the cross section dataset that is
being used. For the
27G19N cross section library, the P$_N$ order extends to 5. As a result,
P$_N$ orders of 1, 3, and 5 are chosen for variations in this parameter.

While the P$_N$ order
does affect angular information in the problem, it will not change the size of
the angular flux matrices. As a result, deterministic runtimes between
differing P$_N$ orders
may vary, but not as significantly as they will in differing quadrature orders
due to the lack of change in I/O requirements as P$_N$ order changes.

Other deterministic parameters may influence the variance reduction parameters
calculated by the $\Omega$ methods.
The spatial discretization, while not a primary factor influencing
the angular flux, still may affect the $\Omega$-methods' performance.
A finer energy group structure may also influence the $\Omega$-method solution.
Finer energy groups will more effectively reflect resonance regions in
scattering and absorption. Scattering effects in certain energy regions will
have angular dependence and, thus, may have a stronger effect on the angular flux
than a coarser energy discretization. Because these particular solution effects
do not directly influence the angular flux and angular effects will be difficult
to isolate, they will not be included
in the angular sensitivity parametric study.

% Add to conclusion future work.
%However, a study extending to include the
%energy group structure, the spatial discretization, and the quadrature type
%certainly could be an area of future work.

Several factors in the deterministic calculation should not have a strong effect
on the angular flux distribution. These include the spatial solver, the
convergence criteria for the solvers, and the within group solver types.
Because these factors should not influence the angular flux any more than any
other part of the solution, they will also not be included in this parametric study.

\subsection{Quadrature Order}
\label{subsec:quadorder}

The results that will be presented in the next two subsections will be similar
to those presented in Section \ref{sec:CharResults}. However, our goal is to see
how changing deterministic parameter type affects the results in the tally
region. With this in mind, the presentation of the results may be adjusted to
more effectively show the effect each parameter has on influencing the Monte
Carlo transport.

Table \ref{tab:quad_foms} contains the FOM results for each of the quadrature
orders run in the parametric study. The results are grouped by FOMs calculated
with the same relative error. The first three sections of the table
pertain to different FOM values, and the last section of the table shows timing
results for the standard Monte Carlo (T$_{MC}$) and the total walltime
(T$_{hybrid}$) for the calculation.

In the tally average relative error subsection of Table \ref{tab:quad_foms},
two strong
dips in the FOM appear in the CADIS results at S$_N$ orders 5 and 10,
and a dip in the CADIS-$\Omega$ FOMs
occur at S$_N$ order 12. These dips are much larger relatively than in the maximum or
minimum relative error subsections of the table. This indicates that for these
particular quadrature orders, fewer particles contribute to the
detector response across all groups. We can also see in the CADIS-$\Omega$
results that
quadrature orders 10, 15 and 17 all have a similar FOM for the tally average
relative error using the Monte Carlo runtime. However, the FOMs for the same
quadratures do not decrease more significantly when using T$_{hybrid}$ to calculate the
FOM, as suggested in Section \ref{subsec:parstudy}. This suggests that the
increased deterministic runtime for I/O is offset consistently by the change in
the FOM between quadrature orders for CADIS-$\Omega$.

In this subsection of the table it is also notable that the oscillations between
maximum and minimum FOM values is much larger for CADIS-$\Omega$ than for CADIS.
For low quadrature orders, CADIS-$\Omega$ shows substantial improvement in the
FOM, while CADIS remains somewhat constant (this is omitting the major dips in FOM
values noted in the previous paragraph). At higher quadrature orders, however,
CADIS-$\Omega$'s performance is inverted and decreases with increasing
quadrature order. CADIS, however, remains fairly constant in FOM for S$_N$
orders 12 and above. Both methods far outperform the nonbiased analog Monte
Carlo run.

The maximum relative error portion of the table also has several notable
datapoints. For CADIS, the dips in FOM are still visible for S$_N$ orders 5 and
10, but quadrature order 7 does not achieve the same high FOM as quadrature
orders 12 and above as it does in the tally average subsection of the table. If
the maximum relative error convergence is the limiting factor for the user,
it appears that using any quadrature order above 10 is a good choice for CADIS.
CADIS-$\Omega$, conversely, has more varied results. No observable trend exists
in the FOM with increasing quadrature order for CADIS-$\Omega$. A dip
in the FOM occurs at quadrature order 12, as it did in the tally average
subsection of the table. This dip, like CADIS' dips, is not as significant as
the dip in the tally average FOMs. Generally, CADIS has higher FOMs when using
the maximum relative error as a success metric. In fact, the only quadrature order where
CADIS-$\Omega$'s FOM is larger than CADIS' is at quadrature order 10.

\begin{table}[h!]
  \centering
  \input{./chapters/characterization_probs/figures/angle/prob_1/reordered_quad_foms}
  \caption[Figure of Merit results for steel beam embedded in concrete, with
  variations in quadrature order.]{Figure of Merit results for steel beam embedded in concrete, with
  variations in quadrature order. Subdivisions of the table indicate
calculations of the FOM using different relative errors. The analog case has a
single value for each relative error as it is not dependent on changes in
deterministic calculation parameters.}
  \label{tab:quad_foms}
\end{table}

In the minimum relative error subsection of Table \ref{tab:quad_foms}
the CADIS and CADIS-$\Omega$ FOM behavior is
much more well-behaved than it is for the preceding two subsections of the
table. There are no dips in the FOM value for either method,
so the lowest relative error will
consistently get better with increasing quadrature order. A slight shift
to a $<1\%$ lower FOM
occurs for quadrature orders 17 and 20, which indicates that increasing
quadrature fidelity does not help improve the FOM past S$_N$ order 15. Similar
behavior is observable for CADIS-$\Omega$ in the minimum relative error
subsection of the table. CADIS-$\Omega$ has a consistently lower-valued FOM
between ~5\%-10\% for all quadrature orders when compared to CADIS.
A turnover occurs in the CADIS-$\Omega$
FOMs at a lower quadrature order, meaning that CADIS-$\Omega$ does not benefit
from increasing S$_N$ order as much as CADIS using this FOM as a metric.
However, beyond quadrature order 15 neither method sees a benefit in the FOM by
increasing the quadrature order.

The timing results in the last section of the table show how much longer it
takes CADIS-$\Omega$ to transport the standard Monte Carlo than CADIS. This was
also noted in Section \ref{subsec:resultbeam}. In the
introduction to this section, it was predicted that the I/O demands for
CADIS-$\Omega$ would impact the MC$_{hybrid}$ FOMs as quadrature order
increases. However, because the CADIS-$\Omega$ Monte Carlo times are already so
much longer than CADIS', this impact is not as significant as expected. Further,
the increase in deterministic runtime seems to change similarly to the increase
in Monte Carlo runtime as the importance map changes. This explains why the FOMs
were not impacted so negatively in the previous sections of the table.

Let us use an illustrative example to compare the FOMs between CADIS and
CADIS-$\Omega$. Returning again to Table
\ref{tab:quad_foms}, at S$_N$ order 5 the non-MC runtime is three minutes for
CADIS, while it is around ten minutes for CADIS-$\Omega$. At S$_N$ order 20, the
CADIS non-MC runtime is 19 minutes; the CADIS-$\Omega$ time is 100 minutes. For
each of these cases, the non-MC runtime is about 4\% that of the Monte Carlo runtime.
Because this fractional time is fairly consistent between CADIS and
CADIS-$\Omega$, we do not see a strong impact on FOM$_{hybrid}$ from the
significantly longer non-MC runtimes in CADIS-$\Omega$.

Table \ref{tab:quad_foms} shows that for the FOM using the tally average relative error,
CADIS-$\Omega$ outperforms CADIS for most quadrature orders (with excpetions
being S$_N$ orders 7 and 12). For the majority of the quadrature orders,
CADIS-$\Omega$ gets more particles to the tally region than CADIS in the same
amount of time. By increasing
quadrature order, CADIS-$\Omega$ generally increases the number of particles to
the tally as a whole, while CADIS remains fairly constant. The table
also shows that by using either the maximum or minimum relative error to
calculate the FOM, CADIS generally outperforms CADIS-$\Omega$. However, while
both the maximum and minimum RE FOMs increase with increasing quadrature order
in CADIS, this is not the case for the tally average FOM. This could be
interpreted as that as the quadrature order increases, more particles reach the extreme
tally bins, but fewer particles end up in the tally overall. For CADIS-$\Omega$,
this behavior is not quite the same. Instead, a peak occurs in the tally
average FOMs at intermediate quadrature orders, and the minimum RE FOM decreases
with increasing quadrature order.

\begin{figure}[htb!]
  \centering
  \begin{subfigure}[t]{\textwidth}
    \centering
    \includegraphics[width=\linewidth]{./chapters/characterization_probs/figures/angle/prob_1/err_quad_cadis.pdf}
    \caption{Relative errors of CADIS results for differing S$_N$ orders.}
    \label{fig:sn_cad_err}
  \end{subfigure}
\end{figure}
\begin{figure}[htb!]\ContinuedFloat
  \centering
  \begin{subfigure}[t]{\textwidth}
    \centering
    \includegraphics[width=\linewidth]{./chapters/characterization_probs/figures/angle/prob_1/err_quad_cadisangle.pdf}
    \caption{Relative errors of CADIS-$\Omega$ results for differing S$_N$
    orders.}
    \label{fig:sn_cadangle_err}
  \end{subfigure}
  \caption[Relative error results for CADIS and CADIS-$\Omega$ for different
  quadrature orders for the problem with a steel beam in concrete.]
  {Relative error results for CADIS (Figure \ref{fig:sn_cad_err})
  and CADIS-$\Omega$ (Figure \ref{fig:sn_cadangle_err}) for different
  quadrature orders for the problem with a steel beam in concrete.}
  \label{fig:sn_errs}
\end{figure}

In the Subsection \ref{sec:CharResults}, it was discussed that while the FOM
shows how quickly a tally may approach a desired value, it does not show how
effectively
each method transported particles to the tally location. Because the same
particle count was used in each variation of the steel beam problem in the angle
sensitivity study, the relative error results achieved by each method can reveal
how well each method transported the same number of starting particles.
The next several plots will present
this information.

Figures \ref{fig:sn_cad_err} and \ref{fig:sn_cadangle_err} show the relative
errors for all tally bins for each quadrature order run of the problem with the
steel beam in concrete for CADIS and CADIS-$\Omega$, respectively.
Unlike Table \ref{tab:quad_foms}, these plots show the
overall behavior of the tally results as a function of changing quadrature
order, so the behavior of non-extreme tally bins can also be observed. As noted
in the discussion accompanying Table \ref{tab:quad_foms}, these intermediate
are important in evaluating the tally average relative error.

Figure \ref{fig:sn_cad_err} plots the tally relative error results for each of
the CADIS runs, binned by energy. The warmer colored red and orange lines show
the low quadrature order results, while the cooler colored lines correspond to
higher quadrature results. For all of the energy bins below $10^{-4}$ MeV, a
reduction in the relative error with increasing quadrature order can be
observed. For quadrature orders S$_N$ 12 and above, the relative error does not
show as much of an improvement in the relative error. Between $10^{-4}$ and
$10^{0}$ MeV, large spikes in the relative error for quadrature orders 5 and 10
exist, explaining the poor behavior of the tally average RE FOM and tally
maximum RE FOM for CADIS.
Quadrature order 7 has relative errors much closer to quadrature orders
12 and above. Because these relative error spikes span so many bins, they affect
the overall tally convergence, and, by extension, the tally average FOM. At very
high energies ($> 10^{0}$ MeV), there is very little improvement in the relative
error with increasing quadrature order.

Figure \ref{fig:sn_cadangle_err} shows the relative error results for
CADIS-$\Omega$. A number of interesting features exist in
this figure that are not reflected in Figure \ref{fig:sn_cad_err}. For example,
in the lowest energy region a decrease in the relative error is seen up to S$_N$
10, but then the relative error increases for higher S$_N$ orders. In the wider
energy bins between
$10^{-6}$ and $10^{-1}$ MeV, quadrature orders 10 and above all achieve a
similar relative error. This is not true in narrow energy bins, where higher
quadrature orders do tend to have a lower relative error. Moving to higher
energies, we can observe a significant spike in the relative error between
$10^{-1}$ to $10^{0}$ MeV for S$_N$ order 12. Although this spike does not span
several energy bins like those seen in Figure \ref{fig:sn_cad_err}, it is very
high when compared to the other relative error bins. As a result, this single
tally bin throws off the tally average FOM results in addition to the tally
maximum RE FOM, as observed in Table
\ref{tab:quad_foms}. In energy bins above this spike, most quadrature orders
produce similar FOMs. The lowest valued energy bin is located in this high
energy region.

\begin{figure}[h!]
  \centering
  \includegraphics[height=10cm]{./chapters/characterization_probs/figures/angle/prob_1/compare_err_quad.pdf}
  \caption[Relative error improvement factor (Eq. \eqref{eq:I-RE}) between CADIS-$\Omega$ and
  CADIS as a function of quadrature order for steel beam embedded in concrete.]
  {Relative error ratio (Eq. \eqref{eq:I-RE}) between CADIS-$\Omega$ and
   CADIS as a function of quadrature order for the problem with
   a steel beam embedded in concrete.}
  \label{fig:prob_1_quad_I_RE}
\end{figure}

While Figure \ref{fig:sn_errs} shows the how the relative errors of the tally
change with different quadrature orders, we have no indication of how CADIS and
CADIS-$\Omega$ change in comparison to one another. Figure
\ref{fig:prob_1_quad_I_RE} shows the relative error improvement factor for each
quadrature order. A value below unity indicates that CADIS-$\Omega$ achieved a
better relative error than CADIS for that bin and quadrature order. In this
figure we can clearly see the effect that the problematic energy bins in each
method have on the improvement factor. In CADIS we observed that bins in the
$10^{-3}$ to $10^{-1}$ were problematic for quadrature order 10; this is
reflected in the very low value of I$_{RE}$ for that energy range and quadrature
order, as shown in by the orange line reaching the lowest values of I$_RE$.
Conversely, we observed that CADIS-$\Omega$ had a very problematic energy
bin between $10^{-1}$ and $10^{0}$ at quadrature order 12. The value of this
I$_{RE}$ is far above the y-limit of Figure \ref{fig:sn_errs}, illustrated with
the yellow line.

Figure \ref{fig:sn_errs} also shows that quadrature order 10 is generally the order
in which CADIS-$\Omega$ outperforms CADIS the most. For this quadrature error,
CADIS-$\Omega$ achieves the lowest error when compared to CADIS. The reasons for
this are twofold: first, it is one of the best performing quadrature sets for
CADIS-$\Omega$, which achieves its lowest relative errors in almost every energy
bin in this quadrature order; second, it is a very poorly performing quadrature
set for CADIS. This synergistic combination results in the best overall
quadrature order for CADIS-$\Omega$.

A region where quadrature order 10 is not the best quadrature order is
in energy regions above ~$10^{-1}$ MeV, whre the higher quadrature
orders--like 15, 17 and 20--outperform CADIS more.
In the low ($<10^{-5}$ MeV) and high ($>10^{0}$ MeV) energy
regions,
CADIS-$\Omega$ obtains lower relative errors than CADIS for all quadrature
orders. In intermediate energy regions, some spikes occur in regions that
indicate a lower relative error is achieved by CADIS. However, generally
CADIS-$\Omega$ achieves lower relative errors than CADIS for most energy bin and
most quadrature orders. Returning again to the
relative error figures of \ref{fig:sn_errs}, the spike in I$_{RE}$ between
$10^{-5}$ and $10^{-4}$
MeV is explained by a relatively low relative error achieved by CADIS, where in
CADIS-$\Omega$ a large spike in the relative error occurs. This is reflected in
the ratio for I$_RE$.

\begin{figure}[h!]
  \centering
  \includegraphics[height=10cm]{./chapters/characterization_probs/figures/angle/prob_1/compare_fom_quad.pdf}
  \caption[Figure of merit improvement factor  (Eq. \eqref{eq:I-FOM}) between CADIS-$\Omega$ and
  CADIS with changes in quadrature order for steel beam embedded in concrete.]
  {Figure of merit improvement factor  (Eq. \eqref{eq:I-FOM}) between CADIS-$\Omega$ and
   CADIS with changes in quadrature order for the problem with
   a steel beam embedded in concrete.}
  \label{fig:prob_1_quad_I_FOM}
\end{figure}

Figure \ref{fig:prob_1_quad_I_FOM} complements the results to Figure
\ref{fig:prob_1_quad_I_RE}. Here the FOM improvement factor is plotted rather
than the relative error improvement factor. Because a higher valued FOM is a
better result, values above $10^{0}$ indicate that CADIS-$\Omega$ outperformed
CADIS. On this plot it is quite clear that for higher energies, CADIS-$\Omega$
consistently outperforms CADIS more
in higher quadrature orders, as observed with I$_{RE}$.

Let us return again to the high and low-energy regions of the plot, as explored
with Figure \ref{fig:prob_1_quad_I_RE}. In this region it can be observed
that for low energies, generally I$_{FOM}$ decreases with increasing
S$_{N}$ order. This behavior reverses at high energies, where the ratio
increases with increasing quadrature order. This may be an effect of anisotropy
in each energy group, as the highest energy has the most anisotropy in the flux.
Recall from Section \ref{subsec:resultbeam} that the anisotropy metric was much
higher at high energies than it was at low energies. It is possible that for
this more anisotropic energy group, increasing the quadrature order improves the
importance map in the $\Omega$ methods more, resulting in a better relative
error, and, consequently, a better FOM.
This would also explain the complementary behavior at low energies. Low
energies generally have more isotropic behavior, and increasing the quadrature
order would not help to improve anisotropy information in the importance map.
As a result, increasing quadrature order would not help the FOM at low energies.

Despite a higher relative FOM at high energies, in higher quadrature orders
CADIS-$\Omega$'s performance does not generally exceed CADIS'. For quadrature
order 20, CADIS-$\Omega$'s FOM is almost always lower than CADIS. On Figure
\ref{fig:prob_1_quad_I_FOM}, the cooler toned lines which correspond to higher
quadrature orders have lower values than the warmer toned lines.
For quadrature order 5,
the relative errors on Figure \ref{fig:prob_1_quad_I_RE} were bookended by
higher order quadratures at middle and low energies. This behavior is not the
same in Figure \ref{fig:prob_1_quad_I_FOM}, where the lowest quadrature order
has a higher relative FOM than any of the quadrature orders above 10. This means
that the time required to solve higher quadrature orders affects the FOM more
negatively than the quadrature order decreases the relative error (and
positively affects the FOM). It could also mean that the relative error
improvement changes more for CADIS than CADIS-$\Omega$ with increasing
quadrature order. As a result, the improvement factor at lower quadrature orders
is better for CADIS-$\Omega$ than at higher quadrature orders.

%[Show FOMs as a function of quad order for first problem] \\
%
%[Show interesting anisotropy plots for extreme-valued quad types.] \\
%
%[Show flux maps for each extreme-valued problem in region of interest.] \\
%
%[Describe results.] \\
%
%[Show FOMs as a function of quad order for second problem] \\
%
%[Show interesting anisotropy plots for extreme-valued quad types.] \\
%
%[Show flux maps for each extreme-valued problem in region of interest.] \\
%
%[Describe results.] \\

\subsection{Scattering (P$_N$) Order}
\label{subsec:pnorder}

Table \ref{tab:pn_foms} is much like that of Table \ref{tab:quad_foms}, but with
differing P$_N$ orders than quadrature orders. The table is split into four
regions, the first three corresponding to FOMs calculated with
different relative errors and the last corresponding to Monte Carlo and hybrid
runtimes for the problem. Each of the three first subsections of the table have
different trends with P$_N$ order, which will be described in the next several
paragraphs.

In the tally average relative error subsection of the table one can see that
CADIS has a dip in the FOM for P$_N$ order 3; both P$_N$ orders 1 and 5 are
higher overall. This effect is not seen in CADIS-$\Omega$, where a decrease in
the FOM is observed with increasing P$_N$ order. As a result, for
CADIS-$\Omega$, lower P$_N$ orders are sufficient for generating biasing
parameters, but for standard CADIS the highest P$_N$ order achieves the best
tally average FOM. Further, for every P$_N$ order, the tally average FOM is
higher for CADIS-$\Omega$ than CADIS.

As with Table \ref{tab:quad_foms}, a dip in CADIS' FOMs is also observable in the
maximum relative error subsection of the table. However, the dip observable at
P$_N$ order 3 also exists in the CADIS-$\Omega$ FOMs. If a user desires to have all
tally bins to be below a particular relative error, P$_N$ order 3 is the worst
option for both methods in this problem. For P$_N$ order 1 CADIS-$\Omega$ is the
better choice, and for P$_N$ order 5, CADIS is the better choice.

\begin{table}[h!]
  \centering
  \input{./chapters/characterization_probs/figures/angle/prob_1/reordered_pn_foms}
  \caption[Figure of Merit results for steel beam embedded in concrete, with
  variations in P$_{N}$ order.]{Figure of Merit results for steel beam embedded in concrete, with
    variations in P$_{N}$ order. Subdivisions of the table indicate
calculations of the FOM using different relative errors. The analog case has a
single value for each relative error as it is not dependent on changes in
deterministic calculation parameters.}
  \label{tab:pn_foms}
\end{table}

Comparing the FOMs for CADIS and CADIS-$\Omega$ using the minimum relative
errors, some interesting trends are visible. In Table \ref{tab:quad_foms} we
observed that as quadrature order increased, the minimum relative error FOM
generally increased or stayed the same for both CADIS and
CADIS-$\Omega$. This is not the case in Table \ref{tab:pn_foms}. As P$_N$ order
increases, the minimum relative error FOM for CADIS decreases, but for
CADIS-$\Omega$ it increases. This means that increasing P$_N$ order does not
move more particles (and reduce the relative error) in the energy bin with the
lowest relative error in CADIS, but it does in CADIS-$\Omega$. Unlike the
maximum relative error subsection of the table, at low P$_N$ order CADIS
outperforms CADIS-$\Omega$, and at high P$_N$ orders CADIS-$\Omega$ outperforms
CADIS.

As with Table \ref{tab:quad_foms}, Table \ref{tab:pn_foms} shows that the
behavior of the FOMs do not follow the same trends between different relative
error measurements. Depending on the user requirements for the method, one may
be a better option than the other. For example, in comparing the FOMs using the
maximum relative error, CADIS is better with higher P$_N$ order. With the FOMs
using the minimum relative error, CADIS-$\Omega$ is better with higher P$_N$
orders.

Looking at the timing results in the last
section of the table, we can see that CADIS-$\Omega$ takes at least five times
longer than CADIS to perform a hybrid run. This is similar to what was observed
for the quadrature order results. However, increasing P$_N$ order increased
CADIS Monte Carlo runtimes roughly 40\% between P$_N$ orders 1 and 5, and
increased CADIS-$\Omega$ runtimes about 22\% for the same quadrature orders.
While the total amount of time added to CADIS-$\Omega$ runtimes is longer, it is
relatively less than the amount that was added to CADIS.

\begin{figure}[htb!]
  \centering
  \begin{subfigure}[t]{\textwidth}
    \centering
    \includegraphics[width=\linewidth]{./chapters/characterization_probs/figures/angle/prob_1/err_pN_cadis.pdf}
    \caption{Relative errors of CADIS results for differing P$_N$ orders.}
    \label{fig:pn_cad_err}
  \end{subfigure}
\end{figure}
\begin{figure}[htb!]\ContinuedFloat
  \centering
  \begin{subfigure}[t]{\textwidth}
    \centering
    \includegraphics[width=\linewidth]{./chapters/characterization_probs/figures/angle/prob_1/err_pN_cadisangle.pdf}
    \caption{Relative errors of CADIS-$\Omega$ results for differing P$_N$
    orders.}
    \label{fig:pn_cadangle_err}
  \end{subfigure}
  \caption[Relative error results for CADIS and CADIS-$\Omega$ with changes in
  P$_N$ order for the problem with a steel beam in concrete.]
  {Relative error results for CADIS and CADIS-$\Omega$ with changes in
  P$_N$ order for the problem with a steel beam in concrete.}
  \label{fig:quad_errs}
\end{figure}

Figures \ref{fig:pn_cad_err} and \ref{fig:pn_cadangle_err} provide additional
information on interpreting Table \ref{tab:pn_foms}. Figure \ref{fig:pn_cad_err}
shows the tally relative error results for each of the P$_N$ order CADIS runs,
and Figure
\ref{fig:pn_cadangle_err} shows the relative error results
for CADIS-$\Omega$. In Figure
\ref{fig:pn_cad_err} the highest relative error for CADIS'
P$_N$ order 1 is the most thermal energy bin, for P$_N$ order 3 is the tally bin
between $10^{-2}$, and for P$_N$ order 5 is the resonance region around
$10^{-6}$. The lowest relative error bin, however, is the same for all P$_N$
orders. This bin is located just below the highest energy bin. The shifting
location of the highest valued relative error energy bin helps to explain the
strange trend of the FOMS in the second region of Table \ref{tab:pn_foms}.
Because the relative error bins  become larger in epithermal
energy groups at P$_N$ order 3, and this shift spans several energy bins, it
also helps to explain the tally average FOM shift to a lower value at P$_N$
order 3.

In Figure \ref{fig:pn_cadangle_err}, no significant shift in the relative error
happens at P$_N$ order 3. However, we can observe a shifting location of the highest
valued relative error. At P$_N$ order 1 the highest valued relative error for
CADIS-$\Omega$ is the lowest energy bin. At P$_N$ order 3 the highest relative
error bin is the resonance region located near $10^{6}$ MeV,  and at P$_N$ order
5 these two bins appear to have a similar relative error. The highest overall
observed relative error occurs in P$_N$ order 3, which is why we see the shift
to a lower FOM at P$_N$ order 3 for the maximum relative error subsection of
Table \ref{tab:pn_foms}. This shift is not as significant as the several-bin
spanning shift in CADIS, so it does not affect the tally average FOM in
CADIS-$\Omega$.

From Figures \ref{fig:pn_cadangle_err} and \ref{fig:pn_cad_err}, we can conclude
that shifts in the relative error that dramatically change between P$_N$ orders
can affect the overall tally convergence. This shift is not predictable, and may
not be observed if combined with a different set of deterministic parameters,
such as quadrature order 15, where both CADIS and CADIS-$\Omega$ have no spikes
in their relative errors.

\begin{figure}[h!]
  \centering
  \includegraphics[height=10cm]{./chapters/characterization_probs/figures/angle/prob_1/compare_err_pN.pdf}
  \caption[Relative error improvement factor (Eq. \eqref{eq:I-RE}) between CADIS-$\Omega$ and
  CADIS with changes in P$_N$ order for steel beam embedded in concrete.]
  {Relative error improvement factor (Eq. \eqref{eq:I-RE}) between CADIS-$\Omega$ and
   CADIS with changes in P$_N$ order for the problem with a
   steel beam embedded in concrete.}
  \label{fig:prob_1_pN_I_RE}
\end{figure}

Figure \ref{fig:prob_1_pN_I_RE} shows the relative error improvement factor by
different P$_N$ orders. This plot complements what was observed in Figure
\ref{fig:prob_1_quad_I_RE}. Recall that a value below unity indicates that
CADIS-$\Omega$ achieved a better relative error than CADIS for a given energy
bin and quadrature order. First, with the exception of a few energy bins in
P$_N$ order 5, CADIS-$\Omega$ has better relative errors than CADIS for the
majority of P$_N$ orders and energy bins. In general, P$_N$ order 3 has the most
energy bins that obtain low values of I$_RE$, and P$_N$ order 5 has the fewest.

Another interesting feature
illustrated in this plot is that different P$_N$ orders perform the best in
distinct energy regions. At low energies P$_N$ order 1 achieves the best
relative errors, at intermediate energies P$_N$ order 3 achieves the best
relative errors, and at high energies all three perform similarly.

For all three
P$_N$ orders, the energy bin located near $10^{-4}$ MeV is problematic.
Returning again to the relative error plots of Figures \ref{fig:pn_cad_err}
and \ref{fig:pn_cadangle_err}, this
particular energy bin had a spike for CADIS-$\Omega$, but remained relatively
small for CADIS. The consistency in each method's performance across all P$_N$
orders is reflected in this problematic energy bin.

\begin{figure}[h!]
  \centering
  \includegraphics[height=10cm]{./chapters/characterization_probs/figures/angle/prob_1/compare_fom_pN.pdf}
  \caption[Figure of merit improvement factor (Eq. \eqref{eq:I-FOM}) between CADIS-$\Omega$ and
  CADIS as a function of P$_N$ order for steel beam embedded in concrete.]
  {Figure of merit improvement factor (Eq. \eqref{eq:I-FOM}) between CADIS-$\Omega$ and
   CADIS as a function of P$_N$ order for the problem with a
   steel beam embedded in concrete.}
  \label{fig:prob_1_pN_I_FOM}
\end{figure}

Figure \ref{fig:prob_1_pN_I_FOM} shows the FOM improvement factor with
increasing P$_N$ order. As with the quadrature orders, the runtimes of
CADIS-$\Omega$ impact the FOMs that it achieves such that many more energy bins
are more in CADIS' favor than in the relative error plot. However, many more
energy bins are above $10^0$ I$_{FOM}$ in P$_N$ order than for quadrature order.
As with I$_{RE}$, the shift in performance in different energy groups changes
with P$_N$ order. At low energies, P$_N$ order 1 achieves the best FOMs for
CADIS-$\Omega$, at intermediate energies P$_N$ order 3, and at high energies all
three P$_N$ orders have superior performance with CADIS-$\Omega$.

It should be
noted that there is no P$_N$ order for which CADIS-$\Omega$ obtains better FOMs
than CADIS in all energy bins. Contrast this to the relative error plot, where
CADIS-$\Omega$ had almost universally better relative errors than CADIS. Again
this undescores the negative impact that time has on CADIS-$\Omega$'s FOM.

% [Show FOMs as a function of pN order for first problem] \\
%
% [Show interesting anisotropy plots for extreme-valued pN orders] \\
%
% [Show flux maps for each extreme-valued problem in region of interest.] \\
%
% [Describe results.] \\
%
% [Show FOMs as a function of pN order for second problem] \\
%
% [Show interesting anisotropy plots for extreme-valued pN orders] \\
%
% [Show flux maps for each extreme-valued problem in region of interest.] \\
%
% [Describe results.] \\

\subsection{General Observations}
\label{subsec:observations}

At this point we are interested in which deterministic parameter value affects
CADIS-$\Omega$ and CADIS' performance more significantly. We
have looked at how varying each metric changes the relative error, I$_{RE}$, and
I$_{FOM}$, and from that we have observed trends associated with varying each
parameter. However, we have not compared each metric against the other.
Figures \ref{fig:angle_err_improvements} and \ref{fig:angle_fom_improvements}
aid in this comparison. As with P$_N$ order and S$_N$
order, these plots show either the relative error or Figure of Merit results for
the angle sensitivity study. Unlike the plots with I$_{RE}$ and I$_{FOM}$, these
figures show how the FOM and relative error change for a single method. That is,
how much does the relative error or the Figure of Merit change between the lowest-
and highest- valued parameters run for CADIS or CADIS-$\Omega$.
These figures are useful to show how
sensitive CADIS and CADIS-$\Omega$ are to P$_N$ order and quadrature order,
respectively.

In Figure
\ref{fig:angle_err_improvements}, the ratio of the relative error in each tally
bin is taken between the lowest and highest-valued parameter run of the
parametric study. For P$_N$ order (the purple lines in the figure)
this is calculated with $RE_{P_N 1}/RE_{P_N 5}$ and for
quadrature order (the green lines in the figure) it is calculated with
$RE_{S_N 5}/RE_{S_N 20}$.
A ratio above unity means that the relative error obtained by
the higher-valued parameter (P$_N$ order 5 or S$_N$ order 20) is lower than that
of the lower-valued parameter.

\begin{figure}[h!]
  \centering
  \includegraphics[height=10cm]{./chapters/characterization_probs/figures/angle/prob_1/improvement_err_allmethds.pdf}
  \caption[Ratio in the relative errors between the lowest and highest variable in the angle
  sensitivity study for CADIS and CADIS-$\Omega$.]{Ratio in the relative errors between
    the lowest and highest variable in the angle sensitivity study for CADIS and CADIS-$\Omega$.}
  \label{fig:angle_err_improvements}
\end{figure}

Figure \ref{fig:angle_err_improvements} shows that a greater change in the
relative error occurs for both CADIS and CADIS-$\Omega$ from S$_N$ order 5 to 20
than it does for P$_N$ orders. A notable exception to this is for CADIS in the
energy range from $10^{-8}$ to $10^{-7}$ MeV, where the relative error
improvement for P$_N$ order exceeds any quadrature order line.
Returning to
the relative error results for just CADIS, as shown in Figure
\ref{fig:pn_cad_err}, this energy range has a very high relative error for P$_N$
order 1, especially when compared to the other energy regions nearby. In this
energy range, the relative error drops from 0.015 to .005 from P$_N$ order 1 to
3, but the energy bin immediately adjacent
only drops about .005 total. The greater change
in the relative error for this region accounts for the spike we see in Figure
\ref{fig:angle_err_improvements}.

The data in this figure also shows us that increasing P$_N$ order for
CADIS-$\Omega$ does not reduce the relative error in the energy range from
$10^{-3}$ to $10^{0}$ MeV. CADIS-$\Omega$'s purple line on this figure is
located below unity in that energy region. Generally this line for
CADIS-$\Omega$ does not see a huge improvement with increasing P$_N$ order.
For a problem like this, a low P$_N$ order may be a good enough choice.

CADIS' results in the same energy region show improvement in the
relative error. However, in many centrally-located energy bins, this improvement
is very small. If a tally existed for a similar problem in these energy ranges,
it may be sufficient to use CADIS with a low P$_N$ order as well.

\begin{figure}[h!]
  \centering
  \includegraphics[height=10cm]{./chapters/characterization_probs/figures/angle/prob_1/improvement_fom_allmethds.pdf}
  \caption[Ratio in the figure of merits between the lowest and highest variable in the angle
  sensitivity study for CADIS and CADIS-$\Omega$.]{Ratio in the figure of merits between
    the lowest and highest variable in the angle sensitivity study for CADIS and CADIS-$\Omega$.}
  \label{fig:angle_fom_improvements}
\end{figure}

In Figure \ref{fig:angle_fom_improvements}, the linestyles and colors match
those in Figure \ref{fig:angle_err_improvements}. The y-axis of this figure
shows the ratio of the FOMs for the lowest- and highest-valued parameters. The
purple lines are calculated by the ratio of $FOM_{P_N 1}/FOM_{P_N 5}$;
the green lines show the
ratio of $FOM_{S_N 5}/FOM_{S_N 20}$; the linestyles indicate the method
type. In this plot, a low-valued ratio reflects a higher valued FOM obtained by
the finer P$_N$ or S$_N$ order.

Some features from \ref{fig:angle_err_improvements} are continued in Figure
\ref{fig:angle_fom_improvements}. For example, the energy bins between $10^{-8}$
and $10^{-7}$ MeV still show a large change for P$_N$ order in CADIS. However,
the addition of time to calculate the FOMs affects both methods. In Figure
\ref{fig:angle_err_improvements}, we observed that for both methods, increasing
P$_N$ order or quadrature order generally decreased the relative error. In
Figure \ref{fig:angle_fom_improvements}, this is not the case. At low energies,
all methods have higher FOMs with increasing parameter resolution. At
intermediate energies, only S$_N$ order strongly changes the FOM. At high
energies, energy bins for both S$_N$ and P$_N$ order wildly oscillate between
improved and not improved.

The CADIS lines in Figure \ref{fig:angle_fom_improvements} generally lie at
lower values than CADIS-$\Omega$. Consequently, larger changes in the FOM are
observable with increasing either P$_N$ or S$_N$ order. This is the case for
most energy bins, but not above $10^0$ MeV. In this region, CADIS-$\Omega$ and
CADIS shift between energy bins in which method sees
a larger change with parameter value selection.

By inspecting both Figure \ref{fig:angle_err_improvements} and
\ref{fig:angle_fom_improvements}, a few common themes appear. First, CADIS has a
larger change in the tally relative error and FOM than CADIS-$\Omega$ for most
energy bins. Second, this general observation does not hold for energy bins
greater than $~10^{-1}$. At these energy regions, CADIS-$\Omega$ achieves a
better relative error with increasing S$_N$ order, but not P$_N$ order. Neither
CADIS-$\Omega$ or CADIS have a dominant trend in FOM values in this region.
Another observation is that generally S$_N$ order has a greater effect on the
relative errors and FOMS for both methods. This is not the case in the high
energy region for FOM values, where both methods are comparable.


\subsection{Operating Point and Static Characteristics}

To see the  non-linear  characteristics  of the plant, we set various constant
input voltages and waited for  the  motor  to  reach  its  settling speed. The
settling speed is then recorded and plotted in function of the  input  voltage
(see figure \ref{fig:static_cc}).

\begin{figure}[h]
    \centering
    \includegraphics[width=\linewidth]{images/static_cc}
    \caption{Static characteristic curve of the plant (motor): Input voltage vs settling rotation speed.}
    \label{fig:static_cc}
\end{figure}

Of particular interest  are  the  areas  close  to \SI{0}{\volt} and the areas
close to  the  maximum  rotation  speed. This is where the plant is not at all
linear.

To see  how  these  non-linearities  affect the step response of the plant, we
performed  two  step  response  experiments,  one in the non-linear region  of
\SI{0}{\volt}-\SI{2}{\volt}  and  another  in  the  fairly  linear  region  of
\SI{2}{\volt}-\SI{10}{\volt}. The results of these experiments are recorded in
figure  \ref{fig:step_responses}  (left)  and   are  mapped  onto  the  static
characteristic curve (right).

When  comparing  the  input  amplitudes  of   both  steps  (\SI{2}{\volt}  and
\SI{8}{\volt}, respectively) to the  step  response  amplitudes  ($43$ rpm and
$197$ rpm, respectively), we expect a perfectly linear system  to  satisfy the
equation $\frac{43}{2} \stackrel{?}{=} \frac{197}{8}$, but this is clearly not
the case.

\begin{figure*}
    \centering
    \includegraphics[width=\linewidth]{images/step_response}
    \caption{Two step response experiments, one in a non-linear region and the other in a fairly linear region. Notice how the step response amplitude differs between the two regions.}
    \label{fig:step_responses}
\end{figure*}


\section{Background}

\subsection{Multi-Agent Pathfinding over 4-Connected Grids}
We use the standard definition of MAPF for 4-connected grids. An $n\times m$ grid is defined by a pair $(G,O)$, where $G=\{(i,j):i\in\{1,\ldots,n\}, j\in\{1,\ldots,m\}\}$ are the cells of the grids and $O\subseteq G$ is a set of obstacle cells. In addition, we have $k$ agents, each of which is associated with an initial cell $I_k$ and a goal cell $G_k$. Intuitively each agent, at any time can perform one of five actions \{\Up,\Down,\Left,\Right,\Wait\}, the first four of which move the agent one cell in the desired direction. \Wait is an action that does not move the agent. When an agent executes a sequence of actions it generates a \emph{path}. A path is a sequence of nodes $u_1u_2\ldots u_m$, where $u_{i+1}$ is a neighbor of $u_i$ or $u_{i+1}=u_i$.  Given a path $u_0u_1\ldots u_m$, we say that the cell visited at time step $t$ is $u_t$ if $t\leq n$ or $u_m$ if $t>m$. Two paths are \emph{conflict-free} if (1) they are such that they do not visit the same cell at the same time step, and (2) agents never `swap' each other; that is they do not exchange (neighboring) cells in consecutive time steps.  A \emph{solution} to a MAPF problem is a list of $k$ pairwise \emph{conflict-free paths}, such that the $i$-th path (for agent $i$) starts in $I_i$ and ends in $G_i$. The cost of a path of size $n$ is $n-1$ (since we assume that actions have a cost of 1). The cost of a solution is the sum of the costs of the paths in the solution. The \emph{makespan} of a solution is the length of the longest path in the solution minus one. Two optimality criteria are usually considered for MAPF. A solution is cost-optimal (also referred to as \emph{optimal under sum-of-costs}) when no other solution exists with a lower cost. A solution is makespan-optimal when no other solution exists with a lower makespan.

\subsection{Answer-Set Programming}
ASP \cite{paper-de-lifschitz-what-is-ASP} is a logic based framework for solving optimization problems. For space limitations, here we describe a subset of an ASP standard that is relevant to this paper.

An ASP \emph{basic program} is a set of rules of the form:
\begin{equation}\label{asprule}
p\leftarrow q_1,q_2,\ldots,q_n.
\end{equation}
where $n\geq 0$, and $p$, $q_1,\ldots,q_n$ are so-called \emph{atoms}. The intuitive interpretation of this rule is as follows ``p is true/provable if so are $q_1,q_2,\ldots,q_n$''. When $n=0$ the rule \eqref{asprule} is called a \emph{fact}.

A \emph{model} of a basic ASP program is a set of atoms $M$ that intuitively contains all and only the atoms that are provable. An important syntactic element relevant to our paper is the so-called \emph{negation as failure}. Rules containing such negated atoms look like:
\begin{equation}\label{asprule}
p\leftarrow q_1,q_2,\ldots,q_n, not\: r_1,not\: r_2, \ldots, not\: r_k .
\end{equation}
The set of atoms $M$ is a model of a program $P$ containing such rules if the \emph{reduct} of $\Pi$ with respect to $M$, denoted as $\Pi^M$ also has $M$ as a model. Intuitively $P^M$ is a basic program which results from simplifying away every occurrence of a $not\:p$ in the obvious way (i.e., eliminating the rule if $p$ is in the model $M$, and removing $not\:p$ from the rule if $p$ is not in the model $M$). For example $M=\{p\}$ is a model of $\Pi=\{p\leftarrow not\: q\}$, since $\Pi^M=\{p\leftarrow \}$ has $M$ as a model. $M'=\{q\}$ is not a model of $\Pi$ since $\Pi^{M'}=\{\}$ does not have $M'$ as a model.

Another relevant type of rule is
\begin{equation}
    |\{p_1,p_2,\ldots,p_n\}|=1 \leftarrow q_1,q_2,\ldots,q_n.
\end{equation}
which states that only one among $\{p_1,\ldots,p_m\}$ is in a model $M$ if so are $\{q_1,\ldots,q_n\}$. In addition, the constraint:
\begin{equation}
    \leftarrow p_1,p_2,\ldots,p_n
\end{equation}
(best pronounced as not all of $p_1,\ldots,p_n$) states that a model cannot contain the set $\{p_1,p_2,\ldots,p_n\}$.

A very relevant feature of ASP is that programs can also contain a minimization statement expressing that one is looking for a model that minimizes a certain criteria. We introduce these constructs later when we see the details of our compilation. An ASP solver receives a program as input and outputs a model.

Finally, ASP programs usually use variables to represent schemas of rules. As such $p(X)\leftarrow q(X)$ represents a family of rules where $X$ moves over all the elements constructible with the syntactic elements mentioned in the program (the so-called Herbrand base). We omit further details for lack of space. What is very relevant however, is that an ASP solver will \emph{ground} a program containing variables, effectively generating all instances of these rule schemas before finding a model.

experimentos:

grillas (la campana)


\input{/Users/alessandromanzotti/Work/preamble.tex}

%%% BEGIN DOCUMENT
\begin{document}
\title{CMB DC Mode}
\author{}
\affiliation{Department of Astronomy \& Astrophysics, University of Chicago, Chicago IL 60637}
\date{\today}

\maketitle

%\section{Intro}\label{sec:intro}
%
%So the idea is that if you ``polarized'' your maps by using a Taylor expansion in the deflection angle the final map is not accurate enough to see the effects we are looking for. So what we have to do is to generate the unlensed fields C$_{XY}$ with $XY={TT,EE,\phi\phi}$ using CAMB. After that we have to fourier transform them so as to have $T(\theta,\phi)$
%
%
%So how do you do this? I do not know about Healpix2 but better to start from standard transform

%\section{random to be organized}
%
%so the idea is that i start my simulation in the frequencies space so what I am choosing is the maximum and minimum l will put in my simulation. The maximum one is going to be something like $N_{x}$uvcell and the minimum one is the uvcell in some sense we are choosing our Nyquist frequencies
%
%Another important thing is page 607 of numerical recipes so you can get the discrete fourier transform from a continuos function fourier transformed but sampled in discrete point in that case you have $H(f_{n})=\text{uvcell}*h_{n}$

\section{variance test}

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.3]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/box.pdf}
%\label{default}
\end{center}
\end{figure}

One way to compute the variance is just to sum over all the modes that are super-sample mode considering the width of the box $\theta_{box}\rightarrow l_{max}=\frac{2\pi}{\theta_{box}}$:

\be \label{eqn:lmax}
(\sigma^{\kappa})^{2}=\sum_{0}^{l_{max}=\frac{2\pi}{\theta_{box}}}\frac{2\ell+1}{4\pi}C_{\ell}^{\kappa}
\ee

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.4]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/Ckappa.pdf}
\caption{Power spectrum}
%\caption{default}
%\label{default}
\end{center}
\end{figure}

where the convergence power is releted to the lensing one by $C^{\kappa}=\ell^{2}(\ell+1)^{2}C^{\phi}/4$.

Increasing the size of the survey, reduce the number of large scale modes that can be consider as super-survey, and so the variance is reduced. This reduce the ``super sample covariance '' effect.
Now the width of the survey could be derived from the total area, assuming it covers a circular area, by $\pi \theta_{box}^{2}=\text{Area}(\frac{\pi}{180})^{2}$.
In this case $l_{max}=\frac{2\pi}{\theta_{box}}=\frac{2\pi}{\sqrt{(\text{tot Area})/\pi} (\pi/180)}=\frac{360\sqrt\pi}{\sqrt{\text{tot Area}}}=\frac{638}{\sqrt{\text{tot Area}}}$, where the total area has to be expressed in degree squared. For a 1000 deg$^{2}$ we get $l_{max}\approx20$

We want to compare this effect to the precision on the measurement of the angular size of sound horizon at last scattering, cause the effect of this background mode can be seen as if the fraction of the sky tested by the survey would have been sitted on a slightly over or under dense region, a slightly closed or open universe. The effect on the power spectrum is the same as a change in the curvature: a shift in the power spectrum.
The current precision reach by planck is $\frac{\sigma_{\theta^{\star}}}{\theta^{\star}}=\frac{0.00006}{1.041}=0.00057$.

We can improve this rough estimate by introducing a simple window function for the survey.

The variance in a 2D flat sky approximation become:
\be
\sigma^{2}_{\kappa}=\int \frac{d^{2}~q}{(2\pi)^{2 }}|\tilde W(q)|^{2} P(q),
\ee
where $\tilde W(q)$ is the fourier transform of the window function (we used the usual Fourier transform conventions).
As a window we can choose a uniform circular disk or radius $R=\theta_{box}$ (normalized so that $\int d^{2}x ~W(x)=1$) in the small angle approximation.
We have
\ba
|\tilde W(q)|&=&\int d^{2}x e^{-i q\cdot x} \Theta(r-R)/(\pi R^{2})\\
&=&\int_{0}^{\infty} x~dx \int_{0}^{2\pi} d\theta e^{-i qx\cos\theta} \Theta(r-R)/(\pi R^{2})\\
&=&1/(\pi R^{2}) \int_{0}^{R} xdx~ \int_{0}^{2\pi} d\theta e^{-i qx\cos\theta} \\
&=&1/(q \pi R^{2}) \int_{0}^{R} xdx~ 2\pi q J_{0}(xq) \\
&=&\frac{2\pi}{\pi R^{2} q^{2}}\int_{0}^{R} d(xq) xq J_{0}(xq) \\
&=&\frac{2\pi}{\pi R^{2} q^{2}}Rq J_{1}(Rq) \\
&=&\frac{2~J_{1}(Rq)}{Rq}. \\
\ea
We have used two properties of bessel functions
\ba
&&J_{n}=\frac{i^{-n}}{\pi}\int_{0}^{\pi}d\theta e^{ix\cos\theta}cos(n\theta)\\
&&\frac{d}{dx}[xJ_{1}(x)]=xJ_{0}(x)\\
\ea

The variance become:
\ba \label{eqn:integral}
\sigma_{\kappa}^{2}&=&\int \frac{d^{2}~\ell}{(2\pi)^{2}} \left(\frac{2~J_{1}(\ell~\theta_{box})}{\ell~\theta_{box}}\right)^{2} C_{\ell}\\
&=&\int \frac{d\ell}{(2\pi)} \ell \left(\frac{2~J_{1}(\ell~\theta_{box})}{\ell~\theta_{box}}\right)^{2} C_{\ell}
\ea
It can also be approximated by a sum
\be \label{eqn:approx}
\sigma_{\kappa}^{2}=\sum \frac{2\ell+1}{4\pi} \left(\frac{2~J_{1}(\ell~\theta_{box})}{\ell~\theta_{box}}\right)^{2} C_{\ell}.
\ee

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/window.pdf}
%\caption{default}
%\label{default}
\end{center}
\end{figure}

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/variance.pdf}
\caption{Integral correspond to \refeq{integral} Sum approximation is \refeq{approx} . No window lmax correspond to \refeq{lmax} which I think is pretty different cause it is like having a rectangle window function in Fourier space which give you an un-normalized sync window function in space domain. }
%\label{default}
\end{center}
\end{figure}

\section{Fisher\_estimate}

I compute the value of  $C^{\rm{fid}}_{\ell}$s using CAMB and with those I compute the Fisher estimates of the effect we are looking for, given the accuracy (beam and white noise) of a detector. See Wayne's notes.

The super sample modes shift the CMB power spectrum and so we have:
\begin{equation}
C_l = C_l^{\rm fid} \left[ 1+ \frac{\partial \ln (l^2 C_l^{\rm fid} )}{\partial \ln l} s \right].
\end{equation}
Notice that the effect is stronger where the derivatives are bigger, near the peaks.
Now we can perform a Fisher estimate of $\sigma_s^2$ (no other parameters marignalized) and compare it to $\sigma_\kappa^2$.
I compute:
\begin{equation}
\frac{\partial C_{\ell}}{\partial s}=C^{\rm fid}\frac{\partial \ln (l^2 C_l^{\rm fid}) }{\partial \ln l},
\end{equation}
directly from the spline function I use to fit the spectrum (maybe we need something more accurate?); after that, following the fisher formalism:
\ben
F_{ss}=\sum_{\ell}\frac{1}{(\delta C_{\ell})^{2}}\left( C^{\rm fid}\frac{\partial \ln (l^2 C_l^{\rm fid} )}{\partial \ln l}\right)^{2}
\een
\ben
F_{ss}=\sum_{\ell}\frac{(2\ell+1)f_{\rm sky}}{2[C^{\rm{fid}}_{\ell}+N_{\ell}]^{2}}\left( C^{\rm fid}\frac{\partial \ln (l^2 C_l^{\rm fid} )}{\partial \ln l}\right)^{2}
\een
assuming SPT-pol 4$\mu K$-arcminute noise and a beam of 1-arcmin:
\be
N_{\ell}=\left( 4 \mu K \left(\frac{\pi}{10800}\right)\right)\exp\{-\ell(\ell+1)\theta\left(\frac{\pi}{10800}\right)/(8\log 2)\}.
\ee
I put the equation explicitly cause I am not sure that when they quote an accuracy they mean this or the same divided by the T$_{CMB}$. Let me know it takes a second to change it (thanks!).

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/derivatives.pdf}
\caption{Absolute value of the derivatives that enter the fisher matrix computation.}
\label{fig:derivatives}
\end{center}
\end{figure}

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/variancefisherfsky.pdf}
\caption{Value of $\sigma^{2}_{s}=\frac{1}{F_{ss}}$ as a function of the maximum multipole considered.}
\label{fig:variancefsky}
\end{center}
\end{figure}

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/logl2cl.pdf}
%\label{default}
\end{center}
\end{figure}
\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{/Users/alessandromanzotti/Work/Astrophysics/Wayne-B_lensing/images/variancefisher.pdf}
\caption{Value of $\sigma^{2}_{s}=\frac{1}{F_{ss}}$ as a function of the maximum multipole considered. $f_{\rm{sky}}$ is chosen considering 1000 deg$^{2}$. Green curve is without instrumental noise, blue take it under consideration. Red line is
$(\frac{\sigma_{\theta^{\star}}}{\theta^{\star}})^{2}$ for Planck. Note: we are close to the edge, I have to carefully check the noise I used is not wrong or too optimistic.}
%\label{default}
\end{center}
\end{figure}

\end{document}


\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
%\usepackage[ddmmyyyy]{datetime}
\usepackage[short,nodayofweek,level,12hr]{datetime}
%\usepackage{cite}
%\usepackage{wrapfig}
%\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\newcommand{\e}{\epsilon}
\newcommand{\dl}{\delta}
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\describe}[2]{\underbrace{#2}_{\text{#1}}}% \describe{}{} - First bracket is for description
%\describe{$\substack{this \\ is \\ substacking}$}{b} - To split the description over multiple lines
\newcommand{\vect}[1]{\underline{#1}}
\newcommand{\uvect}[1]{\hat{#1}}
\newcommand{\1}{\vect{1}}
\newcommand{\grad}{\nabla}
\newcommand{\RR}{\Rightarrow}

\title{Matched Asymptotics for the Axisymmetric Meniscus}
\date{\displaydate{date}}
\newdate{date}{23}{09}{2018}
\author{}

\begin{document}
\maketitle

\section{The Axisymmetric Meniscus}
The setup consists of a cylinder of radius $R$ dipped halfway into a fluid of density $\rho$ and surface tension $\Gamma$ and we are required to find out the shape of the resulting meniscus under the influence of gravity and surface tension. The shape of the meniscus is denoted by $z=f(r)$. Since the problem is axisymmetric, there is no $\theta$ dependence.

We know that at any $r$, the pressure of fluid over the horizontal $z=0$ is being balanced by the pull of surface tension. If pressure inside the fluid is $\hat p$ and outside it is $p$, the unit normal to the meniscus being $\vect n$, then:
\begin{align*}
&\hat p - p = \rho g z = \Gamma \grad \cdot \vect n
\end{align*}
Writing $F = z-f(r) = 0$ and the unit normal as $\vect n=\grad F/|\grad F|$, the divergence of the unit normal comes out to be:
\begin{align*}
&\grad\cdot n = \frac{\frac{-1}{r}\frac{d}{dr}\frac{rdf}{dr}}{\Big(1+\frac{df}{dr}^2\Big)^{1/2}} + \frac{\frac{d^2f}{dr^2}\frac{df}{dr}^2}{\Big(1+\frac{df}{dr}^2\Big)^{3/2}}
\end{align*}
Before proceeding, we would like to scale our equation to make it dimensionless. But, as opposed to the 2D meniscus near a flat wall, this problem has 2 length scales - $R$ and $l_c(=\sqrt{\Gamma/\rho g})$. Therefore, the solution will, in general, be a function of the non-dimensional parameter $R/l_c$ or $(R/l_c)^2=\rho g R^2/\Gamma$ which is the Bond Number $(Bo)$. If $Bo \to \infty$, the radius of the cylinder is much larger than $l_c$ and hence we approach the 2D mensicus case (as long as $r$ remains less than $R$). This is the limit in which the mensicus doesn't sense the curvature of the cylinder.

We are now interested in the opposite limit where the effects of curvature of the cylinder are prominent, $\lim Bo \ll 1$. If we now scale the lengths by $l_c = \sqrt{\Gamma/\rho g}$, The non-dimensional Young-Laplace Equation becomes:
\begin{align*}
& z = \frac{\frac{-1}{r}\frac{d}{dr}\frac{rdf}{dr}}{\Big(1+\frac{df}{dr}^2\Big)^{1/2}} + \frac{\frac{d^2f}{dr^2}\frac{df}{dr}^2}{\Big(1+\frac{df}{dr}^2\Big)^{3/2}}
\end{align*}
which looks nasty by itself, so we will solve the far-field and near-field problems separately and later patch the two solutions.

\subsection*{Far-field solution ($\lim r \gg R$)}

In the far-field, the slope of the meniscus will be small and the equation becomes:
\begin{align*}
&z = \frac 1 r\frac{d}{dr}\frac{rdf}{dr}\\
\Rightarrow& \frac{d^2z}{dr^2} +\frac{dz}{rdr} - z = 0 \tag{using $z=f(r)$}
\end{align*}
which is the modified Bessel's Equation with solutions given by:
\begin{align*}
\RR &z = \describe{Growing solution}{I_0(r)}, \describe{Decaying solution}{K_0(r)}
\end{align*}
$I's$ grow with $r$ and have a essential singularity at infinity. $K's$ decay with $r$ and have singularity at origin (which is fine with us as long as the cylinder has any finite thickness). Hence, we conclude that:
\begin{align*}
&z = A K_0(r/l_c) \quad \text{if} \quad r \gg R
\end{align*}
Thus we obtain the far-field solution.

\subsection*{Near-field solution ($\lim r \ll l_c$)}

Now consider the limit, $r \ll l_c$. Here, we cannot make the linear approximation because slope near the cylinder is not small. But within this limit, it is reasonable to assume that the effect of surface tension will dominate gravity. In the full equation:
\begin{align*}
&  z = \frac{\frac{-1}{r}\frac{d}{dr}\frac{rdf}{dr}}{\Big(1+\frac{df}{dr}^2\Big)^{1/2}} + \frac{\frac{d^2f}{dr^2}\frac{df}{dr}^2}{\Big(1+\frac{df}{dr}^2\Big)^{3/2}}
\end{align*}
the term containing gravity (clearly seen if we re-dimensionalize the equation and bring out the implicit $\sqrt{\Gamma/\rho g}$ is $z$. Therefore, we neglect this term and proceed to obtain:
\begin{align*}
&\frac{d^2z}{dr^2} + \frac{1}{r}\frac{dz}{dr}\Big( 1 + \frac{dz}{dr}^2\Big) = 0
\end{align*}
This can be integrated with a little effort to give:
\begin{align*}
&z = D - C \log\Big[ \frac{r}{C}+\Big(\big(\frac{r}{C}\big)^2-1\Big)^{1/2}\Big]
\end{align*}
%The boundary condition at the wall requires, in dimensional terms, $z=H$ at $r = R$. In non-dimensional terms $z = H/l_c$ at $r = Bo$. For convenience, we will denote the unknown $H/l_c$ as $H$ itself, keeping in mind that height is being measured in units of $l_c$. Therefore the boundary condition gives us:
%\begin{align*}
%& H = C \log\Big[ \frac{Bo}{C}+\Big(\big(\frac{Bo}{C}\big)^2-1\Big)^{1/2}\Big] + D\\
%\RR& D = H - C \log\Big[ \frac{Bo}{C}+\Big(\big(\frac{Bo}{C}\big)^2-1\Big)^{1/2}\Big]
%\end{align*}
%Substituting this in the equation for $z$, we get:
%\begin{align*}
%&z = H + C (\log\Big[ \frac{r}{C}+\Big(\big(\frac{r}{C}\big)^2-1\Big)^{1/2}\Big] - \log\Big[ \frac{Bo}{C}+\Big(\big(\frac{Bo}{C}\big)^2-1\Big)^{1/2}\Big])\\
%&z = H + C \log\Bigg[ \frac{\frac{r}{C}+\Big(\big(\frac{r}{C}\big)^2-1\Big)^{1/2}}{\frac{Bo}{C}+\Big(\big(\frac{Bo}{C}\big)^2-1\Big)^{1/2}}\Bigg]
%\end{align*}
%Or in dimensional terms:
%\begin{align*}
%&z = H + C \log\Bigg[ \frac{\frac{r}{C}+\Big(\big(\frac{r}{C}\big)^2-1\Big)^{1/2}}{\frac{R}{C}+\Big(\big(\frac{R}{C}\big)^2-1\Big)^{1/2}}\Bigg] \quad \text{if} \quad r\ll l_c
%\end{align*}
which is our near-field solution ($C$ and $D$ being arbitrary constants to be determined).

\subsection*{Overlap region}

From the two solutions obtained above, we must construct the solution in the overlap region given by $R \ll r \ll l_c$. In order to do this, we obtain the inner limit of the outer solution and the outer limit of the inner solution and equate the two.

\begin{align*}
&\lim_{r \ll l_c} A K_0(r/l_c) = -A (\log(r/l_c) + \gamma) \tag{\footnotesize{Inner limit of the outer solution}}\\
&\lim_{r \gg R}  D - C \log\Big[ \frac{r}{C}+\Big(\big(\frac{r}{C}\big)^2-1\Big)^{1/2}\Big]  = D - C \log(\frac{2r}{C}) \tag{\footnotesize{outer limit of the inner solution}}
\end{align*}
where $\gamma$ is the Euler-Mascheroni constant. These two solutions are, in fact, the same and hence we can equate them:
\begin{align*}
&-A (\log(r/l_c)+\gamma) = D - C \log(\frac{2r}{C})\\
\RR&-A\log(r/l_c) - A\gamma = D - C \log(\frac{2l_c}{C}\frac{r}{l_c})\\
\RR&-A\log(r/l_c) - A\gamma = D - C \log(\frac{2l_c}{C}) - C\log(\frac{r}{l_c})\\
\RR& -A\log(r/l_c) = -A\log(r/l_c) \quad \text{and} \quad - A\gamma = D - C \log(\frac{2l_c}{C})\\
\RR& A = C \quad \text{and} \quad D = C (\log(\frac{2l_c}{C} - \gamma))
\end{align*}
We have three constants ($A,C,D$) and 2 equations. Third equation comes from the contact angle boundary condition. Denoting the inner solution as $z^i$, we have
\begin{align*}
&\frac{dz^i}{dr} = \tan(\frac{\pi}{2} + \theta_c) = -\cot(\theta_c) \quad @ \quad r=R
\end{align*}
which eventually yields
\begin{align*}
&C = R\cos\theta_c
\end{align*}
This gives us the significance of $C$. When $\theta_c=0$, $C=R$. Finally, we can obtain the height of the meniscus at the surface of the cylinder. Using the near field solution and expressions for $C$ and $D$, we can write:
\begin{align*}
&H = R\cos\theta_c\Bigg[\log\bigg(\frac{2l_c}{R(1+\sin\theta_c)} \bigg)- \gamma \Bigg]
\end{align*}

If $\theta_c = 0$, we get $H = R\log(l_c/R)$. Note that $\log(l_c/R)$ is usually an order one quantity (when $Bo \ll 1$ or $R \ll l_c$). Then the rise is of the order of $R$. This is much less than the rise for the case of flat plate where it was $\sqrt 2 l_c$, of the order of $l_c$.
\section{Appendix}

\subsection{Interpretation of the far-field meniscus using Helmholtz Equation}
The far-field solution was obtained using
\begin{align*}
&z = \frac 1 r\frac{d}{dr}\frac{rdf}{dr}
\end{align*}
which has the form of a Helmholtz equation given by
\begin{align*}
&\grad^2f-k^2f=0
\end{align*}
where $k$ has the dimensions of inverse length scale. To make it explicit, we write the equation as
\begin{align*}
&\grad^2f-\frac{f}{\lambda^2}=0
\end{align*}
where $\lambda$ is a some characterstic length. When $r \ll \lambda$, then the second term is neglected and the equation reduces to a Laplace equation
\begin{align*}
&\grad^2f=0
\end{align*}
and hence, in this limit, $f$ will behave as a solution to the Laplacian. Specifically, if there is a point source in 3D, then $f = -1/4\pi r$ and in 2D it would be $\log(r)/2\pi$. But outside this limit, the form of the solution will be different. If $r \gg \lambda$ we observe an exponential decay of the solution.

For the equation governing the far-field meniscus
\begin{align*}
&z = \frac 1 r\frac{d}{dr}\frac{rdf}{dr}\\
\Rightarrow& \frac{d^2z}{dr^2} +\frac{dz}{rdr} - z = 0 \tag{using $z=f(r)$}\\
\Rightarrow& \grad^2f - \frac{f}{l_c^2} = 0 \tag{dimensionalizing}
\end{align*}
we can similarly deduce the two types of behaviour. At length scales much greater than $l_c$, the term $\frac{dz}{rdr}$ is small and the remaining terms give the decaying exponential solution. Whereas, if we are in the regime where $r \ll l_c$, then $l_c$ is large compared to $r$ and hence the term $z$ gets neglected. The remaining terms then give the logarithmically decaying solution. The full solution, $K_0(r)$, decays exponentially for large $r$ and goes as $-\log(r)$ for small $r$. Thus it respects both the limiting cases.

Consider a positive ion surrounded by a sphere of negative charges of radius $R$. If we want to evaluate the potential close to the charge ($r \ll R$), then the governing equation is a Laplacian and hence potential due to the point charge goes as $1/r$ within the sphere and decays exponentially $e^{-r/R}$ for $r \gg R$.

\subsection{Calculations for the inner region}

\end{document}


\documentclass[letterpaper,12pt]{article}
\usepackage{tabularx} % extra features for tabular environment
\usepackage{amsmath}  % improve math presentation
\usepackage{graphicx} % takes care of graphic including machinery
\usepackage[margin=1in,letterpaper]{geometry} % decreases margins
\usepackage{cite} % takes care of citations
\usepackage[final]{hyperref} % adds hyper links inside the generated pdf file
\hypersetup{
	colorlinks=true,       % false: boxed links; true: colored links
	linkcolor=blue,        % color of internal links
	citecolor=blue,        % color of links to bibliography
	filecolor=magenta,     % color of file links
	urlcolor=blue
}
\usepackage{blindtext}
\usepackage{float}
%++++++++++++++++++++++++++++++++++++++++

\begin{document}

\section{Data\_driven technique to discover optimal model of $\ddot{F}$}

To estimate $\ddot{f}$, a data\_driven technique is employed. We consider $\ddot{F}$ is linear in terms of $\theta$, $ \alpha$, $\dot{\theta}$, and $\dot{\alpha}$ as equation \ref{EqddF} presents.
\begin{equation}\label{EqddF}
\ddot{F}=c_{1} \theta+c_{2} \alpha+c_{3} \dot{\alpha} + c_{4} \dot{\theta}
\end{equation}
where $c_{1}$, $c_{2}$, $c_{3}$, and $c_{4}$ are constant coefficients. From experiment, only the time incremental record of angles $\theta$ and $\alpha$ are available, and $F$ is known by $\theta+1.039\alpha$. To estimate the derivatives and filter the measurement noises of $\theta$ and $\alpha$, the algebraic operation in \cite{FliessRamirez2003} is applied.  We assume the dynamic of system \ref{EqddF} is sparse in the states and employ the least absolute shrinkage and selection operator (LASSO) to estimate the sparse terms through minimizing the cost function $J_{\lambda}$ in \ref{EqCostFuncLASSO}.

\begin{equation}\label{EqCostFuncLASSO}
J_{\lambda}(\mathbf{c}) =\left\Vert \mathbf{e}\right\Vert _{2}^{2}+\lambda\left\Vert \mathbf{c}\right\Vert _{1}
\end{equation}

Let us introduce $c$ as the vector of coefficients and $e$ accounts for the estimation error. $\lambda > 0$ is a preselected positive number known as the sparse regulator. It is common to use cross-validation techniques from machine learning to determine the sparse regulation parameter $\lambda$. The value of $\lambda$ in an finite interval is sampled and total data is divided into train and test dataset. The cross-validation mean square error over the test dataset is computed. The $\lambda$ value which minimizes the cross-validation error is selected. The corresponding model is chosen as an optimal model with a proper balance of complexity and accuracy.

In order to develop robust sparse regression, we propose to combine the sparse regression with bootstrapping. We consider $K$
bootstrap sample vectors containing $L$ elements of the original data points. For
each bootstrap sample vector, the sparse regression is applied to identify the
model. Finally, the parameters of the model is the average of the $K$
estimated coefficient vectors $\hat{\mathbf{c}}_{l}$.%
\begin{equation}
\tilde{\mathbf{c}}=\frac{1}{K}{\sum_{l=1}^{K}}\hat{\mathbf{c}}_{l}
\label{EqBootsrapping}%
\end{equation}

The standard deviation of estimated coefficient vectors $\hat{\mathbf{c}}_{l}$ is computed to study the variation of parameter estimation. We record data for 4 $s$ with the time increment 0.002 $s$. The first half of the data is kept for training and we use the rest for test data. For bootstrapping, 30 samples with the length of 30$\%$ are selected. The algorithm estimates
\begin{equation}
\ddot{F}=(-44.2532 \pm 0.0361) \alpha
\label{EqEstimated}%
\end{equation}

\end{document}


\section{Abstract}
The Ising model in two dimensions was examined to understand phase transitions for a ferromagnetic canonical system. Without the application of an external magnetic field the Ising model is in it's simplest form.\\

I find that the Monte Carlo simulation and analytical solutions coincide with very small error ($O(10^{-3})$) for number of trials above $10^5$ with T=1 and T=2.4. The exception is the average magnetization per spin and susceptibility per spin for T=1, which seems to have unstable solutions  for number of trials above $10^3$

\section{Introduction}
In this project I will study the Ising model in two dimensions. This model is used to simulate phase transitions. When reaching the critical temperature $T_c$ the model gives a phase transition from a system with finite magnetic moment, to a phase with zero magnetization. At the critical temperature we need to examine the system closely to understand how particles interact, since we can have large fluctuations in this transition phase.\\

The model is binary, and in our case we take advantage of that with the objects at each lattice having the option of being a spin up or spin down. These states characterizes the microstates of a substance. \cite{spin}\\

The one- and two- dimensional systems have analytical solutions for various expectation values. Ernst Ising solved the one-dimensional system in 1925. The two-dimensional system allows for phase transitions and was solved analytically by Lars Onsager in 1944 \cite{ising}.  We will look at the simplest two- dimensional case, where we do not allow an external magnetic field. In this case the energy is:

\begin{equation}
E = -J\sum_{<kl>}^Ns_ks_l
\end{equation}

, where J is the coupling constant expressing the strength of the interaction between neigboring spins. $<kl>$ indicates that we sum over the nearest neigbors only, e.g. that only neighboring spins interact with each other. N is the total number of spins. We will assume ferromagnetic ordering,
$J > 0$, which implies a strong interaction between the electrons, hence a strong ordering. $s_k$ and $s_l$ are neighboring spins each represented with a value of $\pm 1$.\\

To model the phase transitions I will use Monte Carlo simulations, specifically the Metropolis algorithm with periodic boundary conditions. Periodic boundary conditions means that at the end of the lattice, we start over from the start of the lattice, e.g. the first and last lattice positions are neighbors.\\

\section{Methods}
\subsubsection{Analytical solutions}
The derivation is based on the lecture note on statistics for the ising model \cite{isingstat}\\

The Ising model is a typical canonical ensemble. The system allows for heat interaction, whilst holding fixed the volume, temperature and number of particles. The partition function is given by:

\begin{equation}
Z = \sum_ie^{-\beta E_i}
\end{equation}

, where $\beta = 1/kT$, where k = Boltzmann's constant and T = temperature, $E_i$ is the energy for each microstate.\\

The Boltzmann probability distribution is given as $P_i$:

\begin{equation}
P_i(\beta) = \frac{e^{-\beta E_i}}{Z}
\end{equation}\\

The mean energy is given as:
\begin{equation}
<E> = \sum_i^ME_iP_i(\beta) = \frac{1}{Z}\sum_i^ME_ie^{-\beta E_i}
\end{equation}\\

And the corresponding specific heat $C_v=\frac{1}{kT^2}$, k and T again being Boltzmann's constant and temperature, is represented by the variance:

\begin{equation}
\sigma^2 = <E^2> - <E>^2 = \frac{1}{Z}\sum_i^ME_i^2e^{-\beta E_i}-(\frac{1}{Z}\sum_i^ME_ie^{-\beta E_i})^2
\end{equation}\\

\begin{equation}
<|M|> = \sum_i^M|M_i|P_i(\beta)
\end{equation}

\begin{equation}
\chi = \frac{<M^2> - <M>^2}{kT^2}
\end{equation}

,where k is Boltzmann's constant and T is temperature

For the 2 by 2 lattice with only neighbors interacting, with either positive or negative spin, I find the same values as found on page 9 of \cite{isingstat}:

\FloatBarrier
\begin{table}

\begin{tabular}{lrrrr}
\toprule
Number spins up &  Degeneracy &  Energy (Ei) &  Magnetization (Mi) \\
\midrule
4 &      1 &      -8J &        4 \\
3 &      4 &      0 &        2 \\
2 &      4 &      0 &        0 \\
2 &      2 &      8J &        0 \\
1 &      4 &      0 &        -2 \\
0 &      1 &      -8J &        -4 \\
\bottomrule

\end{tabular}

\caption{List of configurations with energies and magnetic moment}
\label{tab:Configurations_energy_magnetic}
\end{table}
\FloatBarrier

\subsubsection{Analytical values}
By using table ~\ref{tab:Configurations_energy_magnetic} and inserting values into the theoretical expressions for the partition function, expected energy, specific heat, mean expected absolute value of magnetic moment and susceptibility.\\

Analytical values was calculated to be:\\

\begin{equation}
Z = 12+4cosh(8\beta J)
\end{equation}

\begin{equation}
<E> = \frac{-8Jsinh(8\beta J)}{cosh(8\beta J + 3}
\end{equation}

\begin{equation}
<|M|> = \frac{2e^{8\beta J}+4}{cosh(8\beta J)+3}
\end{equation}

\begin{equation}
\chi = \frac{8(e^{8\beta J}+1)}{(cosh(8\beta J)+3)kT}
\end{equation}

\subsection{Metropolis algorithm}
The metropolis algorithm is a smart method for evaluating a model for a system with not fully disclosed probabilities since it only requires an approximation for the initial probability. Even if we don't know the point density function of the system, we can use a function which is proportional to the original function. In our case we could estimate the exact probability function, but it's very time consuming. Luckily for us we don't need to use the partition function, because the Metropolis-Hastings algorithm only considers the ratio between probabilities. Instead we use rejection sampling.\\

First we calculate the energy of the current state. Then we change the initial configuration by flipping only one spin. Then we compute the energy for this trial state. Then we calculate the energy in the previous step and the current step.  If $\Delta E$, the change in energy, is negative, we accept the new configuration. This means that the energy is lowered, and hopefully we are moving towards the equilibrium state. We also must consider accepting a move if it increases the energy. This is done by rejection sampling. Rejection sampling is done by choosing a random number and comparing it with the weight
$e^{-\beta \Delta E}$, where beta = 1/kT and $\Delta E$ is the change of energy. If the random number is smaller than the weight, we accept the new configuration, otherwise we keep the old configuration. The next step is to update various expectation values. These steps are then repeated to get a sufficiently good representation of states. Each time we sweep through the lattice, constitutes a Monte Carlo Cycle. \cite{lecturenote} page 435 (Ch. 13.5)\\

\newpage
\section{Implementation}
For all programs, see:\\
$\href{https://github.com/larsjbro/FYS4150/tree/master/project_4/source}{https://github.com/larsjbro/FYS4150/tree/master/project_4/source}$

\subsection{Metroplis algorithm}
The metropolis algorithm is used to accept or reject a move, implemented with the following code:

\begin{lstlisting}
def metropolis(E, M, w, size, spin_matrix):
    # Metropolis
    # Loop over all spins, pick a random spin each time
    for s in xrange(size**2):
        x = int(numpy.random.random() * size)
        y = int(numpy.random.random() * size)
        deltaE = 2 * spin_matrix[x, y] * (spin_matrix[periodic(x, size, -1), y]
                                          + spin_matrix[periodic(x, size, 1), y]
                                          + spin_matrix[x, periodic(y, size, -1)]
                                          + spin_matrix[x, periodic(y, size, 1)])

        accept = numpy.random.random() <= w[deltaE + 8]
        if accept:
            spin_matrix[x, y] *= -1
            M += 2 * spin_matrix[x, y]
            E += deltaE
    return E, M
\end{lstlisting}

Since we are only calculating energy between two neighboring spins, the change in energy is simplified as $2*spin\_matrix$ which is also shown in equation 13.6 in \cite{isingstat}. How we accept a move was discussed in the method for the metropolis algorithm above, and implemented as such in the code above.

\subsection{Calculating the critical parameters with Monte Carlo}
Added spin matrix to the existing algorithm for Monte Carlo given on the course material site. The given function from the course, is called monteCarlo. Here I calculate the values for energy, specific heat, magnetization and susceptibility. These can then be compared to the analytical results, which is done in the results section.

\begin{lstlisting}
def compute_monte_carlo(temperature, size, trial_sizes, spin_matrix='ordered'):
    data = []
    for trials in trial_sizes:
        print trials
        t0 = timer()
        data.append(monteCarlo(temperature, size, trials, spin_matrix=spin_matrix))
        print 'elapsed time: {} seconds'.format(timer() - t0)

    data = np.array(data)
    names = ['Average Energy per spin $E/N$',
             'Specific Heat per spin $C_V/N$',
             'Average Magnetization per spin $M/N$',
             'Susceptibility per spin $var(M)/N$',
             'Average |Magnetization| per spin $|M|/N$',
             'Variance of |Magnetization| per spin $var(|M|)/N$',
             'Number of accepted configurations']
    return data, names
\end{lstlisting}

\subsection{Finding the most likely state}
Below is the code used to find the number of Monte Carlo cycles to reach the equlibrium state for a lattice of size 20 times 20, for trials up to $10^5$

\begin{lstlisting}
def task_c(temperatures=(1,)):
    trial_sizes = [10, 30, 100, 300, 1000, 3000, 10000, 30000, 100000] # 10**np.arange(1, 5)
    for temperature in temperatures:
        print temperature
        size = 20
        for spin_matrix in ['ordered', 'random']:
            data, names = compute_monte_carlo(temperature, size, trial_sizes, spin_matrix)

            plt.figure()
            plot_mean_energy_and_magnetization(trial_sizes, data, names, temperature, spin_matrix)
            plt.savefig('task_c_T{}_size{}_{}.png'.format(temperature, 20, spin_matrix))

            plt.figure()
            plot_total_number_of_accepted_configs(trial_sizes, data, names, temperature, spin_matrix)
            plt.savefig('task_c_accepted_T{}_size{}_{}.png'.format(temperature, 20, spin_matrix))
\end{lstlisting}

%*Code/Implementations/test: Readability of code, implementation, testing and discussion of benchmarks. Total number of possible points 20*

\section{Results}
%*Analysis: of results and the effectiveness of their selection and presentation. Are the results well understood and discussed? Total number of possible points: 20*

\subsection{Agreement between analytical and numerical simulations and the equilibrium state}

From the figures 1 and 2 below I can see that temperature T=1 is the hard problem, when the magnetization has unstable solutions for many Monte Carlo cycles. For T=2.4 solutions are acceptable to order $10^{-3}$ when we approach $10^5$ trials. This is also when we reach an approximate equilibrium state for T=2.4. For T=1 the equilibrium state is trapped from the beginning and was never able to change state due to the temperature being too low to access other states. This can be seen in figure 3 and 4.

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_b_abserr_T1_size2.png}

\caption{Absolute error between theoretical and simulated expected values for T=1}
\label{fig:Earth_orbit_sun_Forward_Euler_k_4}
\end{figure}
\FloatBarrier

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_b_abserr_T2_4_size2.png}

\caption{Absolute error between theoretical and simulated expected values for T=2.4}
\label{fig:Earth_orbit_sun_Forward_Euler_k_2}
\end{figure}
\FloatBarrier

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_c_T1_size20_ordered.png}

\caption{Approaching equlibrium state for T=1}
\label{fig:Earth_orbit_sun_Forward_Euler_k_2}
\end{figure}
\FloatBarrier

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_c_T2_4_size20_ordered.png}

\caption{Approaching equlibrium state for T=2.4}
\label{fig:Earth_orbit_sun_Forward_Euler_k_2}
\end{figure}
\FloatBarrier

\subsection{Accepted configurations as a function of temperature}
From figure 5 and 6 below I see that accepted configurations go up with the temperature, meaning that more states are accessible for higher temperatures.

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_c_accepted_T1_size20_ordered.png}

\caption{Accepted configurations as function of Monte Carlo cycles for T=1}
\label{fig:Earth_orbit_sun_Forward_Euler_k_2}
\end{figure}
\FloatBarrier

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_c_accepted_T2_4_size20_ordered.png}

\caption{Accepted configurations as function of Monte Carlo cycles for T=2.4}
\label{fig:Earth_orbit_sun_Forward_Euler_k_2}
\end{figure}
\FloatBarrier

\subsection{Probability distribution}
I see from figure 7 and 8 that the probability for being in an energy state is more correlated in the lower temperatures. The variance of the distribution is very small, which is also reflected in the probability distribution.

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_d_probability_T1_size20_ordered.png}

\caption{Probability for being in different energy states for T=1}
\label{fig:Earth_orbit_sun_Forward_Euler_k_2}
\end{figure}
\FloatBarrier

\FloatBarrier
\begin{figure}[!ht]
\centering
\FloatBarrier
\includegraphics[width=0.70\textwidth]{task_d_probability_T2_4_size20_ordered.png}

\caption{Probability for being in different energy states for T=2.4}
\label{fig:Earth_orbit_sun_Forward_Euler_k_2}
\end{figure}
\FloatBarrier

\section{Conclusion}
It takes a long time to run Monte Carlo cycles. I found that accepted configurations increase with temperature, and that the numerical expression had some issues for the magnetization for low temperatures and many trials.

For $T<T_c$ the probability distribution is very sharp, meaning it's hard to get out of an energy state.

%*Conclusions, discussions and critical comments: on what was learned about the method used and on the results obtained. Possible directions and future improvements? Total number of possible points: 10*

\begin{thebibliography}{99}
\bibitem{heisenberg} W. Heisenberg, Zeits. f. Physik {\bf 77}, 1 (1932).
\bibitem{miller2006} G.~A.~Miller, A.~K.~Opper, and E.~J.~Stephenson, Annu.~Rev.~Nucl.~Sci.~{\bf 56}, 253 (2006).
\bibitem{ekstrom2015} A.~Ekstr\"om, G.~R.~Jansen, K.~A.~Wendt, G.~Hagen, T.~Papenbrock, B.~D.~Carlsson, C.~Forssen, M.~Hjorth-Jensen, P.~Navratil, and W.~Nazarewicz, Phys.~Rev.~C {\bf 91}, 051301(R) (2015).
\bibitem{brown1977} B. A. Brown, A. Arima and J. B. McGrory, Nucl. Phys. {\bf A277}, 77 (1977) and references therein.
\bibitem{ising} $\href{https://en.wikipedia.org/wiki/Ising\_model}{https://en.wikipedia.org/wiki/Ising\_model}$
\bibitem{lecturenote}$\href{https://github.com/CompPhysics/ComputationalPhysics/blob/gh-pages/doc/Lectures/lectures2015.pdf}{https://github.com/CompPhysics/ComputationalPhysics/blob/gh-pages/doc/Lectures/lectures2015.pdf}$, November 19 2017\\
\bibitem{spin}$\href{https://en.wikipedia.org/wiki/Spin-\%C2\%BD}{https://en.wikipedia.org/wiki/Spin-\%C2\%BD}$\\
\bibitem{isingstat}$\href{http://compphysics.github.io/ComputationalPhysics/doc/pub/statphys/pdf/statphys-print.pdf}{http://compphysics.github.io/ComputationalPhysics/doc/pub/statphys/pdf/statphys-print.pdf}$
\end{thebibliography}

%\FloatBarrier
%\begin{figure}[!ht]
%\centering
%\FloatBarrier
%\includegraphics[width=0.45\textwidth]{eigenvector_rho29n128omega500.png}
%
%\caption{Normalized energy for the three lowest eigenvalues for repulsive Coulomb interaction with n=128 and $\omega_r$=5}
%\label{fig:Eigenvalue_states_n_320_omega_500}
%\end{figure}
%\FloatBarrier