# c2x: Dimension reduction

When studying nanotubes, it can be useful to consider line plots along the radius after averaging over the length of the tube and all angles. From version 2.32, c2x can produce such radial plots for cylindrical systems.

When studying surfaces, or solids which fall naturally into planes, it can be useful to produce line plots averaged over the planes perpendicular to those lines.

Although this technique might be most useful in studying surfaces and quickly locating states which are localised around the surface, here as an example, we consider bulk graphite, and a cell file of

%BLOCK LATTICE_CART ang # angstrom units 2.139082747347564 -1.235000000000000 0.000000000000000 0.000000000000000 2.470000000000000 0.000000000000000 0.000000000000000 0.000000000000000 6.790000000000000 %ENDBLOCK LATTICE_CART %BLOCK POSITIONS_FRAC C 0.000000000000000 0.000000000000000 0.000000000000000 C 0.000000000000000 0.000000000000000 0.500000000000000 C 0.333333333333333 0.666666666666667 0.005000000000000 C 0.666666666666667 0.333333333333333 0.505000000000000 %ENDBLOCK POSITIONS_FRAC symmetry_generate kpoint_mp_grid : 1 1 1

(Note that the k point sampling is utterly inadequate for use as anything but an example.)

With four carbon atoms in the cell, and four electrons per band, the highest occupied band will be number 8. Is it evenly distributed between the two layers in the cell?

c2x -P="(0.65,0.5,0):(0.65,0.5,1):100" -B=8 --gnu C.check out.gnu gnuplot out.gnu

A plot up that randomly-chosen vertical line suggests not - the density is clearly on the layer in the middle of the cell, and not the layer at the edge. But it would be better to average over the plane, and not choose a particular location for the line. This is equivalent to changing the Fourier transform grid to have just a single cell in the directions over which we want an average. The g=0 component of an FFT is, afterall, just the average value. This is quite easy in c2x:

c2x -P="(0.65,0.5,0):(0.65,0.5,1):100" -B=8 --gnu -i=1,1,0 C.check out.gnu gnuplot out.gnu

The special value of zero as one dimension in the new FFT grid means use whatever value the old grid had. So this reduces to a column, with the same number of points in the third direction as in the original grid. The result is now independent of the position of the line, so the specification we used

-P="(0.65,0.5,0):(0.65,0.5,1):100"

will produce identical output to

-P="(0.5,0.5,0):(0.5,0.5,1):100"

or any other parallel line. Two useful abbreviations exist (from c2x 2.20). A single zero for a point stands for (0,0,0), so

-P="(0,0,0):(0,0,1):100"

may be written

-P="0:(0,0,1):100"

and the letters a, b and c stand for a line along the corresponding axis, with a number of points equal to the number of FFT grid points plus one. So, if there are 100 grid points along the c axis, then

-P="0:(0,0,1):101"

may be written as

-P=c

One can also specify atom locations rather than fractional co-ordinates, an example of this is given on the c2x and lines page.

Arguably when calculating band densities the best results are
obtained by setting the grid size to at least twice the size of the grid used
for the stored wavefunction. Here the grid used in the calculation
was 15x15x36, so one could argue for `-i=1,1,72`. This
produces a slight improvement to the shape of the peaks.

## The details

The precise details of the Fourier grid resizing can be important. The algorithm used by c2x is as follows.

If wavefunction data are being read, immediately pad the grid in any dimensions which require padding, and then IFFT to real space on that padded grid. Do not perform any truncations at this point.

At this point, if further grid size changes are required, either we have a charge density which could be moving to a coarser or finer grid, or wavefunction derived data moving to a coarser grid. In either case, FFT, pad or truncate in Fourier space as appropriate, and IFFT.

Why this sequence? If a wavefunction were to be averaged immediately on reading, then depending where its nodes are, it might well average to zero, even though its density is non zero. So truncations need to follow converting to real space and calculating densities. If a wavefunction were converted to a density before the grid was padded, this would lose the advantage of padding the grid. The wavefunction is stored "exactly" on the original grid, but its modulus squared will require a grid of twice the cut-off radius for exact storage. So padding the grid needs to precede any modulus squared operation.

## Other averaging

In a very similar fashion one can average over one dimension to reduce the data to a plane. The choice of suitable plotting program and output format may then be less clear.