Skip to content

Commit 684d868

Browse files
authored
Merge branch 'deepmodeling:develop' into dsp1
2 parents 848a52a + 2f59a6f commit 684d868

File tree

99 files changed

+1157
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1157
-376
lines changed

cmake/FindCereal.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if(NOT CEREAL_INCLUDE_DIR)
1515
include(FetchContent)
1616
FetchContent_Declare(
1717
cereal
18-
URL https://github.com/USCiLab/cereal/archive/refs/tags/v1.3.2.tar.gz
18+
URL https://codeload.github.com/USCiLab/cereal/tar.gz/master
1919
)
2020
FetchContent_Populate(cereal)
2121
set(CEREAL_INCLUDE_DIR ${cereal_SOURCE_DIR}/include)

python/pyabacus/src/ModuleNAO/py_m_nao.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,9 @@ void bind_m_nao(py::module& m)
152152
double* cvR = static_cast<double*>(pvR_info.ptr);
153153
ModuleBase::Vector3<double> vR(cvR[0], cvR[1], cvR[2]);
154154
double out[1] = {0.0};
155-
double* grad_out = nullptr;
156-
if (cal_grad)
157-
{
158-
grad_out = new double[3];
159-
}
160-
self.calculate(itype1, l1, izeta1, m1, itype2, l2, izeta2, m2, vR, out, grad_out);
155+
double grad_out[3] = {0.0, 0.0, 0.0};
156+
double* grad_ptr = cal_grad ? grad_out : nullptr;
157+
self.calculate(itype1, l1, izeta1, m1, itype2, l2, izeta2, m2, vR, out, grad_ptr);
161158
py::array_t<double> out_array(1, out);
162159
if (cal_grad)
163160
{

python/pyabacus/src/hsolver/py_diago_dav_subspace.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ class PyDiagoDavSubspace
132132
std::copy(hpsi_ptr, hpsi_ptr + nvec * ld_psi, hpsi_out);
133133
};
134134

135+
auto spsi_func = [this](const std::complex<double>* psi_in,
136+
std::complex<double>* spsi_out,
137+
const int ld_psi,
138+
const int nvec) { syncmem_op()(spsi_out, psi_in, static_cast<size_t>(ld_psi * nvec)); };
139+
135140
obj = std::make_unique<hsolver::Diago_DavSubspace<std::complex<double>, base_device::DEVICE_CPU>>(
136141
precond_vec,
137142
nband,
@@ -145,7 +150,7 @@ class PyDiagoDavSubspace
145150
nb2d
146151
);
147152

148-
return obj->diag(hpsi_func, psi, nbasis, eigenvalue, diag_ethr, scf_type);
153+
return obj->diag(hpsi_func, spsi_func, psi, nbasis, eigenvalue, diag_ethr, scf_type);
149154
}
150155

151156
private:
@@ -156,6 +161,10 @@ class PyDiagoDavSubspace
156161
int nband;
157162

158163
std::unique_ptr<hsolver::Diago_DavSubspace<std::complex<double>, base_device::DEVICE_CPU>> obj;
164+
165+
base_device::DEVICE_CPU* ctx = {};
166+
using syncmem_op = base_device::memory::
167+
synchronize_memory_op<std::complex<double>, base_device::DEVICE_CPU, base_device::DEVICE_CPU>;
159168
};
160169

161170
} // namespace py_hsolver

python/pyabacus/tests/test_m_nao.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,36 @@ def test_rc():
7373
assert orb(0,1,1).l == 1
7474
assert orb(0,2,0).l == 2
7575

76+
def test_twocenterintegrator():
77+
orb_dir = '../../../tests/PP_ORB/'
78+
file_list = ["C_gga_8au_100Ry_2s2p1d.orb", "O_gga_10au_100Ry_2s2p1d.orb"]
79+
file_list = [orb_dir + orbfile for orbfile in file_list]
80+
81+
orb = nao.RadialCollection()
82+
orb.build(2, file_list, 'o')
83+
84+
alpha = nao.RadialCollection()
85+
alpha.build(1, [file_list[0]])
86+
87+
dr = 0.01 # R spacing
88+
rmax = max(orb.rcut_max, alpha.rcut_max)
89+
cutoff = 2.0 * rmax
90+
nr = int(rmax / dr) + 1
91+
92+
orb.set_uniform_grid(True, nr, cutoff, 'i', True)
93+
alpha.set_uniform_grid(True, nr, cutoff, 'i', True)
94+
95+
sbt = base.SphericalBesselTransformer()
96+
orb.set_transformer(sbt)
97+
alpha.set_transformer(sbt)
98+
99+
integrator = nao.TwoCenterIntegrator()
100+
integrator.tabulate(orb, alpha, 'S', nr, cutoff)
76101

102+
overlap = integrator.snap(0, 0, 0, 0, 0, np.array([0.0, 0.0, 0.0]), False)
103+
assert 1 - overlap[0][0] < 1e-10
104+
overlap = integrator.snap(1, 0, 0, 0, 0, np.array([3.0, 3.0, 3.0]), False)
105+
assert abs(overlap[0][0] - 0.031136758774787342) < 1e-10
77106

78107

79108

source/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ list(APPEND device_srcs
5454
source_pw/module_pwdft/kernels/vnl_op.cpp
5555
source_base/kernels/math_ylm_op.cpp
5656
source_hamilt/module_xc/kernels/xc_functional_op.cpp
57+
source_pw/module_pwdft/kernels/cal_density_real_op.cpp
58+
source_pw/module_pwdft/kernels/mul_potential_op.cpp
59+
source_pw/module_pwdft/kernels/vec_mul_vec_complex_op.cpp
60+
source_pw/module_pwdft/kernels/exx_cal_energy_op.cpp
5761
)
5862

5963
if(USE_CUDA)
@@ -80,6 +84,10 @@ if(USE_CUDA)
8084
source_base/kernels/cuda/math_kernel_op.cu
8185
source_base/kernels/cuda/math_kernel_op_vec.cu
8286
source_hamilt/module_xc/kernels/cuda/xc_functional_op.cu
87+
source_pw/module_pwdft/kernels/cuda/cal_density_real_op.cu
88+
source_pw/module_pwdft/kernels/cuda/mul_potential_op.cu
89+
source_pw/module_pwdft/kernels/cuda/vec_mul_vec_complex.cu
90+
source_pw/module_pwdft/kernels/cuda/exx_cal_energy_op.cu
8391
)
8492
endif()
8593

source/Makefile.Objects

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ OBJS_HAMILT=hamilt_pw.o\
342342
velocity_pw.o\
343343
radial_proj.o\
344344
exx_helper.o\
345+
vec_mul_vec_complex_op.o\
346+
exx_cal_energy_op.o\
347+
cal_density_real_op.o\
348+
mul_potential_op.o\
345349

346350
OBJS_HAMILT_OF=kedf_tf.o\
347351
kedf_vw.o\

source/source_base/kernels/math_kernel_op.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "source_base/kernels/math_kernel_op.h"
2+
#include "source_base/module_external/blas_connector.h"
23

34
#include <iomanip>
45
#include <iostream>

source/source_base/kernels/math_kernel_op.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "source_base/macros.h"
77

8-
#include "source_base/module_external/blas_connector.h"
98
#include "source_base/parallel_reduce.h"
109

1110
#include "source_base/module_device/memory_op.h"

source/source_base/kernels/math_kernel_op_vec.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "source_base/kernels/math_kernel_op.h"
2+
#include "source_base/module_external/blas_connector.h"
3+
24

35
namespace ModuleBase
46
{

source/source_base/kernels/test/math_kernel_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "source_base/module_external/blas_connector.h"
21
#include "source_base/constants.h"
32
#include "source_base/module_device/memory_op.h"
43
#include "source_base/kernels/math_kernel_op.h"
4+
#include "source_base/module_external/blas_connector.h"
55

66
#include <complex>
77
#include <gtest/gtest.h>

0 commit comments

Comments
 (0)