5
$\begingroup$

Rephrasing the above, what is the content of the data in the CHGCAR file?

Is the data part shown below representative of the electron-charge density or is it the actual charge in the system and I have to divide by the volume of the unit cell to get the charge density?

64   64   64
 0.27296628474E+03 0.27129538645E+03 0.26632236747E+03 0.25816527382E+03 0.24701868651E+03
 0.23315320780E+03 0.21691723332E+03 0.19873896341E+03 0.17912393717E+03 0.15864307047E+03
 0.13790873569E+03 0.11754046377E+03 0.98125176377E+02 0.80177959210E+02 0.64108387081E+02
 0.50195641939E+02 0.38574367354E+02 0.29232778335E+02 0.22024079253E+02 0.16690923309E+02
 0.12900228129E+02 0.10283187627E+02 0.84752878195E+01 0.72047216409E+01 0.63226226628E+01
 0.57166613639E+01 0.53025284991E+01 0.50199593897E+01 0.48277275324E+01 0.46988015018E+01
 0.46162530737E+01 0.45701256193E+01 0.45552760083E+01 0.45701256193E+01 0.46162530737E+01
 0.46988015018E+01 0.48277275324E+01 0.50199593897E+01 0.53025284991E+01 0.57166613639E+01
 0.63226226628E+01 0.72047216409E+01 0.84752878195E+01 0.10283187627E+02 0.12900228129E+02
 0.16690923309E+02 0.22024079253E+02 0.29232778335E+02 0.38574367354E+02 0.50195641939E+02
 0.64108387081E+02 0.80177959210E+02 0.98125176377E+02 0.11754046377E+03 0.13790873569E+03
 0.15864307047E+03 0.17912393717E+03 0.19873896341E+03 0.21691723332E+03 0.23315320780E+03
 0.24701868651E+03 0.25816527382E+03 0.26632236747E+03 0.27129538645E+03 0.27129538645E+03
..................... over a hundred thousand lines of data
$\endgroup$
3
  • 1
    $\begingroup$ +1. Welcome back! Long time no see. I have commented out the second question due to our one question per post policy, you can ask it as a separate question with the software-recommendations tag. $\endgroup$ Oct 13, 2023 at 17:11
  • 1
    $\begingroup$ Your new edit added "in Python" to the title, but you still have the Fortran tag included, suggesting that originally you wanted something in either Python or Fortran? Does this mean that you found a Fortran solution and now just need a Python solution? $\endgroup$ Oct 13, 2023 at 21:52
  • 2
    $\begingroup$ @Magic_Number no it does not $\endgroup$
    – Pranoy Ray
    Oct 14, 2023 at 13:00

1 Answer 1

1
$\begingroup$

You can simply use ASE to read CHGCAR file by ase.calculators.vasp.VaspChargeDensity:

from ase.calculators.vasp import VaspChargeDensity

vcd = VaspChargeDensity('CHGCAR')
charge_density = vcd.chg
$\endgroup$
3
  • $\begingroup$ But how do I know that ase has a valid code to extract the charge density matrix as is? I have used this before, but what is its validity? I used three different packages to extract a sample CHGCAR, here's how much they varied: ASE: The charge density data has a range of 0.046 --> 7.027 e-/Ang^3 PyMatgen(total): The charge density data has a range of 1.854 --> 284.480 e-/Ang^3 PyMatgen(diff): The charge density data has a range of -0.000 --> 0.000 e-/Ang^3 JARVIS: The charge density data has a range of 0.046 --> 7.027 e-/Ang^3 $\endgroup$
    – Pranoy Ray
    Oct 15, 2023 at 0:32
  • 4
    $\begingroup$ That the read charge density integrates to the expected number of electrons is a simple check. $\endgroup$
    – Ian Bush
    Oct 15, 2023 at 7:42
  • $\begingroup$ So say I have a simple cubic calcium sample with (1/8th) of each atom in every one of the 8 corners. What should the expected number of electrons be? I am getting 10 as the expected number of electrons. I am using the formula: Electrons = vol*np.sum(ecd)/ecd.size @IanBush $\endgroup$
    – Pranoy Ray
    Oct 19, 2023 at 15:01

Not the answer you're looking for? Browse other questions tagged .