diff --git a/README.md b/README.md index f73ba65..9271b7c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ A Python package for plotting the positions, directions or energy distributions # Installation +You will need to have OpenMC version 0.14.0 or newer installed first. + ```bash pip install openmc_source_plotter ``` diff --git a/src/openmc_source_plotter/core.py b/src/openmc_source_plotter/core.py index a73196d..40dbb20 100644 --- a/src/openmc_source_plotter/core.py +++ b/src/openmc_source_plotter/core.py @@ -9,6 +9,18 @@ import openmc.lib import plotly.graph_objects +import pkg_resources + +system_openmc_version = pkg_resources.parse_version(openmc.__version__) +min_openmc_version = pkg_resources.parse_version("0.14.0") +if system_openmc_version < min_openmc_version: + msg = ( + "openmc_source_plotter requires openmc version 0.14.0 or above. " + f"You have openmc version {system_openmc_version} installed. " + "Please update the version of openmc installed" + ) + raise ImportError(msg) + def sample_initial_particles(self, n_samples: int = 1000, prn_seed: int = None):