OpenMC/docs/source/pythonapi/index.rst

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
2 KiB
ReStructuredText
Raw Permalink Normal View History

.. _pythonapi:
==========
Python API
==========
OpenMC includes a rich Python API that enables programmatic pre- and
post-processing. The easiest way to begin using the API is to take a look at the
examples_. This assumes that you are already familiar with Python and common
third-party packages such as `NumPy <https://numpy.org/>`_. If you have never
used Python before, the prospect of learning a new code *and* a programming
language might sound daunting. However, you should keep in mind that there are
many substantial benefits to using the Python API, including:
2017-04-05 07:11:57 -05:00
- The ability to define dimensions using variables.
- Availability of standard-library modules for working with files.
- An entire ecosystem of third-party packages for scientific computing.
- Automated multi-group cross section generation (:mod:`openmc.mgxs`)
2018-02-19 22:51:53 -06:00
- A fully-featured nuclear data interface (:mod:`openmc.data`)
- Depletion capability (:mod:`openmc.deplete`)
2017-04-05 07:11:57 -05:00
- Convenience functions (e.g., a function returning a hexagonal region)
- Ability to plot individual universes as geometry is being created
- A :math:`k_\text{eff}` search function (:func:`openmc.search_for_keff`)
- Random sphere packing for generating TRISO particle locations
2018-11-14 16:03:44 -06:00
(:func:`openmc.model.pack_spheres`)
2018-02-19 22:51:53 -06:00
- Ability to create materials based on natural elements or uranium enrichment
2017-04-05 07:11:57 -05:00
For those new to Python, there are many good tutorials available online. We
recommend going through the modules from `Codecademy
2019-10-03 13:17:15 -05:00
<https://www.codecademy.com/learn/learn-python-3>`_ and/or the `Scipy lectures
<https://scipy-lectures.org/>`_.
2017-04-05 07:11:57 -05:00
The full API documentation serves to provide more information on a given module
or class.
.. tip:: Users are strongly encouraged to use the Python API to generate input
files and analyze results.
.. rubric:: Modules
2017-04-05 07:11:57 -05:00
.. toctree::
2017-11-09 15:53:57 -06:00
:maxdepth: 1
2017-04-05 07:11:57 -05:00
base
model
2017-11-09 15:53:57 -06:00
examples
2018-02-19 22:51:53 -06:00
deplete
2017-11-09 15:53:57 -06:00
mgxs
stats
2017-04-05 07:11:57 -05:00
data
capi
2017-04-05 07:11:57 -05:00
openmoc
.. _examples: https://github.com/openmc-dev/openmc/wiki/Example-Jupyter-Notebooks