Skip to content

Conversation

WHUweiqingzhou
Copy link
Collaborator

@WHUweiqingzhou WHUweiqingzhou commented Jan 24, 2024

Fix #3535.

The list of changes

  1. add a new input parameter mixing_dmr and corresponding UnitTests.
  2. In charge_mixing.h, add a new member Base_Mixing::Mixing_Data dmr_mdata, whose memory can be allocated by Charge_Mixing::allocate_mixing_dmr(). In SCF, Charge_Mixing::allocate_mixing_dmr() is called in ESolver_KS_LCAO::eachiterinit() as
if (GlobalV::MIXING_DMR)
{
    const elecstate::DensityMatrix<TK, double>* dm
        = dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
    int nnr_tmp = dm->get_DMR_pointer(1)->get_nnr();
    this->p_chgmix->allocate_mixing_dmr(nnr_tmp);
}
  1. In density_matrix.h, define a function DensityMatrix::save_DMR() store the current DMR before it is updated in ESolver_KS_LCAO::hamilt2density:
if (GlobalV::MIXING_RESTART > 0 && GlobalV::MIXING_DMR && iter >= GlobalV::MIXING_RESTART)
{
    elecstate::DensityMatrix<TK, double>* dm
        = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
    dm->save_DMR();
}
  1. Similar to Charge_Mixing::mix_rho(chg), define a Charge_Mixing::mix_dmr(dm), and call it in ESolver_KS_LCAO<TK, TR>::eachiterfinish(int iter):
if (GlobalV::MIXING_RESTART > 0 && iter >= GlobalV::MIXING_RESTART && GlobalV::MIXING_DMR )
{
    elecstate::DensityMatrix<TK, double>* dm
                = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
    this->p_chgmix->mix_dmr(dm);
}
  1. To avoid the failure of charge_mixing_test, I move many definitions of get-functions from .cpp into .h.

@WHUweiqingzhou WHUweiqingzhou marked this pull request as draft January 24, 2024 07:51
@WHUweiqingzhou WHUweiqingzhou marked this pull request as ready for review January 26, 2024 09:57
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.

please add documentation for new parameters

@WHUweiqingzhou
Copy link
Collaborator Author

please add documentation for new parameters

done.

@dyzheng dyzheng merged commit 2864d6e into deepmodeling:develop Jan 29, 2024
@WHUweiqingzhou WHUweiqingzhou deleted the mixing_dmr branch January 31, 2024 04:49
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.

Feature: mix density matrix by the coefficients of charge density mixing

3 participants