10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-03 20:53:54 +01:00

Merge pull request #167 from QuantumPackage/dev

Dev
This commit is contained in:
Emmanuel Giner 2021-06-28 11:24:21 +02:00 committed by GitHub
commit 3c4f14c5b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 175 additions and 70 deletions

View File

@ -120,6 +120,7 @@ def write_ezfio(res, filename):
exponent = []
res.convert_to_cartesian()
# ~#~#~#~#~#~#~ #
# P a r s i n g #
# ~#~#~#~#~#~#~ #
@ -177,6 +178,68 @@ def write_ezfio(res, filename):
print("OK")
# _
# |_) _. _ o _
# |_) (_| _> | _>
#
print("Basis\t\t...\t", end=' ')
# ~#~#~#~ #
# I n i t #
# ~#~#~#~ #
coefficient = []
exponent = []
# ~#~#~#~#~#~#~ #
# P a r s i n g #
# ~#~#~#~#~#~#~ #
nbasis = 0
nucl_center = []
curr_center = -1
nucl_shell_num = []
ang_mom = []
nshell = 0
shell_prim_index = [1]
shell_prim_num = []
for b in res.basis:
s = b.sym
if str.count(s, "y") + str.count(s, "x") == 0:
c = b.center
nshell += 1
if c != curr_center:
curr_center = c
nucl_center.append(nbasis+1)
nucl_shell_num.append(nshell)
nshell = 0
nbasis += 1
coefficient += b.coef[:len(b.prim)]
exponent += [p.expo for p in b.prim]
ang_mom.append(str.count(s, "z"))
shell_prim_index.append(len(exponent)+1)
shell_prim_num.append(len(b.prim))
nucl_shell_num.append(nshell+1)
nucl_shell_num = nucl_shell_num[1:]
# ~#~#~#~#~ #
# W r i t e #
# ~#~#~#~#~ #
ezfio.set_basis_basis("Read from ResultsFile")
ezfio.set_basis_basis_nucleus_index(nucl_center)
ezfio.set_basis_prim_num(len(coefficient))
ezfio.set_basis_shell_num(len(ang_mom))
ezfio.set_basis_nucleus_shell_num(nucl_shell_num)
ezfio.set_basis_prim_coef(coefficient)
ezfio.set_basis_prim_expo(exponent)
ezfio.set_basis_shell_ang_mom(ang_mom)
ezfio.set_basis_shell_prim_num(shell_prim_num)
ezfio.set_basis_shell_prim_index(shell_prim_index)
print("OK")
# _
# |\/| _ _ |_) _. _ o _
# | | (_) _> |_) (_| _> | _>

View File

@ -709,6 +709,11 @@ def save_subninja_file(path_module):
" description = Cleaning module {0}".format(path_module.rel),
""]
l_string += ["rule make_tidy",
" command = module_handler.py tidy {0}".format(path_module.rel),
" description = Cleaning module {0}".format(path_module.rel),
""]
l_string += ["rule executables",
" command = make -C {0} executables .gitignore qp_edit.native qp_run.native".format(join("$QP_ROOT","ocaml")),
" description = Updating OCaml executables",
@ -719,6 +724,7 @@ def save_subninja_file(path_module):
"build local: make_local_binaries dummy_target", "",
"build executables: executables local dummy_target", "",
"default executables", "", "build clean: make_clean dummy_target",
"", "build tidy: make_tidy dummy_target",
""]
path_ninja_cur = join(path_module.abs, "build.ninja")
@ -745,6 +751,10 @@ def create_build_ninja_global():
" command = module_handler.py clean --all",
" description = Cleaning all modules", ""]
l_string += ["rule make_tidy",
" command = module_handler.py tidy --all",
" description = Cleaning all modules", ""]
l_string += ["rule make_ocaml",
" command = make -C {0}/ocaml".format("$QP_ROOT"),
" pool = console",
@ -759,6 +769,8 @@ def create_build_ninja_global():
"default ocaml_target",
"",
"build clean: make_clean dummy_target",
"",
"build tidy: make_tidy dummy_target",
"", ]
path_ninja_cur = join(QP_ROOT, "build.ninja")

View File

@ -6,12 +6,18 @@ Module utilitary
Usage:
module_handler.py print_descendant [<module_name>...]
module_handler.py clean [ --all | <module_name>...]
module_handler.py create_git_ignore [<module_name>...]
module_handler.py tidy [ --all | <module_name>...]
module_handler.py create_git_ignore [ --all | <module_name>...]
Options:
print_descendant Print the genealogy of the needed modules
clean Used for ninja clean
tidy A light version of clean, where only the intermediate
files are removed
create_git_ignore deprecated
NEED The path of NEED file.
by default try to open the file in the current path
"""
import os
import sys
@ -209,7 +215,7 @@ if __name__ == '__main__':
# Remove all produced ezfio_config files
for filename in os.listdir( os.path.join(QP_EZFIO, "config") ):
os.remove( os.path.join(QP_EZFIO, "config", filename) )
elif not arguments['<module_name>']:
dir_ = os.getcwd()
@ -230,11 +236,11 @@ if __name__ == '__main__':
for module in l_module:
print(" ".join(sorted(m.l_descendant_unique([module]))))
if arguments["clean"]:
if arguments["clean"] or arguments["tidy"]:
l_dir = ['IRPF90_temp', 'IRPF90_man']
l_file = ["irpf90_entities", "tags", "irpf90.make", "Makefile",
"Makefile.depend", ".ninja_log", ".ninja_deps",
"Makefile.depend", ".ninja_log", ".ninja_deps",
"ezfio_interface.irp.f"]
for module in l_module:
@ -242,25 +248,25 @@ if __name__ == '__main__':
l_symlink = m.l_descendant_unique([module])
l_exe = get_binaries(module_abs)
for f in l_dir:
try:
shutil.rmtree(os.path.join(module_abs, f))
except:
pass
for symlink in l_symlink:
try:
os.unlink(os.path.join(module_abs, symlink))
except:
pass
for f in l_file:
try:
os.remove(os.path.join(module_abs, f))
except:
pass
if arguments["clean"]:
for f in l_dir:
try:
shutil.rmtree(os.path.join(module_abs, f))
except:
pass
for symlink in l_symlink:
try:
os.unlink(os.path.join(module_abs, symlink))
except:
pass
for f in l_file:
try:
os.remove(os.path.join(module_abs, f))
except:
pass
for f in l_exe:
try:
@ -268,6 +274,4 @@ if __name__ == '__main__':
except:
pass
if arguments["create_git_ignore"]:
pass

View File

@ -132,6 +132,8 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in)
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp psi_det_sorted
PROVIDE psi_det_hii selection_weight pseudo_sym
PROVIDE n_act_orb n_inact_orb n_core_orb n_virt_orb n_del_orb seniority_max
PROVIDE pert_2rdm excitation_beta_max excitation_alpha_max excitation_max
if (h0_type == 'CFG') then
PROVIDE psi_configuration_hii det_to_configuration

View File

@ -13,7 +13,7 @@ subroutine run_stochastic_cipsi
double precision :: rss
double precision, external :: memory_of_double
PROVIDE H_apply_buffer_allocated
PROVIDE H_apply_buffer_allocated distributed_davidson mo_two_e_integrals_in_map
N_iter = 1
threshold_generators = 1.d0

View File

@ -21,7 +21,8 @@ subroutine ZMQ_selection(N_in, pt2_data)
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
PROVIDE psi_bilinear_matrix_transp_order selection_weight pseudo_sym
PROVIDE n_act_orb n_inact_orb n_core_orb n_virt_orb n_del_orb seniority_max
PROVIDE pert_2rdm excitation_beta_max excitation_alpha_max excitation_max
call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,'selection')

View File

@ -62,7 +62,8 @@ void getIthBF(Node *inode, int isomo, bool foundBF, int NSOMOMax, int getaddr, i
if(isomo == NSOMOMax){
if(inode->addr == getaddr){
for(int i = NSOMOMax-1; i > -1; i--){
int i;
for(i = NSOMOMax-1; i > -1; i--){
vecBF[i] = inode->cpl;
inode = inode->PREV;
}
@ -150,7 +151,8 @@ void getIthDet(Node *inode, int isomo, bool foundBF, int NSOMOMax, int getaddr,
if(isomo == NSOMOMax){
if(inode->addr == getaddr){
for(int i = NSOMOMax-1; i > -1; i--){
int i;
for(i = NSOMOMax-1; i > -1; i--){
vecBF[i] = inode->cpl;
inode = inode->PREV;
}
@ -224,7 +226,8 @@ void getDetlist(Node *inode, int isomo, int NSOMOMax, int *vecBF, int *detlist){
if(isomo == NSOMOMax){
int idet=0;
for(int k=0;k<NSOMOMax;k++){
int k;
for(k=0;k<NSOMOMax;k++){
if(vecBF[k] == 1) idet = idet | (1<<(NSOMOMax-1-k));
}
detlist[inode->addr]=idet;

View File

@ -34,6 +34,12 @@ doc: If |true|, a memory-mapped file may be used to store the W and S2 vectors i
default: True
interface: ezfio,provider,ocaml
[csf_based]
type: logical
doc: If |true|, use the CSF-based algorithm
default: False
interface: ezfio,provider,ocaml
[distributed_davidson]
type: logical
doc: If |true|, use the distributed algorithm
@ -52,3 +58,8 @@ doc: Maximum number of determinants where |H| is fully diagonalized
interface: ezfio,provider,ocaml
default: 1000
[without_diagonal]
type: logical
doc: If |true|, don't use denominator
default: False
interface: ezfio,provider,ocaml

View File

@ -447,14 +447,24 @@ subroutine davidson_diag_csf_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,sze_csf,N
! Compute residual vector and davidson step
! -----------------------------------------
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,k)
do k=1,N_st_diag
do i=1,sze
U(i,k) = (lambda(k) * U(i,k) - W(i,k) ) &
/max(H_jj(i) - lambda (k),1.d-2)
if (without_diagonal) then
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,k)
do k=1,N_st_diag
do i=1,sze
U(i,k) = (lambda(k) * U(i,k) - W(i,k) ) &
/max(H_jj(i) - lambda (k),1.d-2)
enddo
enddo
enddo
!$OMP END PARALLEL DO
!$OMP END PARALLEL DO
else
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,k)
do k=1,N_st_diag
do i=1,sze
U(i,k) = (lambda(k) * U(i,k) - W(i,k) )
enddo
enddo
!$OMP END PARALLEL DO
endif
do k=1,N_st
residual_norm(k) = u_dot_u(U(1,k),sze)

View File

@ -42,7 +42,7 @@ END_PROVIDER
logical :: converged
logical :: do_csf
PROVIDE threshold_davidson nthreads_davidson
PROVIDE threshold_davidson nthreads_davidson distributed_davidson
! Guess values for the "N_states" states of the |CI| eigenvectors
do j=1,min(N_states,N_det)
do i=1,N_det
@ -56,9 +56,7 @@ END_PROVIDER
enddo
enddo
! Deactivated temporarily: bug in N_csf
! do_csf = s2_eig .and. only_expected_s2 .and. (expected_s2 == 0.d0)
do_csf = .False.
do_csf = s2_eig .and. only_expected_s2 .and. csf_based
if (diag_algorithm == "Davidson") then

View File

@ -46,7 +46,7 @@ subroutine u_0_H_u_0(e_0,u_0,n,keys_tmp,Nint,N_st,sze)
do i=1,N_st
norm = u_dot_u(u_0(1,i),n)
if (norm /= 0.d0) then
e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n)
e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n) / dsqrt(norm)
else
e_0(i) = 0.d0
endif

View File

@ -75,8 +75,8 @@ subroutine u_0_HS2_u_0(e_0,s_0,u_0,n,keys_tmp,Nint,N_st,sze)
do i=1,N_st
norm = u_dot_u(u_0(1,i),n)
if (norm /= 0.d0) then
e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n)
s_0(i) = u_dot_v(s_vec(1,i),u_0(1,i),n)
e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n)/norm
s_0(i) = u_dot_v(s_vec(1,i),u_0(1,i),n)/norm
else
e_0(i) = 0.d0
s_0(i) = 0.d0

View File

@ -1,4 +1,3 @@
BEGIN_PROVIDER [ double precision, mo_overlap,(mo_num,mo_num) ]
implicit none
BEGIN_DOC

View File

@ -296,6 +296,8 @@ end
! If true, the excitation is banned in the selection. Useful with local MOs.
END_DOC
banned_excitation = .False.
use_banned_excitation = .False.
integer :: i,j, icount
integer(key_kind) :: idx
double precision :: tmp

View File

@ -127,9 +127,9 @@ function zmq_port(ishift)
END_DOC
integer, intent(in) :: ishift
character*(8) :: zmq_port
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(zmq_port,'(I8)') zmq_port_start+ishift
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
zmq_port = adjustl(trim(zmq_port))
end
@ -520,9 +520,9 @@ subroutine new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,name_in)
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
zmq_socket_pull = new_zmq_pull_socket ()
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(name,'(A,I8.8)') trim(name_in)//'.', icount
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = len(trim(name))
zmq_state = trim(name)
call lowercase(name,sze)
@ -586,9 +586,9 @@ subroutine end_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,name_in)
integer, save :: icount=0
icount = icount+1
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(name,'(A,I8.8)') trim(name_in)//'.', icount
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = len(trim(name))
call lowercase(name,sze)
if (name /= zmq_state) then
@ -710,9 +710,9 @@ integer function disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_i
disconnect_from_taskserver_state = -1
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(message,*) 'disconnect '//trim(state), worker_id
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = min(510,len(trim(message)))
rc = f77_zmq_send(zmq_to_qp_run_socket, trim(message), sze, 0)
@ -789,9 +789,9 @@ integer function zmq_abort(zmq_to_qp_run_socket)
character*(512) :: message
zmq_abort = 0
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(message,*) 'abort '
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = len(trim(message))
@ -833,9 +833,9 @@ integer function task_done_to_taskserver(zmq_to_qp_run_socket, worker_id, task_i
task_done_to_taskserver = 0
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(message,*) 'task_done '//trim(zmq_state), worker_id, task_id
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = len(trim(message))
rc = f77_zmq_send(zmq_to_qp_run_socket, trim(message), sze, 0)
@ -868,11 +868,11 @@ integer function tasks_done_to_taskserver(zmq_to_qp_run_socket, worker_id, task_
tasks_done_to_taskserver = 0
!$OMP CRITICAL(write)
!$OMP CRITICAL
allocate(character(LEN=64+n_tasks*12) :: message)
write(fmt,*) '(A,X,A,I10,X,', n_tasks, '(I11,1X))'
write(message,*) 'task_done '//trim(zmq_state), worker_id, (task_id(k), k=1,n_tasks)
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = len(trim(message))
rc = f77_zmq_send(zmq_to_qp_run_socket, trim(message), sze, 0)
@ -914,9 +914,9 @@ integer function get_task_from_taskserver(zmq_to_qp_run_socket,worker_id,task_id
get_task_from_taskserver = 0
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(message,*) 'get_task '//trim(zmq_state), worker_id
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = len(trim(message))
rc = f77_zmq_send(zmq_to_qp_run_socket, message, sze, 0)
@ -977,9 +977,9 @@ integer function get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id,task_i
get_tasks_from_taskserver = 0
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(message,'(A,A,X,I10,I10)') 'get_tasks ', trim(zmq_state), worker_id, n_tasks
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
sze = len(trim(message))
rc = f77_zmq_send(zmq_to_qp_run_socket, message, sze, 0)
@ -1079,9 +1079,9 @@ integer function zmq_delete_task(zmq_to_qp_run_socket,zmq_socket_pull,task_id,mo
zmq_delete_task = 0
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(message,*) 'del_task ', zmq_state, task_id
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(message),len(trim(message)),0)
if (rc /= len(trim(message))) then
zmq_delete_task = -1
@ -1121,9 +1121,9 @@ integer function zmq_delete_task_async_send(zmq_to_qp_run_socket,task_id,sending
endif
zmq_delete_task_async_send = 0
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(message,*) 'del_task ', zmq_state, task_id
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(message),len(trim(message)),0)
if (rc /= len(trim(message))) then
zmq_delete_task_async_send = -1
@ -1181,10 +1181,10 @@ integer function zmq_delete_tasks(zmq_to_qp_run_socket,zmq_socket_pull,task_id,n
allocate(character(LEN=64+n_tasks*12) :: message)
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(fmt,*) '(A,1X,A,1X,', n_tasks, '(I11,1X))'
write(message,*) 'del_task '//trim(zmq_state), (task_id(k), k=1,n_tasks)
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(message),len(trim(message)),0)
@ -1230,10 +1230,10 @@ integer function zmq_delete_tasks_async_send(zmq_to_qp_run_socket,task_id,n_task
allocate(character(LEN=64+n_tasks*12) :: message)
!$OMP CRITICAL(write)
!$OMP CRITICAL
write(fmt,*) '(A,1X,A,1X,', n_tasks, '(I11,1X))'
write(message,*) 'del_task '//trim(zmq_state), (task_id(k), k=1,n_tasks)
!$OMP END CRITICAL(write)
!$OMP END CRITICAL
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(message),len(trim(message)),0)