diff --git a/ocaml/.gitignore b/ocaml/.gitignore index 50a9344d..cfb5639a 100644 --- a/ocaml/.gitignore +++ b/ocaml/.gitignore @@ -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 diff --git a/scripts/functionals/do_not_touch_func/EZFIO.cfg b/scripts/functionals/do_not_touch_func/EZFIO.cfg new file mode 100644 index 00000000..86806f76 --- /dev/null +++ b/scripts/functionals/do_not_touch_func/EZFIO.cfg @@ -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. + diff --git a/scripts/functionals/do_not_touch_func/NEED b/scripts/functionals/do_not_touch_func/NEED new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/scripts/functionals/do_not_touch_func/NEED @@ -0,0 +1 @@ + diff --git a/scripts/functionals/do_not_touch_func/e_x.irp.f b/scripts/functionals/do_not_touch_func/e_x.irp.f new file mode 100644 index 00000000..12ea417d --- /dev/null +++ b/scripts/functionals/do_not_touch_func/e_x.irp.f @@ -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 + + diff --git a/scripts/functionals/do_not_touch_func/pot_x_general.irp.f b/scripts/functionals/do_not_touch_func/pot_x_general.irp.f new file mode 100644 index 00000000..a59a03d4 --- /dev/null +++ b/scripts/functionals/do_not_touch_func/pot_x_general.irp.f @@ -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 + diff --git a/src/davidson/davidson_parallel.irp.f b/src/davidson/davidson_parallel.irp.f index 54550c50..a1f69841 100644 --- a/src/davidson/davidson_parallel.irp.f +++ b/src/davidson/davidson_parallel.irp.f @@ -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 - diff --git a/src/dft_one_e/NEED b/src/dft_one_e/NEED index d81183d0..c5d5132e 100644 --- a/src/dft_one_e/NEED +++ b/src/dft_one_e/NEED @@ -1 +1,2 @@ dft_utils_one_e +new_functionals diff --git a/src/dft_one_e/e_xc_general.irp.f b/src/dft_one_e/e_xc_general.irp.f index 99ba19d3..607343ab 100644 --- a/src/dft_one_e/e_xc_general.irp.f +++ b/src/dft_one_e/e_xc_general.irp.f @@ -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 diff --git a/src/dft_one_e/pot_general.irp.f b/src/dft_one_e/pot_general.irp.f index 536c7aeb..3437269e 100644 --- a/src/dft_one_e/pot_general.irp.f +++ b/src/dft_one_e/pot_general.irp.f @@ -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