From 4a6f7a3a928fa634fc1a5384eb43494c59f3d2bf Mon Sep 17 00:00:00 2001 From: Emmanuel Giner Date: Thu, 8 Apr 2021 20:37:17 +0200 Subject: [PATCH] added some stuffs for foboscf --- src/bitmask/modify_bitmasks.irp.f | 8 ++-- src/cas_based_on_top/example.irp.f | 16 ++++--- src/dft_utils_in_r/dm_in_r_routines.irp.f | 56 +++++++++++++++++++++++ src/scf_utils/EZFIO.cfg | 7 +++ src/scf_utils/diagonalize_fock.irp.f | 21 +++++++++ src/scf_utils/fock_matrix.irp.f | 21 +++++++++ 6 files changed, 118 insertions(+), 11 deletions(-) diff --git a/src/bitmask/modify_bitmasks.irp.f b/src/bitmask/modify_bitmasks.irp.f index 834be6c8..ed291adf 100644 --- a/src/bitmask/modify_bitmasks.irp.f +++ b/src/bitmask/modify_bitmasks.irp.f @@ -143,10 +143,10 @@ subroutine print_generators_bitmasks_holes key_tmp(j,1) = generators_bitmask(j,1,i) key_tmp(j,2) = generators_bitmask(j,2,i) enddo - print*,'' - print*,'index hole = ',i - call print_det(key_tmp,N_int) - print*,'' +! print*,'' +! print*,'index hole = ',i +! call print_det(key_tmp,N_int) +! print*,'' enddo deallocate(key_tmp) diff --git a/src/cas_based_on_top/example.irp.f b/src/cas_based_on_top/example.irp.f index f00956e3..2f709495 100644 --- a/src/cas_based_on_top/example.irp.f +++ b/src/cas_based_on_top/example.irp.f @@ -5,37 +5,39 @@ subroutine write_on_top_in_real_space ! This routines is a simple example of how to plot the on-top pair density on a simple 1D grid END_DOC double precision :: zmax,dz,r(3),on_top_in_r,total_density,zcenter,dist + double precision :: core_dens, inact_dens,act_dens(2,1) integer :: nz,i,istate character*(128) :: output integer :: i_unit_output,getUnitAndOpen PROVIDE ezfio_filename output=trim(ezfio_filename)//'.on_top' - print*,'output = ',trim(output) + print*,'output = ',trim(output) i_unit_output = getUnitAndOpen(output,'w') - zmax = 2.0d0 + zmax = 5.0d0 print*,'nucl_coord(1,3) = ',nucl_coord(1,3) print*,'nucl_coord(2,3) = ',nucl_coord(2,3) dist = dabs(nucl_coord(1,3) - nucl_coord(2,3)) - zmax += dist + zmax += dist zcenter = (nucl_coord(1,3) + nucl_coord(2,3))*0.5d0 print*,'zcenter = ',zcenter print*,'zmax = ',zmax nz = 1000 dz = zmax / dble(nz) - r(:) = 0.d0 - r(3) = zcenter -zmax * 0.5d0 + r(:) = 0.d0 + r(3) = zcenter -zmax * 0.5d0 print*,'r(3) = ',r(3) istate = 1 + + write(i_unit_output,*)" z, on-top(z), n(z) " do i = 1, nz call give_on_top_in_r_one_state(r,istate,on_top_in_r) - call give_cas_density_in_r(r,total_density) + call give_cas_density_in_r(core_dens,inact_dens,act_dens,total_density,r) write(i_unit_output,*)r(3),on_top_in_r,total_density r(3) += dz enddo - end diff --git a/src/dft_utils_in_r/dm_in_r_routines.irp.f b/src/dft_utils_in_r/dm_in_r_routines.irp.f index 6fa99e22..9991289c 100644 --- a/src/dft_utils_in_r/dm_in_r_routines.irp.f +++ b/src/dft_utils_in_r/dm_in_r_routines.irp.f @@ -110,6 +110,62 @@ end grad_dm_b *= 2.d0 end + subroutine density_and_grad_alpha_beta(r,dm_a,dm_b, grad_dm_a, grad_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 +! * dm_b = beta density evaluated at r +! * grad_dm_a(1) = X gradient of the alpha density evaluated in r +! * grad_dm_a(1) = X gradient of the beta density evaluated in 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 :: 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(1,1,istate),size(one_e_dm_alpha_ao_for_dft,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(1,1,istate),size(one_e_dm_beta_ao_for_dft,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 + subroutine density_and_grad_lapl_alpha_beta_and_all_aos_and_grad_aos_at_r(r,dm_a,dm_b, grad_dm_a, grad_dm_b, lapl_dm_a, lapl_dm_b, aos_array, grad_aos_array, lapl_aos_array) diff --git a/src/scf_utils/EZFIO.cfg b/src/scf_utils/EZFIO.cfg index 4a56a35b..694590ec 100644 --- a/src/scf_utils/EZFIO.cfg +++ b/src/scf_utils/EZFIO.cfg @@ -51,3 +51,10 @@ doc: If true, leave untouched all the orbitals defined as core and optimize all interface: ezfio,provider,ocaml default: False + +[no_oa_or_av_opt] +type: logical +doc: If true, you set to zero all Fock elements between the orbital set to active and all the other orbitals +interface: ezfio,provider,ocaml +default: False + diff --git a/src/scf_utils/diagonalize_fock.irp.f b/src/scf_utils/diagonalize_fock.irp.f index d501278f..5188581a 100644 --- a/src/scf_utils/diagonalize_fock.irp.f +++ b/src/scf_utils/diagonalize_fock.irp.f @@ -31,6 +31,27 @@ BEGIN_PROVIDER [ double precision, eigenvectors_Fock_matrix_mo, (ao_num,mo_num) enddo enddo endif + if(no_oa_or_av_opt)then + do i = 1, n_act_orb + iorb = list_act(i) + do j = 1, n_inact_orb + jorb = list_inact(j) + F(iorb,jorb) = 0.d0 + F(jorb,iorb) = 0.d0 + enddo + do j = 1, n_virt_orb + jorb = list_virt(j) + F(iorb,jorb) = 0.d0 + F(jorb,iorb) = 0.d0 + enddo + do j = 1, n_core_orb + jorb = list_core(j) + F(iorb,jorb) = 0.d0 + F(jorb,iorb) = 0.d0 + enddo + enddo + endif + ! Insert level shift here do i = elec_beta_num+1, elec_alpha_num diff --git a/src/scf_utils/fock_matrix.irp.f b/src/scf_utils/fock_matrix.irp.f index fc9eaadd..61633d3b 100644 --- a/src/scf_utils/fock_matrix.irp.f +++ b/src/scf_utils/fock_matrix.irp.f @@ -92,6 +92,27 @@ enddo endif + if(no_oa_or_av_opt)then + do i = 1, n_act_orb + iorb = list_act(i) + do j = 1, n_inact_orb + jorb = list_inact(j) + Fock_matrix_mo(iorb,jorb) = 0.d0 + Fock_matrix_mo(jorb,iorb) = 0.d0 + enddo + do j = 1, n_virt_orb + jorb = list_virt(j) + Fock_matrix_mo(iorb,jorb) = 0.d0 + Fock_matrix_mo(jorb,iorb) = 0.d0 + enddo + do j = 1, n_core_orb + jorb = list_core(j) + Fock_matrix_mo(iorb,jorb) = 0.d0 + Fock_matrix_mo(jorb,iorb) = 0.d0 + enddo + enddo + endif + END_PROVIDER