File: lcao.rst

package info (click to toggle)
gpaw 21.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,492 kB
  • sloc: python: 121,997; ansic: 14,138; sh: 1,125; csh: 139; makefile: 43
file content (286 lines) | stat: -rw-r--r-- 10,919 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
.. _lcao:

=========
LCAO Mode
=========

.. highlight:: bash

GPAW supports an alternative mode of calculation,
:dfn:`LCAO mode` [LCAO_article]_,
which will use a basis set of atomic orbital-like functions rather
than grid-based wave functions.  This makes calculations considerably
cheaper, although the accuracy will be limited by the quality of the
chosen basis.

The sections below explain briefly how LCAO mode works, how to
generate basis sets and how to use them in calculations.
LCAO mode is available for TD-DFT via the
:ref:`LCAOTDDFT <lcaotddft>` module.

Introduction
------------

In the LCAO mode the Kohn-Sham pseudo wave functions
`\tilde{\psi}_n(\mathbf r)` are expanded onto a set of atomic-like
orbitals `\Phi_{nlm}(\mathbf r)`, in the same spirit as the SIESTA
method [Siesta]_ :

.. math::

 \tilde{\psi}_n(\mathbf r) = \sum_\mu c_{\mu n} \Phi_{\mu}(\mathbf r)

The basis functions are constructed as products of numerical radial
functions and spherical harmonics

.. math::

  \Phi_{nlm}(\mathbf{r})
  = \Phi_{nlm}(\mathbf r^a + \mathbf R^a)
  = \varphi_{nl}(r^a) Y_{lm}(\hat{\mathbf{r}}^a)

where `\mathbf R^a` is the position of nucleus `a`, and `\mathbf r^a =
\mathbf r - \mathbf R^a`.

In this approximation the variational parameters are the coefficients
`c_{\mu n}` rather than the real space wave function. The eigenvalue
problem then becomes

.. math::

 \sum_\nu H_{\mu\nu} c_{\nu n} = \sum_{\nu} S_{\mu\nu} c_{\nu n} \epsilon_n

which can be solved by directly diagonalizating the Hamiltonian in the
basis of the atomic orbitals.

Some detailed information can be found in the master theses `1`_ and `2`_.

.. _1: ../../_static/askhl_master.pdf
.. _2: ../../_static/marco_master.pdf

Basis-set generation
--------------------

In order to perform an LCAO calculation, a basis-set must be generated
for every element in your system. This can be done by using the
:command:`gpaw-basis` tool, located in your
:file:`{gpaw-directory}/tools` directory. For example, typing::

  $ gpaw-basis H Cl

will generate the basis-set files :file:`H.dzp.basis` and
:file:`Cl.dzp.basis` for hydrogen and chlorine with sensible default
parameters. Note that :file:`dzp` stands for ``double zeta polarized``
which is the default basis-set type. The basis-set should be placed in
the same directory as the GPAW setups
(see :ref:`installation of paw datasets` for details).
For a complete list of the parameters do::

  $ gpaw-basis --help

For technical reasons, the basis set generator always generates the
corresponding PAW, even if the latter exists on the user's system.
Use the ``--save-setup`` option to save the calculated setup along with the
basis set.

Running a calculation
---------------------

In order to run an LCAO calculation, the ``lcao`` mode and a basis-set
should be set in the calculator::

  >>> calc = GPAW(mode='lcao',
  >>>             basis='dzp',
  >>>             ...)

The calculator can then be used in the usual way.  The ``basis``
keyword accepts the same types of values as the ``setups`` keyword,
such as ``basis={'H' : 'dzp', 'O' : 'mine', 'C' : 'szp'}``.

For larger systems, to get good performance, be sure to enable ScaLAPACK
to parallelize the cubic-scaling diagonalization step and distribute
many matrices.  If possible, install and enable Elpa [Elpa]_ to further save
time.  See the :ref:` parallel keyword <manual_parallel>`.


Example
-------

The following example will relax a water molecule using the LCAO
calculator. The ``QuasiNewton`` minimizer will use the forces
calculated using the localized basis set.

.. literalinclude:: lcao_h2o.py

It is possible to switch to the Finite Difference mode and further
relax the structure simply by doing::

  >>> calc.set(mode='fd')
  >>> dyn.run(fmax=0.05)

More on basis sets
------------------

A minimal basis set consists of one atomic orbital-like function for
each valence state of the atom.  Extra radial functions can be added
to improve the span of the basis; basis sets are called *single-zeta*
(sz), *double-zeta* (dz) and so on, depending on the number of such
radial functions per valence state.

It is normally desirable to add a basis function corresponding to the
lowest unoccupied angular momentum quantum number.  This is called a
*polarization* function.

*Double-zeta polarized* basis sets are normally required *and*
sufficient to obtain results of reasonable accuracy; they are also the
basis type generated by default.

A dzp basis set for nitrogen will have 2s and 2p valence states, each
with two radial functions, plus a polarization function of type d, for
a total of 5 distinct radial functions.  Each will be degenerate by
`2l+1`, meaning that GPAW will use a total of 13 basis functions to
represent the atom during a calculation.  Transition metals, having s-
and d-type valence states, get a p-type polarization function and thus
a total of 15 basis functions.

To plot already generated basis functions, use the
:command:`gpaw-analyse-basis` command like::

  $ gpaw-analyse-basis -f H.dzp.basis O.dzp.basis

This will plot the basis functions in the specified files.  If the ``-f`` option is not included, the script will look for the
first matching file in the GPAW setups paths, rather than the precise
specified files.  Run ``gpaw-analyse-basis --help`` for more
options.


.. _ghost-atoms:

Ghost atoms and basis set superposition errors
----------------------------------------------

In the vicinity of a surface with many basis functions, an adsorbate
can "benefit" from the degrees of freedom from the surface basis
functions, resulting in a lower energy compared to a calculation on
the isolated adsorbate and thus too strong binding energy.  This error
referred to as the *basis set superposition error*. It can be
eliminated by adding *ghost* atoms to the calculation on the isolated
adsorbate.  Ghost atoms possess basis functions as normal but do not
otherwise affect the calculation (no projectors, compensation charges
and so on), thereby ensuring that the same degrees of freedom are
available to the wave functions in any calculation.

A calculation with ghost atoms is performed precisely like a normal
calculation, in the sense that the ASE atoms object should contain all
the involved atoms including those which are ghosts, with the only
difference being that ghost atoms have their setup type set to
``ghost``.  It is stressed that the *only* difference between an
ordinary atom and the corresponding ghost atom is the setup type.

Perform a calculation using ghost copper atoms and ordinary oxygen and
hydrogen atoms::

  >>> GPAW(setups={'Cu' : 'ghost', 'O' : 'paw', 'H' : 'paw'},
           basis='dzp',
           mode='lcao',
           ...)

Perform a calculation where atom 17 and atom 42 (designated by their
indices in the ``Atoms`` object) use ordinary setups, while all other
atoms are ghosts::

  >>> GPAW(setups={'default': 'ghost', 17: 'paw', 42:'paw'},
           basis='dzp',
           mode='lcao',
           ...)

.. _poisson_performance:

Notes on performance
--------------------

For larger LCAO calculations, it is crucial to use ScaLAPACK
and recommended to also use Elpa.
See the dedicated section on :ref:`manual_ScaLAPACK` for more information.
Below are some hints on how to obtain good performance for operations not
related to ScaLAPACK.

The *only* difference between the FD (grid-based finite-difference)
and LCAO modes is the way in which pseudo wave functions are
represented.  The usual real-space grid methods are still used for the
density and potential.  The associated computations will therefore
take a larger percentage of the CPU time compared to FD mode, where
operations on the wave functions usually dominate.  Thus it makes
sense to pay some attention to the performance of these operations.

This example shows the
:ref:`most important parameters <manual_parallel>` to achieve
good performance with LCAO.  The example is actually much too small
to make much use of parallelism, but these parameters will provide good
performance for large-scale systems.

.. literalinclude:: lcao_opt.py

.. note::

   The following paragraph refers to the old ``FDPoissonSolver``.  This
   has since been replaced by ``FastPoissonSolver`` which always performs
   well, and for which the paragraph does not apply.

The multigrid method used in the FD Poisson solver relies on alternating
interpolations and restrictions of the density on grids of different
sizes.  Make sure that the grid point count along each axis is
divisible by 8, by specifying e.g. ``gpts=(96, 96, 96)`` when creating
the calculator -- this will *dramatically* reduce the number of
required Poisson iterations in large or very oblong systems in those
cases where the code would otherwise have chosen a grid point count
not divisible by 8.
By default, the FD Poisson solver uses the *Jacobi method*.  To increase
performance further use the *Gauss-Seidel* method instead, which
usually reduces the Poisson iteration count by around 40% (ideally
50%).  Again, please note that none of the above applies to the
``FastPoissonSolver`` which is now default.

Advanced basis generation
-------------------------

The class :class:`gpaw.atom.basis.BasisMaker` is the backend of the
basis generation programme.  Use this to create basis sets with
specialized parameters that cannot be set using the command line
interface.  In particular, the basis generator relies on the *setup*
generator to define the basis functions; therefore, any parameters
that apply to setup generation will equally apply to basis set
generation.

.. autoclass:: gpaw.atom.basis.BasisMaker

This example shows how to generate an RPBE double-zeta basis set for
gold, in which the otherwise empty p-state is considered a valence
state, and using a non-standard size of the augmentation sphere.

.. literalinclude:: basisgeneration.py

Miscellaneous remarks
---------------------

In FD or PW mode, a single LCAO iteration is used to initialize the wave
functions and density.  Specifying a basis to the calculator in FD
or PW mode can be used to increase the quality of the initial guess, but
does not in any other way affect the subsequent iterations::

  >>> calc = GPAW(mode='fd', basis='dzp', ...)

In either mode, if a basis is not specified to the calculator, the
calculator will use the pseudo partial waves `\tilde \phi_i^a(\mathbf
r)`, smoothly truncated to 8 Bohr radii, as a basis.  This corresponds
roughly to a single-zeta basis in most cases.  Depending on the unoccupied
states defined on the PAW setups, it may be roughly equivalent to a
single-zeta polarized basis set for certain elements.

.. [LCAO_article] A. H. Larsen, M. Vanin, J. J. Mortensen, K. S. Thygesen,
  and K. W. Jacobsen, Phys. Rev. B 80, 195112 (2009)

.. [Siesta] J.M. Soler et al.,
   J. Phys. Cond. Matter 14, 2745-2779 (2002)

.. [Elpa]  A Marek et al., J. Phys.: Condens. Matter 26 213201 (2014)