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
174 stars 136 forks source link

Using my own code for calculating dipole #5612

Closed kenan12138 closed 2 days ago

kenan12138 commented 5 days ago

Details

Hello, I used my own code and the SPIN1_CHG.cube file generated by ABACUS to calculate the dipole moment of the corresponding molecule, but the result is not entirely consistent with the one calculated by ABACUS. The values of dipole_ion_x, dipole_ion_y, and dipole_ion_z are very consistent, but there are significant discrepancies in dipole_elec_x, dipole_elec_y, and dipole_elec_z. Could you please take a look at my code and identify where the problem might be and how to correct it? I would greatly appreciate your help! Sorry I can't upload my SPIN1_CHG.cube file, it is too big.cal_dipole.zip

Have you read FAQ on the online manual http://abacus.deepmodeling.com/en/latest/community/faq.html

Task list for Issue attackers (only for developers)

kenan12138 commented 3 days ago

Can someone please help me with my problem?I would be very grateful!

WHUweiqingzhou commented 3 days ago

@ESROAMER, could you provide any suggestion?

ESROAMER commented 3 days ago

Have you tried improving the precision of the output cube?

kenan12138 commented 2 days ago

Have you tried improving the precision of the output cube? Yes i tried.You can take a look at this PPTdipole_comparison.pptx

ESROAMER commented 2 days ago

If it's not the accuracy of the charge density, then it's the precision of the integration grid causing the issue. Here is your cube file Image Using your STRU, I calculated a more precise grid spacing. Here, replace your spacing with these values, and you'll get what you're looking for.

288 0.19578348745833335 0.000000 0.000000
300 0.000000 0.19825745374666667 0.000000
240 0.000000 0.000000 0.1915394778166667
kenan12138 commented 2 days ago

If it's not the accuracy of the charge density, then it's the precision of the integration grid causing the issue. Here is your cube file Image Using your STRU, I calculated a more precise grid spacing. Here, replace your spacing with these values, and you'll get what you're looking for.

288 0.19578348745833335 0.000000 0.000000
300 0.000000 0.19825745374666667 0.000000
240 0.000000 0.000000 0.1915394778166667

Thank you very much for your insightful response. I used the values you provided and recalculated, and indeed the result is much closer to the output from abacus. Could you please let me know where I can set the parameters to achieve a more precise grid spacing?I greatly appreciate your help.

ESROAMER commented 2 days ago

ABACUS currently does not support adjusting the output precision for this part. You can modify the code at this location (https://github.com/deepmodeling/abacus-develop/blob/develop/source/module_io/write_cube.cpp#L171) and recompile the program to obtain the precision you need.

kenan12138 commented 2 days ago

ABACUS currently does not support adjusting the output precision for this part. You can modify the code at this location (https://github.com/deepmodeling/abacus-develop/blob/develop/source/module_io/write_cube.cpp#L171) and recompile the program to obtain the precision you need.

I now know how to solve the issue. Thank you once again for your help, I really appreciate it!