We all know that Vesta helps us visualize the electron clouds present in the CHGCAR data, but I am looking for a better way to process the electron-density data we get in a CHGCAR file for compact handling and eventually better understanding.
For example, I have a CHGCAR file on a 64x64x64 grid. But it is a 5 column dataset as shown below:
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
I understand that this data is written serially, and as a result there are 5 data per line. If there is a way to parse and convert this data into a 3D Matrix of shape (64,64,64), it could be better handled.
Note: This is related to my prior post What is the format of the electron-density data in a CHGCAR file?, but they are distinct questions. While the initial question was about what format was used for CHGCAR data, this particular question aims to find a post-processing method for this data.
code
block rather than a screenshot? This would help for blind people that are using screen readers, it would help with seachability, readability, reproducability, speed of loading on phones and on browsers with image blockers, etc. $\endgroup$code
block with no problem. $\endgroup$