index | modules | gitlab | page source

# Parallel calculations

ASE will automatically run in parallel, if it can import an MPI communicator from any of the supported libraries. ASE will attempt to import communicators from these external libraries: GPAW, Asap, Scientific MPI and MPI4PY.

If a parallel library is found, the `ase.io.read()` function will always read only on master (of the MPI world object) and broadcast the atoms to all other cores. Therefore, always when using `ase.io.read()`, all cores must read the same atoms in same order, for example in the case of a NEB calculation.

If one requires an individual core/cores to read a particular file, please use `Trajectory()`:

    >>> from ase.io import Trajectory
    >>> from ase.parallel import world
    >>> atoms = Trajectory('myfile_{}.traj'.format(world.rank))[-1]

`ase.parallel.``paropen`(name, mode='r', buffering=-1, encoding=None)

  MPI-safe version of open function.

  In read mode, the file is opened on all nodes. In write and append mode, the file is opened on the master only, and /dev/null is opened on all other nodes.

`ase.parallel.``parprint`(*args, **kwargs)

  MPI-safe print - prints only from master.

`ase.parallel.``broadcast`(obj, root=0, comm=<ase.parallel.MPI object>)

  Broadcast a Python object across an MPI communicator and return it.

`ase.parallel.``parallel_function`(func)

  Decorator for broadcasting from master to slaves using MPI.

  Disable by passing parallel=False to the function. For a method, you can also disable the parallel behavior by giving the instance a self.serial = True.

`ase.parallel.``parallel_generator`(generator)

  Decorator for broadcasting yields from master to slaves using MPI.

  Disable by passing parallel=False to the function. For a method, you can also disable the parallel behavior by giving the instance a self.serial = True.

Documentation v: 3.19.0

Versions
  3.20.0b1 (development)
  3.19.0 (latest stable)