diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ac89ad332a..fee682f772 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -80,6 +80,14 @@ jobs: - name: Checkout RMG-Py uses: actions/checkout@v6 + - name: Pin Python version for CI matrix + # environment.yml pins python=3.11 for fast user installs; rewrite to the + # matrix version here so setup-miniconda can inject the correct pin cleanly. + # The -i.bak / rm pattern works on both GNU sed (Linux) and BSD sed (macOS). + run: | + sed -i.bak "s/conda-forge::python =3\.11/conda-forge::python =${{ matrix.python-version }}/" environment.yml + rm -f environment.yml.bak + - name: Setup Miniforge Python ${{ matrix.python-version }} uses: conda-incubator/setup-miniconda@v4 with: @@ -147,13 +155,13 @@ jobs: - name: Checkout RMG-Py uses: actions/checkout@v6 - - name: Setup Miniforge Python 3.9 + - name: Setup Miniforge Python 3.11 uses: conda-incubator/setup-miniconda@v4 with: environment-file: environment.yml miniforge-variant: Miniforge3 miniforge-version: latest - python-version: 3.9 + python-version: 3.11 activate-environment: rmg_env auto-update-conda: true show-channel-urls: true diff --git a/arkane/common.py b/arkane/common.py index a706417b88..938364ce49 100644 --- a/arkane/common.py +++ b/arkane/common.py @@ -695,8 +695,8 @@ def get_principal_moments_of_inertia(coords, numbers=None, symbols=None): tuple: The corresponding principal axes. """ tensor0 = get_moment_of_inertia_tensor(coords=coords, numbers=numbers, symbols=symbols) - # Since tensor0 is real and symmetric, diagonalization is always possible - principal_moments_of_inertia, axes = np.linalg.eig(tensor0) + # tensor0 is real and symmetric by construction; use eigh so eigenvalues are guaranteed real. + principal_moments_of_inertia, axes = np.linalg.eigh(tensor0) principal_moments_of_inertia, axes = zip(*sorted(zip(np.ndarray.tolist(principal_moments_of_inertia), np.ndarray.tolist(axes)), reverse=True)) return principal_moments_of_inertia, axes diff --git a/documentation/source/users/rmg/installation/anacondaDeveloper.rst b/documentation/source/users/rmg/installation/anacondaDeveloper.rst index c3a3ee6cd6..eb56f1faa6 100644 --- a/documentation/source/users/rmg/installation/anacondaDeveloper.rst +++ b/documentation/source/users/rmg/installation/anacondaDeveloper.rst @@ -4,12 +4,26 @@ Installation by Source Using Anaconda Environment for Unix-based Systems: Linux and Mac OSX ******************************************************************************************* -#. Install the `conda` package manager via `miniforge`, if you do not already have it (or Anaconda), by following the `Miniforge installation instructions `_. +#. Before you begin — check your build tools are up to date. + + RMG-Py compiles Cython extensions during installation, so your C compiler and + conda installation must be reasonably modern or the build will fail. + + **On MacOS:** Ensure your Xcode Command Line Tools are current. If they are more than a year or two old, either download the latest Command Line Tools from `Apple Developer Downloads `_ (free Apple ID required) or manually remove them and reinstall them using:: + + xcode-select --install + + **conda version:** Ensure conda is also up to date. To update:: + + conda update -n base -c conda-forge conda + + If ``conda update`` does not advance the version (which can happen), install a specific release explicitly, e.g.:: + + conda install -n base -c conda-forge conda=26.3 + +#. If you do not already have the `conda` package manager (or Anaconda) then install it via `miniforge`, by following the `Miniforge installation instructions `_. -#. If your `conda` version is older than 23.10.0, manually switch the solver backend to `libmamba` (or update your conda):: - conda install -n base conda-libmamba-solver - conda config --set solver libmamba #. There are a few system-level dependencies which are required and should not be installed via Conda. These include `Git `_ for version control, `GNU Make `_, and the C and C++ compilers from the `GNU Compiler Collection (GCC) `_ for compiling RMG. @@ -40,6 +54,7 @@ Installation by Source Using Anaconda Environment for Unix-based Systems: Linux These are a set of packages relevant for software development which have been bundled together by Apple. The easiest way to install this is to simply run one of the commands in the terminal, e.g. ``git``. The terminal will then prompt you to install the Command Line Tools. + See the warning in step 1 about keeping the tools up to date. #. Install the latest versions of RMG and RMG-database through cloning the source code via Git. Make sure to start in an appropriate local directory where you want both RMG-Py and RMG-database folders to exist. @@ -51,7 +66,7 @@ Installation by Source Using Anaconda Environment for Unix-based Systems: Linux It is still possible to clone the repositories using ``https`` if you are unfamiliar with ``ssh``:: - + git clone https://github.com/ReactionMechanismGenerator/RMG-Py.git git clone https://github.com/ReactionMechanismGenerator/RMG-database.git @@ -61,7 +76,9 @@ Installation by Source Using Anaconda Environment for Unix-based Systems: Linux cd RMG-Py -#. Create the conda environment for RMG-Py:: +#. Create the conda environment for RMG-Py. + + To create an environment called ``rmg_env`` containing all that you need for RMG, run:: conda env create -f environment.yml @@ -69,17 +86,13 @@ Installation by Source Using Anaconda Environment for Unix-based Systems: Linux conda env create -f environment.yml -n rmg_env2 - If either of these commands return an error due to being unable to find the ``conda`` command, - try to either close and reopen your terminal to refresh your environment variables - or type the following command. - - If on Linux or pre-Catalina MacOS (or if you have a bash shell):: - - source ~/.bashrc + If you have a recent version of conda (``conda -V`` reports >= 26.3) then the preferred command is without the ``env`` subcommand:: - If on MacOS Catalina or later (or if you have a Z shell):: + conda create --file environment.yml --name rmg_env - source ~/.zshrc + If any of these commands return an error due to being unable to find the ``conda`` command, + (for example if you only just installed it) + then close and reopen your terminal (or log out and log in again) to refresh your environment variables. NOTE: You may wish to forbid ``conda`` from installing from the Anaconda channels due to licensing restrictions. The ``environment.yml`` file already forbids using default channels, but you may further add the file ``.condarc`` to your RMG-Py directory (or modify the ``.condarc`` in your home directory) with the following contents before running the ``conda env create`` command: :: @@ -89,10 +102,10 @@ Installation by Source Using Anaconda Environment for Unix-based Systems: Linux - nodefaults channel_priority: strict custom_channels: - main: null - r: null - anaconda: null - msys2: null + main: null + r: null + anaconda: null + msys2: null #. Activate conda environment :: @@ -119,7 +132,7 @@ Installation by Source Using Anaconda Environment for Unix-based Systems: Linux Installing Julia and ReactionMechanismSimulator.jl (RMS) will enable all the features in RMG that require RMS-based reactors, as well as using ``method='ode'`` when solving the Master Equation with Arkane. - Note that installing RMS can cause errors when running Cantera simulations; this should not affect normal RMG use, but if you wish to run Cantera simulations you will need to maintain a separate conda environment without RMS in it. + Note that installing RMS has sometimes caused errors when running Cantera; this should not affect normal RMG use, but if you wish to run Cantera simulations you might need to use a separate conda environment without RMS in it. Ensure that you have modified your environment variables as described above, and then run the following: :: diff --git a/environment.yml b/environment.yml index 39f4666f0f..bd61b46d04 100644 --- a/environment.yml +++ b/environment.yml @@ -28,12 +28,9 @@ dependencies: - conda-forge::xlrd - conda-forge::xlwt - conda-forge::h5py - # keep graphviz from conda-forge; see https://github.com/ReactionMechanismGenerator/RMG-Py/issues/2750 - conda-forge::graphviz >=12 - conda-forge::markupsafe - conda-forge::psutil - # conda-forge not default, since default has a version information bug - # (see https://github.com/ReactionMechanismGenerator/RMG-Py/pull/2421) - conda-forge::ncurses - conda-forge::suitesparse # ThermoCentralDatabaseInterface fails if pyopenssl is too old. 20 is just a guess at the version number. @@ -50,7 +47,7 @@ dependencies: - rmg::pysidt-rmg >=1.2 # Python tools - - conda-forge::python >=3.9,<3.12 # leave as GEQ so that GitHub actions can add EQ w/o breaking (contradictory deps) + - conda-forge::python =3.11 # pinned to a single version to keep solver fast; CI rewrites this to the matrix version (see CI.yml) - conda-forge::setuptools <80 - conda-forge::coverage - conda-forge::cython >=0.25.2,<3.1 @@ -60,6 +57,7 @@ dependencies: - conda-forge::pydot - conda-forge::jinja2 - conda-forge::jupyter + - conda-forge::pip - conda-forge::pymongo - conda-forge::pyparsing - conda-forge::pyyaml diff --git a/rmgpy/statmech/conformer.pyx b/rmgpy/statmech/conformer.pyx index e3e911248d..4ee18b77ec 100644 --- a/rmgpy/statmech/conformer.pyx +++ b/rmgpy/statmech/conformer.pyx @@ -326,8 +326,8 @@ cdef class Conformer(RMGObject): kg*m^2, while the principal axes have unit length. """ I0 = self.get_moment_of_inertia_tensor() - # Since I0 is real and symmetric, diagonalization is always possible - I, V = np.linalg.eig(I0) + # I0 is real and symmetric by construction; use eigh so eigenvalues are guaranteed real. + I, V = np.linalg.eigh(I0) return I, V @cython.boundscheck(False)