Reusing electrodes

Published: May 28 2014


Tags: electrodes load reuse

In this tutorial, you will learn how to reuse the electrodes for different calculations, thus saving time by only having to calculate the converged state of the electrodes once.

A typical scenario for device studies with ATK is to systematically study the influence of various modifications of the central region. This can be different molecules attached to a nanotube, or various positions for or types of dopants or vacancies, etc. The electrodes are however almost always the same in all these calculations. One can therefore save time by pre-computing the electrodes and save them, and just reuse the converged state in each calculation.


 To do this requires a little bit of scripting, but mostly copying/pasting ready blocks of code.

  1. First decide on which numerical accuracy parameters to use (see the Notes below).
  2. Start by setting up the full calculation as you would normally with some representative central region. We will here assume that the Script Generator in VNL is used for this task.
  3. Save the script, or rather: save two copies of the script, we will here call them and
  4. Open in the Editor (or any editor of your choice) and scroll down to the "device_configuration" definition. It almost always looks like
    device_configuration = DeviceConfiguration(
        [left_electrode, right_electrode]

    Remove these lines. To indicate that this script only serves to compute the electrodes, you may want to remove the definition of the central region altogether to keep things tidy, but it's not strictly necessary
  5. Now scroll down towards the end of the script, and locate the comment lines
    # Device Calculator

    Remove everything from these lines to the end of the script.
  6. Instead, add these lines at the end of the script:
    nlsave('', left_electrode)
    nlsave('', right_electrode)

    The file names can of course be changed to your liking, and should also include the absolute path to where you want to store them. This is especially important if you will execute the script via the Job Manager, since the files are otherwise written to the VNL startup directory.
    NOTE: In the case of identical electrodes, delete the three "right_electrode" lines, and remove the "left" prefix from all remaining variables.
  7. Save the script, and run it.
  8. Meanwhile, we will modify the other script, Open it in the Editor.
  9. Starting from the top, remove the entire definition of the left and right electrodes, i.e. delete all lines until
    # -------------------------------------------------------------
    # Central region
    # -------------------------------------------------------------
  10. Instead, add the following lines at the top of the script:
    left_electrode = nlread("")[0]
    right_electrode = nlread("")[0]

    Obviously, the file names should match those in, if you changed them there.
  11. It is recommended, although not strictly necessary, to also remove the definition of the electrode calculators, including the lines
        [left_electrode_calculator, right_electrode_calculator],

     in the "DeviceCalculator" definition.
  12. That's it! When the electrode calculation is done, you can now run, and see that it completely bypasses the electrode calculation.
  13. For each new geometry to be computed with these electrodes, just replace the definition of the "central_region" in, make sure to check the device parameters such as bias voltage etc, Or, alternatively, apply steps 9-11 above to any complete device calculation script, keeping the points about the numerical accuracy parameters in mind (see step 1 above and the Notes below).



It is important that the parameters used for the electrodes are the same as those that will be used in the final device calculation, or at least very similar. Otherwise the electrode Fermi level alignment vs. the device average Fermi level may change. This generally causes problems for convergence, and thus the whole point of saving time this way is lost.

Therefore, first make a decision on the numerical accuracy parameters, such as exchange-correlation functional, temperature, mesh cut-off, basis set, and so on, and then stick to the same choice for the whole sequence of calculations.

It is absolutely necessary that the k-point sampling in A and B is identically the same, or else an error will be generated.



A device calculation in ATK actually consists of a sequence of up to four individual self-consistent loops:

  1. Left electrode.
  2. Right electrode (unless the same variable is used for left and right electrodes).
  3. Equivalent bulk: the central region, treated as periodic in Z. This optional step is only intermediate, and is used to generate a good starting guess for the "real" calculation.
  4. Open boundary calculation of the full device, using the result of the equivalent bulk as starting guess (if performed), and the electrostatic potential of the electrodes as boundary conditions.

Of these, the device calculation usually takes the longest time, but the equivalent bulk part can also be quite time-consuming, especially for dense systems, since we have to do a full diagonalization in each step, whereas the device calculation contains an inversion in each step, which is performed on block-diagonal sparse matrices.

So, while the electrodes are almost always the quickest part, they can still take some time in absolute terms. Thus, since most systematic studies involve a long sequence of similar calculations, usually with the same electrodes but different central regions, the benefit of the method described above can still be quite large.

1. Start by building the full calculation as you would normally (skip
any analysis, that's for later)

2. Make two additional copies of the script, step1 and step2 (in the
example attached, "" is the original script)

In step1:

3a. Remove the central region completely + the "device_configuration"

3b. Remove all references to the device parameters (not critical).

3c. HOWEVER, make sure to keep any special parameters like basis set etc

3c. Remove the lines at the end which define, print, calculate and save
the device_configuration

3d. Add instead the lines



nlsave('', left_electrode)
nlsave('', right_electrode)

4. In step2:

4a. Remove both electrode geometries and replace by

left_electrode = nlread("")[0]
right_electrode = nlread("")[0]

4b. Remove all electrode parameters, including the lines

[left_electrode_calculator, right_electrode_calculator],

in the DeviceCalculator definition (not critical, but recommended to
avoid confusion)

5. That's it!

In the future, replace the central region in the step2 script with any
new central region you want to use.