CHGCAR: Difference between revisions

From VASP Wiki
No edit summary
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 density times FFT-grid volume is written with max five 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 <math>n(r)</math> is represented on the fine FFT-grid ({{TAG|NGXF}}, {{TAG|NGYF}}, {{TAG|NGZF}}) and is multiplied by the grid volume <math>V_\mathrm{grid}=\mathrm{NGXF} \times \mathrm{NGYF} \times \mathrm{NGZF}</math>.
{{NB|mind|Because VASP internally stores <math>n(r) \times V_\mathrm{grid}</math>, remember that the charge density should be divided by the grid volume for visualization and other analysis.}}


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 iteration over NX is performed in the inner-most loop (fastest) and the loop over NZ is the outer-most (slowest).
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 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
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>.
::<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>.
The dimensions can be increased by increasing the cutoff energy ({{TAG|ENCUT}}) or explicitly by setting {{TAG|NGXF}}, {{TAG|NGYF}}, {{TAG|NGZF}}.


=== Molecular dynamics===
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
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|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.


=== Spin-polarized calculation===
::<code> WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,{{TAGBL|NGXF}}),NY=1,{{TAGBL|NGYF}}),NZ=1,{{TAGBL|NGZF}}) </code>.
In spin-polarized calculations, two sets of data are stored in the {{FILE|CHGCAR}} file.
{{NB|important|Remember that the values must be divided by the FFT-grid volume to obtain the charge density.}}
The first set contains the total charge density (spin up + spin down) and the second one is the magnetization density (spin up - spin down):
::<math>n(r)=data(r)/(NGXF*NGYF*NGZF)</math>
* structure
{{NB|warning|The augmentation occupancies are written up to the ''l''-quantum number set by the {{TAG|LMAXMIX}}.}}
* total charge density (spin up + spin down)
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.
* 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
* Magnetization density (spin up - spin down)
* augmentation occupancies
* Augmentation occupancies
* augmentation occupancies (imaginary part)
For noncollinear calculation ({{TAG|LNONCOLLINEAR}}=T), contains the total charge density and the magnetization density in the spinor basis set by {{TAG|SAXIS}}:
* magnetization density in y-direction
* Structure
* FFT-grid dimensions
* Charge density times FFT-grid volume
* Augmentation occupancies
* Augmentation occupancies (imaginary part)
* Magnetization density times FFT-grid volume **in <math>\sigma_1</math> direction**
* Augmentation occupancies
* Augmentation occupancies (imaginary part)
* Magnetization density times FFT-grid volume in <math>\sigma_2</math> direction
*  ...
*  ...
* magnetization density in z-direction
* Magnetization density times FFT-grid volume in <math>\sigma_3</math> direction
*  ....
*  ....


{{NB|tip|To improve convergence, it is recommended to set {{TAG|ICHARG}} {{=}} 1 when starting calculations repeatedly with small changes in the input parameters.}}
== 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:Files]][[Category:Input files]][[Category:Output files]]

Revision as of 08:56, 7 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 density times FFT-grid volume is written with max five 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 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 to obtain the charge density.
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
  • 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)
  • Magnetization density times FFT-grid volume **in direction**
  • Augmentation occupancies
  • Augmentation occupancies (imaginary part)
  • Magnetization density times FFT-grid volume in direction
  • ...
  • 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