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.
- First decide on which numerical accuracy parameters to use (see the Notes below).
- 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.
- Save the script, or rather: save two copies of the script, we will here call them electrode.py and device.py.
- Open electrode.py in the Editor (or any editor of your choice) and scroll down to the "device_configuration" definition. It almost always looks like
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
- Now scroll down towards the end of the script, and locate the comment lines
Remove everything from these lines to the end of the script.
- Instead, add these lines at the end of the script:
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.
- Save the script electrodes.py, and run it.
- Meanwhile, we will modify the other script, device.py. Open it in the Editor.
- Starting from the top, remove the entire definition of the left and right electrodes, i.e. delete all lines until
- Instead, add the following lines at the top of the script:
Obviously, the file names should match those in electrode.py, if you changed them there.
- It is recommended, although not strictly necessary, to also remove the definition of the electrode calculators, including the lines
in the "DeviceCalculator" definition.
- That's it! When the electrode calculation is done, you can now run device.py, and see that it completely bypasses the electrode calculation.
- For each new geometry to be computed with these electrodes, just replace the definition of the "central_region" in device.py, 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:
- Left electrode.
- Right electrode (unless the same variable is used for left and right electrodes).
- 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.
- 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.