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+'.
None : Show on the screen.
str : Save to the given file.
True : Save to the temporary file, see also
qepy.driver.Driver.get_output()
.
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
- 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
- get_bz_k_points()[source]¶
Return all the k-points in the 1. Brillouin zone.
The coordinates are relative to reciprocal latice vectors.
- 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.
- get_number_of_spins()[source]¶
Return the number of spins in the calculation.
Spin-paired calculations: 1, spin-polarized calculation: 2.
- 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_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.
- 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