This example shows how to perform electronic structure calculations
using pw.x for a system undergoing the presence of a static homogeneous
finite electric field. The method is explained in:

P. Umari and A. Pasquarello, PRL 89,157602 (2002)
I. Souza, J.Iniguez, and D.Vanderbilt, PRL 89, 117602 (2002)

The related parameters are:

In namelist &CONTROL

 
lelfield       LOGICAL ( default = .FALSE. )
               If .TRUE. a homogeneous finite electric field
               described through the modern theory of the polarization
               is applied.
 
 
gdir           INTEGER
               For Berry phase calculation: direction of the k-point
               strings in reciprocal space. Allowed values: 1, 2, 3
               1=first, 2=second, 3=third reciprocal lattice vector
               For calculations with finite electric fields
               (lelfield==.true.), gdir is the direction of the field

	       This is NOT USED if K_POINTS {automatic} IS PRESENT
 
nppstr         INTEGER
               For Berry phase calculation: number of k-points to be
               calculated along each symmetry-reduced string
               The same for calculation with finite electric fields
               (lelfield==.true.)
	       
               This is NOT USED if K_POINTS {automatic} IS PRESENT 


nberrycyc      INTEGER ( default = 1 )
               In the case of a finite electric field  (lelfield==.true.)
               it defines the number of iterations for converging the
               wavefunctions in the electric field Hamiltonian, for each
               external iteration on the charge density
 

In namelist &ELECTRONS

 
efield         REAL ( default = 0.D0 )
               For finite electric field calculations (lelfield == .true.),
               it defines the intensity of the field in a.u.

	       This is NOT USED if K_POINTS {automatic} IS PRESENT

            
           in the case of K_POINTS {automatic}  the electric field is given in 
           Cartesian coordinates through:
 
efield_cart(1)     1st component of the electric field in (Rydberg-type) atomic units   

efield_cart(2)     2st component of the electric field in (Rydberg-type) atomic units

efield_cart(3)     3rd component of the electric field in (Rydberg-type) atomic units




To perform a calculations with an electric field, an estimate of
the optimized wavefunctions is needed to build the electric field
operator (See: I. Souza, J.Iniguez and D. Vanderbilt, PRB 69, 085106,
2004). Therefore when lelfield ==.true. a copy of the wavefunctions
is read from disk (i.e. startingwfc should be 'file').

When  K_POINTS {automatic} IS NOT present


The parameters GDIR defines the direction of the electric field.
The k_points must be given as a series of k-points-strings.
A k-points-string is a series of NPPSTR uniform spaced k-points
along the direction gdir. All the k-points in a string must have
the same weight. 
PAY ATTENTION: in pw.x the default units for k-points coordinates
is 2pi/alat and NOT  crystalline units.

Example of k-strings:

nppstr=4
gdir=1

0.0   KY  KZ  1.
0.25  KY  KZ  1.
0.50  KY  KZ  1.
0.75  KY  KZ  1.

nppstr=4
gdir=3

KX  KY  0.0  1.
KX  KY  0.25 1.
KX  KY  0.50 1.
KX  KY  0.75 1.
 

When  K_POINTS {automatic} IS present

the string are calculated directly by pw.x and 
the electric field must be given in Cartesian coordinates,
also the Polarization (electronic and ionic) is then
reported in  Cartesian coordinates



For every usual iteration of pw.x when the Hartree and exchange-correlation 
potentials are kept fixed, when lelfield==.true. there are NBERRYCYC
iterations. During each of these iterations,  the electric field operator 
(which depends on the wave-functions) is kept fixed; then
the new electric field operator is built from the eigen-wavefunctions,
and a new iteration starts. This has been introduced because
the electric field Hamiltonian depends self consistently on the
wavefunctions.


For every iteration on the charge (usual pw.x iterations), the code
reports the Electronic and Ionic Dipole in a.u. per unit cell and
the expectations values of the operator e^{+iGz}. The letter
is given for the corresponding supercell  containing N_kx*N_ky*N_kz
unit cells (N_kx,N_ky,N_kz are the number of k-points along x,y,z)



Example 1 - dielectric constant of Si

The system is described by a 8-atom cubic unit cell.
We use a regular mesh of 3X3X7 k-points, where we have 7 k-points
along the directions of the electric field: gdir=3,nppstr=7
The first calculation just calculates the electronic structure
without electric field. The second calculation turns on the field
but with 0 a.u. intensity. The third calculation applies a field
of 0.001 a.u..

The electronic dipole D[0.a.u.] at 0 field is a small number in the
order of 1.0d-4.  After the third calculation the electronic dipole
D[0.001 a.u.] at 0.001 a.u. field is 0.9265.

The high-frequency dielectric constant eps_inf is then given by

eps_inf=4*pi*(D[0.001 a.u.]-D[0.0 a.u.])/(0.001 a.u. * Omega) + 1

where Omega is the volume of the unit cell (1054.9778 (a.u.)^3). 
We obtain:

eps_inf=12.04

(Compare: other DFT calculations, 12.7-13.1 , exp. 11.4 )
The result 12.14 is not fully converged with respect to the k-points grid
P.Umari and A. Pasquarello, PRB 68, 085114 (2003).



Example 2 - effective charges of AlAs

The setup of the system is quite the same as in the previous case, with
alat=10.60 a.u. and Omega=1191.0160 (a.u.)^3. The calculation follows the
same logic. Moreover, forces on atoms are computed (tprnfor=.true.)

The electronic dipole D[0.001 a.u.] at 0.001 a.u. field is 0.7400. This yields
eps_inf=8.808. 

The forces F[0.001 a.u.] on atoms (z component) are 0.03054 a.u., almost equal 
for all atoms, while F[0.0 a.u.] is almost zero. The Born effective charges Z*
are thus
    eZ* = (F[0.001 a.u.]-F[0.0 a.u.])/0.001 a.u. = 3.054 a.u.,  Z* = 2.16
BEWARE the electron charge factor "e": e=sqrt(2) in Ry atomic units (e^=2) !



