Workload distribution

Workload of thermal conductivity calculation can be distributed into computer nodes. The distribution over q-point grid points (–gp option), over phonon bands (–bi option), and over both of them are supported. Unless necessary, the distribution over bands is not recommended since it has some amount of overhead in the part of Fourier transformation of force constants. Therefore the distribution over grid-points is explained below. However since the distribution over bands works quite similarly as that over q-points, the usage can be easily guessed.

On each computer node, pieces of lattice thermal conductivity calculation are executed. The resulting data for each grid point are stored in its kappa-mxxx-gx.hdf5 file on each node by setting –write_gamma option. Once all data are obtained, those data are collected by –read_gamma option and the lattice thermal conductivity is obtained.

How to do it

The following example is executed in the Si-PBE example.

To avoid re-calculating fc3 and fc2, fc3.hdf5 and fc2.hdf5 are created on a single node:

% phono3py --dim="2 2 2" --sym-fc -c POSCAR-unitcell

The indices of the irreducible grid-points neccesarry to specify --ga option are found by –wgp option

% phono3py --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --br --wgp

and they are stored in ir_grid_points.yaml.

% egrep '^- grid_point:' ir_grid_points.yaml|awk '{printf("%d,",$3)}'

The calculated data on all the grid points shown above as indices are necessary to obtain lattice thermal conductivity. To distribute computational demands into computer nodes, a set of the grid-point indices are chosen and executed as follows:

% phono3py --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --br --gp="0,1,2,3,4,5,6,7,8,9,20,21,22,23,24,25" --write-gamma

Then many kappa-m191919-gx.hdf5 files are generated. These file names should not be altered because in reading the data by phono3py, those file names are supposed to be so, though there is a little freedom to arrange those file names, for which see -o and -i options. After completing calculations for all irreducible grid-point indices, the RTA thermal conductivity is computed by another run in a short time from the stored data:

% phono3py --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --br --read-gamma

A convenient script

The following short script may be useful to splitting all irreducible grid-point indices into of reasonable number of sets of grid-point indices for workload distribution.

#!/usr/bin/env python

import sys
import yaml

if len(sys.argv) > 1:
    num = int(sys.argv[1])
    num = 1

with open("ir_grid_points.yaml") as f:
    data = yaml.load(f)
    gps = [gp['grid_point'] for gp in data['ir_grid_points']]
    gp_lists = [[] for i in range(num)]
    for i, gp in enumerate(gps):
        gp_lists[i % num].append(gp)
    for gp_set in gp_lists:
        print(",".join(["%d" % gp for gp in gp_set]))

Supposed that this script is saved as,

% phono3py --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" -c POSCAR-unitcell --mesh="19 19 19" --wgp
% python 20

For example distributing into 20 computer nodes using a queueing system,

% j=1; for i in `python 20`;do echo $i; sed -e s/gps/$i/g -e s/num/$j/g|qsub; j=$((j+1)); done

with (here for grid-engine):

#$ -S /bin/zsh
#$ -cwd
#$ -N phono3py-num
#$ -pe mpi* 16
#$ -e err-phono3py-num.log
#$ -o std-phono3py-num.log

phono3py --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --br --gp="gps" --write-gamma