Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create installation script and documentation website #128

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ tmp_*
*.core
.DS_Store # for mac users
**/.DS_Store
**/.idea

# test cache
.pytest_cache
pytestdebug.log

# profiler
*.prof

# Documentation builds
docs/build
docs/source/pythonapi/generated/

32 changes: 32 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements-rtd.txt
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
8 changes: 8 additions & 0 deletions docs/requirements-rtd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sphinx==7.2.6
furo
numpy
numba
matplotlib
scipy
h5py

Empty file added docs/source/_static/.gitkeep
Empty file.
Empty file added docs/source/_templates/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions docs/source/_templates/omcfunction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ fullname }}
{{ underline }}

.. currentmodule:: {{ module }}

.. autofunction:: {{ objname }}
66 changes: 66 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os, sys

sys.path.insert(0, os.path.abspath("../.."))


# On Read the Docs, need to mock any python packages that would require c
from unittest.mock import MagicMock

MOCK_MODULES = ["mpi4py"]
sys.modules.update((mod_name, MagicMock()) for mod_name in MOCK_MODULES)


# -- Project information -----------------------------------------------------

project = "MC/DC"
copyright = "2023, Center for Exascale Monte Carlo Neutron Transport (CEMeNT)"
author = "Center for Exascale Monte Carlo Neutron Transport (CEMeNT)"

# The full version, including alpha/beta/rc tags
release = "0.1"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
]
autosummary_generate = True


# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "furo"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
38 changes: 38 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. MC/DC documentation master file, created by
sphinx-quickstart on Fri Oct 27 14:14:47 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.


=================================
MC/DC: Monte Carlo Dynamic Code
=================================

MC/DC is a performant, scalable, and machine-portable Python-based
Monte Carlo neutron transport software in active development
by the `Center for Exascale Monte Carlo Neutron Transport <https://cement-psaap.github.io/>`_ (CEMeNT).

.. note::
The project is in the early stages of *very* active development,
not even an alpha release!


.. only:: html

--------
Contents
--------

.. toctree::
:maxdepth: 1

install
pythonapi/index


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
89 changes: 89 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. _install:

===================
Installation Guide
===================

This outlines the basic steps to install MC/DC on a local
machine or on HPC machine.

-----------------------------------
Creating an MC/DC Conda environment
-----------------------------------

`Conda <https://conda.io/en/latest/>`_ is an open source package and environment management system
that runs on Windows, macOS, and Linux. It allows for easy installing and switching between multiple
versions of software packages and their dependendencies.
We can't force you to use it, but we do *highly* recommend it, particularly
if you plan on running MC/DC in `numba mode <https://numba.pydata.org/>`_.
**The included installation script will fail if executed outside of a conda environment.**

First, `conda` should be installed with `Miniconda <https://docs.conda.io/en/latest/miniconda.html>`_
or `Anaconda <https://www.anaconda.com/>`_. HPC instructions:

`Quartz <https://hpc.llnl.gov/hardware/compute-platforms/quartz>`_ (LLNL, x86_64),

.. code-block:: sh

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh


`Lassen <https://hpc.llnl.gov/hardware/compute-platforms/lassen>`_ (LLNL, IBM Power9),

.. code-block:: sh

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-ppc64le.sh
bash Miniconda3-latest-Linux-ppc64le.sh


Then create and activate a new conda environment called `mcdc-env` in
which to install MC/DC. This creates an environment with python3.11
installed.

.. code-block:: sh

conda create -n mcdc-env python=3.11
conda activate mcdc-env

-------------------------------------------
Installing from Source on Linux or Mac OS X
-------------------------------------------

All MC/DC source code is hosted on `Github <https://github.com/CEMeNT-PSAAP/MCDC>`_.
If you have `git <https://git-scm.com>`_, you can download MC/DC by entering the
following commands in a terminal:

.. code-block:: sh

git clone https://github.com/CEMeNT-PSAAP/MCDC.git
cd MCDC


The MC/DC repository includes the script ``install.sh``, which will
build MC/DC and all of its dependencies and execute any necessary patches.
This has been tested on Quartz, Lassen, and Apple M2 (as of 11/01/2023).
The ``install.sh`` script **will fail outside of a conda environment**.

On HPC machines, the script will install mpi4py
`from source <https://mpi4py.readthedocs.io/en/stable/install.html#using-distutils>`_.
This means that all appropriate modules must be loaded prior to executing.

On Quartz, the default modules are sufficient (``intel-classic`` and ``mvapich2``).
On Lassen, ``module load gcc/8 cuda/11.3``. Then,

.. code-block:: sh

bash install.sh --hpc


On local machines, mpi4py will be installed using conda,

.. code-block:: sh

bash install.sh


To confirm that everything is properly installed, execute ``pytest`` from the MCDC directory.


74 changes: 74 additions & 0 deletions docs/source/pythonapi/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.. _pythonapi:

================
Input Definition
================

Full API documentation.


Defining materials
------------------

.. autosummary::
:toctree: generated
:nosignatures:
:template: omcfunction.rst

mcdc.material
mcdc.nuclide


Defining geometry
-----------------

.. autosummary::
:toctree: generated
:nosignatures:
:template: omcfunction.rst

mcdc.surface
mcdc.cell
mcdc.universe
mcdc.lattice



Defining simulation
-------------------

.. autosummary::
:toctree: generated
:nosignatures:
:template: omcfunction.rst

mcdc.source
mcdc.tally
mcdc.eigenmode
mcdc.setting



Defining techniques
-------------------

.. autosummary::
:toctree: generated
:nosignatures:
:template: omcfunction.rst

mcdc.implicit_capture
mcdc.weighted_emission
mcdc.population_control
mcdc.branchless_collision
mcdc.time_census
mcdc.weight_window
mcdc.iQMC
mcdc.weight_roulette
mcdc.IC_generator
mcdc.dsm





Loading
Loading