From b60c235623603e61f5d00fd90136cd86fa1a9fac Mon Sep 17 00:00:00 2001 From: Emmanuel Giner Date: Tue, 19 Mar 2019 17:09:36 +0100 Subject: [PATCH] added no core densities --- ocaml/.gitignore | 8 +- src/density_for_dft/density_for_dft.irp.f | 72 ++++++++++++- src/dft_utils_in_r/dm_in_r.irp.f | 125 ++++++++++++++++++++++ 3 files changed, 198 insertions(+), 7 deletions(-) diff --git a/ocaml/.gitignore b/ocaml/.gitignore index 95a2d185..683292ee 100644 --- a/ocaml/.gitignore +++ b/ocaml/.gitignore @@ -13,19 +13,21 @@ Input_davidson.ml Input_density_for_dft.ml Input_determinants.ml Input_dft_keywords.ml +Input_dft_mu_of_r.ml Input_dressing.ml -<<<<<<< HEAD Input_firth_order_der.ml Input_ijkl_ints_in_r3.ml -======= ->>>>>>> 1f647c595d643cf44700972bdf2363b557091c8f Input_mo_one_e_ints.ml Input_mo_two_e_erf_ints.ml Input_mo_two_e_ints.ml +Input_mu_of_r_ints.ml +Input_mu_of_r.ml Input_nuclei.ml Input_perturbation.ml Input_pseudo.ml +Input_rsdft_ecmd.ml Input_scf_utils.ml +Input_two_body_dm.ml qp_create_ezfio qp_create_ezfio.native qp_edit diff --git a/src/density_for_dft/density_for_dft.irp.f b/src/density_for_dft/density_for_dft.irp.f index 7a907418..84f3d349 100644 --- a/src/density_for_dft/density_for_dft.irp.f +++ b/src/density_for_dft/density_for_dft.irp.f @@ -21,8 +21,9 @@ BEGIN_PROVIDER [double precision, one_e_dm_mo_alpha_for_dft, (mo_num,mo_num, N_s endif if(no_core_density .EQ. "no_core_dm")then - integer :: i,j - do i = 1, n_core_orb + integer :: ii,i,j + do ii = 1, n_core_orb + i = list_core(ii) do j = 1, mo_num one_e_dm_mo_alpha_for_dft(j,i,:) = 0.d0 one_e_dm_mo_alpha_for_dft(i,j,:) = 0.d0 @@ -55,8 +56,9 @@ BEGIN_PROVIDER [double precision, one_e_dm_mo_beta_for_dft, (mo_num,mo_num, N_st endif if(no_core_density .EQ. "no_core_dm")then - integer :: i,j - do i = 1, n_core_orb + integer :: ii,i,j + do ii = 1, n_core_orb + i = list_core(ii) do j = 1, mo_num one_e_dm_mo_beta_for_dft(j,i,:) = 0.d0 one_e_dm_mo_beta_for_dft(i,j,:) = 0.d0 @@ -119,3 +121,65 @@ END_PROVIDER one_body_dm_mo_beta_one_det(i,i, 1:N_states) = 1.d0 enddo END_PROVIDER + + + + +BEGIN_PROVIDER [double precision, one_e_dm_mo_alpha_for_dft_no_core, (mo_num,mo_num, N_states)] + implicit none + BEGIN_DOC +! density matrix for alpha electrons in the MO basis without the core orbitals + END_DOC + one_e_dm_mo_alpha_for_dft_no_core = one_e_dm_mo_alpha_for_dft + + integer :: ii,i,j + do ii = 1, n_core_orb + i = list_core(ii) + do j = 1, mo_num + one_e_dm_mo_alpha_for_dft_no_core(j,i,:) = 0.d0 + one_e_dm_mo_alpha_for_dft_no_core(i,j,:) = 0.d0 + enddo + enddo + +END_PROVIDER + +BEGIN_PROVIDER [double precision, one_e_dm_mo_beta_for_dft_no_core, (mo_num,mo_num, N_states)] + implicit none + BEGIN_DOC +! density matrix for beta electrons in the MO basis without the core orbitals + END_DOC + one_e_dm_mo_beta_for_dft_no_core = one_e_dm_mo_beta_for_dft + integer :: ii,i,j + do ii = 1, n_core_orb + i = list_core(ii) + do j = 1, mo_num + one_e_dm_mo_beta_for_dft_no_core(j,i,:) = 0.d0 + one_e_dm_mo_beta_for_dft_no_core(i,j,:) = 0.d0 + enddo + enddo +END_PROVIDER + + BEGIN_PROVIDER [ double precision, one_e_dm_alpha_ao_for_dft_no_core, (ao_num,ao_num,N_states) ] +&BEGIN_PROVIDER [ double precision, one_e_dm_beta_ao_for_dft_no_core, (ao_num,ao_num,N_states) ] + BEGIN_DOC +! one body density matrix on the AO basis based on one_e_dm_mo_alpha_for_dft_no_core + END_DOC + implicit none + integer :: istate + double precision :: mo_alpha,mo_beta + + one_e_dm_alpha_ao_for_dft_no_core = 0.d0 + one_e_dm_beta_ao_for_dft_no_core = 0.d0 + do istate = 1, N_states + call mo_to_ao_no_overlap( one_e_dm_mo_alpha_for_dft_no_core(1,1,istate), & + size(one_e_dm_mo_alpha_for_dft_no_core,1), & + one_e_dm_alpha_ao_for_dft_no_core(1,1,istate), & + size(one_e_dm_alpha_ao_for_dft_no_core,1) ) + call mo_to_ao_no_overlap( one_e_dm_mo_beta_for_dft_no_core(1,1,istate), & + size(one_e_dm_mo_beta_for_dft_no_core,1), & + one_e_dm_beta_ao_for_dft_no_core(1,1,istate), & + size(one_e_dm_beta_ao_for_dft_no_core,1) ) + enddo + +END_PROVIDER + diff --git a/src/dft_utils_in_r/dm_in_r.irp.f b/src/dft_utils_in_r/dm_in_r.irp.f index 774061cf..cc8dc4b4 100644 --- a/src/dft_utils_in_r/dm_in_r.irp.f +++ b/src/dft_utils_in_r/dm_in_r.irp.f @@ -109,6 +109,90 @@ end grad_dm_b *= 2.d0 end +subroutine dm_dft_alpha_beta_no_core_at_r(r,dm_a,dm_b) + implicit none + BEGIN_DOC +! input: r(1) ==> r(1) = x, r(2) = y, r(3) = z +! output : dm_a = alpha density evaluated at r(3) without the core orbitals +! output : dm_b = beta density evaluated at r(3) without the core orbitals + END_DOC + double precision, intent(in) :: r(3) + double precision, intent(out) :: dm_a(N_states),dm_b(N_states) + integer :: istate + double precision :: aos_array(ao_num),aos_array_bis(ao_num),u_dot_v + call give_all_aos_at_r(r,aos_array) + do istate = 1, N_states + aos_array_bis = aos_array + ! alpha density + call dgemv('N',ao_num,ao_num,1.d0,one_e_dm_alpha_ao_for_dft_no_core(1,1,istate),ao_num,aos_array,1,0.d0,aos_array_bis,1) + dm_a(istate) = u_dot_v(aos_array,aos_array_bis,ao_num) + ! beta density + aos_array_bis = aos_array + call dgemv('N',ao_num,ao_num,1.d0,one_e_dm_beta_ao_for_dft_no_core(1,1,istate),ao_num,aos_array,1,0.d0,aos_array_bis,1) + dm_b(istate) = u_dot_v(aos_array,aos_array_bis,ao_num) + enddo +end + + subroutine dens_grad_a_b_no_core_and_aos_grad_aos_at_r(r,dm_a,dm_b, grad_dm_a, grad_dm_b, aos_array, grad_aos_array) + implicit none + BEGIN_DOC +! input: +! +! * r(1) ==> r(1) = x, r(2) = y, r(3) = z +! +! output: +! +! * dm_a = alpha density evaluated at r without the core orbitals +! * dm_b = beta density evaluated at r without the core orbitals +! * aos_array(i) = ao(i) evaluated at r without the core orbitals +! * grad_dm_a(1) = X gradient of the alpha density evaluated in r without the core orbitals +! * grad_dm_a(1) = X gradient of the beta density evaluated in r without the core orbitals +! * grad_aos_array(1) = X gradient of the aos(i) evaluated at r +! + END_DOC + double precision, intent(in) :: r(3) + double precision, intent(out) :: dm_a(N_states),dm_b(N_states) + double precision, intent(out) :: grad_dm_a(3,N_states),grad_dm_b(3,N_states) + double precision, intent(out) :: grad_aos_array(3,ao_num) + integer :: i,j,istate + double precision :: aos_array(ao_num),aos_array_bis(ao_num),u_dot_v + double precision :: aos_grad_array(ao_num,3), aos_grad_array_bis(ao_num,3) + + call give_all_aos_and_grad_at_r(r,aos_array,grad_aos_array) + do i = 1, ao_num + do j = 1, 3 + aos_grad_array(i,j) = grad_aos_array(j,i) + enddo + enddo + + do istate = 1, N_states + ! alpha density + ! aos_array_bis = \rho_ao * aos_array + call dsymv('U',ao_num,1.d0,one_e_dm_alpha_ao_for_dft_no_core(1,1,istate),size(one_e_dm_alpha_ao_for_dft_no_core,1),aos_array,1,0.d0,aos_array_bis,1) + dm_a(istate) = u_dot_v(aos_array,aos_array_bis,ao_num) + + ! grad_dm(1) = \sum_i aos_grad_array(i,1) * aos_array_bis(i) + grad_dm_a(1,istate) = u_dot_v(aos_grad_array(1,1),aos_array_bis,ao_num) + grad_dm_a(2,istate) = u_dot_v(aos_grad_array(1,2),aos_array_bis,ao_num) + grad_dm_a(3,istate) = u_dot_v(aos_grad_array(1,3),aos_array_bis,ao_num) + ! aos_grad_array_bis = \rho_ao * aos_grad_array + + ! beta density + call dsymv('U',ao_num,1.d0,one_e_dm_beta_ao_for_dft_no_core(1,1,istate),size(one_e_dm_beta_ao_for_dft_no_core,1),aos_array,1,0.d0,aos_array_bis,1) + dm_b(istate) = u_dot_v(aos_array,aos_array_bis,ao_num) + + ! grad_dm(1) = \sum_i aos_grad_array(i,1) * aos_array_bis(i) + grad_dm_b(1,istate) = u_dot_v(aos_grad_array(1,1),aos_array_bis,ao_num) + grad_dm_b(2,istate) = u_dot_v(aos_grad_array(1,2),aos_array_bis,ao_num) + grad_dm_b(3,istate) = u_dot_v(aos_grad_array(1,3),aos_array_bis,ao_num) + ! aos_grad_array_bis = \rho_ao * aos_grad_array + enddo + grad_dm_a *= 2.d0 + grad_dm_b *= 2.d0 + end + + + BEGIN_PROVIDER [double precision, one_e_dm_alpha_in_r, (n_points_integration_angular,n_points_radial_grid,nucl_num,N_states) ] &BEGIN_PROVIDER [double precision, one_e_dm_beta_in_r, (n_points_integration_angular,n_points_radial_grid,nucl_num,N_states) ] implicit none @@ -209,3 +293,44 @@ END_PROVIDER enddo END_PROVIDER + + + BEGIN_PROVIDER [double precision, one_e_dm_no_core_and_grad_alpha_in_r, (4,n_points_final_grid,N_states) ] +&BEGIN_PROVIDER [double precision, one_e_dm_no_core_and_grad_beta_in_r, (4,n_points_final_grid,N_states) ] + BEGIN_DOC +! one_e_dm_no_core_and_grad_alpha_in_r(1,i,i_state) = d\dx n_alpha(r_i,istate) without core orbitals +! one_e_dm_no_core_and_grad_alpha_in_r(2,i,i_state) = d\dy n_alpha(r_i,istate) without core orbitals +! one_e_dm_no_core_and_grad_alpha_in_r(3,i,i_state) = d\dz n_alpha(r_i,istate) without core orbitals +! one_e_dm_no_core_and_grad_alpha_in_r(4,i,i_state) = n_alpha(r_i,istate) without core orbitals +! where r_i is the ith point of the grid and istate is the state number + END_DOC + implicit none + integer :: i,j,k,l,m,istate + double precision :: contrib + double precision :: r(3) + double precision, allocatable :: aos_array(:),grad_aos_array(:,:) + double precision, allocatable :: dm_a(:),dm_b(:), dm_a_grad(:,:), dm_b_grad(:,:) + allocate(dm_a(N_states),dm_b(N_states), dm_a_grad(3,N_states), dm_b_grad(3,N_states)) + allocate(aos_array(ao_num),grad_aos_array(3,ao_num)) + do istate = 1, N_states + do i = 1, n_points_final_grid + r(1) = final_grid_points(1,i) + r(2) = final_grid_points(2,i) + r(3) = final_grid_points(3,i) + !!!! Works also with the ao basis + call dens_grad_a_b_no_core_and_aos_grad_aos_at_r(r,dm_a,dm_b, dm_a_grad, dm_b_grad, aos_array, grad_aos_array) + one_e_dm_no_core_and_grad_alpha_in_r(1,i,istate) = dm_a_grad(1,istate) + one_e_dm_no_core_and_grad_alpha_in_r(2,i,istate) = dm_a_grad(2,istate) + one_e_dm_no_core_and_grad_alpha_in_r(3,i,istate) = dm_a_grad(3,istate) + one_e_dm_no_core_and_grad_alpha_in_r(4,i,istate) = dm_a(istate) + + one_e_dm_no_core_and_grad_beta_in_r(1,i,istate) = dm_b_grad(1,istate) + one_e_dm_no_core_and_grad_beta_in_r(2,i,istate) = dm_b_grad(2,istate) + one_e_dm_no_core_and_grad_beta_in_r(3,i,istate) = dm_b_grad(3,istate) + one_e_dm_no_core_and_grad_beta_in_r(4,i,istate) = dm_b(istate) + enddo + enddo + +END_PROVIDER + +