CHGCAR: Difference between revisions

From VASP Wiki
No edit summary
No edit summary
 
(21 intermediate revisions by 6 users not shown)
Line 1: Line 1:
This file contains the lattice vectors, atomic coordinates, the total charge density multiplied by the volume <math>\rho(r)* V_{\rm cell}</math> on the fine FFT-grid (NG(X,Y,Z)F), and the PAW one-center occupancies. {{TAG|CHGCAR}} can be used to restart VASP from an existing charge density. For visualisation the {{TAG|CHG}} file should be used, since the PAW-one centre occupancies are difficult to parse. It is possible to avoid that the {{TAG|CHGCAR}} is written by setting {{TAG|LCHARGE}}=''.FALSE.'' in the {{TAG|INCAR}} file. In VASP, the density is written using the following commands in Fortran:
The {{FILE|CHGCAR}} file stores the charge density and the PAW one-center occupancies. It is written by default, but it can be avoided ({{TAG|LCHARG}}) or redirected to {{FILE|vaspwave.h5}} ({{TAG|LH5}}).
WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYZ),NZ=1,NGZC)
The {{FILE|CHGCAR}} file can be read to restart a calculation ({{TAG|ICHARG}}).
{{NB|tip|We recommend starting from the {{FILE|CHGCAR}} file when repeatedly restarting with small changes in the input parameters, e.g., the '''k'''-point mesh ({{FILE|KPOINTS}}).}}
The {{FILE|CHG}} file also stores the charge density without the PAW one-center occupancies and is intended for visualization and post-processing.


The x index is the fastest index, and the z index the slowest index. The file can be read format-free, because at least in new versions, it is guaranteed that spaces separate each
== Format ==
number. Please do not forget to divide by the volume before visualizing the file!
The {{FILE|CHGCAR}} consists of the following blocks:
* Structure in {{FILE|POSCAR}} format
* FFT-grid dimensions {{TAG|NGXF}}, {{TAG|NGYF}}, {{TAG|NGZF}}
* Charge times FFT-grid volume is written with multiple real numbers per line until all {{TAG|NGXF}}*{{TAG|NGYF}}*{{TAG|NGZF}} values of the block are written.
* Augmentation occupancies


Note that the real-space mesh (NX,NY,NZ) is uniform and spanned by the primitive lattice vectors <math>(\vec{a}, \vec{b}, \vec{c})</math>calculated from
The real-space mesh (NX,NY,NZ) is uniform and is spanned by the lattice vectors <math>\vec{a}, \vec{b}, \vec{c}</math> defined in the structure block. The coordinates of the mesh points can be restored via


For spinpolarized calculations, two sets of data can be found in the {{TAG|CHGCAR}} file. The first set contains the total charge density (spin up  plus spin down), the second one the magnetization density (spin up minus spin down). For non collinear calculations the file contains the total charge density and the magnetisation density in the x, y and z direction in this order.
::<math>(N_x,N_y,N_z) \hat{=} \frac{N_x-1}{N_{GXF}}\mathbf{a}+\frac{N_y-1}{N_{GYF}}\mathbf{b}+\frac{N_z-1}{N_{GZF}}\mathbf{c}</math>.
The dimensions can be increased by increasing the cutoff energy ({{TAG|ENCUT}}) or explicitly by setting the fine FFT-grid dimensions ({{TAG|NGXF}}, {{TAG|NGYF}}, {{TAG|NGZF}}).


For dynamic simulation ({{TAG|IBRION}}=0), the charge density on the file is the predicted charge density for the next step: i.e. it is compatible with the {{TAG|CONTCAR}} file, but incompatible with the last positions in the {{TAG|OUTCAR}} file. This allows the {{TAG|CHGCAR}} and the {{TAG|CONTCAR}} file to be used consistently for a molecular dynamics continuation job. For static calculations and relaxations ({{TAG|IBRION}}=-1,1,2) the written charge density is the self-consistent charge density for the last step and might be used e.g. for accurate band-structure calculations.
To arrange the data on the real-space grid in the unit cell, mind that the data runs fastest over NX and slowest over NZ. To be more explicit, the density is written using the following command in Fortran
 
::<code> WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,{{TAGBL|NGXF}}),NY=1,{{TAGBL|NGYF}}),NZ=1,{{TAGBL|NGZF}}) </code>.
{{NB|important|Remember that the values must be divided by the FFT-grid volume and the cell volume to obtain the charge density <math>n(r)</math> in units 1/Å<math>^3</math>.}}
Hence,
::<math>n(r)=data(r)/(V_{grid}*V_{cell}),    </math>
::<math>V_{grid} = N_{GXF}*N_{GYF}*N_{GZF},  </math>
::<math>V_{cell} = |\mathbf{a}\cdot(\mathbf{b}\times\mathbf{c})| </math>,
where <math>n(r)</math> is the charge density in units 1/Å<math>^3</math>. Sanity check: The integral of <math>n(r)</math> over the unit cell yields the number of valence electrons ({{TAG|NELECT}}),
 
::<math>\text{NELECT}=\int_{V_{cell}} n(\mathbf{r}) d^3\mathbf{r}= \sum_{N_X,N_Y,N_Z} data(N_X,N_Y,N_Z)/(N_{GXF}*N_{GYF}*N_{GZF})</math>.
By our convention, the charge density <math>n(r)</math> is in units 1/Å<math>^3</math> and **not** e/Å<math>^3</math> because the potential (e.g. {{FILE|LOCPOT}}, {{TAG|WRT_POTENTIAL}}) is assumed to be in eV. However, e<math>=1</math>, so while this convention makes the sign of <math>n(r)</math> less ambiguous, it has no effect on the numerical values.
{{NB|warning|The augmentation occupancies are written up to the ''l''-quantum number set by the {{TAG|LMAXMIX}}.}}
Restarting calculations without one-center PAW occupancy matrices up to the appropriate ''l''-quantum number leads to loss of information. This is particularly problematic for calculations with fixed charge density, e.g., band-structure calculations. See {{TAG|LMAXMIX}} for more details.
 
=== Magnetic calculations ===
For magnetic calculations, the {{FILE|CHGCAR}} file contains additional data blocks for the magnetization. In particular, for spin-polarized calculations ({{TAG|ISPIN}}=2), the first set contains the total charge density (spin up + spin down) and the second one is the magnetization density (spin up - spin down):
* Structure
* FFT-grid dimensions
* Charge density times FFT-grid volume (spin up + spin down)
* Augmentation occupancies
* FFT-grid dimensions
* Magnetization density (spin up - spin down)
* Augmentation occupancies
For noncollinear calculation ({{TAG|LNONCOLLINEAR}}=T), contains the total charge density and the magnetization density in the spinor basis set by {{TAG|SAXIS}}:
* Structure
* FFT-grid dimensions
* Charge density times FFT-grid volume
* Augmentation occupancies
* Augmentation occupancies (imaginary part)
* FFT-grid dimensions
* Magnetization density times FFT-grid volume **in <math>\sigma_1</math> direction**
* Augmentation occupancies
* Augmentation occupancies (imaginary part)
* FFT-grid dimensions
* Magnetization density times FFT-grid volume in <math>\sigma_2</math> direction
*  ...
* FFT-grid dimensions
* Magnetization density times FFT-grid volume in <math>\sigma_3</math> direction
*  ....
 
== Molecular dynamics and structure relaxation ({{TAG|IBRION}})==
In the case of [[:Category:Molecular dynamics|molecular-dynamics (MD) simulations]] ({{TAG|IBRION}}=0), {{FILE|CHGCAR}} contains the extrapolated charge density for the next step, which corresponds to the atomic structure in the {{FILE|CONTCAR}} file. Although it makes the charge density incompatible with the last atomic coordinates in the {{FILE|OUTCAR}} file, it allows one to use the {{FILE|CHGCAR}} and the {{FILE|CONTCAR}} files consistently for continuing the MD simulation.
{{NB|warning|In MD simulations, the charge density in {{FILE|CHGCAR}} is not the self-consistent charge density for the structure in the {{FILE|CONTCAR}} file. Hence, one should not perform a band-structure calculation directly after the MD simulation.}}
For static and relaxation calculations ({{TAG|IBRION}}=-1,1,2), the charge density in {{FILE|CHGCAR}} is the self-consistent charge density for the last iteration. Hence, it can be used for accurate band structure calculations.
 
== Related tags and articles ==
{{FILE|WAVECAR}},
{{FILE|CHG}},
{{TAG|LCHARG}},
{{TAG|ICHARG}},
{{TAG|LMAXMIX}}, 
FFT-grid dimensions: {{TAG|ENCUT}},{{TAG|NGXF}},{{TAG|NGYF}},{{TAG|NGZF}}


'''Mind''':  Since the charge density written to the file {{TAG|CHGCAR}} is not the self-consistent charge density for the positions on the {{TAG|CONTCAR}} file, do not perform a bandstructure calculation ({{TAG|ICHARG}}=11) directly after a dynamic simulation ({{TAG|IBRION}}=0).
----
----
[[The_VASP_Manual|Contents]]
[[Category:Files]][[Category:Input files]][[Category:Output files]]
 
[[Category:Files]]

Latest revision as of 22:44, 16 February 2024

The CHGCAR file stores the charge density and the PAW one-center occupancies. It is written by default, but it can be avoided (LCHARG) or redirected to vaspwave.h5 (LH5). The CHGCAR file can be read to restart a calculation (ICHARG).

Tip: We recommend starting from the CHGCAR file when repeatedly restarting with small changes in the input parameters, e.g., the k-point mesh (KPOINTS).

The CHG file also stores the charge density without the PAW one-center occupancies and is intended for visualization and post-processing.

Format

The CHGCAR consists of the following blocks:

  • Structure in POSCAR format
  • FFT-grid dimensions NGXF, NGYF, NGZF
  • Charge times FFT-grid volume is written with multiple real numbers per line until all NGXF*NGYF*NGZF values of the block are written.
  • Augmentation occupancies

The real-space mesh (NX,NY,NZ) is uniform and is spanned by the lattice vectors defined in the structure block. The coordinates of the mesh points can be restored via

.

The dimensions can be increased by increasing the cutoff energy (ENCUT) or explicitly by setting the fine FFT-grid dimensions (NGXF, NGYF, NGZF).

To arrange the data on the real-space grid in the unit cell, mind that the data runs fastest over NX and slowest over NZ. To be more explicit, the density is written using the following command in Fortran

WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXF),NY=1,NGYF),NZ=1,NGZF) .
Important: Remember that the values must be divided by the FFT-grid volume and the cell volume to obtain the charge density in units 1/Å.

Hence,

,

where is the charge density in units 1/Å. Sanity check: The integral of over the unit cell yields the number of valence electrons (NELECT),

.

By our convention, the charge density is in units 1/Å and **not** e/Å because the potential (e.g. LOCPOT, WRT_POTENTIAL) is assumed to be in eV. However, e, so while this convention makes the sign of less ambiguous, it has no effect on the numerical values.

Warning: The augmentation occupancies are written up to the l-quantum number set by the LMAXMIX.

Restarting calculations without one-center PAW occupancy matrices up to the appropriate l-quantum number leads to loss of information. This is particularly problematic for calculations with fixed charge density, e.g., band-structure calculations. See LMAXMIX for more details.

Magnetic calculations

For magnetic calculations, the CHGCAR file contains additional data blocks for the magnetization. In particular, for spin-polarized calculations (ISPIN=2), the first set contains the total charge density (spin up + spin down) and the second one is the magnetization density (spin up - spin down):

  • Structure
  • FFT-grid dimensions
  • Charge density times FFT-grid volume (spin up + spin down)
  • Augmentation occupancies
  • FFT-grid dimensions
  • Magnetization density (spin up - spin down)
  • Augmentation occupancies

For noncollinear calculation (LNONCOLLINEAR=T), contains the total charge density and the magnetization density in the spinor basis set by SAXIS:

  • Structure
  • FFT-grid dimensions
  • Charge density times FFT-grid volume
  • Augmentation occupancies
  • Augmentation occupancies (imaginary part)
  • FFT-grid dimensions
  • Magnetization density times FFT-grid volume **in direction**
  • Augmentation occupancies
  • Augmentation occupancies (imaginary part)
  • FFT-grid dimensions
  • Magnetization density times FFT-grid volume in direction
  • ...
  • FFT-grid dimensions
  • Magnetization density times FFT-grid volume in direction
  • ....

Molecular dynamics and structure relaxation (IBRION)

In the case of molecular-dynamics (MD) simulations (IBRION=0), CHGCAR contains the extrapolated charge density for the next step, which corresponds to the atomic structure in the CONTCAR file. Although it makes the charge density incompatible with the last atomic coordinates in the OUTCAR file, it allows one to use the CHGCAR and the CONTCAR files consistently for continuing the MD simulation.

Warning: In MD simulations, the charge density in CHGCAR is not the self-consistent charge density for the structure in the CONTCAR file. Hence, one should not perform a band-structure calculation directly after the MD simulation.

For static and relaxation calculations (IBRION=-1,1,2), the charge density in CHGCAR is the self-consistent charge density for the last iteration. Hence, it can be used for accurate band structure calculations.

Related tags and articles

WAVECAR, CHG, LCHARG, ICHARG, LMAXMIX, FFT-grid dimensions: ENCUT,NGXF,NGYF,NGZF