Use pip3 install –user pyprecice to install the python language bindings from PyPI

The versioning scheme

The versioning scheme of the python bindings is the preCICE version with the additional version of the python bindings.

Example: version 1 of the python bindings for preCICE version 2.2.0 is 2.2.0.1

Installation

The python bindings for preCICE are published on PyPI with the package pyprecice. You can use your python package manager for installing the language bindings. For example, pip3 install --user pyprecice. Note that preCICE and MPI have to be installed on your system.

Usage

The usage of the python language bindings for preCICE is very similar to the C++ API. Therefore, please refer to our section on coupling your code for getting started. Some important differences:

  • Call import precice at the beginning of your script.
  • The object precice.Interface is the main access point to the preCICE API.
  • We try to follow PEP8 with respect to function and class names. Meaning: write_block_scalar_data, not writeBlockScalarData, since this is a function call.
  • Please use numpy arrays, if this seems appropriate. For scalar data a 1D-numpy with size entries should be used; for vector data a 2D-numpy array with size x dimensions entries should be used. This allows us to drop the size argument some functions calls. Meaning: not writeBlockScalarData (int dataID, int size, int* vertexIDs, double* values), but write_block_scalar_data(dataID, vertexIDs, values).

More details & troubleshooting

The python package and detailed documentation for the python bindings can be found here.