deepmodeling / abacus-develop

An electronic structure package based on either plane wave basis or numerical atomic orbitals.
http://abacus.ustc.edu.cn
GNU Lesser General Public License v3.0
168 stars 129 forks source link

Request: further refactor on out-dated functions write_chg_r_1 and those similar #5209

Open kirk0830 opened 5 days ago

kirk0830 commented 5 days ago

For this function, I have comments in mainly two aspects:

  1. the function name seems not clear enough, and probably is not an appropriate enough choice. (1) If this is really write a file of charge density, then it should not be used to write other things. Obviously you want this function to write cube file for wavefunction too, so it will be better if you change the name to something like "write_vdata_cube" which means writing the volumetric data to cube file. (2) the suffix "r_1" is confusing...I can understand the "r" denotes realspace or something relevant, but what about "_1"? If it is merely for distinguishing this function from other similar implementation(s), I will say it cannot be a good idea.
  2. Please take care of the precision of data. You can dump cube from other software, see how many digits there are for each line, for instance, the voxel, the grid data, etc. You should leave a degree of freedom here to admit user change the precision of cube file, like how the charge density is printed. I suggest you use our formatter library to explicitly control the precision of each line, like
    
    #include "module_base/formatter.h"

const std::string cube; // will be initialized as empty // now print the voxel lines (in total 3) cube += FmtCore::format("%d %10.8f %10.8f %10.8f", nx, dxx, dxy, dxz); cube += //...



_Originally posted by @kirk0830 in https://github.com/deepmodeling/abacus-develop/pull/5140#discussion_r1767814533_
WHUweiqingzhou commented 3 days ago

@AsTonyshment, could you have further refactor plan?

WHUweiqingzhou commented 3 days ago

@AsTonyshment, could you have further refactor plan?

AsTonyshment commented 3 days ago

I will handle this.