The Driver object

The Driver object is a simple way to call the QE/QEpy from python side. Here is how to define a simple scf job:

from qepy import Driver
driver = Driver('qe_in.in')

Here, the first argument specifies the name of QE input file.

List of all Methods

class qepy.driver.Driver(inputfile=None, comm=None, ldescf=False, iterative=False, task='scf', embed=None, prefix=None, outdir=None, logfile=None, qe_options=None, prog='pw', **kwargs)[source]

The driver of QEpy.

Parameters
  • inputfile (str) -- Name of QE input file

  • comm (object) -- Parallel communicator

  • ldescf (bool) -- If True, also print the scf correction term in the iteratively mode

  • iterative (bool) -- Iteratively run the scf or tddft

  • task (str) --

    Task of the driver :

    • 'scf' : scf task

    • 'optical' : Optical absorption spectrum (TDDFT)

    • 'nscf' : read file from scf

  • embed (object (Fortran)) -- embed object for QE

  • prefix (str) -- prefix of QE input/output

  • outdir (str) -- The output directory of QE

  • logfile (str, file or bool) --

    The screen output of QE. If it is a file descriptor, it should open with 'w+'.

  • outdir -- The output directory of QE

  • qe_options (dict) -- A dictionary with input parameters for QE to generate QE input file.

  • kwargs (dict) -- Other options

Note

  • The bool gather parameter in functions means the data is gathered in root or distributed in all cpus.

  • Also contains some interface of ASE calculator, but the units are different.

    • positions : Bohr

    • lattice : Bohr

    • energy : Ry

    • forces : Ry/Bohr

    • stress : Ry/Bohr**3

    • potential : Ry

    • density : 1.0/Bohr**3

calc_energy(**kwargs)[source]

Calculate the energy with the pw2casino of QE.

check_convergence(**kwargs)[source]

Check the convergence of the SCF

data2field(data, cell=None, grid=None)[source]

QE data to dftpy DirectField, please call it in serial.

diagonalize(print_level=2, **kwargs)[source]

Diagonalize the hamiltonian

Parameters

print_level -- The level of output of QE

driver_initialize(**kwargs)[source]

Initialize the driver

Parameters
  • inputfile (str) -- Name of QE input file

  • commf (object) -- Parallel communicator (Fortran)

  • iterative (bool) -- Iteratively run the scf or tddft

  • task (str) --

    Task of the driver :

    • 'scf' : scf task

    • 'optical' : Optical absorption spectrum (TDDFT)

    • 'nscf' : read file from scf

  • qe_options (dict) -- A dictionary with input parameters for QE to generate QE input file.

end_scf(**kwargs)[source]

End the scf and clean the scf workspace. Only need run it in iterative mode

field2data(field, data=None)[source]

dftpy DirectField to QE data, please call it in serial.

classmethod get_ase_atoms()[source]

Return the atom.Atoms from QE.

get_bz_k_points()[source]

Return all the k-points in the 1. Brillouin zone.

The coordinates are relative to reciprocal latice vectors.

get_density(gather=True)[source]

Return density array in real space.

classmethod get_dftpy_ions()[source]

Return the dftpy.Ions from QE.

get_dipole_tddft()[source]

Return the total dipole of tddft task.

get_effective_potential(spin=0, pad=True)[source]

Return pseudo-effective-potential array.

get_eigenvalues(kpt=0, spin=0)[source]

Return eigenvalue array.

get_energy(**kwargs)[source]

Return the total energy.

get_fermi_level()[source]

Return the Fermi level.

get_forces(icalc=0, **kwargs)[source]

Return the total forces. (n, 3)

Parameters

icalc (int) --

icalc

without

bin

0

all

000

1

no ewald

001

2

no local

010

3

no ewald + local

011

4

no nlcc

100

5

no ewald + nlcc

101

6

no local + nlcc

110

7

no ewald + local + nlcc

111

get_ibz_k_points()[source]

Return k-points in the irreducible part of the Brillouin zone.

The coordinates are relative to reciprocal latice vectors.

static get_ions_lattice()[source]

Return the lattice of ions.

static get_ions_positions()[source]

Return the cartesian positions of ions.

static get_ions_symbols()[source]

Return the symbols of ions.

get_k_point_weights()[source]

Weights of the k-points.

The sum of all weights is one.

get_magnetic_moment(**kwargs)[source]

Return the total magnetic moment.

get_number_of_bands()[source]

Return the number of bands.

get_number_of_grid_points(gather=True)[source]

Return the shape of arrays.

get_number_of_k_points()[source]

Return the number of kpoints.

get_number_of_spins()[source]

Return the number of spins in the calculation.

Spin-paired calculations: 1, spin-polarized calculation: 2.

get_occupation_numbers(kpt=0, spin=0)[source]

Return occupation number array.

get_output()[source]

Return the output of QE.

It depends on the logfile of the initialization of the driver :

  • None : return None.

  • str : return all outputs.

  • True : It will return the output from last time.

get_potential_energy(**kwargs)[source]

Return the potential energy.

get_pseudo_density(spin=None, pad=True, gather=True)[source]

Return pseudo-density array.

If spin is not given, then the total density is returned. Otherwise, the spin up or down density is returned (spin=0 or 1).

get_pseudo_wave_function(band=None, kpt=0, spin=0, broadcast=True, pad=True)[source]

Return pseudo-wave-function array.

get_scf_error(**kwargs)[source]

Return the error of the scf

get_scf_steps(**kwargs)[source]

Return the number of steps of scf

get_spin_polarized()[source]

Is it a spin-polarized calculation?

get_stress(**kwargs)[source]

Return the stress (3, 3).

get_wave_function(band=None, kpt=0)[source]

Return wave-function array in real space.

get_xc_functional()[source]

Return the XC-functional identifier.

'LDA', 'PBE', ...

property is_root

Whether it is the root.

If the comm is set, root is rank == 0. Otherwise root is ionode of QE.

mix(mix_coef=0.7, print_level=2)[source]

Mixing the density

Parameters

print_level -- The level of output of QE

pwscf_restart(oldxml=False)[source]

Read PW ouput/restart files.

Parameters

oldxml (bool) --

  • True : read the old format xml file (qe<6.4)

  • False : read the new format xml file (qe>6.3)

save(what='all', **kwargs)[source]

Save the QE data to the disk

Parameters

what (str) --

  • what = 'all'write xml data file, charge density, wavefunctions

    (for final data);

  • what = 'config'write xml data file and charge density; also,

    for nks=1, wavefunctions in plain binary format (see why in comments below). For intermediate or incomplete results;

  • what = 'config-nowf'write xml data file and charge density only;

    (save density);

  • what = 'config-init'write xml data file only excluding final results

    (for dry run, can be called at early stages).

see PW/src/punch.f90

scf(print_level=2, maxiter=None, **kwargs)[source]

Run the scf/tddft until converged or maximum number of iterations

set_external_potential(potential, exttype=None, gather=True, extene=None, **kwargs)[source]

Set the external potential.

Parameters
  • potential ((nnr, nspin)) -- The external potential

  • exttype (int) --

    The type of external potential

    type

    potential

    bin

    0

    external

    000

    1

    pseudo

    001

    2

    hartree

    010

    3

    pseudo + hartree

    011

    4

    xc

    100

    5

    pseudo + xc

    101

    6

    hartree + xc

    110

    7

    pseudo + hartree + xc

    111

stop(exit_status=0, what='all', print_flag=0, **kwargs)[source]

stop.

Parameters
  • exit_status (int) -- 0 : QE will remove it temporary files

  • print_flag (int) -- 0 : Not print time informations

  • what (str) -- see qepy.driver.Driver.save().

tddft_initialize(inputfile=None, commf=None, embed=None, **kwargs)[source]

Initialize the tddft

Parameters
  • inputfile (str) -- Name of QE input file, which also contains &inputtddft section.

  • commf (object) -- Parallel communicator (Fortran)

  • embed (object (Fortran)) -- embed object for QE

tddft_restart(istep=None, **kwargs)[source]

Restart the tddft from previous interrupted run.

Parameters

istep (int) -- Start number of steps, just for output.

update_ions(positions=None, lattice=None, update=0, **kwargs)[source]

update the ions of QE

Parameters
  • positions (np.ndarray (n, 3)) -- positions of ions

  • lattice (3x3 matrix) -- lattice of ions

  • update (int) --

    • 0 : update everything (default)

    • 1 : only update atomic information, not update potential