diff --git a/src/becke_numerical_grid/example.irp.f b/src/becke_numerical_grid/exemple.irp.f similarity index 100% rename from src/becke_numerical_grid/example.irp.f rename to src/becke_numerical_grid/exemple.irp.f diff --git a/src/bitmask/exemple.irp.f b/src/bitmask/exemple.irp.f new file mode 100644 index 00000000..7800e556 --- /dev/null +++ b/src/bitmask/exemple.irp.f @@ -0,0 +1,81 @@ +subroutine example_bitmask + use bitmasks ! you need to include the bitmasks_module.f90 features + implicit none + BEGIN_DOC +! subroutine that illustrates the main features available in bitmask + END_DOC + integer :: i,j + print*,'' + print*,'**************' + print*,'**************' + print*,'MO class: to set the various type of MO class, see the following exectuable' + print*,'qp_set_mo_class' + print*,'**************' + print*,'number of core orbitals = ',n_core_orb + print*,'list of the core orbitals ' + do i = 1, n_core_orb + write(*,'(2(I3,X))')i,list_core(i) + enddo + + print*,'number of inact orbitals = ',n_inact_orb + print*,'list of the inact orbitals ' + do i = 1, n_inact_orb + write(*,'(2(I3,X))')i,list_inact(i) + enddo + + print*,'number of act orbitals = ',n_act_orb + print*,'list of the act orbitals ' + do i = 1, n_act_orb + write(*,'(2(I3,X))')i,list_act(i) + enddo + + print*,'number of virt orbitals = ',n_virt_orb + print*,'list of the virt orbitals ' + do i = 1, n_virt_orb + write(*,'(2(I3,X))')i,list_virt(i) + enddo + print*,'' + print*,'**************' + print*,'**************' + print*,'manipulating bitstrings (usefull for determinant representation)' + print*,'**************' + integer(bit_kind), allocatable :: key(:) + print*,'Size of the integers used to represent all the orbitals ' + print*,'bit_kind = ',bit_kind + print*,'Number of bits in the integers ',bit_kind_size + print*,'Number of integers to represent all the orbitals on integer' + print*,'N_int = ',N_int + allocate(key(N_int)) + print*,'**** ' + print*,' initialize a bistring to zero ' + do i = 1, N_int + key(i) = 0_bit_kind + enddo + print*,'print a human readable representation of the bitstring' + call bitstring_to_str( output, key, N_int ) + print *, trim(output) + integer :: i_orb + character*(2048) :: output + + do i_orb = 1, min(4,mo_tot_num) ! you set the first four bits to 1 in key + call set_bit_to_integer(i_orb,key,N_int) + enddo + print*,'print a human readable representation of the bitstring' + call bitstring_to_str( output, key, N_int ) + print *, trim(output) + print*,'' + integer :: n_elements + integer, allocatable :: list_occ(:) + allocate(list_occ(N_int*bit_kind_size)) + call bitstring_to_list( key, list_occ, n_elements, N_int) + print*,'number of bits set to 1 = ',n_elements + print*,'list of bits set to 1 ' + do i = 1, n_elements + write(*,'(2(I3,X))')i,list_occ(i) + enddo + call clear_bit_to_integer(2,key,N_int) ! you set to 0 the second bit + print*,'print a human readable representation of the bitstring' + call bitstring_to_str( output, key, N_int ) + print *, trim(output) + +end diff --git a/src/determinants/exemple.irp.f b/src/determinants/exemple.irp.f new file mode 100644 index 00000000..24b52232 --- /dev/null +++ b/src/determinants/exemple.irp.f @@ -0,0 +1,165 @@ +subroutine example_determinants + use bitmasks ! you need to include the bitmasks_module.f90 features + implicit none + BEGIN_DOC +! subroutine that illustrates the main features available in determinants + END_DOC + print*,'a determinant is stored as a binary representation of the occupancy of the spatial orbitals' + print*,'see the bitmask module for more information about that ' + print*,'a spin determinant is an array of (N_int) integers of type bit_kind (see bitmask for more information)' + print*,'A determinant containing alpha and beta electrons is an array of dimension (2,N_int)' + integer(bit_kind), allocatable :: det_i(:,:) + allocate(det_i(N_int,2)) + print*,'det_i(1,:) alpha spins ' + print*,'det_i(2,:) beta spins ' + integer :: i,j + print*,'initialize det_i to an electron occupation corresponding RHF or ROHF: ref_bitmask ' + do i = 1, N_int + det_i(i,1) = ref_bitmask(i,1) + det_i(i,2) = ref_bitmask(i,2) + enddo + print*,'' + print*,'print a human readable representation of the determinant ' + call print_det(det_i,N_int) + print*,'doing a single excitation on top of det_i' + integer :: h1,p1,s1,i_ok + h1 = 1 + p1 = elec_alpha_num + 1 + s1 = 1 + print*,'h1 --> p1 of spin s1' + print*,'i_ok == +1 : excitation is possible ' + print*,'i_ok == -1 : excitation is NOT possible ' + call do_mono_excitation(det_i,h1,p1,s1,i_ok) + print*,'h1,p1,s1,i_ok' + print*, h1,p1,s1,i_ok + if(i_ok == -1)then + print*,'excitation was not possible ' + stop + endif + call debug_det(det_i,N_int) + print*,'computing the interaction between ref_determinant and det_i ' + double precision :: h0i,hii,h00 + call i_H_j(det_i,det_i,N_int,h0i) + print*,' < ref | H | det_i > = ',h0i + print*,'computing the diagonal Hamiltonian matrix element of det_i ' + call i_H_j(ref_bitmask,det_i,N_int,hii) + print*,'< det_i | H | det_i > = ',hii + print*,'computing the first-order coefficient of det_i with H0=EN ' + double precision :: c_i + call i_H_j(ref_bitmask,ref_bitmask,N_int,h00) + c_i = h0i/(h00 - hii) + print*,'c_i^{(1)} = ',c_i + print*,'' + print*,'doing another single excitation on top of det_i' + h1 = elec_alpha_num + p1 = elec_alpha_num + 1 + s1 = 2 + call do_mono_excitation(det_i,h1,p1,s1,i_ok) + print*,'h1,p1,s1,i_ok' + print*, h1,p1,s1,i_ok + call i_H_j(det_i,det_i,N_int,h0i) + print*,' < ref | H | det_i > = ',h0i + print*,'computing the diagonal Hamiltonian matrix element of det_i ' + call i_H_j(ref_bitmask,ref_bitmask,N_int,h00) + c_i = h0i/(h00 - hii) + print*,'c_i^{(1)} = ',c_i + print*,'' + print*,'Finding the excitation degree between two arbitrary determinants ' + integer :: exc(0:2,2,2) + double precision :: phase + integer :: h2,p2,s2,degree + call get_excitation_degree(ref_bitmask,det_i,degree,N_int) + print*,'degree = ',degree + print*,'Finding the differences in terms of holes and particles, together with the fermionic phase ' + call get_excitation(ref_bitmask,det_i,exc,degree,phase,N_int) + print*,'Fermionic phase for the excitation from ref_bitmask to det_i' + print*,phase + print*,'put the excitation information in a human readable format' + call decode_exc(exc,degree,h1,p1,h2,p2,s1,s2) + print*,'s1',s1 + print*,'h1,p1 = ',h1,p1 + print*,'s2',s2 + print*,'h2,p2 = ',h2,p2 + print*,'' + print*,'Finding the occupancy of det_i' + integer, allocatable :: occ(:,:) + integer :: n_occ_ab(2) + allocate(occ(N_int*bit_kind_size,2)) + call bitstring_to_list_ab(det_i, occ, n_occ_ab, N_int) + print*,'alpha electrons orbital occupancy' + do i = 1, n_occ_ab(1) ! browsing the alpha electrons + print*,occ(i,1) + enddo + print*,'beta electrons orbital occupancy' + do i = 1, n_occ_ab(2) ! browsing the beta electrons + print*,occ(i,2) + enddo +end + + +subroutine example_determinants_psi_det + use bitmasks ! you need to include the bitmasks_module.f90 features + implicit none + BEGIN_DOC +! subroutine that illustrates the main features available in determinants using the psi_det/psi_coef + END_DOC + read_wf = .True. + touch read_wf + ! you force the wave function to be set to the one in the EZFIO folder + call routine_example_psi_det +end + +subroutine routine_example_psi_det + use bitmasks ! you need to include the bitmasks_module.f90 features + implicit none + BEGIN_DOC +! subroutine that illustrates the main features available in determinants using many determinants + END_DOC + integer :: i,j + integer, allocatable :: degree_list(:) + integer, allocatable :: idx(:) + allocate(degree_list(N_det),idx(0:N_det)) + + print*,'Number of determinants in the wave function' + print*,'N_det = ',N_det + print*,'' + print*,'Printing in a human readable format all Slater determinants ' + do i = 1, N_det + call debug_det(psi_det(1,1,i),N_int) + enddo + print*,'' + print*,'Number of states computed ' + print*,'N_states = ',N_states + print*,'Printing the coefficients for all states for all Slater determinants ' + do j = 1, N_states + print*,'State = ',j + do i = 1, N_det + write(*,'(I9,X,F16.10)')i,psi_coef(i,j) + enddo + enddo + print*,'' + print*,'Finding the connection through a bielectronic operator in the wave function' + print*,'You want to know the connections of the first determinant ' + ! wave function determinant exc degree list + call get_excitation_degree_vector( psi_det , psi_det(1,1,1),degree_list,N_int,N_det,idx) + double precision :: hij + double precision, allocatable :: i_H_psi(:) + allocate(i_H_psi(N_states)) + i_H_psi = 0.d0 + print*,'Computing = \sum_I c_I ' + do i = 1, idx(0) ! number of Slater determinants connected to the first one + print*,'Determinant connected' + call debug_det(psi_det(1,1,idx(i)),N_int) + print*,'excitation degree = ',degree_list(i) + call i_H_j(psi_det(1,1,1) , psi_det(1,1,idx(i)),hij,N_int) + do j = 1, N_states + i_H_psi(j) += hij * psi_coef(idx(i),j) + enddo + enddo + print*,'i_H_psi = ',i_H_psi +end + + + + +