CHGCAR: Difference between revisions

From VASP Wiki
No edit summary
 
(12 intermediate revisions by 6 users not shown)
Line 1: Line 1:
The {{FILE|CHGCAR}} file stores the charge density and the PAW one-center occupancies and can be used
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}}).
for restarting VASP calculations. The {{FILE|CHG}} file also stores the charge
The {{FILE|CHGCAR}} file can be read to restart a calculation ({{TAG|ICHARG}}).
density and has a similar structure, however, {{FILE|CHG}} does not contain the PAW one-center occupancies and is mainly intended for visualization and post-processing.
{{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}}).}}
VASP creates the {{FILE|CHGCAR}} file by default, but it can be avoided by setting {{TAG|LCHARG}} = .FALSE. in the {{TAG|INCAR}} file.
The {{FILE|CHG}} file also stores the charge density without the PAW one-center occupancies and is intended for visualization and post-processing.


== Format ==  
== Format ==  
The {{FILE|CHGCAR}} consists of the following blocks:
The {{FILE|CHGCAR}} consists of the following blocks:
* structure
* Structure in {{FILE|POSCAR}} format
* charge density
* FFT-grid dimensions {{TAG|NGXF}}, {{TAG|NGYF}}, {{TAG|NGZF}}
* augmentation occupancies
* 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.  
The structure block uses the same format as the {{FILE|POSCAR}} file.
* Augmentation occupancies
The total charge density is represented on the fine FFT-grid ({{TAG|NGXF}},{{TAG|NGYF}},{{TAG|NGZF}}) and is multiplied by the cell volume, i.e., <math>n(r)* V_{\rm cell}</math>.
Thus, remember that the charge density should be divided by the cell volume for visualization.
As the density is written out 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>,
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


the iteration over NX is performed in the inner-most loop (fastest) and the loop over NZ is the outer-most (slowest).  
::<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>.
In the new versions of VASP, the values of the charge density in {{TAG|CHGCAR}} are separated by spaces and can be read format-free.
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}}).
The augmentation occupancies are written to {{TAG|CHGCAR}} up to the ''l''-quantum number, which is set by the {{TAG|LMAXMIX}} flag.
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


::<math>(N_x,N_y,N_z) \hat{=} \frac{N_x-1}{N_{GXF}}\vec{a}+\frac{N_y-1}{N_{GYF}}\vec{b}+\frac{N_z-1}{N_{GZF}}\vec{c}</math>.
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


=== Molecular dynamics===
::<code> WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,{{TAGBL|NGXF}}),NY=1,{{TAGBL|NGYF}}),NZ=1,{{TAGBL|NGZF}}) </code>.
In the case of [[:Category:Molecular dynamics|molecular-dynamics simulations]] ({{TAG|IBRION}}=0), {{FILE|CHGCAR}} contains the predicted 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|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>.}}
{{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.}}
Hence,
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.
::<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}}),


=== Spin-polarized calculation===
::<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>.
In spin-polarized calculations, two sets of data are stored in the {{FILE|CHGCAR}} file.
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.
The first set contains the total charge density (spin up + spin down) and the second one is the magnetization density (spin up - spin down):
{{NB|warning|The augmentation occupancies are written up to the ''l''-quantum number set by the {{TAG|LMAXMIX}}.}}
* structure
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.
* total charge density (spin up + spin down)
* augmentation occupancies
* magnetization density (spin up - spin down)
* augmentation occupancies


=== Noncollinear magnetism ===
=== Magnetic calculations ===
In non-collinear calculations, {{FILE|CHGCAR}} contains the total charge density and the magnetization density in the x, y, and z-direction:
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
* Structure
* total charge density
* FFT-grid dimensions
* augmentation occupancies
* Charge density times FFT-grid volume (spin up + spin down)
* augmentation occupancies (imaginary part)
* Augmentation occupancies
* magnetization density in x-direction
* FFT-grid dimensions
* augmentation occupancies
* Magnetization density (spin up - spin down)
* augmentation occupancies (imaginary part)
* Augmentation occupancies
* magnetization density in y-direction
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
*  ...
*  ...
* magnetization density in z-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}}


----
----
 
[[Category:Files]][[Category:Input files]][[Category:Output files]][[Category:Electronic ground-state properties]][[Category:Charge density]]
[[Category:Files]][[Category:Input files]][[Category:Output files]]

Latest revision as of 12:00, 11 June 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