Tutorial
After installation, PyZFS can be executed in two ways:
Construct
WavefunctionLoaderandZFSCalculationfrom within Python terminal or Jupyter notebook, and callZFSCalculation.solveto perform the calculation.An example Python script for computing the ZFS tensor for oxygen molecule is shown below.
path/to/o2.xmlshould be replaced by the path to thepyzfs/examples/o2_qbox_xml/o2.xmlfile in the PyZFS folder.>>> from pyzfs.common.wfc.qboxloader import QboxWavefunctionLoader >>> from pyzfs.zfs.main import ZFSCalculation >>> wfcloader = QboxWavefunctionLoader(filename='/path/to/o2.xml') # Construct wavefunction loader >>> zfscalc = ZFSCalculation(wfcloader=wfcloader) # Set up ZFS calculation >>> zfscalc.solve() # Perform ZFS calculation
Example Jupyter notebooks can be found at
examples/o2_qbox_xml/run.ipynbandexamples/o2_qe_hdf5/run.ipynb.Directly execute PyZFS. This approach works more smoothly with MPI.
For serial execution, simply type the following command in the folder that contains DFT wavefunction file(s)
$ pyzfs [--flags]
For parallel execution, use the following command
$ mpiexec [-n num_of_processes] pyzfs [--flags]
where
num_of_processesis the number of processes. PyZFS distributes the calculations on a square grid of processes. Ifnum_of_processesis not a square number, PyZFS will use the largest square number of processes smaller thannum_of_processesfor calculations.Note that to use the above pyzfs command, one needs to install PyZFS through pip (see Installation). If one manually added the PyZFS directory to
PYTHONPATHwithout installing it, one needs to replace the above commands with$ python -m pyzfs.run [--flags]
and
$ mpiexec [-n num_of_processes] python -m pyzfs.run [--flags]
Acceptable flags [–flags] are listed below. For detailed explanation see
pyzfs/run.py.path: Working directory for this calculation. Python will first change the working dir before any calculations. Default is..wfcfmt: Format of input wavefunction. Default isqeh5Supported options are:qeh5: Quantum ESPRESSO (v6.x or v7.x) HDF5 save file.pathshould contain theprefix.xmlfile and theprefix.savefolder.qe: Quantum ESPRESSO (v6.1 only) save file.pathshould be the save folder that containsdata-files.xmletc. Deprecated in favor ofqeh5.qbox: Qbox XML file.cube-wfc: Cube files of (real) wavefunctions (Kohn-Sham orbitals).cube-density: Cube files of (signed) squared wavefunction. This option supportspp.xoutput withplot_num = 7andlsign = .TRUE..
filename: Name of the Qbox sample XML file that contains input wavefunction. Only used ifwfcfmtisqbox.fftgrid: FFT grid used. Default iswave. Supported options are:density: The density grid is used for FFT.wave: A reduced grid is used for FFT, which is computationally less expensive and is recommended for large-scale calculations.
memory: Controls whether certain intermediate quantities are kept in memory or re-computed every time. Supported options arehigh,low, andcriticalwhich keeps the decreasing amount of quantities in memory. Default iscriticalwhich costs least memory and is recommended for large-scale calculations.
An example execution command for Quantum ESPRESSO HDF5 save file is
$ mpiexec pyzfs --wfcfmt qeh5 --prefix pwscf
where
pwscfis the prefix used in the Quantum ESPRESSO calculation.An example execution command for Qbox XML save file is
$ mpiexec pyzfs --wfcfmt qbox --filename gs.xml
where
gs.xmlis the XML save file generated by Qbox.
See pyzfs/examples for examples of computing the ZFS tensor for the oxygen molecule and the nitrogen-vacancy (NV) center in diamond.
After PyZFS is executed, the D tensor, its eigenvalues and eigenvectors are printed by the end of the output. The widely-used scalar D and E parameters are also printed. A zfs.xml file is generated that includes these information, facilitating parsing the results through scripts.
PyZFS can scale to thousands of MPI processes. Starting from version 2.0, further speedup can be achieved by using NVIDIA GPUs. The code has been applied to systems with up to 5000 valence electrons. For large calculations, typical walltime for a calculation is on the order of 12-24 hours on CPUs, and 1-2 hours on GPUs.