10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-19 12:32:30 +01:00

Added stop in (T)

This commit is contained in:
Anthony Scemama 2024-05-27 11:38:57 +02:00
parent 4d18a0124e
commit 09d9a814d2
4 changed files with 122 additions and 4 deletions

View File

@ -0,0 +1,101 @@
! ---
program deb_mos
implicit none
my_grid_becke = .True.
PROVIDE tc_grid1_a tc_grid1_r
my_n_pt_r_grid = tc_grid1_r
my_n_pt_a_grid = tc_grid1_a
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
if(tc_integ_type .eq. "numeric") then
my_extra_grid_becke = .True.
PROVIDE tc_grid2_a tc_grid2_r
my_n_pt_r_extra_grid = tc_grid2_r
my_n_pt_a_extra_grid = tc_grid2_a
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
endif
call print_mos()
end
! ---
subroutine print_mos()
implicit none
integer :: i, ipoint
double precision :: r(3)
double precision :: mo_val, mo_der(3), mo_lap
PROVIDE final_grid_points mos_in_r_array mos_grad_in_r_array mos_lapl_in_r_array
! do ipoint = 1, n_points_final_grid
! r(:) = final_grid_points(:,ipoint)
! print*, r
! enddo
double precision :: accu_vgl(5)
double precision :: accu_vgl_nrm(5)
do ipoint = 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)
write(1111, '(5(f15.7, 3X))') r
do i = 1, mo_num
mo_val = mos_in_r_array (i,ipoint)
mo_der(:) = mos_grad_in_r_array(i,ipoint,:)
mo_lap = mos_lapl_in_r_array(i,ipoint,1) + mos_lapl_in_r_array(i,ipoint,2) + mos_lapl_in_r_array(i,ipoint,3)
write(1111, '(5(f15.7, 3X))') mo_val, mo_der, mo_lap
enddo
enddo
do ipoint = 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)
write(2222, '(5(f15.7, 3X))') r
do i = 1, mo_num
mo_val = mos_in_r_array_qmckl (i,ipoint)
mo_der(:) = mos_grad_in_r_array_qmckl(i,ipoint,:)
mo_lap = mos_lapl_in_r_array_qmckl(i,ipoint)
write(2222, '(5(f15.7, 3X))') mo_val, mo_der, mo_lap
enddo
enddo
accu_vgl = 0.d0
accu_vgl_nrm = 0.d0
do ipoint = 1, n_points_final_grid
do i = 1, mo_num
mo_val = mos_in_r_array (i,ipoint)
mo_der(:) = mos_grad_in_r_array(i,ipoint,:)
mo_lap = mos_lapl_in_r_array(i,ipoint,1) + mos_lapl_in_r_array(i,ipoint,2) + mos_lapl_in_r_array(i,ipoint,3)
accu_vgl_nrm(1) += dabs(mo_val)
accu_vgl_nrm(2) += dabs(mo_der(1))
accu_vgl_nrm(3) += dabs(mo_der(2))
accu_vgl_nrm(4) += dabs(mo_der(3))
accu_vgl_nrm(5) += dabs(mo_lap)
mo_val -= mos_in_r_array_qmckl (i,ipoint)
mo_der(:) -= mos_grad_in_r_array_qmckl(i,ipoint,:)
mo_lap -= mos_lapl_in_r_array_qmckl(i,ipoint)
accu_vgl(1) += dabs(mo_val)
accu_vgl(2) += dabs(mo_der(1))
accu_vgl(3) += dabs(mo_der(2))
accu_vgl(4) += dabs(mo_der(3))
accu_vgl(5) += dabs(mo_lap)
enddo
enddo
accu_vgl(:) *= 1.d0 / accu_vgl_nrm(:)
print *, accu_vgl
return
end
! ---

View File

@ -158,7 +158,7 @@ END_PROVIDER
double precision, allocatable :: vgl(:,:,:)
allocate( vgl(mo_num,5,n_points_final_grid))
rc = qmckl_get_mo_basis_mo_vgl_inplace(qmckl_ctx, vgl, n_points_final_grid*mo_num*5_8)
rc = qmckl_get_mo_basis_mo_vgl(qmckl_ctx, vgl, n_points_final_grid*mo_num*5_8)
if (rc /= QMCKL_SUCCESS) then
print *, irp_here, 'qmckl error in get_mo_vgl'
rc = qmckl_check(qmckl_ctx, rc)

View File

@ -217,11 +217,14 @@ subroutine ccsd_par_t_space_stoch(nO,nV,t1,t2,f_o,f_v,v_vvvo,v_vvoo,v_vooo,energ
print '(A)', ' ======================= ============== =========='
double precision :: t_error
call set_multiple_levels_omp(.False.)
call wall_time(t00)
imin = 1_8
!$OMP PARALLEL &
!$OMP PRIVATE(ieta,eta,a,b,c,kiter,isample) &
t_error = huge(1.d0)
!$OMP PARALLEL &
!$OMP PRIVATE(ieta,eta,a,b,c,kiter,isample) &
!$OMP DEFAULT(SHARED) NUM_THREADS(nthreads_pt2)
do kiter=1,Nabc
@ -328,15 +331,23 @@ subroutine ccsd_par_t_space_stoch(nO,nV,t1,t2,f_o,f_v,v_vvvo,v_vvoo,v_vooo,energ
if (norm > 0.d0) then
energy_stoch = ET / norm
variance = ET2 / norm - energy_stoch*energy_stoch
if (norm > 1.d0) then
t_error = dsqrt(variance/(norm-1.d0))
else
t_error = dsqrt(variance)
endif
endif
energy = energy_det + energy_stoch
print '('' '',F20.8, '' '', ES12.4,'' '', F8.2,'' '')', eccsd+energy, dsqrt(variance/(norm-1.d0)), 100.*real(Ncomputed)/real(Nabc)
print '('' '',F20.8, '' '', ES12.4,'' '', F8.2,'' '')', eccsd+energy, t_error, 100.*real(Ncomputed)/real(Nabc)
endif
!$OMP END MASTER
if (t_error < cc_par_t_stop) exit
if (imin > Nabc) exit
enddo
!$OMP TASKWAIT
!$OMP END PARALLEL
print '(A)', ' ======================= ============== ========== '

View File

@ -58,6 +58,12 @@ doc: If true, the CCSD(T) will be computed.
interface: ezfio,ocaml,provider
default: False
[cc_par_t_stop]
type: double precision
doc: Stops the calculation when the statistical error bar is below the given value.
interface: ezfio,ocaml,provider
default: 1.e-5
[cc_dev]
type: logical
doc: Only for dev purposes.