TABLE OF CONTENTS


50-propagate

DESCRIPTION

This example shows how use the PWTK's propagate mechanism.

"Propagate" is a simple mechanism that propagates script snippets to child PWTK instances. Child PWTK instances are remotes, backgrounds, threads, thread-pools, and queues, i.e., scripts supplied to ::pwtk::bg, ::pwtk::thread, ::pwtk::tpool::job, ::pwtk::remote, ::pwtk::SLURM, ::pwtk::PBS, ::pwtk::LSF, ::pwtk::LL commands.

For example, consider the following script:

   
    import common.pwtk
    SYSTEM { ecutwfc = 30.0 }

    remote machine1 {
        runPW calc1
    }

This script fails. The problem is that ::pwtk::remote spawns a new child process on the remote host that is born in the empty state, implying that in the above example it only consists of the "runPW calc1" command, hence it lacks the data to create the pw.x input file.

In contrast, the following script is OK:

    propagate {
       import common.pwtk
       SYSTEM { ecutwfc = 30.0 }
    }
    remote machine1 {
        runPW calc1
    }

because the ::pwtk::propagate command instructs PWTK that the script snipped encapsulated into the curly braces should be propagated to child processes.

EXAMPLE SOURCE FILE

propagate.pwtk

SOURCE

# ::pwtk::propagate is used to inform PWTK what to propagate to child processes

propagate {
    import Si.pwtk

    # we will run 2 concurrent jobs; the number of processors
    # used for each job depends on the number of available cores;
    # edit according to your preference
    prefix mpirun -np 2

    # let's perform a PBE instead of the PZ calculation
    ATOMIC_SPECIES {
        Si 1.0 Si.pbe-rrkj.UPF
    }
}


# below, two sets of calculations are performed concurrently with ::pwtk::bg

# the 1st set of calculations
bg {
    scanpar e [seq 15 5 30] {
        SYSTEM "ecutwfc = $e, ecutrho = 4*$e"
        # perform pw.x calculation and write total energy to datafile
        write ecut.pbe.dat [pwo_totene [runPW scf.Si_e$e.pbe]]
    }
    # plot the result to the PNG image
    plot -t png -xl "ecutwfc (Ry)" -yl "Total energy (Ry)" ecut.pbe.dat
}

# the 2nd set of calculations
bg {
    scanpar k {2 4 6 8} {
        K_POINTS automatic "$k $k $k   1 1 1"
        # perform pw.x calculation and write total energy to datafile
        write k.pbe.dat [pwo_totene [runPW scf.Si_k$k.pbe]]
    }
    # plot the result to the PNG image
    plot -t png -xl "k of (k × k × k)" -yl "Total energy (Ry)" k.pbe.dat
}