TABLE OF CONTENTS


43-slurm-composite

DESCRIPTION

This examples demonstrates how to spawn several Slurm jobs within a single PWTK script, where the later jobs depend on the previous ones. To this end, the ::pwtk::afterDone command is used which waits for the specified jobs to be completed before proceeding.

This example splits the calculation of Hubbard U parameters over perturbed atoms and q points; the example is adopted from HP/examples/exemple07 of Quantum ESPRESSO. The system considered is bulk ferromagnetic Ni2MnGa.

BEWARE

This example takes a while to complete.

EXAMPLE SOURCE FILE

slurm-composite.pwtk

SOURCE

# Slurm jobs are PWTK child processes, born in the empty state. Hence,
# we need to inform PWTK with ::pwtk::propagate what to propagate to
# child processes. For further info, see the 50-propagate example (or
# the propagate.pwtk file).

propagate {
    # running this example in a temporary directory
    set tmpdir $env(HOME)/tmp/Ni2MnGa
    print "Running this example in $tmpdir"

    file mkdir $tmpdir
    cd $tmpdir
    restart on
    
    # the pw.x input data

    CONTROL { outdir = '.'  pseudo_dir = '.'  prefix = 'Ni2MnGa' }
    SYSTEM {
        ibrav = 7  celldm(1) = 7.80  celldm(3) = 1.4142136  nat = 4  ntyp = 3
        ecutwfc = 50.0  ecutrho = 400.0
        occupations ='smearing'  smearing ='mv'  degauss = 0.01
        nspin = 2,
        starting_magnetization(Mn) = 0.5
        starting_magnetization(Ni) = 0.5
    }
    ELECTRONS { conv_thr =  1.d-15  mixing_beta = 0.7 }
    ATOMIC_SPECIES {
        Mn  54.938  Mn.pbesol-spn-rrkjus_psl.0.3.1.UPF
        Ni  58.693  Ni.pbesol-n-rrkjus_psl.0.1.UPF
        Ga  69.723  Ga.pbesol-dn-rrkjus_psl.0.2.UPF
    }
    ATOMIC_POSITIONS {crystal} {
        Mn  0.0  0.0  0.0 
        Ni  1/2  3/4  1/4 
        Ni  1/2  1/4  3/4 
        Ga  0.0  1/2  1/2 
    }
    K_POINTS {automatic} {
        4 4 4  0 0 0
    }
    HUBBARD {ortho-atomic} {
        U Mn-3d 0.0001
        U Ni-3d 0.0001
    }

    # the hp.x input data common to all hp.x calcs

    INPUTHP {
        nq1 = 2  nq2 = 2  nq3 = 2
        conv_thr_chi = 1.0d-8
        iverbosity = 2
    }
}


# let's define a Slurm profile with ::pwtk::slurm_profile
# (such profiles are typically defined by the user in ~/.pwtk/slurm.tcl
#  as to be avialable in any PWTK script)

slurm_profile small {
    #!/bin/sh
    #SBATCH --nodes=1
    #SBATCH --ntasks=4
    #SBATCH --time=06:00:00    
} {    
    prefix mpirun -np 4
    prefix "singularity exec $env(HOME)/bin/qe-7.3.1-intel.sif mpirun -np 4"
}


# the head part of the batch shell script is defined with ::pwtk::slurm_head
# (this can be typically defined by the user in ~/.pwtk/slurm.tcl)

slurm_head {
    #module load QuantumESPRESSO/7.1-foss-2022a; # EDIT THIS
}


# submit the SCF calculation to Slurm with ::pwtk::SLURM

SLURM small {
    runPW scf.Ni2MnGa
}

# we need to wait for the SCF calculation to finish before we can proceed,
# hence we use ::pwtk::afterDone

afterDone scf.Ni2MnGa.out


# run hp.x calculations per-partes

foreach atom {Mn Ni} {
    foreach {start_q last_q} {
        1 2
        3 4
    } {
        # run the hp.x calculation for $atom from q-points in [$start_q,$last_q]
        SLURM small {
            INPUTHP " perturb_only_atom($atom) = .true.
                      start_q = $start_q
                      last_q  = $last_q "
            runHP hp.Ni2MnGa.$atom.q$start_q-$last_q            
        }
        # wait for the calculation to finish before proceeding
        afterDone hp.Ni2MnGa.$atom.q$start_q-$last_q.out
    }
    
    # collect all q points for $atom
    SLURM small {
        INPUTHP " perturb_only_atom($atom) = .true.
                  sum_pertq = .true. "
        runHP hp.Ni2MnGa.$atom.collect
    }
    # wait for the calculation to complete
    afterDone  hp.Ni2MnGa.$atom.collect.out
}




# the final step: collect all pieces of the response matrices, invert
# them and calculate U for Mn and Ni

SLURM small {
    INPUTHP { compute_hp = .true. }
    runHP hp.Ni2MnGa.final
}