1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-12-22 04:13:40 +01:00

Compare commits

..

3 Commits

Author SHA1 Message Date
0c5b6834b1 Managed memory 2023-12-05 17:45:25 +01:00
36fda1d1bb Fix density matrices in SR correction 2023-11-10 14:23:26 +01:00
adec973978 Multi-state corrections 2023-11-02 12:29:53 +01:00
7 changed files with 231 additions and 231 deletions

View File

@ -138,15 +138,15 @@ void compute_h_oo_chol_gpu(gpu_data* data, int igpu)
double* d_cc_space_v_ov_chol = data[igpu].cc_space_v_ov_chol;
double* d_tau_kau;
cudaStat = cudaMalloc((void **)&d_tau_kau, cholesky_mo_num*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tau_kau, cholesky_mo_num*nV*nO * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
double* d_tmp_ovv;
cudaStat = cudaMalloc((void **)&d_tmp_ovv, nO*nV*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp_ovv, nO*nV*nV * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
double* d_tmp_vov;
cudaStat = cudaMalloc((void **)&d_tmp_vov, nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp_vov, nV*nO*nV * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -239,7 +239,7 @@ void compute_h_vo_chol_gpu(gpu_data* data, int igpu)
cublasDcopy(handle, nV*nO, d_cc_space_f_vo, 1, d_H_vo, 1);
double* d_tmp_k;
cudaStat = cudaMalloc((void **)&d_tmp_k, cholesky_mo_num * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp_k, cholesky_mo_num * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
alpha = 2.0;
@ -261,7 +261,7 @@ void compute_h_vo_chol_gpu(gpu_data* data, int igpu)
cudaFree(d_tmp_k);
double* d_tmp;
cudaStat = cudaMalloc((void **)&d_tmp, cholesky_mo_num*nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp, cholesky_mo_num*nO*nO * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
alpha = 1.0;
@ -273,7 +273,7 @@ void compute_h_vo_chol_gpu(gpu_data* data, int igpu)
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_T, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_tmp2;
cudaStat = cudaMalloc((void **)&d_tmp2, cholesky_mo_num*nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp2, cholesky_mo_num*nO*nO * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -344,11 +344,11 @@ void compute_h_vv_chol_gpu(gpu_data* data, int igpu)
double* d_cc_space_v_ov_chol = data[igpu].cc_space_v_ov_chol;
double* d_tau_kia;
cudaStat = cudaMalloc((void **)&d_tau_kia, cholesky_mo_num*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tau_kia, cholesky_mo_num*nO*nV * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
double* d_tmp_oov;
cudaStat = cudaMalloc((void **)&d_tmp_oov, nO*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp_oov, nO*nO*nV * sizeof(double), 1);
assert(cudaStat == cudaSuccess);
alpha = 1.0;
@ -433,7 +433,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
double* d_r2;
lda = nO * nO;
cudaStat = cudaMalloc((void **)&d_r2, lda * nV * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_r2, lda * nV * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cudaMemset(d_r2, 0, nO*nO*nV*nV*sizeof(double));
memset(r2, 0, nO*nO*nV*nV*sizeof(double));
@ -458,7 +458,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
double* d_H_vv = data[igpu].H_vv;
double* d_K1;
cudaStat = cudaMalloc((void **)&d_K1, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_K1, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
#pragma omp sections
@ -467,7 +467,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_J1;
cudaStat = cudaMalloc((void **)&d_J1, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_J1, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -479,7 +479,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
double* d_X_ovoo;
cudaStat = cudaMalloc((void **)&d_X_ovoo, nO*nV*nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_ovoo, nO*nV*nO*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 0.0;
beta = 1.0;
@ -502,7 +502,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
double* d_Y_ovov;
cudaStat = cudaMalloc((void **)&d_Y_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -534,7 +534,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasSetStream(handle, NULL);
double* d_tmp_cc;
cudaStat = cudaMalloc((void **)&d_tmp_cc, cholesky_mo_num*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp_cc, cholesky_mo_num*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -546,7 +546,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_T, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_J1_tmp;
cudaStat = cudaMalloc((void **)&d_J1_tmp, nV*nO*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_J1_tmp, nV*nO*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -578,7 +578,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cudaFree(d_J1_tmp);
double* d_X_voov;
cudaStat = cudaMalloc((void **)&d_X_voov, nV*nO*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_voov, nV*nO*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -612,7 +612,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasSetStream(handle, NULL);
double* d_Z_ovvo;
cudaStat = cudaMalloc((void **)&d_Z_ovvo, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Z_ovvo, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = -1.0;
@ -641,7 +641,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
}
double* d_Y_vovo;
cudaStat = cudaMalloc((void **)&d_Y_vovo, nV*nO*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y_vovo, nV*nO*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -657,7 +657,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
}
double* d_X_ovvo;
cudaStat = cudaMalloc((void **)&d_X_ovvo, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_ovvo, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -732,11 +732,11 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_X;
cudaStat = cudaMalloc((void **)&d_X, nV*nO*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X, nV*nO*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_Y;
cudaStat = cudaMalloc((void **)&d_Y, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -771,7 +771,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasSetStream(handle, NULL);
double* d_Z;
cudaStat = cudaMalloc((void **)&d_Z, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Z, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -787,7 +787,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
double* d_t1v;
cudaStat = cudaMalloc((void **)&d_t1v, cholesky_mo_num*nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_t1v, cholesky_mo_num*nO*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -799,7 +799,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_T, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_K1tmp;
cudaStat = cudaMalloc((void **)&d_K1tmp, nO*nO*nV*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_K1tmp, nO*nO*nV*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -852,7 +852,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_Y_oooo;
cudaStat = cudaMalloc((void**)&d_Y_oooo, nO*nO*nO*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_Y_oooo, nO*nO*nO*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -864,7 +864,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_A1;
cudaStat = cudaMalloc((void**)&d_A1, nO*nO*nO*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_A1, nO*nO*nO*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -916,7 +916,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_g_vir;
cudaStat = cudaMalloc((void**)&d_g_vir, nV*nV*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_g_vir, nV*nV*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasDcopy(handle, nV*nV, d_H_vv, 1, d_g_vir, 1);
@ -929,7 +929,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_tmp_k;
cudaStat = cudaMalloc((void**)&d_tmp_k, cholesky_mo_num*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_tmp_k, cholesky_mo_num*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
beta = 0.0;
@ -949,7 +949,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cudaFree(d_tmp_k);
double* d_tmp_vo;
cudaStat = cudaMalloc((void**)&d_tmp_vo, cholesky_mo_num*nV*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_tmp_vo, cholesky_mo_num*nV*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
beta = 0.0;
@ -960,7 +960,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_T, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_tmp_vo2;
cudaStat = cudaMalloc((void**)&d_tmp_vo2, cholesky_mo_num*nV*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_tmp_vo2, cholesky_mo_num*nV*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t i=0 ; i<nO ; ++i) {
cudaStreamCreate(&(stream[i]));
@ -990,7 +990,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cudaFree(d_tmp_vo2);
double* d_Y_oovv;
cudaStat = cudaMalloc((void**)&d_Y_oovv, nO*nO*nV*nV*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_Y_oovv, nO*nO*nV*nV*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
beta = 0.0;
@ -1035,12 +1035,12 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
{
double* d_g_occ;
lda = nO;
cudaStat = cudaMalloc((void **)&d_g_occ, nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_g_occ, nO*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasDcopy(handle, nO*nO, d_H_oo, 1, d_g_occ, 1);
double* d_X;
cudaStat = cudaMalloc((void **)&d_X, cholesky_mo_num*sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X, cholesky_mo_num*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 2.0;
@ -1077,7 +1077,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_X_oovv;
cudaStat = cudaMalloc((void **)&d_X_oovv, nO*nO*nV*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_oovv, nO*nO*nV*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1130,11 +1130,11 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_X_vovv;
cudaStat = cudaMalloc((void **)&d_X_vovv, nV*nO*nV*BLOCK_SIZE * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_vovv, nV*nO*nV*BLOCK_SIZE * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_Y_oovv;
cudaStat = cudaMalloc((void **)&d_Y_oovv, nO*nO*nV*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y_oovv, nO*nO*nV*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t iblock=0 ; iblock<nV ; iblock += BLOCK_SIZE) {
@ -1197,7 +1197,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_tcc2;
cudaStat = cudaMalloc((void **)&d_tcc2, cholesky_mo_num*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tcc2, cholesky_mo_num*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1209,7 +1209,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_T, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_tcc;
cudaStat = cudaMalloc((void **)&d_tcc, cholesky_mo_num*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tcc, cholesky_mo_num*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1221,7 +1221,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
double* d_X_ovvo;
cudaStat = cudaMalloc((void **)&d_X_ovvo, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_ovvo, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1265,7 +1265,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_X_oovv;
cudaStat = cudaMalloc((void **)&d_X_oovv, nO*nO*nV*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_oovv, nO*nO*nV*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1296,7 +1296,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
}
double* d_X_vovo;
cudaStat = cudaMalloc((void **)&d_X_vovo, nV*nO*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_vovo, nV*nO*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 0.0;
@ -1316,7 +1316,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasSetStream(handle, NULL);
double* d_Y_oovo;
cudaStat = cudaMalloc((void **)&d_Y_oovo, nO*nO*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y_oovo, nO*nO*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1382,12 +1382,12 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
{
double* d_J1;
lda = nO*nV;
cudaStat = cudaMalloc((void **)&d_J1, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_J1, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(lda, nV*nO, sizeof(double), J1, lda, d_J1, lda);
double* d_X_ovvo;
cudaStat = cudaMalloc((void **)&d_X_ovvo, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_ovvo, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -1411,7 +1411,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cudaFree(d_J1);
double* d_Y_voov;
cudaStat = cudaMalloc((void **)&d_Y_voov, nV*nO*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y_voov, nV*nO*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -1434,7 +1434,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasSetStream(handle, NULL);
double* d_Z_ovov;
cudaStat = cudaMalloc((void **)&d_Z_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Z_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1479,11 +1479,11 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_X_ovov;
cudaStat = cudaMalloc((void **)&d_X_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_Y_ovov;
cudaStat = cudaMalloc((void **)&d_Y_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -1516,7 +1516,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasSetStream(handle, NULL);
double* d_Z_ovov;
cudaStat = cudaMalloc((void **)&d_Z_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Z_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1562,11 +1562,11 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_X_ovov;
cudaStat = cudaMalloc((void **)&d_X_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_Y_ovov;
cudaStat = cudaMalloc((void **)&d_Y_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Y_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
@ -1600,7 +1600,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasSetStream(handle, NULL);
double* d_Z_ovov;
cudaStat = cudaMalloc((void **)&d_Z_ovov, nO*nV*nO*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_Z_ovov, nO*nV*nO*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 1.0;
@ -1648,7 +1648,7 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
double* d_tmp_cc;
lda = cholesky_mo_num * nV;
cudaStat = cudaMalloc((void **)&d_tmp_cc, lda * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp_cc, lda * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha=1.0; beta=0.0;
@ -1657,15 +1657,15 @@ void compute_r2_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, A, m, B, k, &beta, C, m);
double* d_tmp_cc2;
cudaStat = cudaMalloc((void **)&d_tmp_cc2, cholesky_mo_num*nV*sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tmp_cc2, cholesky_mo_num*nV*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_B1;
cudaStat = cudaMalloc((void**)&d_B1, nV*nV*BLOCK_SIZE*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_B1, nV*nV*BLOCK_SIZE*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_tmpB1;
cudaStat = cudaMalloc((void**)&d_tmpB1, nV*BLOCK_SIZE*nV*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_tmpB1, nV*BLOCK_SIZE*nV*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
#pragma omp for
@ -1781,7 +1781,7 @@ void compute_r1_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
double* d_r1;
lda = nO ;
cudaStat = cudaMalloc((void **)&d_r1, lda * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_r1, lda * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cudaMemset(d_r1, 0, nO*nV*sizeof(double));
memset(r1, 0, nO*nV*sizeof(double));
@ -1808,7 +1808,7 @@ void compute_r1_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDcopy(handle, nO*nV, d_cc_space_f_ov, 1, d_r1, 1);
double* d_X_oo;
cudaStat = cudaMalloc((void **)&d_X_oo, nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_oo, nO*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = -2.0;
@ -1855,7 +1855,7 @@ void compute_r1_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_X_voov;
cudaStat = cudaMalloc((void **)&d_X_voov, nV* nO* nO* nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_voov, nV* nO* nO* nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
for (size_t i=0 ; i<nV ; ++i) {
@ -1901,7 +1901,7 @@ void compute_r1_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_X_ovov;
cudaStat = cudaMalloc((void **)&d_X_ovov, nO* nV* nO* nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_X_ovov, nO* nV* nO* nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasDcopy(handle, nO*nV*nO*nV, d_cc_space_v_ovov, 1, d_X_ovov, 1);
@ -1939,7 +1939,7 @@ void compute_r1_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_T_vvoo;
cudaStat = cudaMalloc((void **)&d_T_vvoo, nV*nV*nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_T_vvoo, nV*nV*nO*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 0.0;
@ -1950,11 +1950,11 @@ void compute_r1_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
cublasDgeam(handle, CUBLAS_OP_N, CUBLAS_OP_T, nV*nV, nO*nO, &alpha, A, lda, &beta, B, ldb, C, ldc);
double* d_W_vvov;
cudaStat = cudaMalloc((void **)&d_W_vvov, nV*nV*nO*BLOCK_SIZE * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_W_vvov, nV*nV*nO*BLOCK_SIZE * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_W_vvov_tmp;
cudaStat = cudaMalloc((void **)&d_W_vvov_tmp, nV*nO*nV*BLOCK_SIZE * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_W_vvov_tmp, nV*nO*nV*BLOCK_SIZE * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
@ -2008,7 +2008,7 @@ void compute_r1_space_chol_gpu(gpu_data* data, int nO, int nV, double* t1, doubl
#pragma omp section
{
double* d_W_oovo;
cudaStat = cudaMalloc((void **)&d_W_oovo, nO*nO*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_W_oovo, nO*nO*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
alpha = 2.0;

View File

@ -36,125 +36,125 @@ gpu_data* gpu_init(
double* d_cc_space_v_oo_chol;
lda = cholesky_mo_num * nO;
cudaStat = cudaMalloc((void **)&d_cc_space_v_oo_chol, lda * nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_oo_chol, lda * nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(cholesky_mo_num*nO, nO, sizeof(double), cc_space_v_oo_chol, lda, d_cc_space_v_oo_chol, lda);
double* d_cc_space_v_ov_chol;
lda = cholesky_mo_num * nO;
cudaStat = cudaMalloc((void **)&d_cc_space_v_ov_chol, lda * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_ov_chol, lda * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(cholesky_mo_num*nO, nV, sizeof(double), cc_space_v_ov_chol, lda, d_cc_space_v_ov_chol, lda);
double* d_cc_space_v_vo_chol;
lda = cholesky_mo_num * nV;
cudaStat = cudaMalloc((void **)&d_cc_space_v_vo_chol, lda * nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_vo_chol, lda * nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(cholesky_mo_num*nV, nO, sizeof(double), cc_space_v_vo_chol, lda, d_cc_space_v_vo_chol, lda);
double* d_cc_space_v_vv_chol;
lda = cholesky_mo_num * nV;
cudaStat = cudaMalloc((void **)&d_cc_space_v_vv_chol, lda * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_vv_chol, lda * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(cholesky_mo_num*nV, nV, sizeof(double), cc_space_v_vv_chol, lda, d_cc_space_v_vv_chol, lda);
double* d_cc_space_v_oooo;
cudaStat = cudaMalloc((void**)&d_cc_space_v_oooo, nO*nO*nO*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_v_oooo, nO*nO*nO*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nO*nO, nO*nO, sizeof(double), cc_space_v_oooo, nO*nO, d_cc_space_v_oooo, nO*nO);
double* d_cc_space_v_vooo;
cudaStat = cudaMalloc((void**)&d_cc_space_v_vooo, nV*nO*nO*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_v_vooo, nV*nO*nO*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nV*nO, nO*nO, sizeof(double), cc_space_v_vooo, nV*nO, d_cc_space_v_vooo, nV*nO);
double* d_cc_space_v_voov;
cudaStat = cudaMalloc((void**)&d_cc_space_v_voov, nV*nO*nO*nV*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_v_voov, nV*nO*nO*nV*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nV*nO, nO*nV, sizeof(double), cc_space_v_voov, nV*nO, d_cc_space_v_voov, nV*nO);
double* d_cc_space_v_oovv;
cudaStat = cudaMalloc((void**)&d_cc_space_v_oovv, nO*nO*nV*nV*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_v_oovv, nO*nO*nV*nV*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nO*nO, nV*nV, sizeof(double), cc_space_v_oovv, nO*nO, d_cc_space_v_oovv, nO*nO);
double* d_cc_space_v_vvoo;
cudaStat = cudaMalloc((void**)&d_cc_space_v_vvoo, nV*nV*nO*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_v_vvoo, nV*nV*nO*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nV*nV, nO*nO, sizeof(double), cc_space_v_vvoo, nV*nV, d_cc_space_v_vvoo, nV*nV);
double* d_cc_space_v_oovo;
lda = nO*nO;
cudaStat = cudaMalloc((void **)&d_cc_space_v_oovo, nO*nO*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_oovo, nO*nO*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(lda, nV*nO, sizeof(double), cc_space_v_oovo, lda, d_cc_space_v_oovo, lda);
double* d_cc_space_v_ovvo;
lda = nO*nV;
cudaStat = cudaMalloc((void **)&d_cc_space_v_ovvo, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_ovvo, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(lda, nV*nO, sizeof(double), cc_space_v_ovvo, lda, d_cc_space_v_ovvo, lda);
double* d_cc_space_v_ovov;
lda = nO*nV;
cudaStat = cudaMalloc((void **)&d_cc_space_v_ovov, nO*nV*nV*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_ovov, nO*nV*nV*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(lda, nV*nO, sizeof(double), cc_space_v_ovov, lda, d_cc_space_v_ovov, lda);
double* d_cc_space_v_ovoo;
lda = nO*nV;
cudaStat = cudaMalloc((void **)&d_cc_space_v_ovoo, nO*nV*nO*nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_cc_space_v_ovoo, nO*nV*nO*nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(lda, nO*nO, sizeof(double), cc_space_v_ovoo, lda, d_cc_space_v_ovoo, lda);
double* d_cc_space_f_oo;
cudaStat = cudaMalloc((void**)&d_cc_space_f_oo, nO*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_f_oo, nO*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nO, nO, sizeof(double), cc_space_f_oo, nO, d_cc_space_f_oo, nO);
double* d_cc_space_f_vo;
cudaStat = cudaMalloc((void**)&d_cc_space_f_vo, nV*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_f_vo, nV*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nV, nO, sizeof(double), cc_space_f_vo, nV, d_cc_space_f_vo, nV);
double* d_cc_space_f_ov;
cudaStat = cudaMalloc((void**)&d_cc_space_f_ov, nV*nO*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_f_ov, nV*nO*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nO, nV, sizeof(double), cc_space_f_ov, nO, d_cc_space_f_ov, nO);
double* d_cc_space_f_vv;
cudaStat = cudaMalloc((void**)&d_cc_space_f_vv, nV*nV*sizeof(double));
cudaStat = cudaMallocManaged((void**)&d_cc_space_f_vv, nV*nV*sizeof(double), 1);
assert (cudaStat == cudaSuccess);
cublasSetMatrix(nV, nV, sizeof(double), cc_space_f_vv, nV, d_cc_space_f_vv, nV);
double* d_tau;
lda = nO * nO;
cudaStat = cudaMalloc((void **)&d_tau, lda * nV * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tau, lda * nV * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_tau_x;
lda = nO * nO;
cudaStat = cudaMalloc((void **)&d_tau_x, lda * nV * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_tau_x, lda * nV * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_t1;
cudaStat = cudaMalloc((void **)&d_t1, nO * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_t1, nO * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_t2;
cudaStat = cudaMalloc((void **)&d_t2, nO*nO*nV*nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_t2, nO*nO*nV*nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_H_oo;
cudaStat = cudaMalloc((void **)&d_H_oo, nO * nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_H_oo, nO * nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_H_vo;
cudaStat = cudaMalloc((void **)&d_H_vo, nV * nO * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_H_vo, nV * nO * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
double* d_H_vv;
cudaStat = cudaMalloc((void **)&d_H_vv, nV * nV * sizeof(double));
cudaStat = cudaMallocManaged((void **)&d_H_vv, nV * nV * sizeof(double), 1);
assert (cudaStat == cudaSuccess);
data[igpu].cc_space_v_oo_chol = d_cc_space_v_oo_chol;

View File

@ -16,70 +16,79 @@ BEGIN_PROVIDER [ double precision, alpha_coef, (0:1) ]
END_PROVIDER
BEGIN_PROVIDER [ double precision, alpha_coef_r, (0:1) ]
BEGIN_PROVIDER [ double precision, alpha_coef_r, (0:1,N_states) ]
implicit none
BEGIN_DOC
! SavCar-JCP-23, corrected for small mu
END_DOC
integer :: istate
double precision :: num, den
double precision :: a0, b0, delta_E, E
E = energy_mu + correction_alpha_1
do istate = 1,N_states
delta_E = (energy_mu(istate) + correction_alpha_1(istate)) - energy_mu0(istate)
a0 = delta_E * correction_mu0(istate) + 2.d0/dsqrt(dacos(-1.d0))*(delta_E - correction_mu0(istate)) * mu_erf
b0 = correction_mu0(istate)*correction_mu0(istate)
delta_E = E - energy_mu0
num = 0.319820d0 + mu_erf * (1.063846d0 + mu_erf)
den = 0.487806d0 + mu_erf * (1.375439d0 + mu_erf)
alpha_coef_r(0,istate) = (a0 + mu_erf*num)/(b0 + mu_erf*den)
a0 = delta_E * correction_mu0 + 2.d0/dsqrt(dacos(-1.d0))*(delta_E - correction_mu0) * mu_erf
b0 = correction_mu0*correction_mu0
num = 0.319820d0 + mu_erf * (1.063846d0 + mu_erf)
den = 0.487806d0 + mu_erf * (1.375439d0 + mu_erf)
alpha_coef_r(0) = (a0 + mu_erf*num)/(b0 + mu_erf*den)
num = 0.113074d0 + mu_erf * (0.638308d0 + mu_erf)
den = 0.122652d0 + mu_erf * (0.674813d0 + mu_erf)
alpha_coef_r(1) = (a0 + mu_erf*num)/(b0 + mu_erf*den)
! delta_E = (energy_mu + correction_alpha_1) - energy_mu0
! a0 = delta_E * correction_mu0 + 2.d0/dsqrt(dacos(-1.d0))*(delta_E - correction_mu0) * mu_erf
! b0 = correction_mu0*correction_mu0
num = 0.113074d0 + mu_erf * (0.638308d0 + mu_erf)
den = 0.122652d0 + mu_erf * (0.674813d0 + mu_erf)
alpha_coef_r(1,istate) = (a0 + mu_erf*num)/(b0 + mu_erf*den)
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, energy_mu0 ]
BEGIN_PROVIDER [ double precision, energy_mu0, (N_states) ]
implicit none
BEGIN_DOC
! E(mu=0)
END_DOC
integer :: l
integer :: l, istate
double precision, external :: ddot
energy_mu0 = 0.d0
do l=1,mo_num
energy_mu0 += ddot(mo_num, one_e_dm_mo(1,l), 1, mo_one_e_integrals(1,l), 1)
do istate = 1,N_states
energy_mu0(istate) = 0.d0
do l=1,mo_num
energy_mu0(istate) += ddot(mo_num, one_e_dm_mo_alpha(1,l,istate), 1, mo_one_e_integrals(1,l), 1)
energy_mu0(istate) += ddot(mo_num, one_e_dm_mo_beta(1,l,istate), 1, mo_one_e_integrals(1,l), 1)
enddo
energy_mu0(istate) = energy_mu0(istate) + nuclear_repulsion
enddo
energy_mu0 = energy_mu0 + nuclear_repulsion
END_PROVIDER
BEGIN_PROVIDER [ double precision, correction_alpha_0_r ]
BEGIN_PROVIDER [ double precision, correction_alpha_0_r, (N_states) ]
implicit none
BEGIN_DOC
! alpha_0r(mu) * <Psi(mu)|W_bar_mu|Psi(mu)>
END_DOC
integer :: k,l
integer :: k,l, istate
double precision :: c0
double precision, external :: ddot
c0 = 0.5d0 * alpha_coef_r(0)
correction_alpha_0_r = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_0_r += c0 * ddot (mo_num*mo_num, two_e_dm_mo(1,1,k,l), 1, W_bar_mu(1,1,k,l), 1)
do istate = 1,N_states
c0 = 0.5d0 * alpha_coef_r(0,istate)
correction_alpha_0_r(istate) = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_0_r += c0 * ddot (mo_num*mo_num, full_occ_2_rdm_spin_trace_mo(1,1,k,l,istate), 1, W_bar_mu(1,1,k,l), 1)
enddo
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, correction_alpha_1_r ]
BEGIN_PROVIDER [ double precision, correction_alpha_1_r, (N_states) ]
implicit none
BEGIN_DOC
! alpha_0(mu) * <Psi(mu)|W_bar_mu|Psi(mu)>_s + alpha_1(mu) * <Psi(mu)|W_bar_mu|Psi(mu)>_t
@ -87,17 +96,19 @@ BEGIN_PROVIDER [ double precision, correction_alpha_1_r ]
double precision :: c1, c0
integer :: k,l
integer :: k,l, istate
double precision, external :: ddot
c0 = 0.5d0 * alpha_coef_r(0)
c1 = 0.5d0 * alpha_coef_r(1)
do istate = 1,N_states
c0 = 0.5d0 * alpha_coef_r(0,istate)
c1 = 0.5d0 * alpha_coef_r(1,istate)
correction_alpha_1_r = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_1_r += c0 * ddot (mo_num*mo_num, two_e_dm_mo_singlet(1,1,k,l), 1, W_bar_mu(1,1,k,l), 1)
correction_alpha_1_r += c1 * ddot (mo_num*mo_num, two_e_dm_mo_triplet(1,1,k,l), 1, W_bar_mu(1,1,k,l), 1)
correction_alpha_1_r(istate) = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_1_r(istate) += c0 * ddot (mo_num*mo_num, two_e_dm_mo_singlet(1,1,k,l,istate), 1, W_bar_mu(1,1,k,l), 1)
correction_alpha_1_r(istate) += c1 * ddot (mo_num*mo_num, two_e_dm_mo_triplet(1,1,k,l,istate), 1, W_bar_mu(1,1,k,l), 1)
enddo
enddo
enddo
END_PROVIDER

View File

@ -1,33 +1,37 @@
BEGIN_PROVIDER [ double precision, two_e_dm_mo_singlet, (mo_num, mo_num, mo_num, mo_num) ]
BEGIN_PROVIDER [ double precision, two_e_dm_mo_singlet, (mo_num, mo_num, mo_num, mo_num, N_states) ]
implicit none
BEGIN_DOC
! Ps(r1,r2,r1',r2') = 1/2 (P(r1,r2,r1',r2') + P(r1,r2,r2',r1'))
END_DOC
integer :: i,j,k,l
integer :: i,j,k,l,istate
do l=1,mo_num
do k=1,mo_num
do j=1,mo_num
do i=1,mo_num
two_e_dm_mo_singlet(i,j,k,l) = 0.5d0 * (two_e_dm_mo(i,j,k,l) + two_e_dm_mo(i,j,l,k))
do istate = 1,N_states
do l=1,mo_num
do k=1,mo_num
do j=1,mo_num
do i=1,mo_num
two_e_dm_mo_singlet(i,j,k,l,istate) = 0.5d0 * (full_occ_2_rdm_spin_trace_mo(i,j,k,l,istate) + full_occ_2_rdm_spin_trace_mo(i,j,l,k,istate))
enddo
enddo
enddo
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, two_e_dm_mo_triplet, (mo_num, mo_num, mo_num, mo_num) ]
BEGIN_PROVIDER [ double precision, two_e_dm_mo_triplet, (mo_num, mo_num, mo_num, mo_num, N_states) ]
implicit none
BEGIN_DOC
! Ps(r1,r2,r1',r2') = 1/2 (P(r1,r2,r1',r2') - P(r1,r2,r2',r1'))
END_DOC
integer :: i,j,k,l
integer :: i,j,k,l, istate
do l=1,mo_num
do k=1,mo_num
do j=1,mo_num
do i=1,mo_num
two_e_dm_mo_triplet(i,j,k,l) = 0.5d0 * (two_e_dm_mo(i,j,k,l) - two_e_dm_mo(i,j,l,k))
do istate = 1,N_states
do l=1,mo_num
do k=1,mo_num
do j=1,mo_num
do i=1,mo_num
two_e_dm_mo_triplet(i,j,k,l,istate) = 0.5d0 * (full_occ_2_rdm_spin_trace_mo(i,j,k,l,istate) - full_occ_2_rdm_spin_trace_mo(i,j,l,k,istate))
enddo
enddo
enddo
enddo

View File

@ -55,7 +55,7 @@ BEGIN_PROVIDER [ double precision, W_bar_mu, (mo_num, mo_num, mo_num, mo_num) ]
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, energy_mu ]
BEGIN_PROVIDER [ double precision, energy_mu, (N_states) ]
implicit none
BEGIN_DOC
! E(mu)
@ -63,40 +63,45 @@ BEGIN_PROVIDER [ double precision, energy_mu ]
double precision :: one_e, two_e
integer :: k,l
integer :: k,l, istate
double precision, external :: ddot
one_e = 0.d0
two_e = 0.d0
do l=1,mo_num
one_e += ddot(mo_num, one_e_dm_mo(1,l), 1, mo_one_e_integrals(1,l), 1)
do k=1,mo_num
two_e += 0.5d0 * ddot (mo_num*mo_num, two_e_dm_mo(1,1,k,l), 1, W_mu(1,1,k,l), 1)
do istate = 1,N_states
one_e = 0.d0
two_e = 0.d0
do l=1,mo_num
one_e += ddot(mo_num, one_e_dm_mo_alpha(1,l,istate), 1, mo_one_e_integrals(1,l), 1)
one_e += ddot(mo_num, one_e_dm_mo_beta (1,l,istate), 1, mo_one_e_integrals(1,l), 1)
do k=1,mo_num
two_e += 0.5d0 * ddot (mo_num*mo_num, full_occ_2_rdm_spin_trace_mo(1,1,k,l,istate), 1, W_mu(1,1,k,l), 1)
enddo
enddo
energy_mu(istate) = one_e + two_e + nuclear_repulsion
enddo
enddo
energy_mu = one_e + two_e + nuclear_repulsion
END_PROVIDER
BEGIN_PROVIDER [ double precision, correction_alpha_0 ]
BEGIN_PROVIDER [ double precision, correction_alpha_0, (N_states) ]
implicit none
BEGIN_DOC
! alpha_0(mu) * <Psi(mu)|W_bar_mu|Psi(mu)>
END_DOC
integer :: k,l
integer :: k,l, istate
double precision :: c0
double precision, external :: ddot
c0 = 0.5d0 * alpha_coef(0)
correction_alpha_0 = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_0 += c0 * ddot (mo_num*mo_num, two_e_dm_mo(1,1,k,l), 1, W_bar_mu(1,1,k,l), 1)
do istate=1,N_states
correction_alpha_0(istate) = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_0(istate) += c0 * ddot (mo_num*mo_num, full_occ_2_rdm_spin_trace_mo(1,1,k,l,istate), 1, W_bar_mu(1,1,k,l), 1)
enddo
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, correction_alpha_1 ]
BEGIN_PROVIDER [ double precision, correction_alpha_1, (N_states) ]
implicit none
BEGIN_DOC
! alpha_0(mu) * <Psi(mu)|W_bar_mu|Psi(mu)>_s + alpha_1(mu) * <Psi(mu)|W_bar_mu|Psi(mu)>_t
@ -104,55 +109,62 @@ BEGIN_PROVIDER [ double precision, correction_alpha_1 ]
double precision :: c1, c0
integer :: k,l
integer :: k,l, istate
double precision, external :: ddot
c0 = 0.5d0 * alpha_coef(0)
c1 = 0.5d0 * alpha_coef(1)
correction_alpha_1 = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_1 += c0 * ddot (mo_num*mo_num, two_e_dm_mo_singlet(1,1,k,l), 1, W_bar_mu(1,1,k,l), 1)
correction_alpha_1 += c1 * ddot (mo_num*mo_num, two_e_dm_mo_triplet(1,1,k,l), 1, W_bar_mu(1,1,k,l), 1)
do istate=1,N_states
correction_alpha_1(istate) = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_alpha_1(istate) += c0 * ddot (mo_num*mo_num, two_e_dm_mo_singlet(1,1,k,l,istate), 1, W_bar_mu(1,1,k,l), 1)
correction_alpha_1(istate) += c1 * ddot (mo_num*mo_num, two_e_dm_mo_triplet(1,1,k,l,istate), 1, W_bar_mu(1,1,k,l), 1)
enddo
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, correction_mu ]
BEGIN_PROVIDER [ double precision, correction_mu, (N_states) ]
implicit none
BEGIN_DOC
! <Psi(mu)|W_bar_mu|Psi(mu)>
END_DOC
integer :: k,l
integer :: k,l, istate
double precision :: c0
double precision, external :: ddot
c0 = 0.5d0
correction_mu = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_mu += c0 * ddot (mo_num*mo_num, two_e_dm_mo(1,1,k,l), 1, W_bar_mu(1,1,k,l), 1)
do istate=1,N_states
correction_mu(istate) = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_mu(istate) += c0 * ddot (mo_num*mo_num, full_occ_2_rdm_spin_trace_mo(1,1,k,l,istate), 1, W_bar_mu(1,1,k,l), 1)
enddo
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, correction_mu0 ]
BEGIN_PROVIDER [ double precision, correction_mu0, (N_states) ]
implicit none
BEGIN_DOC
! <Psi(mu)|W|Psi(mu)> : Should be <Psi(0)|W|Psi(0)>
END_DOC
integer :: k,l
integer :: k,l,istate
double precision :: c0
double precision, external :: ddot
c0 = 0.5d0
correction_mu0 = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_mu0 += c0 * ddot (mo_num*mo_num, two_e_dm_mo(1,1,k,l), 1, W_bar_mu0(1,1,k,l), 1)
do istate=1,N_states
correction_mu0(istate) = 0.d0
do l=1,mo_num
do k=1,mo_num
correction_mu0(istate) += c0 * ddot (mo_num*mo_num, full_occ_2_rdm_spin_trace_mo(1,1,k,l,istate), 1, W_bar_mu0(1,1,k,l), 1)
enddo
enddo
enddo
END_PROVIDER

View File

@ -8,27 +8,40 @@ end
subroutine run
implicit none
integer :: istate
do istate=1,N_states
print *, '', istate
print *, 'State ', istate
print *, '---'
print *, 'mu', mu_erf
print *, 'E(mu)', energy_mu
print *, 'E(mu)', energy_mu(istate)
print *, '---'
print *, 'W_bar(mu)', correction_mu
print *, 'E(mu) + <W_bar(mu)>', energy_mu + correction_mu
print *, 'W_bar(mu)', correction_mu(istate)
print *, 'E(mu) + <W_bar(mu)>', energy_mu(istate) + correction_mu(istate)
print *, '---'
print *, 'alpha_0', alpha_coef(0)
print *, 'correction 0', correction_alpha_0
print *, 'E(mu) + alpha_0 <W_bar(mu)> = ', energy_mu + correction_alpha_0
print *, 'correction 0', correction_alpha_0(istate)
print *, 'E(mu) + alpha_0 <W_bar(mu)> = ', energy_mu(istate) + correction_alpha_0(istate)
print *, '---'
print *, 'alpha_1', alpha_coef(1)
print *, 'correction 1', correction_alpha_1
print *, 'E(mu) + alpha_0 <W_bar(mu)>_s + alpha_1 <W_bar(mu)>_t = ', energy_mu + correction_alpha_1
print *, 'correction 1', correction_alpha_1(istate)
print *, 'E(mu) + alpha_0 <W_bar(mu)>_s + alpha_1 <W_bar(mu)>_t = ', energy_mu(istate) + correction_alpha_1(istate)
print *, '---'
print *, 'alpha_0_r', alpha_coef_r(0)
print *, 'correction 0', correction_alpha_0_r
print *, 'E(mu) + alpha_0_r <W_bar(mu)> = ', energy_mu + correction_alpha_0_r
print *, 'alpha_0_r', alpha_coef_r(0,istate)
print *, 'correction 0', correction_alpha_0_r(istate)
print *, 'E(mu) + alpha_0_r <W_bar(mu)> = ', energy_mu(istate) + correction_alpha_0_r(istate)
print *, '---'
print *, 'alpha_1_r', alpha_coef_r(1)
print *, 'correction 1', correction_alpha_1_r
print *, 'E(mu) + alpha_0_r <W_bar(mu)>_s + alpha_1_r <W_bar(mu)>_t = ', energy_mu + correction_alpha_1_r
print *, 'alpha_1_r', alpha_coef_r(1,istate)
print *, 'correction 1', correction_alpha_1_r(istate)
print *, 'E(mu) + alpha_0_r <W_bar(mu)>_s + alpha_1_r <W_bar(mu)>_t = ', energy_mu(istate) + correction_alpha_1_r(istate)
print *, '---'
print *,''
print '(''|'',A6,''|'',5(A20,''|''))', 'E(mu)', '<W>', 'E(mu) + <W>', 'E(mu) + \alpha_0<W>', &
'E(mu) + \alpha_0<W>_s + \alpha_1<W>_t', 'E(mu) + \alpha_0_r<W>_s + \alpha_1_r<W>_t'
print '(''|'',F6.2,''|'',5(F20.15,''|''))', mu_erf, energy_mu(istate), energy_mu(istate) + correction_mu(istate), energy_mu(istate) + &
correction_alpha_0(istate), energy_mu(istate) + correction_alpha_1(istate), energy_mu(istate) + &
correction_alpha_1_r(istate)
enddo
end

View File

@ -29,6 +29,8 @@ BEGIN_PROVIDER [ double precision, ao_pseudo_grid, (ao_num,-pseudo_lmax:pseudo_l
enddo
ao_pseudo_grid = 0.d0
!$OMP PARALLEL DO DEFAULT(SHARED) &
!$OMP PRIVATE(j,k,c,l,i,a,n_a,g_a,m,y)
do j=1,pseudo_grid_size
do k=1,nucl_num
c(1:3) = nucl_coord(k,1:3)
@ -48,6 +50,7 @@ BEGIN_PROVIDER [ double precision, ao_pseudo_grid, (ao_num,-pseudo_lmax:pseudo_l
enddo
enddo
enddo
!$OMP END PARALLEL DO
deallocate(r)
END_PROVIDER
@ -75,54 +78,11 @@ BEGIN_PROVIDER [ double precision, mo_pseudo_grid, (ao_num,-pseudo_lmax:pseudo_l
double precision :: y
double precision, allocatable :: r(:)
allocate (r(pseudo_grid_size))
dr = pseudo_grid_rmax/dble(pseudo_grid_size)
r(1) = 0.d0
do j=2,pseudo_grid_size
r(j) = r(j-1) + dr
enddo
mo_pseudo_grid = 0.d0
do n=1,pseudo_grid_size
do k=1,nucl_num
do l=0,pseudo_lmax
do m=-l,l
do i=1,ao_num
if (dabs(ao_pseudo_grid(i,m,l,k,n)) < 1.e-12) then
cycle
endif
do j=1,mo_num
mo_pseudo_grid(j,m,l,k,n) = mo_pseudo_grid(j,m,l,k,n) + &
ao_pseudo_grid(i,m,l,k,n) * mo_coef(i,j)
enddo
enddo
enddo
enddo
enddo
enddo
deallocate(r)
mo_pseudo_grid = 0.d0
call dgemm('T','N', mo_num, (2*pseudo_lmax+1)*(pseudo_lmax+1)*nucl_num*pseudo_grid_size, &
ao_num, 1.d0, mo_coef, size(mo_coef,1), ao_pseudo_grid, &
size(ao_pseudo_grid,1), 0.d0, mo_pseudo_grid, size(mo_pseudo_grid,1))
END_PROVIDER
double precision function test_pseudo_grid_ao(i,j)
implicit none
integer, intent(in) :: i,j
integer :: k,l,m,n
double precision :: r, dr,u
dr = pseudo_grid_rmax/dble(pseudo_grid_size)
test_pseudo_grid_ao = 0.d0
r = 0.d0
do k=1,pseudo_grid_size
do n=1,nucl_num
do l = 0,pseudo_lmax
u = pseudo_v_kl(n,l,1) * exp(-pseudo_dz_kl(n,l,1)*r*r)* r*r*dr
do m=-l,l
test_pseudo_grid_ao += ao_pseudo_grid(i,m,l,n,k) * ao_pseudo_grid(j,m,l,n,k) * u
enddo
enddo
enddo
r = r+dr
enddo
end