processIsMaster
—
Query function for parallel computation. Returns True, if the process
is the master process in the parallel computation or the only process in a serial
computation. Returns False, if the process is a client process in a
parallel calculation.
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