# Charge density from Elk

This example shows the charge density of graphite using Elk and c2x.

### `elk.in`

```  tasks
0
33

avec
4.6562852   0.0000000   0.0000000
-2.3281426   4.0324612   0.0000000
0.0000000   0.0000000  12.6819520

atoms
1
'C.in'
4
0.0000000   0.0000000   0.2500000  0.0 0.0 0.0
0.3333333   0.6666667   0.2500000  0.0 0.0 0.0
0.0000000   0.0000000   0.7500000  0.0 0.0 0.0
0.6666667   0.3333333   0.7500000  0.0 0.0 0.0

plot3d
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
55 55 55

demaxbnd
3.0
```

### `C.in`

```'C'                                        : spsymb
'carbon'                                   : spname
-6.00000                                  : spzn
21894.16672                              : spmass
0.816497E-06    1.4500   32.2046   300    : sprmin, rmt, sprmax, nrmt
4                                        : spnst
1   0   1   2.00000    T                 : spn, spl, spk, spocc, spcore
2   0   1   2.00000    F
2   1   1   1.00000    F
2   1   2   1.00000    F
1                                        : apword
0.1500   0  F                             : apwe0, apwdm, apwve
0                                        : nlx
2                                        : nlorb
0   2                                    : lorbl, lorbord
0.1500   0  F                             : lorbe0, lorbdm, lorbve
0.1500   1  F
1   2                                    : lorbl, lorbord
0.1500   0  F                             : lorbe0, lorbdm, lorbve
0.1500   1  F
```

(Note this is not the `C.in` which is provided in the Elk distribution, but rather one given here.)

After Elk is run

```  \$ elk elk.in
```

c2x can be run on its output

```\$ c2x -v --xsf RHO3D.OUT rho.xsf
Closest atoms separation 1.42259 A
Cell volume 35.285744
natoms      4
First FFT grid     55 55 55
spins=1   spinors=1
Found 3D data for Density
min=0.0318241 max=417.415 sum=113028 int=23.9716
(integral is e per cell for charge and spin densities)
```

Note that c2x needs to read `GEOMETRY.OUT` in order to find the atomic positions. Also that the integral of the density, even with quite a fine grid, is still noticeably different from the expected value of 24 exactly. This is to be expected with a discretely-sampled rapidly-varying density.

To generate this, after starting xcrysden with:

```  \$ xcrysden --xsf rho.xsf
```

The Modify menu was used to change the number of units drawn to three in the X and Y directions. Then, after selecting Tools, Data Grid, and clicking OK to load the 3D data in the default manner, the isovalue was set to 0.5, and the "Expand Isosurface" settings to "separately in each direction" and 3 for X-dir, 2 for Y-dir. Finally, in the Display menu, crystal cells were turned off. A little zooming and rotation then produced the image shown.