Skip to content

Conversation

@WHUweiqingzhou
Copy link
Collaborator

Fix #3363.
Now ABACUS has implemented various charge mixing methods. To avoid too many uses of if...elseif, a more general design is urgently needed. Besides that, possible new method, f.e. #3335 is also needed to be taken into consideration. To this end, I introduce two new local variables _mixing_rho_type_num and _mixing_rho_unit_num.

Notes:

_mixing_rho_type_num represents how many types of density stored in mixing data. f.e., if only mix charge density (including total density and magnetic density), this value is 1; if we also mix kinetic density, _mixing_rho_type_num will be 2.
_mixing_rho_unit_num represents how many units of density in each density type. It is 1 for nspin=1 ($\rho$); 2 for for nspin=2 ($\rho, m$); 4 for nspin=4 ($\rho,m_x,m_y,m_z$); 2 for nspin=4 using angle mixing method ($\rho,|m|$).

List of Changes

  1. add local variables _mixing_rho_type_num and _mixing_rho_unit_num in charge_mixing.h
  2. replace GlobalV::variables by using local variables in mix_rho_real()
  3. refactor Kerker_screen_real() and inner_product_real() by using _mixing_rho_type_num and _mixing_rho_unit_num

@WHUweiqingzhou WHUweiqingzhou marked this pull request as draft January 8, 2024 02:08
@WHUweiqingzhou WHUweiqingzhou deleted the refactor_mixing branch July 9, 2024 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: the charge mixing code should be refactored

1 participant