|
| 1 | +============ |
| 2 | +Installation |
| 3 | +============ |
| 4 | + |
| 5 | +Python package |
| 6 | +-------------- |
| 7 | + |
| 8 | +To install the **expreccs** executable in an existing Python environment: |
| 9 | + |
| 10 | +.. code-block:: bash |
| 11 | +
|
| 12 | + pip install git+https://github.com/cssr-tools/expreccs.git |
| 13 | +
|
| 14 | +If you are interested in modifying the source code, then you can clone the repository and |
| 15 | +install the Python requirements in a virtual environment with the following commands: |
| 16 | + |
| 17 | +.. code-block:: console |
| 18 | +
|
| 19 | + # Clone the repo |
| 20 | + git clone https://github.com/cssr-tools/expreccs.git |
| 21 | + # Get inside the folder |
| 22 | + cd expreccs |
| 23 | + # Create virtual environment |
| 24 | + python3 -m venv vexpreccs |
| 25 | + # Activate virtual environment |
| 26 | + source vexpreccs/bin/activate |
| 27 | + # Upgrade pip, setuptools, and wheel |
| 28 | + pip install --upgrade pip setuptools wheel |
| 29 | + # Install the expreccs package |
| 30 | + pip install -e . |
| 31 | + # For contributions/testing/linting, install the dev-requirements |
| 32 | + pip install -r dev-requirements.txt |
| 33 | +
|
| 34 | +.. note:: |
| 35 | + |
| 36 | + For not macOS users, to install the Python opm package, execute in the terminal **pip install opm**. |
| 37 | + For macOS, see :ref:`macOS`. |
| 38 | + |
| 39 | +OPM Flow |
| 40 | +-------- |
| 41 | +You also need to install: |
| 42 | + |
| 43 | +* OPM Flow (https://opm-project.org, Release 2024.04 or current master branches) |
| 44 | + |
| 45 | +.. tip:: |
| 46 | + |
| 47 | + See the `CI.yml <https://github.com/cssr-tools/expreccs/blob/main/.github/workflows/CI.yml>`_ script |
| 48 | + for installation of OPM Flow (binary packages) and the expreccs package in Linux. |
| 49 | + |
| 50 | +Source build in Linux/Windows |
| 51 | ++++++++++++++++++++++++++++++ |
| 52 | +If you are a Linux user (including the Windows subsystem for Linux), then you could try to build Flow (after installing the `prerequisites <https://opm-project.org/?page_id=239>`_) from the master branches with mpi support by running |
| 53 | +in the terminal the following lines (which in turn should build flow in the folder ./build/opm-simulators/bin/flow.): |
| 54 | + |
| 55 | +.. code-block:: console |
| 56 | +
|
| 57 | + CURRENT_DIRECTORY="$PWD" |
| 58 | +
|
| 59 | + for repo in common grid models simulators |
| 60 | + do |
| 61 | + git clone https://github.com/OPM/opm-$repo.git |
| 62 | + done |
| 63 | +
|
| 64 | + mkdir build |
| 65 | +
|
| 66 | + for repo in common grid models |
| 67 | + do |
| 68 | + mkdir build/opm-$repo |
| 69 | + cd build/opm-$repo |
| 70 | + cmake -DUSE_MPI=1 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo |
| 71 | + make -j5 opm$repo |
| 72 | + cd ../.. |
| 73 | + done |
| 74 | +
|
| 75 | + mkdir build/opm-simulators |
| 76 | + cd build/opm-simulators |
| 77 | + cmake -DUSE_MPI=1 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid;$CURRENT_DIRECTORY/build/opm-models" $CURRENT_DIRECTORY/opm-simulators |
| 78 | + make -j5 flow |
| 79 | + cd ../.. |
| 80 | +
|
| 81 | +
|
| 82 | +.. tip:: |
| 83 | + |
| 84 | + You can create a .sh file (e.g., build_opm_mpi.sh), copy the previous lines, and run in the terminal **source build_opm_mpi.sh** |
| 85 | + |
| 86 | +.. _macOS: |
| 87 | + |
| 88 | +Source build in macOS |
| 89 | ++++++++++++++++++++++ |
| 90 | +For macOS, there are no available binary packages, so OPM Flow needs to be built from source, in addition to the dune libraries and the opm Python |
| 91 | +package (see the `prerequisites <https://opm-project.org/?page_id=239>`_, which can be installed using macports or brew). This can be achieved by the following lines: |
| 92 | + |
| 93 | +.. code-block:: console |
| 94 | +
|
| 95 | + CURRENT_DIRECTORY="$PWD" |
| 96 | +
|
| 97 | + for module in common geometry grid istl |
| 98 | + do git clone https://gitlab.dune-project.org/core/dune-$module.git --branch v2.9.1 |
| 99 | + done |
| 100 | + for module in common geometry grid istl |
| 101 | + do ./dune-common/bin/dunecontrol --only=dune-$module cmake -DCMAKE_DISABLE_FIND_PACKAGE_MPI=1 |
| 102 | + ./dune-common/bin/dunecontrol --only=dune-$module make -j5 |
| 103 | + done |
| 104 | +
|
| 105 | + for repo in common grid models simulators |
| 106 | + do |
| 107 | + git clone https://github.com/OPM/opm-$repo.git |
| 108 | + done |
| 109 | +
|
| 110 | + source vexpreccs/bin/activate |
| 111 | +
|
| 112 | + mkdir build |
| 113 | +
|
| 114 | + for repo in common grid models |
| 115 | + do |
| 116 | + mkdir build/opm-$repo |
| 117 | + cd build/opm-$repo |
| 118 | + cmake -DPYTHON_EXECUTABLE=$(which python) -DWITH_NDEBUG=1 -DUSE_MPI=0 -DOPM_ENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo |
| 119 | + make -j5 |
| 120 | + cd ../.. |
| 121 | + done |
| 122 | +
|
| 123 | + mkdir build/opm-simulators |
| 124 | + cd build/opm-simulators |
| 125 | + cmake -DUSE_MPI=0 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid;$CURRENT_DIRECTORY/build/opm-models" $CURRENT_DIRECTORY/opm-simulators |
| 126 | + make -j5 flow |
| 127 | + cd ../.. |
| 128 | +
|
| 129 | + echo "export PYTHONPATH=\$PYTHONPATH:$CURRENT_DIRECTORY/build/opm-common/python" >> $CURRENT_DIRECTORY/vexpreccs/bin/activate |
| 130 | +
|
| 131 | +
|
| 132 | +This builds OPM Flow as well as the opm Python package, and it exports the required PYTHONPATH. Then after execution, deactivate and activate the Python virtual environment. |
| 133 | + |
| 134 | +Regarding the resdata Python package, it might not be available depending on the Python version (e.g., it is not found using Python 3.9, but it is installed using Python 3.10). |
| 135 | +Then, it is recommended to use a Python version equal or higher than 3.10; otherwise, remove resdata from the requirements in the `pyproject.toml <https://github.com/cssr-tools/expreccs/blob/main/pyproject.toml>`_, |
| 136 | +and the opm Python package will be used (this is the default package for reading the simulation files, see the :ref:`overview`). |
0 commit comments