meld.comm

class meld.comm.MPICommunicator(n_atoms, n_replicas)[source]

Class to handle communications between master and slaves using MPI.

Parameters:
  • n_atoms – number of atoms
  • n_replicas – number of replicas

Note

creating an MPI communicator will not actually initialize MPI. To do that, call initialize().

broadcast_alphas_to_slaves(alphas)[source]

Send the alpha values to the slaves.

Parameters:alphas – a list of alpha values, one for each replica. The master node’s alpha value should be included in this list. The master node will always be at alpha=0.0
Returns:None
broadcast_states_for_energy_calc_to_slaves(states)[source]

Broadcast states to all slaves. Send all results from this step to every slave so that we can calculate the energies and do replica exchange.

Parameters:states – a list of states
Returns:None
broadcast_states_to_slaves(states)[source]

Send a state to each slave.

Parameters:states – a list of states. The list of states should include the state for the master node. These are the states that will be simulated on each replica for each step.
Returns:the state to run on the master node
exchange_states_for_energy_calc(state)[source]

Exchange states between all processes.

Parameters:state – the state for this node
Returns:a list of states from all nodes
gather_energies_from_slaves(energies_on_master)[source]

Receive a list of energies from each slave.

Parameters:energies_on_master – a list of energies from the master
Returns:a square matrix of every state on every replica to be used for replica exchange
gather_states_from_slaves(state_on_master)[source]

Receive states from all slaves

Parameters:state_on_master – the state on the master after simulating
Returns:A list of states, one from each replica. The returned states are the states after simulating.
initialize()[source]

Initialize and start MPI

is_master()[source]

Is this the master node?

Returns:True if we are the master, otherwise False
receive_alpha_from_master()[source]

Receive alpha value from master node.

Returns:a floating point value for alpha in [0,1]
receive_state_from_master()[source]

Get state to run for this step

Returns:the state to run for this step
receive_states_for_energy_calc_from_master()[source]

Receive all states from master.

Returns:a list of states to calculate the energy of
send_energies_to_master(energies)[source]

Send a list of energies to the master.

Parameters:energies – a list of energies to send to the master
Returns:None
send_state_to_master(state)[source]

Send state to master

Parameters:state – State to send to master. This is the state after simulating this step.
Returns:None