StoreOnDisk

class StoreOnDisk(filename=None, mode=None, working_directory=None)

Class indicating that the self energies should be cached to disk.

The given file will be used for both reading and writing self energies if mode is Append. If no filename is given, or mode is ReadOnly, newly calculated self energies are stored in a temporary cache file for the duration of the calculation (note that this file will be deleted at the end of the calculation).

Parameters:
  • filename (str) – The filename to read/write self energies to.
  • mode (Append | ReadOnly) – Whether newly calculated self energies are added to the given file. With Append, new self energies are appended to the file. With ReadOnly, they are stored in a temporary file that is discarded at the end of the calculation.
    Default: Append
  • working_directory (str) – The directory to store temporary cache files in.
    Default: The system’s temporary directory.

Usage Examples

Basic examples on how to use StoreOnDisk() and other storage strategies can be found in the Usage Examples of RecursionSelfEnergy.

Temporarily save self energies on disk

Define that the self energies are saved on disk in a temporary file after the first iteration of the SCF loop and reused in the following iterations.

self_energy_calculator = RecursionSelfEnergy(
    storage_strategy=StoreOnDisk()
)

By default, a temporary cache file is created in the system’s temporary directory. The location of the temporary cache file can also be specified.

self_energy_calculator = RecursionSelfEnergy(
    storage_strategy=StoreOnDisk(working_directoy='/home/user/')
)

Reuse self energies between calculations

Specify the path of the file that stores the calculated self energies after the first iteration of the SCF loop.

self_energy_calculator = RecursionSelfEnergy(
    storage_strategy=StoreOnDisk(filename='/home/user/selfenergycache.hdf5')
)

Note

Self energies are stored on disk using the HDF5 format. The filename provided to StoreOnDisk() can have any extension.

In subsequent calculations, the previously calculated self energies can be reused by providing the same path again.

Important

QuantumATK does not verify the validity of the self energies in the provided file. Providing a cache file containing self energies calculated for a different electrode will give incorrect results.

By default, self energies not present in the cache file are calculated and added to the cache file. This can be avoided by marking the cache file read-only.

self_energy_calculator = RecursionSelfEnergy(
    storage_strategy=StoreOnDisk(
        filename='/home/user/selfenergycache.hdf5'),
        mode=ReadOnly
        )
)

Notes

In each step of the SCF loop of a device calculation, the same self energies need to be evaluated.

The StoreOnDisk() storage strategy specifies that each self energy is calculated only once and stored on disk. The self energies are reused in subsequent iterations. This strategy can significantly improve performance, but requires sufficient disk space.

In calculations involving a large number of parallel processes, storing the self energies to disk is equally fast as the SaveInMemory() storage strategy inside a single node. However, when a custom filename is used, the performance can slightly slow down when multiple nodes are involved in the calculation. If a temporary file is used instead, there is no slowdown across nodes. After the self energies have been stored, the StoreOnDisk() and SaveInMemory() storage strategies provide a similar performance improvement regardless of the parameters used.

Note that the StoreOnDisk() storage strategy requires less memory than the SaveInMemory() strategy, and is therefore the recommended choice for memory-intensive calculations when there is plenty of disk space available.