class SimPEG.meta.MultiprocessingMetaSimulation(simulations, mappings, n_processes=None)[source]#

Bases: MetaSimulation

Multiprocessing version of simulation of simulations.

This class makes use of the multiprocessing module to provide concurrency, executing the internal simulations in parallel. This class is meant to be a (mostly) drop in replacement for MetaSimulation. If you want to test your implementation, we recommend starting with a small problem using MetaSimulation, then switching it to this class. the serial version of this class is good for testing correctness.

If using this class, please be conscious of your operating system’s default method of spawning new processes. On Windows systems this means that the user must be sure that this code is only executed on the main process. Usually this is solved in your main script by protecting your function calls by checking if you are in __main__ with:

>>> from SimPEG.meta import MultiprocessingMetaSimulation
>>> if __name__ == '__main__':
...     # Do processing here
...     sim = MultiprocessingMetaSimulation(...)
...     sim.dpred(model)

You must also be sure to call sim.close() before discarding this worker to kill the subprocesses that are created, as you would with any other multiprocessing queue.

>>> sim.close()
simulations(n_sim) list of SimPEG.simulation.BaseSimulation

The list of unique simulations that each handle a piece of the problem.

mappings(n_sim) list of SimPEG.maps.IdentityMap

The map for every simulation. Every map should accept the same length model, and output a model appropriate for its paired simulation.


The number of processes to spawn internally. This will default to multiprocessing.cpu_count(). The number of processes spawned will be the minimum of this number and the number of simulations.


On Unix systems with python version 3.8 the default fork method of starting the processes has lead to program stalls in certain cases. If you encounter this try setting the start method to `spawn’.

>>> import multiprocessing as mp
>>> mp.set_start_method("spawn")




Jtvec(m, v[, f])

Jtv = Jtvec(m, v, f=None) Effect of transpose of J(m) on a vector v.

Jvec(m, v[, f])

Jv = Jvec(m, v, f=None) Effect of J(m) on a vector v.

dpred(m[, f])

Create the projected data from a model.


Create fields for every simulation.

getJtJdiag(m[, W, f])

Return the squared sum of columns of the Jacobian.