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
173 stars 132 forks source link

Refactor: the force and stress calculations related to two-center integrals #4274

Closed WHUweiqingzhou closed 2 weeks ago

WHUweiqingzhou commented 5 months ago

Background

In the current code, the part related to the density matrix has already been substituted with the reconstructed HContainer module from version 3.4.0. However, other physical quantities are still utilizing the old data structures. This leads to:

  1. The new and old data structures coexist within the Force/Stress module.
  2. The old data structures related to force computation in LCAO_Matrix cannot be eliminated, taking up a significant amount of memory.

Intended file deletion:

/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp  
/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp   
/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_vl.cpp      
/module_hamilt_lcao/hamilt_lcaodft/foverlap_k.cpp     
/module_hamilt_lcao/hamilt_lcaodft/ftvnl_dphi_k.cpp   
/module_hamilt_lcao/hamilt_lcaodft/fvl_dphi_k.cpp      
/module_hamilt_lcao/hamilt_lcaodft/fvnl_dbeta_k.cpp   

Intended data deletion:

//========================================
    // FORCE
    //========================================

    //-----------------------------------------
    // force in LCAO
    // used in gamma only algorithm.
    //-----------------------------------------
    double* DSloc_x;
    double* DSloc_y;
    double* DSloc_z;

    //-----------------------------------------
    // force in LCAO
    // used in k-points algorithm.
    //-----------------------------------------
    double* DSloc_Rx;
    double* DSloc_Ry;
    double* DSloc_Rz;

    //-----------------------------------------
    // dT + part of dVNL
    // used in gamma only algorithm.
    //-----------------------------------------
    double* DHloc_fixed_x;
    double* DHloc_fixed_y;
    double* DHloc_fixed_z;

    //-----------------------------------------
    // dT + part of dVNL
    // used in kpoint algorithm.
    //-----------------------------------------
    double* DHloc_fixedR_x;
    double* DHloc_fixedR_y;
    double* DHloc_fixedR_z;

    //----------------------------------------
    // r_mu - r_nu
    //----------------------------------------

    double* DH_r;//zhengdy added 2017-07

    double* stvnl11;
    double* stvnl12;
    double* stvnl13;
    double* stvnl22;
    double* stvnl23;
    double* stvnl33;

    double* DSloc_11;
    double* DSloc_12;
    double* DSloc_13;
    double* DSloc_22;
    double* DSloc_23;
    double* DSloc_33;

    double* DHloc_fixed_11;
    double* DHloc_fixed_12;
    double* DHloc_fixed_13;
    double* DHloc_fixed_22;
    double* DHloc_fixed_23;
    double* DHloc_fixed_33;

Describe the solution you'd like

Task list only for developers

Notice Possible Changes of Behavior (Reminder only for developers)

No response

Notice any changes of core modules (Reminder only for developers)

No response

Notice Possible Changes of Core Modules (Reminder only for developers)

No response

Additional Context

No response

Task list for Issue attackers (only for developers)

maki49 commented 5 months ago

Good idea, maybe the local potential grid integration can also be moved into operator Veff and finally ftable can be deleted?

Another suggestion is that, the two common interfaces can be designed like cal_force_stress(const DensityMatrix<T>& dm) and cal_force_stress(const double** rho) declared in the base class OperatorLCAO to be overridden , while other dependences are passed into the constructor of each operator. The inspiration comes from my need to call each term twice with everything the same except for the density (matrix) in #2460.

mohanchen commented 5 months ago

How to leave extra freedom for GPU implementation of force should be considerd.