Commit b4e4d866 authored by Charles G Waldman's avatar Charles G Waldman
Browse files

Merge branch 'cgw-pdf' into 'main'

Enable PDF output

See merge request !170
parents 5b828a94 14e57f0e
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -34,16 +34,33 @@ can be built locally by:
> pip install sphinx sphinx_rtd_theme sphinx-tabs sphinxcontrib-bibtex
```

2. Build the documentation:
2. Build the documentation (HTML):

```shell
> mkdir build
> sphinx-build -b html docs/source_docs/ build
$ make  # note, "make html" also works
```

The HTML pages will now be located in the `build` directory. Open the
`index.html` with your favorite browser:
The HTML pages will be located in the `build/html` directory.
Open the `index.html` with your favorite browser:

```shell
> firefox build/index.html
$ firefox build/html/index.html
```

3. Build the documentation (PDF):

You will need xetex.  You should be able to get this from your
distribution's package repository.  On Ubuntu something like
``sudo apt-get install texlive-xetex`` should do the trick.
More info at https://www.tug.org/texlive/

```shell
$ make pdf
```

The output file `mfix.pdf` will be in `build/latex`

4. Cleaning up:
``` shell
$ make clean
```
+4 −0
Original line number Diff line number Diff line
@@ -15,3 +15,7 @@
.eqno {
    float: right;
}

.wy-nav-content {
    max-width: none;
}
+22 −0
Original line number Diff line number Diff line
@@ -194,3 +194,25 @@ texinfo_documents = [
     author, 'MFIX-Exa Team', "MFIX-Exa, it's MFiX... but now with more Exa!",
     'Miscellaneous Aardvark'),
]

latex_engine = 'xelatex'

latex_elements = {
    'geometry': r'\usepackage[margin=0.75in]{geometry}',
    'preamble': r'''
% Increase minimum column width
\setlength{\tymin}{120pt}
% Allow text to wrap better in table cells
\usepackage{ragged2e}
\RaggedRight
% More vertical space in table rows
\renewcommand{\arraystretch}{1.2}
% Fix for tables with problematic content
\usepackage{ltablex}
\usepackage{tabularx}
% Prevent overfull hbox in tables
\setlength{\emergencystretch}{3em}
''',
}
# Use longtable for better page breaks and wrapping
latex_table_style = ['longtable', 'colorrows']
+10 −10
Original line number Diff line number Diff line
@@ -233,20 +233,20 @@ The mean of this distribution is computed as
.. math::
   :label: eq_normal_dist_FN_to_FV_mean

   \begin{align}
   \begin{aligned}
       \mu_V =& \frac{ \int_{-\infty}^{\infty} x \tilde{f}_X^V(x) dx }{\int_{-\infty}^{\infty} \tilde{f}_X^V(x) dx } \\[10pt]
             =& \frac{3\sigma_N^4 + 6\sigma_N^2\mu_N^2 + \mu_N^4}{3\sigma_N^2 \mu_N + \mu_N^3}
   \end{align}
   \end{aligned}

and the variance is given by

.. math::
   :label: eq_normal_dist_FN_to_FV_variance

   \begin{align}
   \begin{aligned}
       \sigma^2_V =& \frac{ \int_{-\infty}^{\infty} (x - \mu_V)^2 \tilde{f}_X^V(x) dx }{\int_{-\infty}^{\infty} \tilde{f}_X^V(x) dx } \\[10pt]
                  =& \frac{3\sigma_N^4 (3\mu_N + 2b) + \sigma^2(\mu_N^3 + 6\mu_N^2 b + 3\mu_Nb^2)+\mu_N^3 b^2}{3\sigma_N^2 \mu_N + \mu_N^3}
   \end{align}
   \end{aligned}

where :math:`b = (\mu_N - \mu_V)`. Because the volume-weighted distribution is normally distributed, the computed
mean and variance can be substituted directly into :eq:`eq_normal_dist`.
@@ -264,10 +264,10 @@ mean and standard deviation, :math:`\mu_V` and :math:`\sigma_V`, by solving the

.. math::

   \begin{align}
   \begin{aligned}
     f_1(\mu_N,\sigma_N) &= \left( 3\sigma_N^4 + 6\sigma_N^2\mu_N^2 + \mu_N^4 \right) - \mu_V \left( 3\sigma_N^2 \mu_N + \mu_N^3 \right) = 0 \\
     f_2(\mu_N,\sigma_N) &= \left(3\sigma_N^4 (3\mu_N + 2b) + \sigma^2(\mu_N^3 + 6\mu_N^2 b + 3\mu_Nb^2)+\mu_N^3 b^2\right) - \sigma^2_V \left( 3\sigma_N^2 \mu_N + \mu_N^3 \right) = 0
   \end{align}
   \end{aligned}

This system is solved using the homotopy method outlined in :cite:t:`Burden10`. To ensure rapid convergence, initial guesses for
:math:`\mu_N` and :math:`\sigma_N` are calculated from the density function created by dividing :eq:`eq_normal_dist` by :math:`x^3`
@@ -288,11 +288,11 @@ are found by setting the derivative of :eq:`eq_normal_dist_FV_to_FN_initial_expr
.. math::
   :label: eq_normal_dist_FV_to_FN_discrete_values

   \begin{align}
   \begin{aligned}
     x_{\mathrm{min}} \; =& \; \left( \mu_V - \sqrt{\mu_V^2 -12\sigma_V^2}\right)/2 \\
     x_{\mathrm{mid}} \; =& \; \left(\mu_V + \sqrt{\mu_V^2 -12\sigma_V^2}\right)/2 \\
     x_{\mathrm{max}} \; =& \; 2x_{\mathrm{mid}} - x_{\mathrm{min}}
   \end{align}
   \end{aligned}

.. _fig_normal-dist-pdf-approx_FN:

@@ -464,10 +464,10 @@ while the parameter :math:`\mu` is computed directly from the other distribution

.. math::

   \begin{align}
   \begin{aligned}
       \mu_V =& \mu_N + 3.0\sigma^2 \\[10pt]
       \mu_N =& \mu_V - 3.0\sigma^2
   \end{align}
   \end{aligned}

.. rubric:: Sampling a log-normal distribution

+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
Defining chemical reactions
===========================

.. |tol_eq| replace:: :math:`\left|\sum\text{products - \sum\text{reactants}\right| < \text{tolerance}`
.. |tol_eq| replace:: :math:`\left|\sum \mathrm{products} - \sum \mathrm{reactants}\right| < \mathrm{tolerance}`

The following inputs are defined using the prefix ``chemistry``:

Loading