added new feature for new dft functionals

This commit is contained in:
eginer 2019-01-29 18:49:25 +01:00
parent 3315d9855d
commit 9762b51df5
9 changed files with 153 additions and 33 deletions

1
ocaml/.gitignore vendored
View File

@ -17,6 +17,7 @@ Input_dressing.ml
Input_mo_one_e_ints.ml
Input_mo_two_e_erf_ints.ml
Input_mo_two_e_ints.ml
Input_new_functionals.ml
Input_nuclei.ml
Input_perturbation.ml
Input_pseudo.ml

View File

@ -0,0 +1,18 @@
[new_exchange_functional]
type: character*(32)
doc: name of the exchange functional
interface: ezfio, provider, ocaml
default: short_range_LDA
[new_correlation_functional]
type: character*(32)
doc: name of the correlation functional
interface: ezfio, provider, ocaml
default: short_range_LDA
[new_HF_exchange]
type: double precision
doc: Percentage of HF exchange in the DFT model
interface: ezfio,provider,ocaml
default: 0.

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,33 @@
BEGIN_PROVIDER[double precision, energy_x_new_functional, (N_states) ]
&BEGIN_PROVIDER[double precision, energy_c_new_functional, (N_states) ]
implicit none
BEGIN_DOC
! energy_x_new_functional = define here your functional
! energy_c_new_functional = define here your functional
END_DOC
energy_x_new_functional = 0.d0
energy_c_new_functional = 0.d0
if(trim(new_exchange_functional)=="your_new_keyword")then
energy_x_new_functional = 0.d0 ! replace by your new provider
else if(new_exchange_functional.EQ."None")then
energy_x_new_functional = 0.d0 ! replace by your new provider
else
print*, 'Exchange functional required does not exist ...'
print*,'new_exchange_functional',new_exchange_functional
stop
endif
if(trim(new_correlation_functional)=="your_new_keyword")then
energy_c_new_functional = 0.d0 ! replace by your new provider
else if(new_correlation_functional.EQ."None")then
energy_c_new_functional = 0.d0 ! replace by your new provider
else
print*, 'Correlation functional required does not exist ...'
print*,'new_correlation_functional',new_correlation_functional
stop
endif
END_PROVIDER

View File

@ -0,0 +1,40 @@
BEGIN_PROVIDER [double precision, potential_new_functional_x_alpha_ao,(ao_num,ao_num,N_states)]
&BEGIN_PROVIDER [double precision, potential_new_functional_x_beta_ao,(ao_num,ao_num,N_states)]
&BEGIN_PROVIDER [double precision, potential_new_functional_c_alpha_ao,(ao_num,ao_num,N_states)]
&BEGIN_PROVIDER [double precision, potential_new_functional_c_beta_ao,(ao_num,ao_num,N_states)]
implicit none
BEGIN_DOC
! define here your exchange/correlation potentials for alpha/beta electrons
END_DOC
potential_new_functional_x_alpha_ao = 0.d0
potential_new_functional_c_alpha_ao = 0.d0
potential_new_functional_x_beta_ao = 0.d0
potential_new_functional_c_beta_ao = 0.d0
if(trim(new_exchange_functional)=="your_new_keyword")then
potential_new_functional_x_alpha_ao = 0.d0 ! replace by your new provider
potential_new_functional_x_beta_ao = 0.d0 ! replace by your new provider
else if(new_exchange_functional.EQ."None")then
potential_new_functional_x_alpha_ao = 0.d0
potential_new_functional_x_beta_ao = 0.d0
else
print*, 'Exchange functional required does not exist ...'
print*,'new_exchange_functional',new_exchange_functional
stop
endif
if(trim(new_correlation_functional)=="your_new_keyword")then
potential_new_functional_c_alpha_ao = 0.d0 ! replace by your new provider
potential_new_functional_c_beta_ao = 0.d0 ! replace by your new provider
else if(new_correlation_functional.EQ."None")then
potential_new_functional_c_alpha_ao = 0.d0
potential_new_functional_c_beta_ao = 0.d0
else
print*, 'Correlation functional required does not ecist ...'
print*,'new_correlation_functional',new_correlation_functional
stop
endif
END_PROVIDER

View File

@ -35,31 +35,50 @@ subroutine davidson_run_slave(thread,iproc)
integer(ZMQ_PTR) :: zmq_socket_push
integer, external :: connect_to_taskserver
integer :: doexit, send, receive
integer, external :: zmq_get_N_states_diag
PROVIDE mpi_rank
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
doexit = 0
if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then
doexit=1
endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
send = doexit
call MPI_AllReduce(send, receive, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
doexit=1
endif
doexit = receive
IRP_ENDIF
if (doexit) then
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
return
endif
zmq_socket_push = new_zmq_push_socket(thread)
integer :: ierr, doexit
do
doexit = 0
if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then
call sleep( int(1.5+float(mpi_rank)/10.) )
if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then
doexit=1
endif
endif
IRP_IF MPI
include 'mpif.h'
integer :: sendbuf, recvbuf
sendbuf = doexit
recvbuf = doexit
call MPI_ALLREDUCE(sendbuf, recvbuf, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
print *, irp_here//': Unable to reduce '
stop -1
endif
doexit = recvbuf
IRP_ENDIF
if (doexit == 0) then
exit
else
print *, irp_here, ': retrying connection (', doexit, ')'
endif
enddo
do
if (zmq_get_N_states_diag(zmq_to_qp_run_socket, 1) /= -1) then
exit
endif
print *, irp_here, ': Waiting for N_states_diag'
call sleep(1)
enddo
call davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_states_diag, N_det, worker_id)
integer, external :: disconnect_from_taskserver
@ -72,8 +91,7 @@ subroutine davidson_run_slave(thread,iproc)
endif
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
call end_zmq_push_socket(zmq_socket_push)
call end_zmq_push_socket(zmq_socket_push,thread)
end subroutine
@ -123,9 +141,8 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze,
endif
do while (zmq_get_dmatrix(zmq_to_qp_run_socket, worker_id, 'u_t', u_t, ni, nj, size(u_t,kind=8)) == -1)
print *, 'mpi_rank, N_states_diag, N_det'
print *, mpi_rank, N_states_diag, N_det
stop 'u_t'
call sleep(1)
print *, irp_here, ': waiting for u_t...'
enddo
IRP_IF MPI
@ -330,9 +347,9 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze)
call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,'davidson')
! integer :: N_states_diag_save
! N_states_diag_save = N_states_diag
! N_states_diag = N_st
integer :: N_states_diag_save
N_states_diag_save = N_states_diag
N_states_diag = N_st
if (zmq_put_N_states_diag(zmq_to_qp_run_socket, 1) == -1) then
stop 'Unable to put N_states_diag on ZMQ server'
endif
@ -451,8 +468,8 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze)
!$OMP TASKWAIT
!$OMP END PARALLEL
! N_states_diag = N_states_diag_save
! SOFT_TOUCH N_states_diag
N_states_diag = N_states_diag_save
SOFT_TOUCH N_states_diag
end
@ -565,4 +582,3 @@ integer function zmq_get_N_states_diag(zmq_to_qp_run_socket, worker_id)
endif
IRP_ENDIF
end

View File

@ -1 +1,2 @@
dft_utils_one_e
new_functionals

View File

@ -20,6 +20,8 @@
else if(exchange_functional.EQ."None")then
energy_x = 0.d0
energy_x = 0.d0
else if(exchange_functional.EQ."my_functional")then
energy_x = energy_x_new_functional
else
print*, 'Exchange functional required does not exist ...'
print*,'exchange_functional',exchange_functional
@ -41,6 +43,8 @@
else if(correlation_functional.EQ."None")then
energy_c = 0.d0
energy_c = 0.d0
else if(correlation_functional.EQ."my_functional")then
energy_c = energy_c_new_functional
else
print*, 'Correlation functional required does not ecist ...'
print*,'correlation_functional',correlation_functional

View File

@ -20,6 +20,9 @@
else if(exchange_functional.EQ."PBE")then
potential_x_alpha_ao = potential_x_alpha_ao_PBE
potential_x_beta_ao = potential_x_beta_ao_PBE
else if(exchange_functional.EQ."my_functional")then
potential_x_alpha_ao = potential_new_functional_x_alpha_ao
potential_x_beta_ao = potential_new_functional_x_beta_ao
else if(exchange_functional.EQ."None")then
potential_x_alpha_ao = 0.d0
potential_x_beta_ao = 0.d0
@ -41,6 +44,9 @@
else if(correlation_functional.EQ."PBE")then
potential_c_alpha_ao = potential_c_alpha_ao_PBE
potential_c_beta_ao = potential_c_beta_ao_PBE
else if(correlation_functional.EQ."my_functional")then
potential_c_alpha_ao = potential_new_functional_c_alpha_ao
potential_c_beta_ao = potential_new_functional_c_beta_ao
else if(correlation_functional.EQ."None")then
potential_c_alpha_ao = 0.d0
potential_c_beta_ao = 0.d0