forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
363 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
source/module_hamilt_lcao/module_gint/new_grid_tech/gint_fvl_meta.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#include "module_base/array_pool.h" | ||
#include "module_base/global_function.h" | ||
#include "gint_fvl_meta.h" | ||
#include "gint_common.h" | ||
#include "phi_operator.h" | ||
|
||
namespace ModuleGint | ||
{ | ||
|
||
void Gint_fvl_meta::cal_gint() | ||
{ | ||
init_DMRGint_(); | ||
transfer_DM_to_DMGint(gint_info_, DMR_vec_, DMRGint_vec_); | ||
cal_fvl_svl_(); | ||
} | ||
|
||
void Gint_fvl_meta::init_DMRGint_() | ||
{ | ||
DMRGint_vec_.resize(nspin_); | ||
for (int is = 0; is < nspin_; is++) | ||
{ | ||
DMRGint_vec_[is] = gint_info_->get_hr<double>(); | ||
} | ||
} | ||
|
||
void Gint_fvl_meta::cal_fvl_svl_() | ||
{ | ||
#pragma omp parallel | ||
{ | ||
PhiOperator phi_op; | ||
ModuleBase::matrix* fvl_thread = nullptr; | ||
ModuleBase::matrix* svl_thread = nullptr; | ||
if(isforce_) | ||
{ | ||
fvl_thread = new ModuleBase::matrix(*fvl_); | ||
fvl_thread->zero_out(); | ||
} | ||
if(isstress_) | ||
{ | ||
svl_thread = new ModuleBase::matrix(*svl_); | ||
svl_thread->zero_out(); | ||
} | ||
#pragma omp for schedule(dynamic) | ||
for(const auto& biggrid: gint_info_->get_biggrids()) | ||
{ | ||
if(biggrid->get_atoms().size() == 0) | ||
{ | ||
continue; | ||
} | ||
phi_op.set_bgrid(biggrid); | ||
ModuleBase::Array_Pool<double> phi(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_x(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_y(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_z(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> ddphi_xx(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> ddphi_xy(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> ddphi_xz(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> ddphi_yy(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> ddphi_yz(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> ddphi_zz(phi_op.get_rows(), phi_op.get_cols()); | ||
phi_op.set_phi_dphi(phi.get_ptr_1D(), dphi_x.get_ptr_1D(), dphi_y.get_ptr_1D(), dphi_z.get_ptr_1D()); | ||
phi_op.set_ddphi(ddphi_xx.get_ptr_1D(), ddphi_xy.get_ptr_1D(), ddphi_xz.get_ptr_1D(), | ||
ddphi_yy.get_ptr_1D(), ddphi_yz.get_ptr_1D(), ddphi_zz.get_ptr_1D()); | ||
ModuleBase::Array_Pool<double> phi_vldr3(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> phi_vldr3_DM(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_x_vldr3(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_y_vldr3(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_z_vldr3(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_x_vldr3_DM(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_y_vldr3_DM(phi_op.get_rows(), phi_op.get_cols()); | ||
ModuleBase::Array_Pool<double> dphi_z_vldr3_DM(phi_op.get_rows(), phi_op.get_cols()); | ||
for (int is = 0; is < nspin_; is++) | ||
{ | ||
ModuleBase::zeros(phi_vldr3.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
ModuleBase::zeros(phi_vldr3_DM.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
ModuleBase::zeros(dphi_x_vldr3.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
ModuleBase::zeros(dphi_y_vldr3.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
ModuleBase::zeros(dphi_z_vldr3.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
ModuleBase::zeros(dphi_x_vldr3_DM.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
ModuleBase::zeros(dphi_y_vldr3_DM.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
ModuleBase::zeros(dphi_z_vldr3_DM.get_ptr_1D(), phi_op.get_rows()*phi_op.get_cols()); | ||
phi_op.phi_mul_vldr3(vr_eff_[is], dr3_, phi.get_ptr_2D(), phi_vldr3.get_ptr_2D()); | ||
phi_op.phi_mul_vldr3(vofk_[is], dr3_, dphi_x.get_ptr_2D(), dphi_x_vldr3.get_ptr_2D()); | ||
phi_op.phi_mul_vldr3(vofk_[is], dr3_, dphi_y.get_ptr_2D(), dphi_y_vldr3.get_ptr_2D()); | ||
phi_op.phi_mul_vldr3(vofk_[is], dr3_, dphi_z.get_ptr_2D(), dphi_z_vldr3.get_ptr_2D()); | ||
phi_op.phi_mul_dm(phi_vldr3.get_ptr_2D(), *DMRGint_vec_[is], false, phi_vldr3_DM.get_ptr_2D()); | ||
phi_op.phi_mul_dm(dphi_x_vldr3.get_ptr_2D(), *DMRGint_vec_[is], false, dphi_x_vldr3_DM.get_ptr_2D()); | ||
phi_op.phi_mul_dm(dphi_y_vldr3.get_ptr_2D(), *DMRGint_vec_[is], false, dphi_y_vldr3_DM.get_ptr_2D()); | ||
phi_op.phi_mul_dm(dphi_z_vldr3.get_ptr_2D(), *DMRGint_vec_[is], false, dphi_z_vldr3_DM.get_ptr_2D()); | ||
if(isforce_) | ||
{ | ||
phi_op.phi_dot_dphi(phi_vldr3_DM.get_ptr_2D(), dphi_x.get_ptr_2D(), dphi_y.get_ptr_2D(), dphi_z.get_ptr_2D(), fvl_thread); | ||
phi_op.phi_dot_dphi(dphi_x_vldr3_DM.get_ptr_2D(), ddphi_xx.get_ptr_2D(), ddphi_xy.get_ptr_2D(), ddphi_xz.get_ptr_2D(), fvl_thread); | ||
phi_op.phi_dot_dphi(dphi_y_vldr3_DM.get_ptr_2D(), ddphi_xy.get_ptr_2D(), ddphi_yy.get_ptr_2D(), ddphi_yz.get_ptr_2D(), fvl_thread); | ||
phi_op.phi_dot_dphi(dphi_z_vldr3_DM.get_ptr_2D(), ddphi_xz.get_ptr_2D(), ddphi_yz.get_ptr_2D(), ddphi_zz.get_ptr_2D(), fvl_thread); | ||
} | ||
if(isstress_) | ||
{ | ||
phi_op.phi_dot_dphi_r(phi_vldr3_DM.get_ptr_2D(), dphi_x.get_ptr_2D(), dphi_y.get_ptr_2D(), dphi_z.get_ptr_2D(), svl_thread); | ||
phi_op.phi_dot_dphi_r(dphi_x_vldr3_DM.get_ptr_2D(), ddphi_xx.get_ptr_2D(), ddphi_xy.get_ptr_2D(), ddphi_xz.get_ptr_2D(), svl_thread); | ||
phi_op.phi_dot_dphi_r(dphi_y_vldr3_DM.get_ptr_2D(), ddphi_xy.get_ptr_2D(), ddphi_yy.get_ptr_2D(), ddphi_yz.get_ptr_2D(), svl_thread); | ||
phi_op.phi_dot_dphi_r(dphi_z_vldr3_DM.get_ptr_2D(), ddphi_xz.get_ptr_2D(), ddphi_yz.get_ptr_2D(), ddphi_zz.get_ptr_2D(), svl_thread); | ||
} | ||
} | ||
} | ||
#pragma omp critical | ||
{ | ||
if(isforce_) | ||
{ | ||
fvl_[0] += fvl_thread[0]; | ||
delete fvl_thread; | ||
} | ||
if(isstress_) | ||
{ | ||
svl_[0] += svl_thread[0]; | ||
delete svl_thread; | ||
} | ||
} | ||
} | ||
} | ||
|
||
} // namespace ModuleGint |
53 changes: 53 additions & 0 deletions
53
source/module_hamilt_lcao/module_gint/new_grid_tech/gint_fvl_meta.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <vector> | ||
#include "module_hamilt_lcao/module_hcontainer/hcontainer.h" | ||
#include "module_base/matrix.h" | ||
#include "gint.h" | ||
#include "gint_info.h" | ||
|
||
namespace ModuleGint | ||
{ | ||
class Gint_fvl_meta : public Gint | ||
{ | ||
public: | ||
Gint_fvl_meta( | ||
const int nspin, | ||
const std::vector<const double*>& vr_eff, | ||
const std::vector<const double*>& vofk, | ||
const std::vector<HContainer<double>*>& DMR_vec, | ||
const bool isforce, | ||
const bool isstress, | ||
ModuleBase::matrix* fvl, | ||
ModuleBase::matrix* svl) | ||
: nspin_(nspin), vr_eff_(vr_eff), vofk_(vofk), DMR_vec_(DMR_vec), | ||
isforce_(isforce), isstress_(isstress), fvl_(fvl), svl_(svl), | ||
dr3_(gint_info_->get_mgrid_volume()) {}; | ||
|
||
void cal_gint() override; | ||
|
||
private: | ||
void init_DMRGint_(); | ||
|
||
void cal_fvl_svl_(); | ||
|
||
// input | ||
const int nspin_; | ||
std::vector<const double*> vr_eff_; | ||
std::vector<const double*> vofk_; | ||
std::vector<HContainer<double>*> DMR_vec_; | ||
const bool isforce_; | ||
const bool isstress_; | ||
|
||
// output | ||
ModuleBase::matrix* fvl_; | ||
ModuleBase::matrix* svl_; | ||
|
||
// intermediate variables | ||
std::vector<std::shared_ptr<HContainer<double>>> DMRGint_vec_; | ||
|
||
double dr3_; | ||
}; | ||
|
||
} // namespace ModuleGint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.