# Difference between revisions of "Tutorial:Sternheimer linear response"

The Sternheimer approach to perturbation theory allows efficient calculations of linear and non-linear response properties. The basis of this method, just as in standard perturbation theory, is to calculate the variation of the wave-functions under a given perturbing potential. The advantage of the method is that the variations are obtained by solving the linear equation that only depends on the occupied states instead of requiring an (infinite) sum over unoccupied states. In the case of (time-dependent) density functional theory the variation of the Hamiltonian includes a term that depends on the variation of the density, so this equation must be solved self-consistently.

To run a Sternheimer calculation with Octopus, the only previous calculation you need is a ground-state calculation. For this tutorial we will use a water molecule, with this basic input file for the ground state:

CalculationMode = gs

%Coordinates
'O'  |  0.000000  | -0.553586  |  0.000000
'H'  |  1.429937  |  0.553586  |  0.000000
'H'  | -1.429937  |  0.553586  |  0.000000
%

Radius = 10
Spacing = 0.65
ConvRelDens = 1e-6


We use a tighter setting on SCF convergence (ConvRelDens) which will help the ability of the Sternheimer calculation to converge numerically, and we increase a bit the size of the box as response calculations tend to require more space around the molecule than ground-state calculations to be converged.

After the ground-state calculation is finished, we change the run mode to em_resp, to run a calculation of the electric-dipole response:

CalculationMode = em_resp


Next, to specify the frequency of the response we use the EMFreqs block; in this case we will use three values 0.00, 0.15 and 0.30 [Ha]:

%EMFreqs
3 | 0.0 | 0.3
%


and we will also specify a small imaginary part to the frequency of 0.1 [eV], which avoids divergence on resonance:

EMEta = 0.1/27.211383


We are using the default symmetric QMR linear solver. In the run, you will see calculations for each frequency for the x, y, and z directions, showing SCF iterations, each having linear-solver iterations for the individual states' , labelled by the k-point/spin (ik) and state (ist). The norm of , the number of linear-solver iterations (iter), and the residual are shown for each. First we see the static response:

Info: Calculating response for the x-direction and frequency 0.0000.
Info: EM Resp. restart information will be written to 'restart/em_resp'.
Info: EM Resp. restart information will be read from 'restart/em_resp'.

** Warning:
**   Unable to read response wavefunctions from 'wfs_x_f1+': Initializing to zero.

Info: Finished reading information from 'restart/em_resp'.
--------------------------------------------
LR SCF Iteration:   1
Frequency:             0.000000 Eta :             0.003675
ik  ist                norm   iters            residual
1    1            0.215260      51        0.913922E-02
1    2            1.563449      98        0.961813E-02
1    3            1.605779     121        0.995669E-02
1    4            1.160936     110        0.954961E-02


Later will come the dynamical response. The negative state indices listed indicate response for . For each frequency, the code will try to use a saved response density from the closest previously calculated frequency.

Info: SCF for response converged in   19 iterations.
Total Hamiltonian applications:   14416
Info: Finished writing information to 'restart/em_resp'.
Info: Calculating response for the y-direction and frequency 0.3000.
Info: EM Resp. restart information will be written to 'restart/em_resp'.
Info: EM Resp. restart information will be read from 'restart/em_resp'.
Info: Finished reading information from 'restart/em_resp'.
--------------------------------------------
LR SCF Iteration:   1
Frequency:             0.300000 Eta :             0.003675
ik  ist                norm   iters            residual
1    1            0.122694      15        0.997305E-02
1   -1            0.196960      29        0.948786E-02
1    2            0.444521      28        0.943525E-02
1   -2            1.157900      98        0.981841E-02
1    3            1.040127      48        0.945472E-02
1   -3            4.007068     158        0.992077E-02
1    4            0.574396      34        0.998836E-02
1   -4            2.235525     172        0.986707E-02


At the end, you will have a directory called em_resp containing a subdirectory for each frequency calculated, each in turn containing eta (listing = 0.1 [eV]), alpha (containing the real part of the polarizability tensor), and cross_section (containing the cross-section for absorption, based on the imaginary part of the polarizability).