Questaal Home
Navigation

lmf in reduced dimensions

Summary

lmf can treat a system that is periodic in a plane and finite in the perpendicular direction, such as a slab, a monolayer or a surface, without periodic images along the third lattice vector. The cell contains the slab and a layer of vacuum, as in the usual supercell approach; in 2D mode the Coulomb interaction does not wrap around the cell along the third lattice vector, so a net dipole of the slab does not produce a spurious periodic-image electric field in the vacuum.

2D mode is switched on with the tag HAM_DIM_PER=2 (equivalently, HAM_DIM_TWOD=1) which also selects the slab-truncated Coulomb kernel for the electrostatic potential, as described below (token VHAR, which follows PER by default). Self-consistency requires some care with the density mixing as explained below. For a comparison of 2D and 3D results in a Ni/graphene system, see here.

A system that is periodic in one dimension only, such as an atomic chain, is treated in 1D mode (PER=1); see 1D (wire) mode and, for the margin used when the potential in the vacuum is replaced; see The margin in the slab and in the wire.

If you want to bypass the nitty-gritty of implementation, you can jump immediately to the section Getting started with a reduced-dimension geometry.

Table of Contents

What changes in 1D and 2D modes

Reduction in periodicity appears in three places:

  • Reduced periodicity in basis functions (Bloch’s theorem)
  • Reduced periodicity in the one-body Hartree potential) and associated terms in total energy
  • Reduced periodicity in the two-body exchange (Fock matrix)

The last appears only in diagrammatic methods; as of this writing only the DFT part is implemented. It will be discussed here when available. Dealing with the Hartree potential has complications because of its long ranged nature. Options to deal with in Questaal’s lmf are explained below. The same reductions apply to a system periodic in one dimension (a wire; see 1D (wire) mode).

Note: Even in reduced dimensions, 3D lattice vectors must still be input. This is because they are used in managing the size of the vacuum when calculating the Hartree (and exchange-correlation) potential. PLAT(1) and PLAT(2) refer to lattice vectors in the plane, and PLAT(3) out-of-plane. It is a requirement that PLAT(1) and PLAT(2) lie in the xy plane and that PLAT(3) point along z, whether in 2D or 1D modes. These extra lattice vectors are artificial, but needed to obtain a reliable electrostatic potential well into the vacuum.

You want to make them large enough so that the interstitial is adequately represented, but not too large as this significantly slows the calculation. In the wire case where two vectors are supplied instead of one, you also should make these vectors compatible with whatever symmetry is present in the wire. lmf has a special help mode --findmargin, that mode does not compute any electronic structure, but supplies suggested sizes of lattice vectors to yield reliable potential and exits. This switch is discussed in section on Getting started with a reduced-dimension geometry.

2D Ewald sums in the basis

The envelope functions are smoothed Hankel functions. Their Bloch sums, and the Bloch sums of the Gaussian functions needed to make matrix elements, are lattice sums that are evaluated by the Ewald method. In 3D the sums run over the three lattice vectors; in 2D mode the translations run only over the two in-plane lattice vectors, PLAT(1) and PLAT(2) (even thouhg the input file still requires three lattice vectors).

The 2D mode is turned on by HAM_DIM_PER=2 for the envelope functions, and by HAM_DIM_VHAR=1 for the Gaussian and Hankel functions that enter the electrostatic potential (see below). The Ewald parameter and the real- and reciprocal-space lattice vector lists are generated in 2D mode, from the cell area, in a separate pass of the lattice generator; the 2D lists are not subsets of the 3D ones. For a wire (PER=1) the translations run only along PLAT(3) and the lists are generated in 1D; see 1D (wire) mode.

Coulomb kernel for Hartree and Exchange interactions

The Yukawa potential, , is the bare Coulomb potential (in Ry units) screened with a Thomas-Fermi function with screening wave number , , where is the Fermi energy of etf; the Hankel energy is . It has a Fourier transform

The electrostatic potential is obtained from Poisson’s equation. For a periodic system defined by reciprocal lattice vectors , it is the product of the bare Coulomb kernel () and the density

is made from in reciprocal space because of the simple algebraic relation between and there.

In 2D, periodicity is lost and the kernel must be Fourier transformed in to yield a mixed space representation:

With periodicity, become a set of discrete points and .

This representation is not convenient for solution of Poisson’s equation, as the relation between and is no longer algebraic. By keeping the interaction only for separations between field point and source point , where and is the supercell length along , and transforming back to reciprocal space, we obtain a truncated kernel [1,2], but once again defined in 3D reciprocal space.

The integral can be carried out

On the grid of points of the supercell, with , we get . Then and so the sin term drops out and

Some observations and caveats:

  • Taking makes the bracket 1 and recovers the 3D case, .
  • The sin term vanishes only on the grid with , so the form with alone is not valid for arbitrary . Thus enters explicitly into the formula.
  • For the bare (unscreened) kernel, and . For the kernel diverges as when , with a finite remainder , so the term needs separate handling. In the DFT case the term is dropped, as in the 3D kernel.
  • With there is no divergence at . The term is for , with no divergence needed to be removed. The truncation error is only of order , because the Yukawa tail is exponentially screened. That is why the truncation matters much less than for the bare Coulomb kernel.
  • The kernel depends only on the separation , not on the absolute position. It equals the true interaction for and is zero for . Because the cell is periodic with period , a source at is seen by the field point through the periodic image of nearest to , which lies within of it. Thus the potential is not set to zero anywhere, and it is the potential of the isolated slab at when every source is within of . A source farther than is not dropped: it contributes through the wrong image, from the other side of the cell.
  • Let the nuclei of the slab have lowest and highest coordinates and , and let be the distance between them. The potential is exact for . This range has width and is non-empty only if . It includes the slab and extends a distance (not ) beyond the outermost atoms, above and below. The potential at is the same as at , so there is no distinction between the two sides of the slab. The potential is not exact only in a window of width centred on , where is the point of the cell farthest from the slab; there some sources are seen through the wrong image, and the planar average of the potential differs from that of an isolated slab. Since is the extent of the nuclei, the extent of the charge is somewhat larger, because of the density tails (and the augmentation spheres).
  • Translating all the charge rigidly along translates the potential by the same amount, since the kernel depends only on and the cell is periodic. On the real-space mesh this is exact only for translations that are a multiple of the mesh spacing.
  • For , where , continue with and take the real part, as in the principal-value prescription. Then , so the bracket oscillates in instead of decaying.

This is the exact potential of an isolated slab at every point within of all the charge, which requires the charge to be confined to a region of thickness . For a slab centred in the cell this means a vacuum of at least on each side; see above for the range of that is exact. The in-plane components decay as away from the slab, as for the true potential. The same truncation is applied to the Gaussian (compensating) charges.

The kernel is exact within of all the charge. Only in the window of width centred on (see above) does the planar average () of the truncated potential fail to be the potential of an isolated slab: some sources are seen through the wrong periodic image, so the planar average there is not the correct vacuum potential. The next section fixes this.

Planar average of the potential in the vacuum

After the smooth electrostatic potential has been transformed back to the real-space mesh, the routine smvpln2d (in fp/smves.f) replaces the planar average of the potential ( component) in the window where the kernel is not exact (see above) by a smooth continuation. The components are left alone.

  1. The slab is bounded by the outermost atoms: the largest periodic gap in z between atoms is taken to be vacuum, and the slab thickness is the distance between the atoms bounding that gap. (It is the extent of the nuclei, not of the charge.) The margin (HAM_DIM_MARGIN) stands for the extent of the charge beyond the outermost atoms. The charge is then within of the slab centre .
  2. The planar average is exact for $$z-z_\mathrm{mid}\le z_c-hz_c$$. It is left unchanged there.
    (If the cell is so short that , the unchanged region is the slab plus margin, $$z-z_\mathrm{mid}\le h$$.)
  3. In the window beyond, of width and centred at , the planar average is replaced by the constant value it has at the edge on each side, and the two values are joined by a quintic step over the central half of the window, so that the potential remains periodic and smooth.

The default margin is where is the slab thickness (the default for a wire is different; see here). The program prints the atom extent, the margin, and the step of the potential across the slab, for example

2D planar ves: atoms span z = (0.000,13.350)  margin = 4.562  zc = 22.738  replaced beyond |z-zmid| = 11.501  istl potential step = 0.068762

(the value after “replaced beyond” is ). The margin must cover the charge outside the outermost atoms: the exact region ends at from the slab centre, and no charge may lie in the replaced window. Both hold if the margin is not smaller than the true extent of the charge beyond the atoms, and not larger than ; this range is non-empty only if the cell is long enough, . The program prints a warning if the slab plus margin do not fit within . With a negative value of HAM_DIM_MARGIN the replacement is skipped. As of this writing, the effect of margin has not been adequately tested.

For a wire, the analogous replacement of the axially averaged potential is described in 1D (wire) mode, and its margin in The margin in the slab and in the wire.

The HAM_DIM tag

2D mode, and 1D mode for a wire (PER=1), is controlled by the compound tag HAM_DIM in category HAM:

HAM_DIM[per=# twod=# vhar=1 margin=# qtol=# mfix=#]
TokenArgumentsDefaultExplanation
PERi3Number of periodic dimensions; an alternative way to give TWOD. It is read first, and if it is given TWOD is not read.
3: 3D periodic boundary conditions (same as TWOD=0).
2: 2D periodic boundary conditions, a slab (same as TWOD=1).
1: 1D periodic boundary conditions, a wire (same as TWOD=2).
Sets the number of dimensions in which the lattice is periodic and the basis functions are Bloch summed.
TWODi0Read only if PER is not given.
0: 3D periodic boundary conditions.
1: 2D periodic boundary conditions with vacuum above and below the atoms.
2: 1D periodic boundary conditions (a wire along z, with vacuum around the axis); see below.
VHARisame as PER (0 for PER=3, otherwise 1)Coulomb kernel used to make the electrostatic (Hartree) potential.
0: 3D periodic boundary conditions.
1: truncated kernel: slab-truncated for PER=3 or 2 (see the discussion about reduced kernels), cylinder-truncated for PER=1 (see below). The lattice sums of the compensating densities are made in 2D (1D for PER=1), and the planar (axial for PER=1) average of the potential in the vacuum is replaced by its continuation.
MARGINrnot setUsed only when VHAR=1. Margin (a.u.) added to the slab limits when the planar average of the electrostatic potential is replaced by its vacuum continuation (see smvpln2d). For PER=1 it is added to the radius of the atoms about the axis; see below. If not set, the default is used: for the slab, where is the slab thickness and is defined above; for the wire it is taken from the density (see QTOL), and the replacement is skipped if it does not fit in the cell (below). An explicit value is always used as given. Any negative value switches the replacement off.
QTOLr5e-3Used only for PER=1 with VHAR=1, when MARGIN is not set. The default wire margin is taken from the radius outside which the charge per unit length of the smooth density (e/a.u.) is below QTOL. A smaller value gives a larger margin; see below.
MFIXi1Used only for PER=1 with VHAR=1, when MARGIN is not set.
1: the default wire margin is calculated from the density of the first iteration and kept fixed; it is stored in the rst file.
0: it is recalculated at every iteration; see below.

Example: The following fragment of a ctrl file turns on the 2D mode and keeps the default margin:

HAM     ...
        dim[per=2]

For a wire, use dim[per=1]; see 1D (wire) mode. The older form, dim[twod=1] for a slab and dim[twod=2] for a wire, is equivalent.

Geometry requirements for a slab (for a wire, see here):

  • the first two lattice vectors PLAT(1) and PLAT(2) must lie in the xy plane and PLAT(3) must be along z.
  • the slab thickness (the distance between the nuclei with the largest and smallest ) must be less than , with , with the charge confined to the slab (for a slab centred in the cell the vacuum is then at least on each side). The potential is exact within the slab and a distance beyond the outermost atoms; see the discussion about reduced kernels. The density tails count: leave at least about 5 a.u. beyond the outermost atoms within ; see here. The program warns if the room is less than twice the largest augmentation radius.

Restrictions: a homogeneous background charge and the dipole correction are not available when VHAR=1.

PER and VHAR act independently and normally you should not set VHAR: its default follows PER. The Bloch sums of the compensating densities that correct the plane-wave potential must use the same kernel as the plane-wave sums, so they follow VHAR, not PER. The geometry requirements apply when either token is 1.

The mixed settings are not normally needed. In the five-atom slab of this section (vacuum of about 32 a.u.), PER=3 and PER=2 at the same VHAR gave the same total energies, RMS DQ and forces to at least seven digits over 10 iterations, because the basis functions decay within the vacuum; PER=2 was 10–18% faster in that test, since the 2D lattice lists are much shorter. The results depend on VHAR, not on PER.

Check that the tag is read with lmf --input (prints the help for HAM_DIM_PER, HAM_DIM_TWOD, HAM_DIM_VHAR, HAM_DIM_MARGIN, HAM_DIM_QTOL and HAM_DIM_MFIX) and with --show=2 (prints what was read). The program announces the two switches in the line special: 2D, 2D-ves (2D for PER=2 and 2D-ves for VHAR=1).

Density mixing in a slab: special considerations

The density of a slab is mixed with the same algorithm as any other lmf calculation, controlled by the string ITER_MIX, but the choice of the model dielectric function that screens the density difference matters more. For slabs we recommend the option etf (Thomas-Fermi function) rather than elind (Lindhard function). The test case designed for this page uses the following

mix=a2,etf=0.83,b=0.2,n=10,k=10

together with the switch –floorxfer. Tests and tables are below. The switch blm –dim also puts etf in the mixing string, for a wire as well as a slab (1D (wire) mode).

In many systems several independent factors can be responsible for barriers to convergence. Here we cover some of the most common ones. Let be the difference between the output and input densities of an iteration. The simplest estimate for the next iteration is linear mixing, . In this expression, of is combined with . Its functionality is limited, for several reasons. The two most common ones are:

  1. The Coulomb kernel connecting and may greatly amplify for a given , for some components. This is especially the case for slab geometries. The amplification can be greatly ameliorated by screening, as this page explains. However, for low-dimensional systems available model dielectric functions can artificially cause charge to spill into the vacuum. This page explains what occurs and how to address the issue.

  2. Mixing of prior iterations. Knowledge of pairs from prior iterations can be used to greatly accelerate convergence. Questaal has two algorithms (Anderson and Broyden methods) designed to use such information for this purpose. See this page.

Why screening is important

Let be the difference between the output and input densities of an iteration. The change in the electrostatic potential caused by is (Ry units), so the small- components of have the largest effect. If the new input density is simply , these long-wavelength components make the potential, and then the output density, overshoot from one iteration to the next: charge sloshing. The cell of a slab is long in the direction perpendicular to the slab, so its smallest is small, and charge can slosh across it. The mixing step therefore replaces by , with a model dielectric function that is large at small (the “Kerker” idea; see here). In the language of the code, a screening charge is added to the output density.

Without screening the iteration for the test case is unstable even for At the smallest of the cell of this test, , so these modes are damped by that factor.

Origin of the floor

The screening charge is local in reciprocal space but nonlocal in real space. What the screening does with the differences in the slab, especially large ones, therefore affects what appears in the vacuum. The mixing step adds to the linearly mixed density the screened change . When a model is used for , some screening charge spills out into the vacuum, and creates a floor, especially when is large as it is in initial iterations. How much is spilled depends on the functional form of : The Lindhard function spills much more than the Thomas-Fermi function, as explained next, which is why it is recommended to use the latter.

The floor dies out slowly with self-consistency, because floor is removed by the mixing at a rate of per iteration. In this instance , so a single iteration reduces the floor density by only about 0.4%. A uniform shift cannot be used to remove it because the total charge must be conserved. Instead we use the algorithm activated by  –floorxfer.

Why the Thomas-Fermi function is preferred in a slab

Expressions for the Thomas-Fermi and Lindhard functions are given here.

  • For the Thomas-Fermi function is smooth, and the corresponding real-space kernel decays exponentially with the screening length . The screening charge generated in the slab does not reach far into the vacuum.
  • The Lindhard function is non-analytic at . The screening charge oscillates in sign and does not decay as a simple exponential into slab, because of that. It deposits a small spurious density in the vacuum in every iteration.

Thus, while both T-F and Lindhard functions similarly provide the key damping of the small- components of , the nonanalytic behavior of Lindhard significantly exacerbates the unwanted spillage of charge into the vacuum. T-F does not remove the floor completely though. Switch  –floorxfer explained below is designed to ameliorate this problem.

Both the Thomas-Fermi and the Lindhard model dielectric functions are defined by a single parameter, a Fermi energy (in Ry), from which the Thomas-Fermi wave number follows as . The strength of the damping is controlled by this parameter. You supply it with etf=# or elind=# in the  mix  string of ITER_MIX, as shown above. The test case compares etf = 0.4, 0.83 and 1.6. The larger the value, the higher the Fourier components that are screened. Picking it too large (small) overdamps (underdamps) the screening. You can reach a good compromise simply by addting etf to the mixing string; this selects T-F screening with the default . (Or, be fancier and choose etf=−#: this selects the default, scaled by #.) The default value itself comes from HAM_ELIND, which is unless you set it, meaning 0.7 times the free-electron gas value for the given volume and number of valence electrons (see here). For the test demonstration the default would be 0.83 Ry. The mixing string sets it explicitly with etf=0.83.

Choice of Anderson or Broyden methods to accelerate convergence.

Linear mixing can result in slow convergence, and Questaal has two accelerators that mix prior iterations of pairs, Anderson and Broyden methods. The usual default is to mix with Broyden, as the method is somewhat more sophisticated. We have found however, that it tends to be less stable, and Anderson mixing is recommended for reduced dimensional systems. When creating the input file using the blm utility, it notices when reduced dimensions are specified (--dim), and will switch the default from Broyden to Anderson mixing.

The –floorxfer and –rhopos switches

As mentioned earlier, screening via a model dielectric function can induce a spurious positive “floor” charge in the vacuum. It is also the case that spurious negative charges can appear as well, either for the same reason as the positive floor charge appears, but also because the local densities have representation in spherical harmonics. They have to be tabulated points on a (spherical) mesh to evaluate the exchange correlation energy, and because the is cut off at some maximum value, some points where the density is low might turn negative because of the approximation. Thus lmf has two switches to take care of different aspects of spurious positive or negative charges:

  • –floorxfer works in the mixing step, right after charge is mixed as described in the documentation for ITER_MIX. –floorxfer[~theta=#][~alpha=#][~pos] moves the charge that the mixing step leaves in the vacuum into the dense region, conserving the total charge. The result becomes the next input density and enters the mixing history. Only the smooth mesh density is changed. Its motivation, the derivation and its properties are given here. The defaults are and . The option ~pos also removes the negative points of the smooth density (see below).

  • –rhopos works when a density is supplied to make the potential, before the potential is built. It clips negative points of the smooth density and of the sphere (augmentation) densities, then rescales to keep the charge. The XC evaluation also uses the clipped density.

The ~pos option

The option ~pos also removes negative values of each spin density on the mesh, taking the charge they carry from the dense region (mathematics). Thus there are four possibilities

modeswitchesacts onwhat it does
A–floorxfernew input density, in the mixing stepMoves the vacuum charge into the dense region. Negative values are left alone.
B–floorxfer~posnew input density, in the mixing stepAs A, and also removes the negative points of the smooth density of each spin on the mesh, taking the charge from the dense region. The result is the input density of the next iteration and is what enters the mixing history. Only the smooth density is changed.
C–floorxfer –rhoposinput density, at the start of the iteration, before the potential is madeAs A in the mixing step. Then –rhopos removes the negative points of the smooth density and of the densities in the augmentation spheres, restoring the charge by rescaling, and the exchange-correlation potential is evaluated from the positive density.
D–floorxfer~pos –rhoposbothThe mixing step delivers an input density with no negative smooth density, so –rhopos should have little left to change on the mesh; it still covers the augmentation spheres and the density seen by the exchange-correlation potential.

These different modes are analyzed for the test case below.

Test Case : graphene on Ni

This section provides detailed tests comparing 2D and 3D, together with tests of convergence to self-consistency, for a three-layer of slab with a monolayer of C on top.

The tests compare, for the five-atom slab, starting from free atoms with mix=a2,etf=0.83,b=0.2, 100 iterations each. The four runs differ in what is done about the negative density (tests A, B, C, D as described above).

The ctrl file is generated from the init file given in the box below.

LATTICE
#       SPCGRP=
        ALAT=1  UNITS=A
        PLAT=    2.4890159    0.0000000    0.0000000
                 1.2445079    2.1555510    0.0000000
                 0.0000000    0.0000000   44.0645459
# 5 atoms, 2 species
SITE
     ATOM=Ni   X=     0.3333333    0.3333333    0.4538796
     ATOM=Ni   X=    -0.3333333    0.6666667    0.5000000
     ATOM=Ni   X=     0.0000000    0.0000000    0.5461204
     ATOM=C    X=     0.0000000    0.0000000    0.5915083
     ATOM=C    X=     0.3333333    0.3333333    0.5915083
SPEC
     NI MMOM=0,0,1
     ATOM=Ni PZ= 5.4 5.4 4.4
     ATOM=C  PZ= 3.5 3.4

Make a ctrl file with, e.g.

blm --brief --dim~twod=0 --forces --rsham~el=-.4,-1.2~npr=50 --nk~8,8,1 --gmax=18 --autobas~ehmx=-.4~eloc=-3.5~loc=5 --scala=2.4890159 --xshft=0,0,-19.9999985 --mix~nit=40~beta=0.2~imixs --omax=-.03 --mag --rseq~rmesha=.005 nig 

This places the bottom of the slab at . The ctrl file should have a line

    dim[twod={tw} vhar={vh}]

Tags are explained in this table.

Comparing 2D and 3D calculations

In 3D the periodic images of a slab with a net dipole produce a spurious electric field in the vacuum. With the truncated kernel (VHAR=1) there is no such field, so the total energy and forces differ slightly from the 3D values for such a slab, even for a thick vacuum. The following compares the two modes for a five-atom slab (two species, not mirror symmetric, with a net dipole) and a cell with a.u., in which the atoms span 13.35 a.u. along z. Both runs start from free atoms, use Anderson mixing with Thomas-Fermi screening (mix=a2,etf=0.83,b=0.2) and –floorxfer (see below); they are converged to RMS DQ of about 5×10−6 (3D, 70 iterations) and 2×10−6 (2D, 90 iterations).

3D2D
ehf (Ry)−9261.0200825−9261.0198861
ehk (Ry)−9261.0200891−9261.0199274
Maximum Harris force (mRy/au)29.329.4
Maximum eigenvalue correction (mRy/au)0.10

Dependence on the vacuum thickness

The same calculation was done for three cells that differ only in the length of the third lattice vector: 0.8, 1.0 and 1.2 times that of the cell above. The atoms (spanning 13.35 a.u. along z) and the in-plane lattice are the same. All calculations use mix=a2,etf=0.83,b=0.2 and –floorxfer, start from free atoms and were iterated 90 times (70 for the 3D run of the middle cell, which is the one used in the comparison above). Here is the span of the atoms.

L=36.4 a.u.L=45.5 a.u.L=54.6 a.u.
z_c=L/2 (a.u.)18.1922.7427.29
(z_c-t)/2: room beyond the outer atoms (a.u.)2.424.696.97
Margin used by smvpln2d (a.u.)2.424.564.56
ehf, 3D (Ry)−9261.0201123−9261.0200825not run
ehf, 2D (Ry)−9260.9891391−9261.0198861−9261.0200013
ehf 2D − 3D (mRy)+30.97+0.196
Maximum Harris force, 2D (mRy/au)46.729.429.3

It is seen that 3D is nearly independent of the length of the cell, while 2D is only so for the middle and larger cells.

There are two main possibilities: either the 2D basis set differs from the 3D basis set, with its artificial periodic images, or the differing treatment of the Hartree potentials is responsible. This can be checked by running 2D mode, but with VHAR=0. In this case, it turns out that the truncated kernel for the Hartree potential is responsible for poor agreement in the short vacuum case. The truncated Coulomb kernel is exact only for charge that is confined to a region of thickness . In the shortest cell only 2.4 a.u. are available beyond the outermost atoms, about the radius of the augmentation sphere (2.28 a.u.), so part of the density tail lies outside that region. In the middle cell there are 4.7 a.u. and in the longest 7.0 a.u.

Rule of thumb. Leave at least about 5 a.u. of vacuum beyond the outermost atoms, inside the truncation length, that is a.u., with and the span of the atoms. In this system 2.4 a.u. is not enough, and with 4.7 a.u. the energy is within 0.12 mRy and the forces within 0.10 mRy/au of those for 7.0 a.u. We did not test longer cells, so the energy at 7.0 a.u. may itself not be fully converged with respect to the length of the cell. The program prints a warning if is smaller than twice the largest augmentation radius (4.56 a.u. here). Note that this is a condition on the density and not only on the atoms.

Convergence of the density mixing in a slab

In a calculation for a slab (a cell with a large region of vacuum, in 3D or 2D mode), the density mixing algorithm can build up a small spurious density in the vacuum, a “floor”, of order 10−5 e/a.u.3. The floor is not present in the output density of the band calculation. It is made by the mixing step, and it persists because the screened RMS difference between input and output densities (printed as RMS DQ) is almost insensitive to it, so the iteration can look converged while the vacuum density is still wrong.

This section explains where the floor comes from, how to avoid it (Anderson mixing with Thomas-Fermi screening, option etf of ITER_MIX, and the switches –floorxfer and –rhopos) and shows how convergence depends on the screening parameter etf and the mixing parameter beta, in 3D and in 2D. The recommended settings are collected below. The reasoning behind etf is given above, and the mathematics of –floorxfer in the self-consistency page.

  • Anderson mixing with Thomas-Fermi screening, with etf of about 0.83 and beta between 0.1 and 0.2, for example in category ITER:

    mix=a2,etf=0.83,b=0.2,n=10,k=10
    
  • the switches –floorxfer and –rhopos on the command line. –floorxfer moves the charge that the mixing leaves in the vacuum into the dense region, and –rhopos removes negative density; they are described here, and the four ways of combining them (modes A–D, including the option –floorxfer~pos) in The ~pos option. Removing the negative density, by –rhopos or by ~pos, roughly halves the number of iterations needed in the test below: see –floor.

Do not rely on RMS DQ alone: also check that ehk and ehf agree. Do not judge forces before the iteration has converged; in the first iterations the Harris force can be particularly unreliable. You can get an estimate of how reliable the force is from the line printed in each iteration

Maximum Harris force = # mRy/au (site #)  Max eval correction = #

The eigenvalue correction is the largest correction term in the force, in the same units, and the force can be trusted only when it is smaller than the force itself. The righ-hand figure below shows how both the force and the correction evolve with iteration number. You cansee that the force stabilizes at around the 10th iteration, even though the density is fairly far from self-consistency.

–floor

Four kinds of density correction schemes were run, cases A, B, C, D as described above.

Convergence rate. Left: RMS of each iteration for runs A–D, iterations 1–80. Right: run D, iterations 1–40: RMS (log scale, left axis), and the maximum Harris force and the maximum eigenvalue correction to it (linear scale, right axis, 0–100 mRy/au. Removing the negative density, by ~pos or by –rhopos, roughly halves the number of iterations needed to bring RMS below 10−3. The gain shrinks at tighter thresholds, differs between the variants (it is largest for B), and is gone at 3×10−5. None of the variants accelerates the final approach, which is the same slow long-wavelength mode in all runs, reducing RMS by a factor of 0.92–0.96 per iteration.

Run D: energy error, RMS DQ and charge moved by –floorxfer, iterations 1-40. Left: distance of ehf and ehk from the converged ehf, ehf∞ = −9261.0199200 Ry (log scale; ehf is always below ehf∞ and ehk above it), together with RMS (log scale, right axis). Right: charge moved by –floorxfer from the vacuum to the dense region in each iteration (open symbols: moved the other way). Over these 40 iterations the deviation of the density from self-consistency, RMS , falls by nearly three orders of magnitude (from 4×10−2 to 6×10−5), while the deviations of ehf and ehk from ehf∞ fall by about four and five orders of magnitude (from 0.2 and 9 Ry to 1×10−5 and 4×10−5 Ry). The total energy is thus variational in : its error falls faster than . Similarly, the forces stabilize quickly because of the eigenvalue correction term. From iteration 10 on the maximum Harris force stays between 26 and 34 mRy/au, approximately independent of . Without the correction, the error in the force would be approximately proportional to : the correction itself, which is the size of that error, falls with .

Dependence on etf and beta

Every test was started from free atoms (no restart file, no mixing file) with mix=a2, –floorxfer and the parameters shown, for 50 iterations. The cell is a five-atom slab; the 3D and 2D cells are identical, so 2D differs only in the treatment of the Coulomb interaction (2D mode). The figure shows all 50 iterations of every test, for 3D (left) and 2D (right). The top row is the RMS DQ and the bottom row is |ΔE| = |ehk − ehf| (Ry). Colors distinguish etf (0.4 blue, 0.83 orange, 1.6 green); dashed lines are beta=0.1 and solid lines beta=0.2.

RMS DQ and |ehk-ehf| versus iteration for etf=0.4, 0.83, 1.6 and beta=0.1, 0.2, in 3D (left) and 2D (right). The convergence is similar in 3D and 2D, though the final RMS DQ is somewhat lower in 3D in every case. With beta=0.1 the convergence is smooth, with no large jumps, for every etf but slow; beta=0.2 reaches a lower RMS DQ, but less smoothly. A larger etf damps the small- components more strongly, and etf=1.6 has fewer large jumps than the smaller values (etf=0.4 and 0.83 are similar), but it slows the convergence of the energy, most clearly in 2D with etf=1.6. etf=0.83 converges the energy better than etf=1.6 and the density comparably, so it is a good compromise. Also note that with the floor removed, ehk and ehf usually agree well before the RMS DQ is small.

1D (wire) mode

PER=1 (equivalently, TWOD=2) treats a system that is periodic only along PLAT(3), such as an atomic chain, with vacuum around the axis. It is the 1D analog of the slab: the Bloch sums of the basis functions and (for VHAR=1) of the compensating densities are made in 1D, and the Coulomb kernel is truncated to a cylinder of radius , the half-length of the shortest lattice vector in the plane perpendicular to the axis. The kernel, and the steps in which it is used, are given in The smooth electrostatic potential in 2D and 1D. The potential is exact for charge within of the axis. Beyond that radius the axially averaged potential is replaced by its exterior multipole continuation (the analog of the planar average in the slab), whose fit starts at the radius of the atoms plus the margin. Unless you set HAM_DIM_MARGIN the margin is taken from the extent of the density (HAM_DIM_QTOL) and is then kept fixed (HAM_DIM_MFIX); see The margin in the slab and in the wire.

Geometry requirements: PLAT(3) must be along z and PLAT(1), PLAT(2) in the xy plane; leave at least about 5 a.u. of density-free space beyond the density tails within . A homogeneous background charge and the dipole correction are not available. lmf announces the mode in the line special: ….

Status: for a dimerized carbon chain the smooth electrostatic potential of VHAR=1 agrees with a 3D calculation in a cell three times wider to about Ry out to the cell edge. In self-consistent runs of a carbon chain in a 72 a.u. cell (with one atom displaced), the total energy agrees with the 3D calculation to a few Ry and the forces to 0.01 mRy/a.u. In a 24 a.u. cell the replacement is skipped (see below) and the energy agrees with the 3D calculation in the same cell to Ry.

The margin in the slab and in the wire

Why the potential is replaced in the vacuum. The truncated Coulomb kernel gives the correct potential only near the charge. The components that vary in the periodic directions ( for the slab, for the wire) decay exponentially away from the charge and are left alone. The average over the periodic directions ( or ) is not: in a region far from the charge (for the slab, a window of width centred on the point of the cell farthest from the slab) some sources are seen through the wrong periodic image (slab), or the potential is partly that of the neighbouring wires (wire), instead of the potential of an isolated slab or wire. lmf therefore keeps this average where it is trustworthy, close to the charge, and replaces it by its known form in the vacuum. This step is called the replacement; it is done by smvpln2d for the slab and by smvpln1d for the wire, after the smooth potential has been transformed back to the real-space mesh. It changes only the smooth potential in the vacuum, and nothing inside the region where the charge is.

What the margin does. The margin is the code’s estimate of how far the charge extends beyond the outermost atoms (the sphere radii plus the density tails). The kernel is exact at a point only if all the charge is within of it, so the margin fixes where the exact region ends, and hence where the replacement begins. Inside that region the potential is as the kernel made it; outside, it is replaced.

  • For the slab, with , the region kept is . In the window beyond (the whole of it, if the cell is tight), the average is replaced by the constant value it has at the edge of the kept region on each side, and the two values are joined by a smooth step across the window. With a cell longer than the minimum, the kernel’s own vacuum potential is therefore kept out to .
  • For the wire, the region kept is a cylinder of radius about the axis, where is the radius of the atoms about the axis and the margin. Outside the charge the axial average satisfies the 2D Laplace equation, so it is fitted, on an annulus that begins at , to plus multipole terms, and continued outward. The result is blended into the original potential over about 1 a.u. beyond and faded to the constant at , so that the potential stays periodic.

The margin is thus a statement about the density: beyond the atoms plus the margin, the charge is negligible. The replacement relies on this.

  • A margin that is too small puts the edge of the exact region, and for the wire the fit annulus, inside the tail of the density. For the slab, the tail charge beyond the margin is then seen through the wrong image at the edge of the kept region (a soft error, growing as the margin shrinks below the charge extent), and the edge value is taken where the potential is not yet exact. For the wire the fit is not harmonic: it absorbs real charge, the logarithmic coefficient becomes too large and the fit residual rises. The replacement then degrades the potential instead of repairing it, and in a self-consistent run it can slow the convergence.
  • A margin that is too large does not leave room in the cell. The limit is the same for both geometries: the extent of the charge (the slab half-thickness, or the radius of the atoms about the axis, plus the margin) must not exceed half the truncation length, or . For the slab the program warns if it is exceeded, and does nothing if no vacuum is left. For the wire the replacement is skipped, with a warning, if the margin exceeds .
  • A negative margin (HAM_DIM_MARGIN) switches the replacement off. The potential is then the one the truncated kernel gives, which is correct near the charge. In tests, energies and forces were insensitive to the replacement in a wide cell.

For this reason the margin and the cell are linked: the margin needed depends on how far the density extends, and the cell must be wide enough to hold the charge, the margin and the vacuum. The two cases differ as follows:

ItemSlabWire  
Measured fromthe outermost atomic planes, along zthe axis: (radius of the atoms about it) plus the margin gives the fit radius   
Average replacedplanar average ()axial average ()  
Replacementbeyond $$z-z_\mathrm{mid}=\max(z_c-h,h)h=t/2+m$$): the constant value at the edge on each side, joined by a quintic step across the windowa fit multipoles () on an annulus starting at , blended in over about 1 a.u. and faded to at
Default margin (a.u.)  
Basis of the defaultgeometry onlythe density: is the radius outside which the charge per unit length is below HAM_DIM_QTOL  
When calculatedat every iterationonce, then kept (HAM_DIM_MFIX=1) and stored in the restart file  
Cell too narrowthe default is reduced to fit within the replacement is skipped, with a warning, if the default exceeds   
Explicit HAM_DIM_MARGINused as given; negative switches the replacement offused as given; negative switches the replacement off  

The quantities used above are defined as follows.

Here is the slab thickness, the radius of the atoms about the axis, the mesh spacing, and the smallest radius outside which the charge per unit length, with the axial average of , is below HAM_DIM_QTOL.

If the default wire margin exceeds the cell is too narrow to leave a density-free annulus for the fit. The program then prints a warning and keeps the truncated-kernel potential; nothing is stored in this case, so the margin is calculated again at the next iteration. Forcing the replacement with a reduced margin in such a cell was found to slow the self-consistency and to degrade the energy. A default margin that fits is calculated once, on the first iteration, and kept (HAM_DIM_MFIX=1); it is stored in the restart file, so a continued run uses the same margin. This can be problematic since the self-consistent density can be more extended than the starting density: then the margin calculated earlier no longer fits the cell, and the replacement can then slow the convergence. You can surmount this by setting HAM_DIM_MFIX=0 to calculate the margin, and test whether it fits, at every iteration; the replacement is then skipped whenever it does not fit. To find the margin and the cell size it needs before running, see Getting started with a reduced-dimension geometry.

The wire default margin is taken from the density and the slab default from the sphere radii. (The construction is a heuristic one). The wire fit assumes that the exterior potential is harmonic (a constant, a logarithm and multipoles), so a fit annulus that begins inside the density tail gives a poor fit and a worse potential. The slab replacement holds the planar average at a constant and is probably less sensitive to a small remaining density, but this has not been checked. The same density criterion could be used for the slab default; it would change slab results. –findmargin already applies it to a slab, but only to report the margin and cell needed, and the default margin is unchanged.

Getting started with a reduced-dimension geometry

A wire needs a cell wide enough for the vacuum fit, and a slab needs a long enough PLAT(3); both depend on how far the density extends (see The margin in the slab and in the wire). A way to set up a calculation is:

  1. Make the input file with the tag HAM_DIM, for example with blm --dim~per=1 (see here), with a first guess for the lattice vectors. You may find it helpful to refer to the test case this page uses for benchmarking and illustrations.
  2. Run lmf --findmargin. If the vacuum is too small, or much larger than needed, scale the lattice vectors to the suggested value, or slightly more. You may want to repeat this step as there is some nonlinearity in the algorithm. You may also want to set explicitly HAM_DIM_MARGIN rather than relying on the default.
  3. Run lmfa
  4. Run lmf in the usual way

--findmargin works for a slab (PER=2) and for a wire (PER=1) when VHAR=1. It does not run the self-consistency cycle, but is intended to appropriately size the vacuum and interpolate the potential into the vacuum where the Poisson solver is not valid. From the starting density (the free-atom density, or the density in the restart file if there is one) it calculates the margin as defined above, ignoring HAM_DIM_MARGIN and any margin stored in the restart file, and checks the cell:

  • Wire: the vacuum fit has room if , so the shortest in-plane lattice vector must be at least .
  • Slab: the slab and its margin fit within the truncation length if , so the length of PLAT(3) must be at least ( is the thickness of the slab).

The program prints , the present length and and says whether the cell is large enough or too short. For a wire it also prints suggested lattice vectors in units of ALAT (PLAT(1) and PLAT(2) scaled); for a slab it prints the minimum and the present length of PLAT(3) and the vacuum they imply, but no lattice vectors. It is advisory and writes no file. Cartesian site positions are not changed (positions in crystal coordinates would have to be converted). Since depends slightly on the cell through the density, repeat the run in the new cell. If the density reaches the cell edge, is only a lower bound, and the program says so.

Dependence on the tolerance

The result of --findmargin depends on a tolerance and on a few fixed choices. When running lmf --findmargin, you can specify a tolerance yourself, e.g. lmf --findmargin~rtol=#.

  • Charge cutoff. The extent of the density is the radius (wire) or distance (slab) outside which the integral of is below HAM_DIM_QTOL. (Caution: the default value was heuristically chosen has not been fully checked.) For a wire this is a charge per unit length (e/a.u.); for a slab the same number is read as a charge per unit area (e/a.u.). A smaller value gives a larger margin and a larger minimum cell. --findmargin~rtol=# replaces it for the purposes of the test, and the program also prints a table for different choices of tolerance. The table gives the density-based margin, the margin after the floor is applied, and the minimum cell. When the floor is binding, as in the slab below, the margin and the minimum cell do not change with the tolerance, while the density-based margin does.
  • Fixed numbers. The margin is , with the mesh spacing; the wire condition has a safety factor 0.9.
  • The density. The extent is measured from , the smooth density on the mesh, so negative regions count as charge and the densities inside the augmentation spheres are not included. The free-atom density is narrower than the self-consistent one, so run --findmargin on a converged density if the cell is critical.

The smooth electrostatic potential in 2D and 1D

This section collects, in the order in which they are carried out, the steps by which lmf (routine smves in fp/smves.f) makes the electrostatic potential of the smooth density when HAM_DIM_VHAR=1, and shows how the slab (PER=2) and the wire (PER=1) differ.

The density is split into a smooth part on a uniform mesh and local parts inside the augmentation spheres. Compensating Gaussians (and the smoothed Hankel functions that represent the core densities) are added to to make , which has the same multipole moments in each sphere as the true density, so that the local parts are neutral. The potential of is the true potential in the interstitial. Write for the potential of alone.

  1. Smooth density. is Fourier transformed from the real-space mesh to . The spin densities are added, since electrostatics depends on the total density only.
  2. Potential of . Routine vesft makes for (Rydberg units). The factor is 1 in 3D. For a slab it is , and for a wire it is the cylinder factor of 1D (wire) mode; see Table below. The term is dropped as in 3D.
  3. Compensating charges. Routine vesgcm adds the Fourier transforms of (Gaussians and core Hankel functions) with the same kernel, which gives , and the integrals of and of the smoothed Hankel functions with . The same factor is used wherever the Coulomb kernel appears in reciprocal space, for example in the Harris force correction.
  4. On-site pairs. The remaining integrals, those of gaussians and the Hankel functions to obtain the potential from the compensating gaussians, , are made analytically (routine ugcomp) from Bloch sums of Gaussians and Hankel functions. is confined to the spheres only if these sums have the same periodicity as the plane-wave sums, so they are made in 2D for a slab (translations in the plane only) or in 1D for a wire (translations along PLAT(3) only), with the Ewald method in the reduced dimension. This is why VHAR, and not PER, selects them.
  5. Constant shift. The exact 2D or 1D lattice sums and the truncated plane-wave kernel (with removed) differ by a constant for each pair of on-site charges. With the integral of , the cell volume and , the shift added to the on-site potentials is for a slab (), and for a wire, with . (The wire shift comes from the logarithmic kernel of the exact 1D sums, whose divergent constant is dropped.)
  6. Mesh and constant. is scattered to the mesh and transformed to real space, and its values on the sphere boundaries are used to fix the constant potential vconst as in 3D.
  7. Vacuum. The kernel is exact only at points within (slab) or (wire) of all the charge, so the (slab) or (wire) average of the potential is not the true vacuum potential everywhere: for the slab it is wrong only in a window of width centred on the point of the cell farthest from the slab (the potential is exact for a distance beyond the outermost atoms on both sides), because some sources are seen through the wrong periodic image; for the wire it is partly the image of the neighbouring wires. This is not physical; it is an outcome of the truncated Coulomb interaction combined with the 3D periodicity of the cell. The average is replaced by its vacuum continuation: see Planar average of the potential in the vacuum and The margin in the slab and in the wire. The components with (or ) decay as (or ) and are left alone.

The table summarizes the differences.

ItemSlabWire
Periodic directionsthe plane of PLAT(1), PLAT(2)PLAT(3), along z
Truncation length half the shortest in-plane lattice vector
Truncated kernel ; for
Charge for which the potential is exactthickness (exact within of all the charge)within of the axis
Bloch sums of Gaussians and Hankel functions (ugcomp)2D Ewald1D Ewald
Constant shift of on-site pairs
Averaged component replaced in the vacuumplanar average ()axial average ()
Replacementconstant at the slab edges, joined by a quintic step (smvpln2d)multipole fit outside the margin, faded to at (smvpln1d)
Default marginfrom the muffin-tin radiifrom the density (QTOL)

References

[1] S. Ismail-Beigi, Truncation of periodic image interactions for confined systems, Phys. Rev. B73, 233103 (2006).

[2] C. A. Rozzi, D. Varsano, A. Marini, E. K. U. Gross, and A. Rubio, Exact Coulomb cutoff technique for supercell calculations, Phys. Rev. B73, 205119 (2006).