10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2025-01-03 18:16:04 +01:00

added transform basis

This commit is contained in:
eginer 2024-12-13 17:35:24 +01:00
parent e4b9e4a901
commit 3465065264
17 changed files with 237 additions and 23 deletions

View File

@ -3,6 +3,12 @@ type: character*(256)
doc: Name of the |ao_extra| basis set doc: Name of the |ao_extra| basis set
interface: ezfio interface: ezfio
[ao_extra_only_1s]
type: logical
doc: If |true|, you know that the additional AO basis is built only with 1s functions
interface: ezfio, provider
default: true
[ao_extra_num] [ao_extra_num]
type: integer type: integer
doc: Number of |ao_extras| doc: Number of |ao_extras|
@ -85,3 +91,14 @@ doc: phase shift for each primitive GTOs |ao_extra|
size: (3,ao_extra_basis.ao_extra_num,ao_extra_basis.ao_extra_prim_num_max) size: (3,ao_extra_basis.ao_extra_num,ao_extra_basis.ao_extra_prim_num_max)
interface: ezfio, provider interface: ezfio, provider
[ao_extra_one_e_dm]
type: double precision
doc: reduced density matrix on the ao extra basis
size: (ao_extra_basis.ao_extra_num,ao_extra_basis.ao_extra_num)
interface: ezfio, provider
[ao_extra_center]
type: double precision
doc: shift with which the atoms are shifted to mimick p functions
interface: ezfio

View File

@ -0,0 +1,4 @@
2
H 0. 0. 0.
Li 0. 0. 1.0

View File

@ -2,3 +2,14 @@
extra_basis extra_basis
=========== ===========
Plugin to handle an extra basis, which is attached to the extra_nuclei.
It is essentially a duplication of all important quantities (coefficients, exponents and so on) of the usual |AO| basis.
An interesting feature is the possibility to fit any basis made at most with "p" functions onto a purely "s" basis.
This is done with the various scripts here:
- qp_fit_1s_basis : script that creates an |EZFIO| folder corresponding to an .xyz file and a basis fitted with only "s" functions
- qp_add_extra_fit_system : script that takes as input an |EZFIO| folder and an .xyz file and add an extra_basis and extra_nuclei with a 1s fitted basis
Ex:
qp_add_extra_fit_system LiH.ezfio/ h2o.xyz # takes the EZFIO folder "LiH.ezfio" and creates all necessary additional basis and nuclei based on h2o.xyz, but only with 1s functions.

View File

@ -10,11 +10,28 @@ program fit_1s_basis
print*,'Writting the results in the extra_nuclei and ao_extra_basis folders of EZFIO' print*,'Writting the results in the extra_nuclei and ao_extra_basis folders of EZFIO'
print*,'New number of atomic functions : ' print*,'New number of atomic functions : '
print*,'n_func_tot = ',n_func_tot print*,'n_func_tot = ',n_func_tot
print*,'extra_fictious_nucl = ',extra_fictious_nucl
do i = 1, extra_fictious_nucl
print*,list_fict_nucl(i)
enddo
print*,''
print*,''
do i = 1, nucl_num
print*,list_real_nucl(i)
enddo
call ezfio_set_extra_nuclei_extra_nucl_num(new_nucl_num) call ezfio_set_extra_nuclei_extra_nucl_num(new_nucl_num)
call ezfio_set_extra_nuclei_extra_nucl_fictious_num(extra_fictious_nucl)
call ezfio_set_extra_nuclei_extra_nucl_real_num(nucl_num)
call ezfio_set_extra_nuclei_extra_nucl_fictious_list(list_fict_nucl)
call ezfio_set_extra_nuclei_extra_nucl_real_list(list_real_nucl)
call ezfio_set_extra_nuclei_extra_nucl_real_fictious_list(extra_nucl_real_fictious_list_prov)
call ezfio_set_extra_nuclei_extra_nucl_charge(new_nucl_charge_1s) call ezfio_set_extra_nuclei_extra_nucl_charge(new_nucl_charge_1s)
call ezfio_set_extra_nuclei_extra_nucl_coord(new_nucl_coord_1s) call ezfio_set_extra_nuclei_extra_nucl_coord(new_nucl_coord_1s)
call ezfio_set_extra_nuclei_extra_nucl_label(new_nucl_label_1s) call ezfio_set_extra_nuclei_extra_nucl_label(new_nucl_label_1s)
!
call ezfio_set_ao_extra_basis_ao_extra_num(n_func_tot) call ezfio_set_ao_extra_basis_ao_extra_num(n_func_tot)
call ezfio_set_ao_extra_basis_ao_extra_center(ao_extra_center)
call ezfio_set_ao_extra_basis_ao_extra_nucl(new_ao_nucl_1s) call ezfio_set_ao_extra_basis_ao_extra_nucl(new_ao_nucl_1s)
call ezfio_set_ao_extra_basis_ao_extra_prim_num(new_ao_prim_num_1s) call ezfio_set_ao_extra_basis_ao_extra_prim_num(new_ao_prim_num_1s)
call ezfio_set_ao_extra_basis_ao_extra_coef(new_ao_coef_1s) call ezfio_set_ao_extra_basis_ao_extra_coef(new_ao_coef_1s)

View File

@ -0,0 +1,7 @@
3
O 0.000000 -0.399441 3.000000
H 0.761232 0.199721 3.000000
H -0.761232 0.199721 3.000000

View File

@ -12,7 +12,7 @@ fi
currdir=${PWD} currdir=${PWD}
# list of the scripts to be used by the module # list of the scripts to be used by the module
scripts_list="qp_copy_extra_basis" scripts_list="qp_copy_extra_basis qp_add_extra_fit_system qp_copy_extra_basis_to_usual_basis qp_fit_1s_basis"
# Make a symbolic link for all scripts to be used in the ${QP_ROOT}/scripts/ # Make a symbolic link for all scripts to be used in the ${QP_ROOT}/scripts/
# directory. # directory.

View File

@ -84,20 +84,31 @@ BEGIN_PROVIDER [ integer, list_2p_functions, (n_2p_func_orig)]
enddo enddo
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ integer, extra_fictious_nucl]
implicit none
extra_fictious_nucl = n_2p_func_tot
END_PROVIDER
BEGIN_PROVIDER [ integer, new_nucl_num] BEGIN_PROVIDER [ integer, new_nucl_num]
implicit none implicit none
new_nucl_num = nucl_num + n_2p_func_tot new_nucl_num = nucl_num + n_2p_func_tot
print*,'new_nucl_num = ',new_nucl_num print*,'new_nucl_num = ',new_nucl_num
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ character*(32), new_nucl_label_1s , (new_nucl_num) ] BEGIN_PROVIDER [ character*(32), new_nucl_label_1s , (new_nucl_num) ]
&BEGIN_PROVIDER [ integer, list_real_nucl, (nucl_num) ]
&BEGIN_PROVIDER [ integer, list_fict_nucl, (extra_fictious_nucl) ]
implicit none implicit none
integer :: i integer :: i,j
do i = 1, nucl_num do i = 1, nucl_num
new_nucl_label_1s(i) = nucl_label(i) new_nucl_label_1s(i) = nucl_label(i)
list_real_nucl(i) = i
enddo enddo
j=0
do i = nucl_num+1,new_nucl_num do i = nucl_num+1,new_nucl_num
j+=1
new_nucl_label_1s(i) = "X" new_nucl_label_1s(i) = "X"
list_fict_nucl(j) = i
enddo enddo
END_PROVIDER END_PROVIDER
@ -111,6 +122,7 @@ END_PROVIDER
BEGIN_PROVIDER [ double precision, new_nucl_coord_1s_transp, (3,new_nucl_num)] BEGIN_PROVIDER [ double precision, new_nucl_coord_1s_transp, (3,new_nucl_num)]
&BEGIN_PROVIDER [ double precision, new_nucl_charge_1s, (new_nucl_num)] &BEGIN_PROVIDER [ double precision, new_nucl_charge_1s, (new_nucl_num)]
&BEGIN_PROVIDER [ integer, extra_nucl_real_fictious_list_prov, (extra_fictious_nucl)]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! the real atoms are located in the first nucl_num entries ! the real atoms are located in the first nucl_num entries
@ -138,11 +150,13 @@ END_PROVIDER
new_nucl_coord_1s_transp(1:3,k)= nucl_coord_transp(1:3,i) new_nucl_coord_1s_transp(1:3,k)= nucl_coord_transp(1:3,i)
new_nucl_coord_1s_transp(good_i,k)+= ao_extra_center new_nucl_coord_1s_transp(good_i,k)+= ao_extra_center
new_nucl_charge_1s(k) = 0.d0 new_nucl_charge_1s(k) = 0.d0
extra_nucl_real_fictious_list_prov(k-nucl_num)=i
k+=1 k+=1
! one is centered in R_x - d ! one is centered in R_x - d
new_nucl_coord_1s_transp(1:3,k)= nucl_coord_transp(1:3,i) new_nucl_coord_1s_transp(1:3,k)= nucl_coord_transp(1:3,i)
new_nucl_coord_1s_transp(good_i,k)-= ao_extra_center new_nucl_coord_1s_transp(good_i,k)-= ao_extra_center
new_nucl_charge_1s(k) = 0.d0 new_nucl_charge_1s(k) = 0.d0
extra_nucl_real_fictious_list_prov(k-nucl_num)=i
enddo enddo
else if(ao_l(i_ao).gt.1)then else if(ao_l(i_ao).gt.1)then
print*,'WARNING ! Lmax value not implemented yet !' print*,'WARNING ! Lmax value not implemented yet !'

View File

@ -0,0 +1,19 @@
#!/bin/bash
# specify the QP folder
QP=$QP_ROOT
dir=${QP}
# sourcing the quantum_package.rc file
. ${QP}/quantum_package.rc
# The main EZFIO folder
main=${1%/}
# The XYZ file containing the geometry of the additional system you want to add
extra=${2%.xyz}
basis_extra=sto-3g
ezfio_extra=${extra}_${basis_extra}_1s
echo $ezfio_extra
qp_fit_1s_basis $extra $basis_extra
qp set_file $ezfio_extra
qp run scf | tee ${ezfio_extra}.scf.out
qp run save_one_e_dm | tee ${ezfio_extra}.one_rdm.out
qp_copy_extra_basis ${ezfio_extra} $main

View File

@ -4,7 +4,11 @@ QP=$QP_ROOT
dir=${QP} dir=${QP}
# sourcing the quantum_package.rc file # sourcing the quantum_package.rc file
. ${QP}/quantum_package.rc . ${QP}/quantum_package.rc
# script that copy all data from |AO| basis and nuclei of EZFIO_extra to the ao_extra_basis and extra_nuclei of EZFIO_target
# use:
# qp_copy_extra_basis EZFIO_extra EZFIO_target
EZFIO_extra=${1%/} EZFIO_extra=${1%/}
EZFIO_extra=${EZFIO_extra%.xyz}
EZFIO_target=${2%/} EZFIO_target=${2%/}
@ -56,4 +60,8 @@ i=primitives_normalized
newfile=primitives_normalized_extra newfile=primitives_normalized_extra
cp ${EZFIO_extra}/ao_basis/$i ${EZFIO_target}/ao_extra_basis/$newfile cp ${EZFIO_extra}/ao_basis/$i ${EZFIO_target}/ao_extra_basis/$newfile
echo "COPYING ALL DATA FROM "$EZFIO_extra"/aux_quantities/ to "${EZFIO_target}"/ao_extra_basis/"
i=data_one_e_dm_tot_ao.gz
newfile=ao_extra_one_e_dm.gz
cp ${EZFIO_extra}/aux_quantities/$i ${EZFIO_target}/ao_extra_basis/$newfile

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
# specify the QP folder # specify the QP folder
# script that copy all data in ao_extra_basis and extra_nuclei and copy it to ao_basis and ao_nuclei
QP=$QP_ROOT QP=$QP_ROOT
dir=${QP} dir=${QP}
# sourcing the quantum_package.rc file # sourcing the quantum_package.rc file
@ -52,8 +53,5 @@ do
echo $newfile echo $newfile
cp ${EZFIO_extra}/ao_extra_basis/$i ${EZFIO_target}/ao_basis/$newfile cp ${EZFIO_extra}/ao_extra_basis/$i ${EZFIO_target}/ao_basis/$newfile
done done
#i=primitives_normalized
#newfile=primitives_normalized_extra
#cp ${EZFIO_extra}/ao_basis/$i ${EZFIO_target}/ao_extra_basis/$newfile

View File

@ -0,0 +1,12 @@
#!/bin/bash
## Takes as an argument an xyz file and a basis, and fit the AO basis onto an "s" basis only
## use:
# qp_fit_1s_basis my_xyz_file.xyz basis
source ~/qp2/quantum_package.rc
input=${1%.xyz}
basis=$2
ezfio_fit=${input}_${basis}_1s
qp create_ezfio -b $basis $input.xyz -o $ezfio_fit
# Fitting the original basis on 1s only basis functions
qp run fit_1s_basis |tee ${ezfio_fit}.fit_1s.out
qp_copy_extra_basis_to_usual_basis $ezfio_fit $ezfio_fit

View File

@ -0,0 +1,49 @@
subroutine rotate_nuclei(phi,theta,psi,nucl_centers,n_nucl,nucl_centers_after)
implicit none
BEGIN_DOC
! routine that rotates a set of nuclei according to three axis corresponding to angles phi, theta, psi.
END_DOC
double precision, intent(in) :: phi,theta,psi
double precision, intent(in) :: nucl_centers(3,n_nucl)
integer, intent(in) :: n_nucl
double precision, intent(out):: nucl_centers_after(3,n_nucl)
double precision :: r_mat(3,3)
call r_phi_theta_psi_matrix(phi,theta,psi,r_mat)
call get_AB_prod(r_mat,3,3,nucl_centers,n_nucl,nucl_centers_after)
end
subroutine r_phi_theta_psi_matrix(phi,theta,psi,r_mat)
implicit none
BEGIN_DOC
! routine that creates the rotation matrix corresponding to phi,theta,psi
!
! according to conventions in MDFT code
END_DOC
double precision, intent(in) :: phi,theta,psi
double precision, intent(out):: r_mat(3,3)
double precision :: ctheta, stheta
double precision :: cphi , sphi
double precision :: cpsi , spsi
ctheta = dcos(theta)
cphi = dcos(phi)
cpsi = dcos(psi)
stheta = dsin(theta)
sphi = dsin(phi)
spsi = dsin(psi)
r_mat(1,1) = ctheta*cphi*cpsi-sphi*spsi
r_mat(1,2) = -ctheta*cphi*spsi-sphi*cpsi
r_mat(1,3) = stheta*cphi
r_mat(2,1) = ctheta*sphi*cpsi+cphi*spsi
r_mat(2,2) = -ctheta*sphi*spsi+cphi*cpsi
r_mat(2,3) = stheta*sphi
r_mat(3,1) = -stheta*cpsi
r_mat(3,2) = stheta*spsi
r_mat(3,3) = ctheta
end

View File

@ -9,7 +9,7 @@ then
fi fi
# list of the scripts to be used by the module # list of the scripts to be used by the module
scripts_list="qp_copy_extra_basis" scripts_list="qp_copy_extra_basis qp_add_extra_fit_system qp_copy_extra_basis_to_usual_basis qp_fit_1s_basis"
# Destroy ONLY the symbolic link for the scripts to be used in the # Destroy ONLY the symbolic link for the scripts to be used in the
# ${QP_ROOT}/scripts/ directory. # ${QP_ROOT}/scripts/ directory.

View File

@ -3,6 +3,12 @@ doc: Number of nuclei
type: integer type: integer
interface: ezfio, provider interface: ezfio, provider
[extra_nucl_pouet]
doc: Number of nuclei
type: integer
interface: ezfio, provider, ocaml
default:1
[extra_nucl_label] [extra_nucl_label]
doc: Nuclear labels doc: Nuclear labels
type: character*(32) type: character*(32)
@ -21,3 +27,30 @@ type: double precision
size: (extra_nuclei.extra_nucl_num,3) size: (extra_nuclei.extra_nucl_num,3)
interface: ezfio interface: ezfio
[extra_nucl_real_num]
doc: Number of real nuclei
type: integer
interface: ezfio, provider
[extra_nucl_fictious_num]
doc: Number of fictious nuclei
type: integer
interface: ezfio, provider
[extra_nucl_real_fictious_list]
doc: List of real nuclei to which fictious nuclei are attached to
type: integer
size: (extra_nuclei.extra_nucl_fictious_num)
interface: ezfio, provider
[extra_nucl_fictious_list]
doc: List of fictious nuclei
type: integer
size: (extra_nuclei.extra_nucl_fictious_num)
interface: ezfio, provider
[extra_nucl_real_list]
doc: List of real nuclei
type: integer
size: (extra_nuclei.extra_nucl_real_num)
interface: ezfio, provider

View File

@ -38,3 +38,10 @@ type: double precision
size: (ao_basis.ao_num,ao_basis.ao_num,determinants.n_states) size: (ao_basis.ao_num,ao_basis.ao_num,determinants.n_states)
[data_one_e_dm_tot_ao]
interface: ezfio, provider
doc: TOTAL (Alpha+Beta) one body density matrix on the |AO| basis computed with the wave function
type: double precision
size: (ao_basis.ao_num,ao_basis.ao_num,determinants.n_states)

View File

@ -1,24 +1,41 @@
program print_mos program print_mos
implicit none implicit none
integer :: i,nx integer :: i,nx
double precision :: r(3), xmax, dx, accu print*,ao_kinetic_integrals(1,1)
double precision, allocatable :: mos_array(:) double precision :: xmin,xmax,dx,x,accu,gtt,g,alpha,pi,accu_norm
double precision:: alpha,envelop,dm_a,dm_b pi = dacos(-1.d0)
allocate(mos_array(mo_num)) alpha = 2.D0
xmax = 5.d0 xmin=0.d0
nx = 1000 xmax=5.D0
dx=xmax/dble(nx) nx=10000
r = 0.d0 dx=(xmax-xmin)/dble(nx)
alpha = 0.5d0 x = 0.d0
accu = 0.d0
accu_norm = 0.d0
do i = 1, nx do i = 1, nx
call dm_dft_alpha_beta_at_r(r,dm_a,dm_b) accu += g(x,alpha)*gtt(x,alpha)*x**2 * dx
call give_all_mos_at_r(r,mos_array) accu_norm += g(x,alpha)**2*x**2 * dx
accu = mos_array(3)**2+mos_array(4)**2+mos_array(5)**2 write(33,*)x,g(x,alpha),gtt(x,alpha)
accu = dsqrt(accu) x+=dx
envelop = (1.d0 - dexp(-alpha * r(3)**2))
write(33,'(100(F16.10,X))')r(3), mos_array(1), mos_array(2), accu, dm_a+dm_b, envelop
r(3) += dx
enddo enddo
accu=accu * 4.d0 * pi
accu_norm *= 4.d0 * pi
print*,'accu_norm = ',accu_norm
accu*=-0.5D0
print*,'accu = ',accu/accu_norm
end
double precision function gtt(x,alpha)
implicit none
double precision, intent(in) :: x,alpha
gtt = dexp(-alpha*x*x) * (4.D0*alpha**2*x**2 - 4.d0 * alpha)
end end
double precision function g(x,alpha)
implicit none
double precision, intent(in) :: x,alpha
g = dexp(-alpha*x*x)
end

View File

@ -27,4 +27,5 @@ subroutine routine_save_one_e_dm
call ezfio_set_aux_quantities_data_one_e_dm_beta_mo(one_e_dm_mo_beta) call ezfio_set_aux_quantities_data_one_e_dm_beta_mo(one_e_dm_mo_beta)
call ezfio_set_aux_quantities_data_one_e_dm_alpha_ao(one_e_dm_ao_alpha) call ezfio_set_aux_quantities_data_one_e_dm_alpha_ao(one_e_dm_ao_alpha)
call ezfio_set_aux_quantities_data_one_e_dm_beta_ao(one_e_dm_ao_beta) call ezfio_set_aux_quantities_data_one_e_dm_beta_ao(one_e_dm_ao_beta)
call ezfio_set_aux_quantities_data_one_e_dm_tot_ao(one_e_dm_ao)
end end