### Install Documentation Dependencies Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/devguide/docbuild.rst Install the necessary Python packages for building documentation. This should be run from the root of the OpenMC repository. ```sh python -m pip install "[docs]" ``` -------------------------------- ### Compile and Install OpenMC Locally on Linux/macOS Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Commands to build and install OpenMC from source, specifying a local installation prefix. This is useful when administrative privileges are unavailable. ```sh cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local .. make make install ``` -------------------------------- ### XML: Wireframe Raytrace Camera Setup Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/io_formats/plots.rst Example of setting camera position and look-at point for a wireframe raytrace plot. ```xml 0 0 10 0 0 0 ``` -------------------------------- ### Install Manpage, License, and Headers Source: https://github.com/openmc-dev/openmc/blob/develop/CMakeLists.txt Installs the OpenMC manpage, license file, and header files to their respective system-wide locations. ```cmake install(FILES man/man1/openmc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME copyright) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES "${CMAKE_BINARY_DIR}/include/openmc/version.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openmc) ``` -------------------------------- ### Select HDF5 Installation Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Set the HDF5_ROOT environment variable to specify the installation directory for HDF5. This is useful if HDF5 is not on your PATH or if you have multiple installations. ```sh export HDF5_ROOT=/opt/hdf5/1.8.15 cmake /path/to/openmc ``` ```sh HDF5_ROOT=/opt/hdf5/1.8.15 cmake /path/to/openmc ``` -------------------------------- ### Compile and Install OpenMC on Linux/macOS Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Standard commands to build and install OpenMC from source on Linux and macOS. This installs the 'openmc' executable to the system's default path. ```sh mkdir build && cd build cmake .. make make install ``` -------------------------------- ### Install OpenMC Prerequisites on Ubuntu Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/quickinstall.rst Installs essential development packages required for building OpenMC from source on Ubuntu systems using apt. ```sh sudo apt install g++ cmake libhdf5-dev libpng-dev ``` -------------------------------- ### Install OpenMC Executable and Libraries Source: https://github.com/openmc-dev/openmc/blob/develop/CMakeLists.txt Installs the OpenMC executable, libraries, and associated CMake configuration files. ```cmake include(CMakePackageConfigHelpers) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC) install(TARGETS openmc libopenmc EXPORT openmc-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install(EXPORT openmc-targets FILE OpenMCTargets.cmake NAMESPACE OpenMC:: DESTINATION ${INSTALL_CONFIGDIR}) configure_package_config_file( "cmake/OpenMCConfig.cmake.in" "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" INSTALL_DESTINATION ${INSTALL_CONFIGDIR} ) write_basic_package_version_file( "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" VERSION ${OPENMC_VERSION} COMPATIBILITY AnyNewerVersion ) install(FILES "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" DESTINATION "${INSTALL_CONFIGDIR}" ) ``` -------------------------------- ### Install Commit Hooks Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/devguide/workflow.rst Install a post-commit hook to automatically format C++ files using clang-format. Ensure clang-format is installed on your system. ```sh tools/dev/install-commit-hooks.sh ``` -------------------------------- ### Install HDF5 Development Files on Debian/Ubuntu Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Install the HDF5 library development files, required for OpenMC's input/output, on Debian-based systems using apt. ```bash sudo apt install libhdf5-dev ``` -------------------------------- ### Install libpng on Debian/Ubuntu Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Installs the libpng library required for PNG output. This is necessary for OpenMC's built-in plotting capabilities. ```bash sudo apt install libpng-dev ``` -------------------------------- ### Build PDF Documentation Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/devguide/docbuild.rst Build the documentation in PDF format. Ensure a LaTeX distribution is installed. Navigate to the 'docs' directory and run the make command. ```sh make latexpdf ``` -------------------------------- ### Install CMake on Debian/Ubuntu Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Install the CMake build system on Debian-based systems using the apt package manager. ```bash sudo apt install cmake ``` -------------------------------- ### Run OpenMC from Model Directory Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/scripts.rst Navigate to the directory containing your XML input files and execute the 'openmc' command to start a simulation. ```sh cd /home/username/somemodel openmc ``` -------------------------------- ### Handle {fmt} Library Source: https://github.com/openmc-dev/openmc/blob/develop/CMakeLists.txt Includes the {fmt} library, either by forcing vendored libraries or by finding it. Sets the install target. ```cmake if(OPENMC_FORCE_VENDORED_LIBS) set(FMT_INSTALL ON CACHE BOOL "Generate the install target.") add_subdirectory(vendor/fmt) else() find_package_write_status(fmt) if (NOT fmt_FOUND) set(FMT_INSTALL ON CACHE BOOL "Generate the install target.") add_subdirectory(vendor/fmt) endif() endif() ``` -------------------------------- ### Minimal Depletion Example Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/pythonapi/deplete.rst Demonstrates a basic depletion calculation using CoupledOperator and CECMIntegrator. Requires OpenMC model and a chain file. ```python import openmc import openmc.deplete geometry = openmc.Geometry.from_xml() settings = openmc.Settings.from_xml() model = openmc.Model(geometry, settings) # Representation of a depletion chain chain_file = "chain_casl.xml" operator = openmc.deplete.CoupledOperator(model, chain_file) # Set up 5 time steps of one day each dt = [24 * 60 * 60] * 5 power = 1e6 # constant power of 1 MW # Deplete using mid-point predictor-corrector cecm = openmc.deplete.CECMIntegrator(operator, dt, power) cecm.integrate() ``` -------------------------------- ### Energy Filter Example Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/io_formats/tallies.rst Defines energy bins for pre-collision energies. This example creates two bins: 0-1 MeV and 1-20 MeV. ```xml ``` -------------------------------- ### Install g++ Compiler on Debian/Ubuntu Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Install the g++ C/C++ compiler on Debian-based systems using the apt package manager. ```bash sudo apt install g++ ``` -------------------------------- ### Install MPICH and OpenMPI on Debian/Ubuntu Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Installs MPI implementations for distributed-memory parallel runs. OpenMC is tested with OpenMPI and MPICH. ```bash sudo apt install mpich libmpich-dev sudo apt install openmpi-bin libopenmpi-dev ``` -------------------------------- ### CI Debugging Output Example Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/devguide/tests.rst Example output from a CI log indicating a tmate session link for debugging failed tests. This output is shown after a test failure when CI debugging is enabled. ```text [...] A tmate session will be opened at: https://github.com/openmc-dev/openmc/runs/1234567890?check_suite_focus=true [...] ``` -------------------------------- ### Energy Out Filter Example Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/io_formats/tallies.rst Defines energy bins for post-collision energies. This example creates two bins: 0-1 MeV and 1-20 MeV. ```xml ``` -------------------------------- ### Install OpenMC Prerequisites on macOS with Homebrew Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/quickinstall.rst Installs necessary packages for building OpenMC with multithreading on macOS using Homebrew. This includes LLVM, CMake, HDF5, Python, and libomp. ```sh brew install llvm cmake hdf5 python libomp libpng ``` -------------------------------- ### Cell Containment Example (XML and Math) Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/methods/geometry.rst An example demonstrating how a cell is defined using surfaces in XML and the corresponding mathematical inequalities that a point must satisfy to be inside the cell. ```xml ``` ```math x^2 + y^2 + z^2 - 10^2 < 0 \ x - (-3) > 0 \ y - 2 < 0 ``` -------------------------------- ### Python Regression Test Example: PyAPITestHarness Source: https://github.com/openmc-dev/openmc/blob/develop/AGENTS.md This example shows how to set up and run a Python regression test using PyAPITestHarness. It involves creating a model, configuring settings, and executing the test harness. ```python from openmc.examples import pwr_pin_cell from tests.testing_harness import PyAPITestHarness def test_my_feature(): model = pwr_pin_cell() model.settings.particles = 1000 # Modify to exercise feature harness = PyAPITestHarness('statepoint.10.h5', model) harness.main() ``` -------------------------------- ### Independent Source Example Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/settings.rst Creates an isotropic, monoenergetic source uniformly distributed over a cube with a specified time distribution. ```python source = openmc.IndependentSource() source.space = openmc.stats.Box((-5, -5, -5), (5, 5, 5)) source.angle = openmc.stats.Isotropic() source.energy = openmc.stats.Discrete([10.0e6], [1.0]) source.time = openmc.stats.Uniform(0, 1e-6) settings.source = source ``` -------------------------------- ### Mu Filter Example (Equi-width bins) Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/io_formats/tallies.rst Defines bins for the cosine of the change in particle angle. This example creates five equi-width bins spanning -1.0 to 1.0. ```xml ``` -------------------------------- ### Install OpenMC from AUR using yay Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Install the 'openmc-git' package from the Arch User Repository using the 'yay' AUR helper. This command builds OpenMC directly from the latest development sources. ```bash yay -S openmc-git ``` -------------------------------- ### Enable CMake Option Source: https://github.com/openmc-dev/openmc/blob/develop/docs/source/usersguide/install.rst Set CMake options to customize the build. For example, to enable profiling, use the -D