processIsMaster

processIsMaster()

Function for querying if a process is a delegator or worker process.

Returns:

True if the process is the delegator process in the parallel computation. False if it is a worker process.

Return type:

bool

Usage Examples

Printing the total energy to the terminal window. If the program is run in a parallel fashion, the processIsMaster function can be used to ensure that only the master process prints to the screen.

# Set up configuration
molecule_configuration = MoleculeConfiguration(
    elements=[Nitrogen, Hydrogen, Hydrogen, Hydrogen],
    cartesian_coordinates=[[ 0.     ,  0.      ,  0.124001],
                           [ 0.     ,  0.941173, -0.289336],
                           [ 0.81508, -0.470587, -0.289336],
                           [-0.81508, -0.470587, -0.289336]]*Angstrom
    )

# Define the calculator
calculator = HuckelCalculator()
molecule_configuration.setCalculator(calculator)

# Print the total energy to the screen
# and avoid writing this for each process.

energy = TotalEnergy(molecule_configuration).evaluate()

if processIsMaster():
   print('Total Energy =', energy)

process_is_master.py

Notes

Care should be taken when using the processIsMaster function. Misuse can cause the program to freeze. We recommend that the this function is used only for printing to the terminal while debugging.