The versioning scheme
The versioning scheme of the python bindings is the preCICE version with the additional version of the python bindings.
1 of the python bindings for preCICE version
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. This will automatically install the latest version of the bindings compatible with the latest version of preCICE. If you are using an older version of preCICE, you have to explicitly tell pip to download the correct version (For example,
pip3 install --user pyprecice==126.96.36.199 for preCICE version
2.2.0). See the PyPI release history for a list of available version. Note that preCICE and MPI have to be installed on your system.
Alternatives & Community packages
- Build the latest version from source: You can get the latest version of python bindings from github.com/precice/python-bindings. Refer to the
README.mdin the repository for building instructions.
- You can also install pyprecice using
conda install -c conda-forge pyprecice. The package is maintained at conda-forge/pyprecice.
- If you are using Arch Linux, there is a package on AUR you might want to use.
- For Spack, see our documentation page on Spack installation.
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:
import preciceat the beginning of your script.
- The object
precice.Interfaceis the main access point to the preCICE API.
- We try to follow PEP8 with respect to function and class names. Meaning:
writeBlockScalarData, since this is a function call.
- Please use
numpyarrays, if this seems appropriate. For scalar data a 1D-
sizeentries should be used; for vector data a 2D-
size x dimensionsentries should be used. This allows us to drop the
sizeargument some functions calls. Meaning: not
writeBlockScalarData (int dataID, int size, int* vertexIDs, double* values), but
write_block_scalar_data(dataID, vertexIDs, values).
- Refer to the python version of the tutorial for the elastic tube in 1D and the corresponding source code for a complete example of how pyprecice can be used to couple your code.
help()function for getting detailed usage information. Example: Open a python3 shell,
More details & troubleshooting
The python package and detailed documentation for the python bindings can be found here.