Closed mkhorton closed 7 years ago
It is rare you want to write a Chgcar for VASP reading. The purpose of writefile is to generate volumetric data for reading by VESTA.
Admittedly a rare issue, but I encountered this today (it's a bit off-topic for this bug report, but I'm trying to find a suitable smaller file format so we can visualize CHGCARs interactively on the web, and was trying conversions to/from this alternative format to see how bad the information loss was, when I realized that even just loading/writing a Chgcar with no changes with pymatgen wasn't working).
Though the good news with the compression is that I'm getting compressed Chgcars of the order of 50-150 kB (100-1000x compression ratio), which will be more than good enough for visualization purposes. I very much doubt they'll be good enough for VASP inputs though but I was curious to try.
What kind of compression? Honestly, if you want to compress CHGCARs, the easiest way is to reduce res. E.g., if you have a 40x40x40 resolution CHGCAR, you coarse grain it to 20x20x20. That will immediately gain 7/8 reduction.
Well, I was trying to find a format that would already work with NGL Viewer (or 3Dmol/JSmol etc.) to save any additional development time -- the author of NGL recommended an 8 bit per voxel binary format, which would be fine, ~ 1/2 MB or so, though we do lose a lot of information.
The problem with coarse-graining and visualization is that you already have to do interpolation/smoothing to construct a smooth iso-surface, and throwing away spatial resolution makes that a lot worse -- purely for visualization purposes, I think spatial resolution is more important, and voxel bit depth less so.
System
Summary
Reading a CHGCAR and then writing that same CHGCAR results in a CHGCAR that can not be read by VASP.
Example code
Tested with an
MPStaticSet
andmpr.get_structures('NaCl')[0]
as the input structure, vasp.5.4.1Error message
CHGCAR reading fails with error:
Suggested solution (if any)
It looks like this information is missing from the end (and middle) of the CHGCAR:
However, manually adding this information to the pymatgen-generated file results in VASP getting stuck on reading the CHGCAR with this message:
magnetization density of overlapping atoms calculated
Not sure what's going on here, but we should fix it to make sure
write_file
does actually produce a VASP-readable CHGCAR.