Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor&Fix: remove normalization of numerical atomic orbitals in psi_initializer #3716

Merged
merged 13 commits into from
Mar 26, 2024

Conversation

kirk0830
Copy link
Collaborator

@kirk0830 kirk0830 commented Mar 15, 2024

Result

Previous:
wannier-200
Now:
wannier-200

Reminder

  • Have you linked an issue with this pull request?
  • Have you noticed possible changes of behavior below or in the linked issue?
  • Have you explained the changes of codes in core modules of ESolver, HSolver, ElecState, Hamilt, Operator or Psi? (ignore if not applicable)

Linked Issue

Fix #3713

What's changed?

  • Change the normalization of numerical atomic orbital from incomplete |k+G>-spanned space to |r>, make it in accord with module_nao
  • Annotation change: previous annotation is somewhat difficult to read, all functions mess up with their annotations. Therefore annotations are rewritten. Additionally more annotations are added in ESolver_KS_PW, recording present development progress and future to implement design.
  • Remove redundant virtual functions in psi_initializer: previously all functions are declared in base class psi_initializer, while it is actually not needed, because some functions will only be called inside class. After removal, now psi_initializer does not have too many functions and become much easier to maintain.
  • Rename member function of psi_initializer: cal_psig -> proj_ao_onkG, create_ovlpjlqX -> allocate_table, ...
  • Change to use STL container with algorithm: to meet the requirement of RAII, STL is used to replace all raw pointer or dynamic array based on raw pointer. This will be more parallel-safe and more strictly prevent the memory leaking problem.
  • Use smart pointer to manage memory of psig, psi_initializer in esolver: use smart pointer to manage the variable lifespan, no manual delelte is needed anymore.

Any changes of core modules? (ignore if not applicable)

  • Yes, change to use smart pointer to manage lifespan of psi_initializer in esolver_ks_pw, also add abundant annotations, illustrating consideration and develop progress.

@kirk0830 kirk0830 closed this Mar 18, 2024
@kirk0830 kirk0830 changed the title Fix: turn off normalization of pw-represented numerical atomic orbitals in towannier90 interface Refactor&Fix: move normalization of numerical atomic orbitals from G to r space Mar 19, 2024
@kirk0830 kirk0830 reopened this Mar 19, 2024
@kirk0830 kirk0830 marked this pull request as draft March 19, 2024 10:48
@kirk0830 kirk0830 marked this pull request as ready for review March 20, 2024 06:40
@kirk0830 kirk0830 added Bugs (Exclude input and output) Bugs that only solvable with sufficient knowledge of DFT Feature Discussed The features will be discussed first but will not be implemented soon labels Mar 20, 2024
@kirk0830 kirk0830 changed the title Refactor&Fix: move normalization of numerical atomic orbitals from G to r space Refactor&Fix: remove normalization of numerical atomic orbitals in psi_initializer Mar 22, 2024
Copy link
Collaborator

@dyzheng dyzheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this PR affect the result of examples/wannier90 or examples/berryphase ?

@kirk0830
Copy link
Collaborator Author

Will this PR affect the result of examples/wannier90 or examples/berryphase ?

@dyzheng for wannier90, I guess you mean examples/interface_wannier90. If so, my answer would be yes, the result I posted is the comparison between before and after removal of normalization after projecting onto |k+G> basis.
For berry phase, I am not sure about the reference value, but I had a look into the TIME_STATISTICS table in running_nscf.log, I did not find the psi_initializer_nao related items:

TIME STATISTICS
------------------------------------------------------------------------------------
     CLASS_NAME                 NAME            TIME(Sec)  CALLS   AVG(Sec) PER(%)
------------------------------------------------------------------------------------
                     total                        5.03           7   0.72   100.00
Driver               reading                      0.00           1   0.00     0.04
Input                Init                         0.00           1   0.00     0.02
Input_Conv           Convert                      0.00           1   0.00     0.01
Driver               driver_line                  5.03           1   5.03    99.96
UnitCell             check_tau                    0.00           1   0.00     0.00
PW_Basis_Sup         setuptransform               0.01           1   0.01     0.22
PW_Basis_Sup         distributeg                  0.00           1   0.00     0.00
mymath               heapsort                     0.00           3   0.00     0.03
PW_Basis_K           setuptransform               0.02           1   0.02     0.31
PW_Basis_K           distributeg                  0.00           1   0.00     0.00
PW_Basis             setup_struc_factor           0.02           1   0.02     0.31
NOrbital_Lm          extra_uniform                0.22         661   0.00     4.41
Mathzone_Add1        SplineD2                     0.01         661   0.00     0.17
Mathzone_Add1        Cubic_Spline_Interpolation   0.07         661   0.00     1.42
ppcell_vl            init_vloc                    0.00           1   0.00     0.04
Ions                 opt_ions                     4.65           1   4.65    92.50
ESolver_KS_LCAO      othercalculation             4.65           1   4.65    92.49
ESolver_KS_LCAO      beforesolver                 0.04           1   0.04     0.73
ESolver_KS_LCAO      set_matrix_grid              0.02           1   0.02     0.48
atom_arrange         search                       0.00           1   0.00     0.01
Grid_Technique       init                         0.00           1   0.00     0.07
Grid_BigCell         grid_expansion_index         0.00           2   0.00     0.02
Record_adj           for_2d                       0.02           1   0.02     0.38
Grid_Driver          Find_atom                    0.00          55   0.00     0.01
LCAO_Hamilt          grid_prepare                 0.00           1   0.00     0.00
Veff                 initialize_HR                0.00           1   0.00     0.02
OverlapNew           initialize_SR                0.00           1   0.00     0.02
EkineticNew          initialize_HR                0.00           1   0.00     0.02
NonlocalNew          initialize_HR                0.00           1   0.00     0.10
Charge               set_rho_core                 0.00           1   0.00     0.00
ModuleIO             read_rhog                    0.00           1   0.00     0.00
Potential            init_pot                     0.06           1   0.06     1.10
Potential            update_from_charge           0.06           1   0.06     1.10
Potential            cal_fixed_v                  0.01           1   0.01     0.12
PotLocal             cal_fixed_v                  0.01           1   0.01     0.12
PW_Basis_Sup         recip2real                   0.03           6   0.00     0.56
PW_Basis_Sup         gathers_scatterp             0.00           6   0.00     0.01
Potential            cal_v_eff                    0.05           1   0.05     0.97
H_Hartree_pw         v_hartree                    0.01           1   0.01     0.16
PW_Basis_Sup         real2recip                   0.02           6   0.00     0.49
PW_Basis_Sup         gatherp_scatters             0.00           6   0.00     0.00
PotXC                cal_v_eff                    0.04           1   0.04     0.82
XC_Functional        v_xc                         0.04           1   0.04     0.82
Potential            interpolate_vrs              0.00           1   0.00     0.00
HSolverLCAO          solve                        1.67           1   1.67    33.32
HamiltLCAO           updateHk                     1.03         128   0.01    20.55
OperatorLCAO         init                         0.92         384   0.00    18.39
Veff                 contributeHR                 0.35           1   0.35     7.05
Gint_interface       cal_gint                     0.35           1   0.35     7.02
Gint_interface       cal_gint_vlocal              0.35           1   0.35     7.02
Gint_Tools           cal_psir_ylm                 0.01          51   0.00     0.12
Gint_k               transfer_pvpR                0.00           1   0.00     0.03
OverlapNew           calculate_SR                 0.09           1   0.09     1.79
OverlapNew           contributeHk                 0.02         128   0.00     0.37
EkineticNew          contributeHR                 0.20           1   0.20     3.96
EkineticNew          calculate_HR                 0.19           1   0.19     3.83
NonlocalNew          contributeHR                 0.34           1   0.34     6.69
NonlocalNew          calculate_HR                 0.34           1   0.34     6.67
OperatorLCAO         contributeHk                 0.03         128   0.00     0.67
HSolverLCAO          hamiltSolvePsiK              0.64         128   0.01    12.73
DiagoElpa            elpa_solve                   0.62         128   0.00    12.43
Local_Orbital_wfc    wfc_2d_to_grid               0.00         128   0.00     0.02
ORB_gaunt_table      init_Gaunt_CH                0.00           1   0.00     0.02
ORB_gaunt_table      Calc_Gaunt_CH                0.00        1631   0.00     0.01
ORB_gaunt_table      init_Gaunt                   0.01           1   0.01     0.13
ORB_gaunt_table      Get_Gaunt_SH                 0.00       25313   0.00     0.07
ORB_table_phi        cal_ST_Phi12_R               0.66        1617   0.00    13.11
------------------------------------------------------------------------------------

Thus I think it would not affect result of berryphase calculation inside ABACUS.

Copy link
Collaborator

@dyzheng dyzheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fixing, I think this change will not affect the result of SCF with LCAO_in_PW, and I hope it can help the correctness of wannier90 interface.

@dyzheng dyzheng merged commit 7dccf77 into deepmodeling:develop Mar 26, 2024
12 checks passed
@kirk0830 kirk0830 deleted the towannier-fix-1 branch May 27, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugs (Exclude input and output) Bugs that only solvable with sufficient knowledge of DFT Feature Discussed The features will be discussed first but will not be implemented soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There may be problems with the projection of the atomic orbital basis onto plane waves (lcao-in-pw).
4 participants