9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-21 11:03:29 +01:00

Merge alors

This commit is contained in:
Emmanuel Giner LCT 2019-10-24 13:55:38 +02:00
parent 502e787323
commit 40239f100c
24 changed files with 500 additions and 563 deletions

39
TODO
View File

@ -2,16 +2,8 @@
* Faire que le slave de Hartree-fock est le calcul des integrales AO en parallele * Faire que le slave de Hartree-fock est le calcul des integrales AO en parallele
# Web/doc
* Creer une page web pas trop degueu et la mettre ici : http://lcpq.github.io/quantum_package
* Creer une page avec la liste de tous les exectuables
# Exterieur # Exterieur
* Molden format : http://cheminf.cmbi.ru.nl/molden/molden_format.html : read+write. Thomas est dessus
* Un module pour lire les integrales Moleculaires depuis un FCIDUMP * Un module pour lire les integrales Moleculaires depuis un FCIDUMP
* Un module pour lire des integrales Atomiques (voir module de Mimi pour lire les AO Slater) * Un module pour lire des integrales Atomiques (voir module de Mimi pour lire les AO Slater)
* Format Fchk (gaussian) * Format Fchk (gaussian)
@ -24,16 +16,8 @@
# User doc: # User doc:
* Videos:
+) RHF
* Renvoyer a la doc des modules : c'est pour les programmeurs au depart!
* Mettre le mp2 comme exercice * Mettre le mp2 comme exercice
* Interfaces : molden/fcidump * Interfaces : molden/fcidump
* Natural orbitals
* Parameters for Hartree-Fock
* Parameters for Davidson
* Running in parallel
# Programmers doc: # Programmers doc:
@ -42,33 +26,10 @@
# Config file for Cray # Config file for Cray
# EZFIO sans fork
Refaire les benchmarks
# Documentation de qpsh
# Documentation de /etc # Documentation de /etc
# Toto
Re-design de qp command
Doc: plugins et qp_plugins
Ajouter les symetries dans devel Ajouter les symetries dans devel
<<<<<<< HEAD
Compiler ezfio avec openmp
# Parallelize i_H_psi
=======
# Parallelize i_H_psi
<<<<<<< HEAD
=======
>>>>>>> minor_modifs
IMPORTANT: IMPORTANT:
Davidson Diagonalization Davidson Diagonalization

2
configure vendored
View File

@ -11,6 +11,8 @@ eval set -- "$TEMP"
export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )" export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )"
echo "QP_ROOT="$QP_ROOT echo "QP_ROOT="$QP_ROOT
unset CC
unset CCXX
# When updating version, update also etc files # When updating version, update also etc files

View File

@ -92,52 +92,58 @@ F 1
1 0.0816000 1.0000000 1 0.0816000 1.0000000
BERYLLIUM BERYLLIUM
S 9 S 11
1 6863.0000000 0.0002360 1 6.863000E+03 2.360000E-04
2 1030.0000000 0.0018260 2 1.030000E+03 1.826000E-03
3 234.7000000 0.0094520 3 2.347000E+02 9.452000E-03
4 66.5600000 0.0379570 4 6.656000E+01 3.795700E-02
5 21.6900000 0.1199650 5 2.169000E+01 1.199650E-01
6 7.7340000 0.2821620 6 7.734000E+00 2.821620E-01
7 2.9160000 0.4274040 7 2.916000E+00 4.274040E-01
8 1.1300000 0.2662780 8 1.130000E+00 2.662780E-01
9 0.1101000 -0.0072750 9 2.577000E-01 1.819300E-02
S 9 10 1.101000E-01 -7.275000E-03
1 6863.0000000 -0.0000430 11 4.409000E-02 1.903000E-03
2 1030.0000000 -0.0003330 S 11
3 234.7000000 -0.0017360 1 6.863000E+03 -4.300000E-05
4 66.5600000 -0.0070120 2 1.030000E+03 -3.330000E-04
5 21.6900000 -0.0231260 3 2.347000E+02 -1.736000E-03
6 7.7340000 -0.0581380 4 6.656000E+01 -7.012000E-03
7 2.9160000 -0.1145560 5 2.169000E+01 -2.312600E-02
8 1.1300000 -0.1359080 6 7.734000E+00 -5.813800E-02
9 0.1101000 0.5774410 7 2.916000E+00 -1.145560E-01
8 1.130000E+00 -1.359080E-01
9 2.577000E-01 2.280260E-01
10 1.101000E-01 5.774410E-01
11 4.409000E-02 3.178730E-01
S 1 S 1
1 0.2577000 1.0000000 1 2.577000E-01 1.000000E+00
S 1 S 1
1 0.0440900 1.0000000 1 4.409000E-02 1.000000E+00
S 1 S 1
1 0.0150300 1.0000000 1 1.470000E-02 1.000000E+00
P 3 P 5
1 7.4360000 0.0107360 1 7.436000E+00 1.073600E-02
2 1.5770000 0.0628540 2 1.577000E+00 6.285400E-02
3 0.4352000 0.2481800 3 4.352000E-01 2.481800E-01
4 1.438000E-01 5.236990E-01
5 4.994000E-02 3.534250E-01
P 1 P 1
1 0.1438000 1.0000000 1 1.438000E-01 1.000000E+00
P 1 P 1
1 0.0499400 1.0000000 1 4.994000E-02 1.000000E+00
P 1 P 1
1 0.0070600 1.0000000 1 9.300000E-03 1.000000E+00
D 1 D 1
1 0.3480000 1.0000000 1 3.493000E-01 1.000000E+00
D 1 D 1
1 0.1803000 1.0000000 1 1.724000E-01 1.000000E+00
D 1 D 1
1 0.0654000 1.0000000 1 5.880000E-02 1.000000E+00
F 1 F 1
1 0.3250000 1.0000000 1 3.423000E-01 1.0000000
F 1 F 1
1 0.1533000 1.0000000 1 1.188000E-01 1.000000E+00
BORON BORON
S 8 S 8

View File

@ -15,7 +15,7 @@ module Determinants_by_hand : sig
state_average_weight : Positive_float.t array; state_average_weight : Positive_float.t array;
} [@@deriving sexp] } [@@deriving sexp]
val read : ?full:bool -> unit -> t option val read : ?full:bool -> unit -> t option
val write : t -> unit val write : ?force:bool -> t -> unit
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t option val of_rst : Rst_string.t -> t option
@ -318,22 +318,23 @@ end = struct
None None
;; ;;
let write { n_int ; let write ?(force=false)
bit_kind ; { n_int ;
n_det ; bit_kind ;
n_det_qp_edit ; n_det ;
expected_s2 ; n_det_qp_edit ;
psi_coef ; expected_s2 ;
psi_det ; psi_coef ;
n_states ; psi_det ;
state_average_weight ; n_states ;
} = state_average_weight ;
} =
write_n_int n_int ; write_n_int n_int ;
write_bit_kind bit_kind; write_bit_kind bit_kind;
write_n_det n_det; write_n_det n_det;
write_n_states n_states; write_n_states n_states;
write_expected_s2 expected_s2; write_expected_s2 expected_s2;
if n_det <= n_det_qp_edit then if force || (n_det <= n_det_qp_edit) then
begin begin
write_n_det_qp_edit n_det; write_n_det_qp_edit n_det;
write_psi_coef ~n_det:n_det ~n_states:n_states psi_coef ; write_psi_coef ~n_det:n_det ~n_states:n_states psi_coef ;
@ -596,7 +597,7 @@ psi_det = %s
let new_det = let new_det =
{ det with n_det = (Det_number.of_int n_det_new) } { det with n_det = (Det_number.of_int n_det_new) }
in in
write new_det write ~force:true new_det
;; ;;
let extract_state istate = let extract_state istate =
@ -628,7 +629,7 @@ psi_det = %s
let new_det = let new_det =
{ det with n_states = (States_number.of_int 1) } { det with n_states = (States_number.of_int 1) }
in in
write new_det write ~force:true new_det
;; ;;
let extract_states range = let extract_states range =
@ -665,6 +666,7 @@ psi_det = %s
det.psi_coef.(!state_shift+i) <- det.psi_coef.(!state_shift+i) <-
det.psi_coef.(i+ishift) det.psi_coef.(i+ishift)
done done
; Printf.printf "OK\n%!" ;
end; end;
state_shift := !state_shift + n_det state_shift := !state_shift + n_det
) sorted_list ) sorted_list
@ -672,7 +674,7 @@ psi_det = %s
let new_det = let new_det =
{ det with n_states = (States_number.of_int @@ List.length sorted_list) } { det with n_states = (States_number.of_int @@ List.length sorted_list) }
in in
write new_det write ~force:true new_det
;; ;;
end end

View File

@ -175,7 +175,7 @@ nucl_coord = %s
nucl_num nucl_num
) :: ( ) :: (
List.init nucl_num (fun i-> List.init nucl_num (fun i->
Printf.sprintf " %-3s %d %s" Printf.sprintf " %-3s %3d %s"
(b.nucl_label.(i) |> Element.to_string) (b.nucl_label.(i) |> Element.to_string)
(b.nucl_charge.(i) |> Charge.to_int ) (b.nucl_charge.(i) |> Charge.to_int )
(b.nucl_coord.(i) |> Point3d.to_string ~units:Units.Angstrom) ) (b.nucl_coord.(i) |> Point3d.to_string ~units:Units.Angstrom) )

View File

@ -839,21 +839,6 @@ if __name__ == "__main__":
l_module = d_binaries.keys() l_module = d_binaries.keys()
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ #
# C h e c k _ c o h e r e n c y #
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ #
for module in dict_root_path.values():
if module not in d_binaries:
l_msg = ["{0} is a root module but does not contain a main file.",
"- Create it in {0}",
"- Or delete {0} `qp_module uninstall {0}`",
"- Or install a module that needs {0} with a main "]
print "\n".join(l_msg).format(module.rel)
sys.exit(1)
# ~#~#~#~#~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~#~#~#~#~ #
# G l o b a l _ b u i l d # # G l o b a l _ b u i l d #
# ~#~#~#~#~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~#~#~#~#~ #

View File

@ -120,7 +120,7 @@ let set str s =
match s with match s with
{write} {write}
| Electrons -> write Electrons.(of_rst, write) s | Electrons -> write Electrons.(of_rst, write) s
| Determinants_by_hand -> write Determinants_by_hand.(of_rst, write) s | Determinants_by_hand -> write Determinants_by_hand.(of_rst, write ~force:false) s
| Nuclei_by_hand -> write Nuclei_by_hand.(of_rst, write) s | Nuclei_by_hand -> write Nuclei_by_hand.(of_rst, write) s
| Ao_basis -> () (* TODO *) | Ao_basis -> () (* TODO *)
| Mo_basis -> () (* TODO *) | Mo_basis -> () (* TODO *)

View File

@ -3,28 +3,28 @@ integer function number_of_holes(key_in)
BEGIN_DOC BEGIN_DOC
! Function that returns the number of holes in the inact space ! Function that returns the number of holes in the inact space
! !
! popcnt( ! popcnt(
! xor( ! xor(
! iand( ! iand(
! reunion_of_core_inact_bitmask(1,1), ! reunion_of_core_inact_bitmask(1,1),
! xor( ! xor(
! key_in(1,1), ! key_in(1,1),
! iand( ! iand(
! key_in(1,1), ! key_in(1,1),
! cas_bitmask(1,1,1)) ! cas_bitmask(1,1,1))
! ) ! )
! ), ! ),
! reunion_of_core_inact_bitmask(1,1)) ) ! reunion_of_core_inact_bitmask(1,1)) )
! !
! (key_in && cas_bitmask) ! (key_in && cas_bitmask)
! +---------------------+ ! +---------------------+
! electrons in cas xor key_in ! electrons in cas xor key_in
! +---------------------------------+ ! +---------------------------------+
! electrons outside of cas && reunion_of_core_inact_bitmask ! electrons outside of cas && reunion_of_core_inact_bitmask
! +------------------------------------------------------------------+ ! +------------------------------------------------------------------+
! electrons in the core/inact space xor reunion_of_core_inact_bitmask ! electrons in the core/inact space xor reunion_of_core_inact_bitmask
! +---------------------------------------------------------------------------------+ ! +---------------------------------------------------------------------------------+
! holes ! holes
END_DOC END_DOC
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
@ -59,48 +59,6 @@ integer function number_of_holes(key_in)
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) )& + popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) )& + popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) ) + popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) )
else if(N_int == 5)then
number_of_holes = number_of_holes &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,1), xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1)))), reunion_of_core_inact_bitmask(5,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,2), xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1)))), reunion_of_core_inact_bitmask(5,2)) )
else if(N_int == 6)then
number_of_holes = number_of_holes &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,1), xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1)))), reunion_of_core_inact_bitmask(5,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,2), xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1)))), reunion_of_core_inact_bitmask(5,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,1), xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1)))), reunion_of_core_inact_bitmask(6,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,2), xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1)))), reunion_of_core_inact_bitmask(6,2)) )
else if(N_int == 7)then
number_of_holes = number_of_holes &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,1), xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1)))), reunion_of_core_inact_bitmask(5,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,2), xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1)))), reunion_of_core_inact_bitmask(5,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,1), xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1)))), reunion_of_core_inact_bitmask(6,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,2), xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1)))), reunion_of_core_inact_bitmask(6,2)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(7,1), xor(key_in(7,1),iand(key_in(7,1),cas_bitmask(7,1,1)))), reunion_of_core_inact_bitmask(7,1)) )&
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(7,2), xor(key_in(7,2),iand(key_in(7,2),cas_bitmask(7,2,1)))), reunion_of_core_inact_bitmask(7,2)) )
else else
do i = 1, N_int do i = 1, N_int
number_of_holes = number_of_holes & number_of_holes = number_of_holes &
@ -131,97 +89,37 @@ integer function number_of_particles(key_in)
number_of_particles= 0 number_of_particles= 0
if(N_int == 1)then if(N_int == 1)then
number_of_particles= number_of_particles & number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) )) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ))
else if(N_int == 2)then else if(N_int == 2)then
number_of_particles= number_of_particles & number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) & + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) & + popcnt( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) + popcnt( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ) )
else if(N_int == 3)then else if(N_int == 3)then
number_of_particles= number_of_particles & number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) )) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) & + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) )) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) & + popcnt( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) )) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) & + popcnt( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) )) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) & + popcnt( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) )) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) + popcnt( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ))
else if(N_int == 4)then else if(N_int == 4)then
number_of_particles= number_of_particles & number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) & + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) & + popcnt( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) & + popcnt( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) & + popcnt( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) & + popcnt( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) & + popcnt( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) + popcnt( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ) )
else if(N_int == 5)then
number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) )
else if(N_int == 6)then
number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) ) &
+ popcnt( iand( iand( xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1))), virt_bitmask(6,1) ), virt_bitmask(6,1)) ) &
+ popcnt( iand( iand( xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1))), virt_bitmask(6,2) ), virt_bitmask(6,2)) )
else if(N_int == 7)then
number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) ) &
+ popcnt( iand( iand( xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1))), virt_bitmask(6,1) ), virt_bitmask(6,1)) ) &
+ popcnt( iand( iand( xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1))), virt_bitmask(6,2) ), virt_bitmask(6,2)) ) &
+ popcnt( iand( iand( xor(key_in(7,1),iand(key_in(7,1),cas_bitmask(7,1,1))), virt_bitmask(7,1) ), virt_bitmask(7,1)) ) &
+ popcnt( iand( iand( xor(key_in(7,2),iand(key_in(7,2),cas_bitmask(7,2,1))), virt_bitmask(7,2) ), virt_bitmask(7,2)) )
else if(N_int == 8)then
number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) ) &
+ popcnt( iand( iand( xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1))), virt_bitmask(6,1) ), virt_bitmask(6,1)) ) &
+ popcnt( iand( iand( xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1))), virt_bitmask(6,2) ), virt_bitmask(6,2)) ) &
+ popcnt( iand( iand( xor(key_in(7,1),iand(key_in(7,1),cas_bitmask(7,1,1))), virt_bitmask(7,1) ), virt_bitmask(7,1)) ) &
+ popcnt( iand( iand( xor(key_in(7,2),iand(key_in(7,2),cas_bitmask(7,2,1))), virt_bitmask(7,2) ), virt_bitmask(7,2)) ) &
+ popcnt( iand( iand( xor(key_in(8,1),iand(key_in(8,1),cas_bitmask(8,1,1))), virt_bitmask(8,1) ), virt_bitmask(8,1)) ) &
+ popcnt( iand( iand( xor(key_in(8,2),iand(key_in(8,2),cas_bitmask(8,2,1))), virt_bitmask(8,2) ), virt_bitmask(8,2)) )
else else
do i = 1, N_int do i = 1, N_int
number_of_particles= number_of_particles & number_of_particles= number_of_particles &
+ popcnt( iand( iand( xor(key_in(i,1),iand(key_in(i,1),cas_bitmask(i,1,1))), virt_bitmask(i,1) ), virt_bitmask(i,1)) ) & + popcnt( iand( xor(key_in(i,1),iand(key_in(i,1),cas_bitmask(i,1,1))), virt_bitmask(i,1) )) &
+ popcnt( iand( iand( xor(key_in(i,2),iand(key_in(i,2),cas_bitmask(i,2,1))), virt_bitmask(i,2) ), virt_bitmask(i,2)) ) + popcnt( iand( xor(key_in(i,2),iand(key_in(i,2),cas_bitmask(i,2,1))), virt_bitmask(i,2) ))
enddo enddo
endif endif
end end
@ -248,163 +146,51 @@ logical function is_a_two_holes_two_particles(key_in)
i_diff = i_diff & i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ) )
else if(N_int == 2)then else if(N_int == 2)then
i_diff = i_diff & i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) & + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) & + popcnt( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) )) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) + popcnt( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ))
else if(N_int == 3)then else if(N_int == 3)then
i_diff = i_diff & i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) & + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) & + popcnt( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) & + popcnt( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) & + popcnt( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) + popcnt( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ) )
else if(N_int == 4)then else if(N_int == 4)then
i_diff = i_diff & i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) & + popcnt( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) & + popcnt( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) & + popcnt( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) & + popcnt( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) & + popcnt( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) & + popcnt( iand( xor(key_in(4,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) & + popcnt( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) + popcnt( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ) )
else if(N_int == 5)then
i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,1), xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1)))), reunion_of_core_inact_bitmask(5,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,2), xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1)))), reunion_of_core_inact_bitmask(5,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) )
else if(N_int == 6)then
i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,1), xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1)))), reunion_of_core_inact_bitmask(5,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,2), xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1)))), reunion_of_core_inact_bitmask(5,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,1), xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1)))), reunion_of_core_inact_bitmask(6,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,2), xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1)))), reunion_of_core_inact_bitmask(6,2)) ) &
+ popcnt( iand( iand( xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1))), virt_bitmask(6,1) ), virt_bitmask(6,1)) ) &
+ popcnt( iand( iand( xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1))), virt_bitmask(6,2) ), virt_bitmask(6,2)) )
else if(N_int == 7)then
i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,1), xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1)))), reunion_of_core_inact_bitmask(5,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,2), xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1)))), reunion_of_core_inact_bitmask(5,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,1), xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1)))), reunion_of_core_inact_bitmask(6,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,2), xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1)))), reunion_of_core_inact_bitmask(6,2)) ) &
+ popcnt( iand( iand( xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1))), virt_bitmask(6,1) ), virt_bitmask(6,1)) ) &
+ popcnt( iand( iand( xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1))), virt_bitmask(6,2) ), virt_bitmask(6,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(7,1), xor(key_in(7,1),iand(key_in(7,1),cas_bitmask(7,1,1)))), reunion_of_core_inact_bitmask(7,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(7,2), xor(key_in(7,2),iand(key_in(7,2),cas_bitmask(7,2,1)))), reunion_of_core_inact_bitmask(7,2)) ) &
+ popcnt( iand( iand( xor(key_in(7,1),iand(key_in(7,1),cas_bitmask(7,1,1))), virt_bitmask(7,1) ), virt_bitmask(7,1)) ) &
+ popcnt( iand( iand( xor(key_in(7,2),iand(key_in(7,2),cas_bitmask(7,2,1))), virt_bitmask(7,2) ), virt_bitmask(7,2)) )
else if(N_int == 8)then
i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,1), xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1)))), reunion_of_core_inact_bitmask(1,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(1,2), xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1)))), reunion_of_core_inact_bitmask(1,2)) ) &
+ popcnt( iand( iand( xor(key_in(1,1),iand(key_in(1,1),cas_bitmask(1,1,1))), virt_bitmask(1,1) ), virt_bitmask(1,1)) ) &
+ popcnt( iand( iand( xor(key_in(1,2),iand(key_in(1,2),cas_bitmask(1,2,1))), virt_bitmask(1,2) ), virt_bitmask(1,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,1), xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1)))), reunion_of_core_inact_bitmask(2,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(2,2), xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1)))), reunion_of_core_inact_bitmask(2,2)) ) &
+ popcnt( iand( iand( xor(key_in(2,1),iand(key_in(2,1),cas_bitmask(2,1,1))), virt_bitmask(2,1) ), virt_bitmask(2,1)) ) &
+ popcnt( iand( iand( xor(key_in(2,2),iand(key_in(2,2),cas_bitmask(2,2,1))), virt_bitmask(2,2) ), virt_bitmask(2,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,1), xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1)))), reunion_of_core_inact_bitmask(3,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(3,2), xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1)))), reunion_of_core_inact_bitmask(3,2)) ) &
+ popcnt( iand( iand( xor(key_in(3,1),iand(key_in(3,1),cas_bitmask(3,1,1))), virt_bitmask(3,1) ), virt_bitmask(3,1)) ) &
+ popcnt( iand( iand( xor(key_in(3,2),iand(key_in(3,2),cas_bitmask(3,2,1))), virt_bitmask(3,2) ), virt_bitmask(3,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,1), xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1)))), reunion_of_core_inact_bitmask(4,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(4,2), xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1)))), reunion_of_core_inact_bitmask(4,2)) ) &
+ popcnt( iand( iand( xor(key_in(4,1),iand(key_in(4,1),cas_bitmask(4,1,1))), virt_bitmask(4,1) ), virt_bitmask(4,1)) ) &
+ popcnt( iand( iand( xor(key_in(4,2),iand(key_in(4,2),cas_bitmask(4,2,1))), virt_bitmask(4,2) ), virt_bitmask(4,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,1), xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1)))), reunion_of_core_inact_bitmask(5,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(5,2), xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1)))), reunion_of_core_inact_bitmask(5,2)) ) &
+ popcnt( iand( iand( xor(key_in(5,1),iand(key_in(5,1),cas_bitmask(5,1,1))), virt_bitmask(5,1) ), virt_bitmask(5,1)) ) &
+ popcnt( iand( iand( xor(key_in(5,2),iand(key_in(5,2),cas_bitmask(5,2,1))), virt_bitmask(5,2) ), virt_bitmask(5,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,1), xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1)))), reunion_of_core_inact_bitmask(6,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(6,2), xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1)))), reunion_of_core_inact_bitmask(6,2)) ) &
+ popcnt( iand( iand( xor(key_in(6,1),iand(key_in(6,1),cas_bitmask(6,1,1))), virt_bitmask(6,1) ), virt_bitmask(6,1)) ) &
+ popcnt( iand( iand( xor(key_in(6,2),iand(key_in(6,2),cas_bitmask(6,2,1))), virt_bitmask(6,2) ), virt_bitmask(6,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(7,1), xor(key_in(7,1),iand(key_in(7,1),cas_bitmask(7,1,1)))), reunion_of_core_inact_bitmask(7,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(7,2), xor(key_in(7,2),iand(key_in(7,2),cas_bitmask(7,2,1)))), reunion_of_core_inact_bitmask(7,2)) ) &
+ popcnt( iand( iand( xor(key_in(7,1),iand(key_in(7,1),cas_bitmask(7,1,1))), virt_bitmask(7,1) ), virt_bitmask(7,1)) ) &
+ popcnt( iand( iand( xor(key_in(7,2),iand(key_in(7,2),cas_bitmask(7,2,1))), virt_bitmask(7,2) ), virt_bitmask(7,2)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(8,1), xor(key_in(8,1),iand(key_in(8,1),cas_bitmask(8,1,1)))), reunion_of_core_inact_bitmask(8,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(8,2), xor(key_in(8,2),iand(key_in(8,2),cas_bitmask(8,2,1)))), reunion_of_core_inact_bitmask(8,2)) ) &
+ popcnt( iand( iand( xor(key_in(8,1),iand(key_in(8,1),cas_bitmask(8,1,1))), virt_bitmask(8,1) ), virt_bitmask(8,1)) ) &
+ popcnt( iand( iand( xor(key_in(8,2),iand(key_in(8,2),cas_bitmask(8,2,1))), virt_bitmask(8,2) ), virt_bitmask(8,2)) )
else else
@ -412,8 +198,8 @@ logical function is_a_two_holes_two_particles(key_in)
i_diff = i_diff & i_diff = i_diff &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(i,1), xor(key_in(i,1),iand(key_in(i,1),cas_bitmask(i,1,1)))), reunion_of_core_inact_bitmask(i,1)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(i,1), xor(key_in(i,1),iand(key_in(i,1),cas_bitmask(i,1,1)))), reunion_of_core_inact_bitmask(i,1)) ) &
+ popcnt( xor( iand(reunion_of_core_inact_bitmask(i,2), xor(key_in(i,2),iand(key_in(i,2),cas_bitmask(i,2,1)))), reunion_of_core_inact_bitmask(i,2)) ) & + popcnt( xor( iand(reunion_of_core_inact_bitmask(i,2), xor(key_in(i,2),iand(key_in(i,2),cas_bitmask(i,2,1)))), reunion_of_core_inact_bitmask(i,2)) ) &
+ popcnt( iand( iand( xor(key_in(i,1),iand(key_in(i,1),cas_bitmask(i,1,1))), virt_bitmask(i,1) ), virt_bitmask(i,1)) ) & + popcnt( iand( xor(key_in(i,1),iand(key_in(i,1),cas_bitmask(i,1,1))), virt_bitmask(i,1) )) &
+ popcnt( iand( iand( xor(key_in(i,2),iand(key_in(i,2),cas_bitmask(i,2,1))), virt_bitmask(i,2) ), virt_bitmask(i,2)) ) + popcnt( iand( xor(key_in(i,2),iand(key_in(i,2),cas_bitmask(i,2,1))), virt_bitmask(i,2) ))
enddo enddo
endif endif
is_a_two_holes_two_particles = (i_diff >3) is_a_two_holes_two_particles = (i_diff >3)
@ -484,10 +270,8 @@ logical function is_a_1h1p(key_in)
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
integer :: number_of_particles, number_of_holes integer :: number_of_particles, number_of_holes
is_a_1h1p = .False.
if(number_of_holes(key_in).eq.1 .and. number_of_particles(key_in).eq.1)then is_a_1h1p = (number_of_holes(key_in) == 1) .and. (number_of_particles(key_in) == 1)
is_a_1h1p = .True.
endif
end end
@ -495,10 +279,8 @@ logical function is_a_1h2p(key_in)
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
integer :: number_of_particles, number_of_holes integer :: number_of_particles, number_of_holes
is_a_1h2p = .False.
if(number_of_holes(key_in).eq.1 .and. number_of_particles(key_in).eq.2)then is_a_1h2p = (number_of_holes(key_in) == 1) .and. (number_of_particles(key_in) == 2)
is_a_1h2p = .True.
endif
end end
@ -506,10 +288,8 @@ logical function is_a_2h1p(key_in)
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
integer :: number_of_particles, number_of_holes integer :: number_of_particles, number_of_holes
is_a_2h1p = .False.
if(number_of_holes(key_in).eq.2 .and. number_of_particles(key_in).eq.1)then is_a_2h1p = (number_of_holes(key_in) == 2) .and. (number_of_particles(key_in) == 1)
is_a_2h1p = .True.
endif
end end
@ -517,10 +297,8 @@ logical function is_a_1h(key_in)
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
integer :: number_of_particles, number_of_holes integer :: number_of_particles, number_of_holes
is_a_1h = .False.
if(number_of_holes(key_in).eq.1 .and. number_of_particles(key_in).eq.0)then is_a_1h = (number_of_holes(key_in) == 1) .and. (number_of_particles(key_in) == 0)
is_a_1h = .True.
endif
end end
@ -528,10 +306,8 @@ logical function is_a_1p(key_in)
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
integer :: number_of_particles, number_of_holes integer :: number_of_particles, number_of_holes
is_a_1p = .False.
if(number_of_holes(key_in).eq.0 .and. number_of_particles(key_in).eq.1)then is_a_1p = (number_of_holes(key_in) == 0) .and. (number_of_particles(key_in) == 1)
is_a_1p = .True.
endif
end end
@ -539,10 +315,8 @@ logical function is_a_2p(key_in)
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
integer :: number_of_particles, number_of_holes integer :: number_of_particles, number_of_holes
is_a_2p = .False.
if(number_of_holes(key_in).eq.0 .and. number_of_particles(key_in).eq.2)then is_a_2p = (number_of_holes(key_in) == 0) .and. (number_of_particles(key_in) == 2)
is_a_2p = .True.
endif
end end
@ -550,10 +324,8 @@ logical function is_a_2h(key_in)
implicit none implicit none
integer(bit_kind), intent(in) :: key_in(N_int,2) integer(bit_kind), intent(in) :: key_in(N_int,2)
integer :: number_of_particles, number_of_holes integer :: number_of_particles, number_of_holes
is_a_2h = .False.
if(number_of_holes(key_in).eq.2 .and. number_of_particles(key_in).eq.0)then is_a_2h = (number_of_holes(key_in) == 2) .and. (number_of_particles(key_in) == 0)
is_a_2h = .True.
endif
end end

View File

@ -156,7 +156,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in)
do pt2_stoch_istate=1,N_states do pt2_stoch_istate=1,N_states
state_average_weight(:) = 0.d0 state_average_weight(:) = 0.d0
state_average_weight(pt2_stoch_istate) = 1.d0 state_average_weight(pt2_stoch_istate) = 1.d0
TOUCH state_average_weight pt2_stoch_istate TOUCH state_average_weight pt2_stoch_istate selection_weight
PROVIDE nproc pt2_F mo_two_e_integrals_in_map mo_one_e_integrals pt2_w PROVIDE nproc pt2_F mo_two_e_integrals_in_map mo_one_e_integrals pt2_w
PROVIDE psi_selectors pt2_u pt2_J pt2_R PROVIDE psi_selectors pt2_u pt2_J pt2_R
@ -720,92 +720,95 @@ END_PROVIDER
BEGIN_PROVIDER [ double precision, pt2_w, (N_det_generators) ] BEGIN_PROVIDER [ double precision, pt2_w, (N_det_generators) ]
&BEGIN_PROVIDER [ double precision, pt2_cW, (0:N_det_generators) ] &BEGIN_PROVIDER [ double precision, pt2_cW, (0:N_det_generators) ]
&BEGIN_PROVIDER [ double precision, pt2_W_T ] &BEGIN_PROVIDER [ double precision, pt2_W_T ]
&BEGIN_PROVIDER [ double precision, pt2_u_0 ] &BEGIN_PROVIDER [ double precision, pt2_u_0 ]
&BEGIN_PROVIDER [ integer, pt2_n_0, (pt2_N_teeth+1) ] &BEGIN_PROVIDER [ integer, pt2_n_0, (pt2_N_teeth+1) ]
implicit none implicit none
integer :: i, t integer :: i, t
double precision, allocatable :: tilde_w(:), tilde_cW(:) double precision, allocatable :: tilde_w(:), tilde_cW(:)
double precision :: r, tooth_width double precision :: r, tooth_width
integer, external :: pt2_find_sample integer, external :: pt2_find_sample
double precision :: rss
double precision, external :: memory_of_double, memory_of_int
rss = memory_of_double(2*N_det_generators+1)
call check_mem(rss,irp_here)
if (N_det_generators == 1) then
pt2_w(1) = 1.d0
pt2_cw(1) = 1.d0
pt2_u_0 = 1.d0
pt2_W_T = 0.d0
pt2_n_0(1) = 0
pt2_n_0(2) = 1
else
allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators))
tilde_cW(0) = 0d0
do i=1,N_det_generators
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate)**2 !+ 1.d-20
enddo
double precision :: norm
norm = 0.d0
do i=N_det_generators,1,-1
norm += tilde_w(i)
enddo
tilde_w(:) = tilde_w(:) / norm
tilde_cW(0) = -1.d0
do i=1,N_det_generators
tilde_cW(i) = tilde_cW(i-1) + tilde_w(i)
enddo
tilde_cW(:) = tilde_cW(:) + 1.d0
pt2_n_0(1) = 0
do
pt2_u_0 = tilde_cW(pt2_n_0(1))
r = tilde_cW(pt2_n_0(1) + pt2_minDetInFirstTeeth)
pt2_W_T = (1d0 - pt2_u_0) / dble(pt2_N_teeth)
if(pt2_W_T >= r - pt2_u_0) then
exit
end if
pt2_n_0(1) += 1
if(N_det_generators - pt2_n_0(1) < pt2_minDetInFirstTeeth * pt2_N_teeth) then
print *, "teeth building failed"
stop -1
end if
end do
do t=2, pt2_N_teeth
r = pt2_u_0 + pt2_W_T * dble(t-1)
pt2_n_0(t) = pt2_find_sample(r, tilde_cW)
end do
pt2_n_0(pt2_N_teeth+1) = N_det_generators
pt2_w(:pt2_n_0(1)) = tilde_w(:pt2_n_0(1))
do t=1, pt2_N_teeth
tooth_width = tilde_cW(pt2_n_0(t+1)) - tilde_cW(pt2_n_0(t))
if (tooth_width == 0.d0) then
tooth_width = sum(tilde_w(pt2_n_0(t):pt2_n_0(t+1)))
endif
ASSERT(tooth_width > 0.d0)
do i=pt2_n_0(t)+1, pt2_n_0(t+1)
pt2_w(i) = tilde_w(i) * pt2_W_T / tooth_width
end do
end do
pt2_cW(0) = 0d0
do i=1,N_det_generators
pt2_cW(i) = pt2_cW(i-1) + pt2_w(i)
end do
pt2_n_0(pt2_N_teeth+1) = N_det_generators
double precision :: rss endif
double precision, external :: memory_of_double, memory_of_int
if (N_det_generators == 1) then
pt2_w = 1.d0
pt2_cw = 1.d0
pt2_W_T = 1.d0
pt2_u_0 = 1.d0
pt2_n_0 = 1
return
endif
rss = memory_of_double(2*N_det_generators+1)
call check_mem(rss,irp_here)
allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators))
tilde_cW(0) = 0d0
do i=1,N_det_generators
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate)**2 !+ 1.d-20
enddo
double precision :: norm
norm = 0.d0
do i=N_det_generators,1,-1
norm += tilde_w(i)
enddo
tilde_w(:) = tilde_w(:) / norm
tilde_cW(0) = -1.d0
do i=1,N_det_generators
tilde_cW(i) = tilde_cW(i-1) + tilde_w(i)
enddo
tilde_cW(:) = tilde_cW(:) + 1.d0
pt2_n_0(1) = 0
do
pt2_u_0 = tilde_cW(pt2_n_0(1))
r = tilde_cW(pt2_n_0(1) + pt2_minDetInFirstTeeth)
pt2_W_T = (1d0 - pt2_u_0) / dble(pt2_N_teeth)
if(pt2_W_T >= r - pt2_u_0) then
exit
end if
pt2_n_0(1) += 1
if(N_det_generators - pt2_n_0(1) < pt2_minDetInFirstTeeth * pt2_N_teeth) then
print *, "teeth building failed"
end if
end do
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do t=2, pt2_N_teeth
r = pt2_u_0 + pt2_W_T * dble(t-1)
pt2_n_0(t) = pt2_find_sample(r, tilde_cW)
end do
pt2_n_0(pt2_N_teeth+1) = N_det_generators
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
pt2_w(:pt2_n_0(1)) = tilde_w(:pt2_n_0(1))
do t=1, pt2_N_teeth
tooth_width = tilde_cW(pt2_n_0(t+1)) - tilde_cW(pt2_n_0(t))
if (tooth_width == 0.d0) then
tooth_width = sum(tilde_w(pt2_n_0(t):pt2_n_0(t+1)))
endif
ASSERT(tooth_width > 0.d0)
do i=pt2_n_0(t)+1, pt2_n_0(t+1)
pt2_w(i) = tilde_w(i) * pt2_W_T / tooth_width
end do
end do
pt2_cW(0) = 0d0
do i=1,N_det_generators
pt2_cW(i) = pt2_cW(i-1) + pt2_w(i)
end do
pt2_n_0(pt2_N_teeth+1) = N_det_generators
END_PROVIDER END_PROVIDER

View File

@ -70,8 +70,6 @@ subroutine update_pt2_and_variance_weights(pt2, variance, norm, N_st)
variance_match_weight(k) = product(memo_variance(k,:)) variance_match_weight(k) = product(memo_variance(k,:))
enddo enddo
print *, '# PT2 weight ', real(pt2_match_weight(:),4)
print *, '# var weight ', real(variance_match_weight(:),4)
SOFT_TOUCH pt2_match_weight variance_match_weight SOFT_TOUCH pt2_match_weight variance_match_weight
end end
@ -85,7 +83,7 @@ BEGIN_PROVIDER [ double precision, selection_weight, (N_states) ]
case (0) case (0)
print *, 'Using input weights in selection' print *, 'Using input weights in selection'
selection_weight(1:N_states) = state_average_weight(1:N_states) selection_weight(1:N_states) = c0_weight(1:N_states) * state_average_weight(1:N_states)
case (1) case (1)
print *, 'Using 1/c_max^2 weight in selection' print *, 'Using 1/c_max^2 weight in selection'
@ -94,20 +92,30 @@ BEGIN_PROVIDER [ double precision, selection_weight, (N_states) ]
case (2) case (2)
print *, 'Using pt2-matching weight in selection' print *, 'Using pt2-matching weight in selection'
selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states) selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states)
print *, '# PT2 weight ', real(pt2_match_weight(:),4)
case (3) case (3)
print *, 'Using variance-matching weight in selection' print *, 'Using variance-matching weight in selection'
selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states)
print *, '# var weight ', real(variance_match_weight(:),4)
case (4) case (4)
print *, 'Using variance- and pt2-matching weights in selection' print *, 'Using variance- and pt2-matching weights in selection'
selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) * pt2_match_weight(1:N_states) selection_weight(1:N_states) = c0_weight(1:N_states) * sqrt(variance_match_weight(1:N_states) * pt2_match_weight(1:N_states))
print *, '# PT2 weight ', real(pt2_match_weight(:),4)
print *, '# var weight ', real(variance_match_weight(:),4)
case (5) case (5)
print *, 'Using variance-matching weight in selection' print *, 'Using variance-matching weight in selection'
selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states)
print *, '# var weight ', real(variance_match_weight(:),4)
case (6)
print *, 'Using CI coefficient weight in selection'
selection_weight(1:N_states) = c0_weight(1:N_states)
end select end select
print *, '# Total weight ', real(selection_weight(:),4)
END_PROVIDER END_PROVIDER
@ -645,7 +653,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
logical :: ok logical :: ok
integer :: s1, s2, p1, p2, ib, j, istate integer :: s1, s2, p1, p2, ib, j, istate
integer(bit_kind) :: mask(N_int, 2), det(N_int, 2) integer(bit_kind) :: mask(N_int, 2), det(N_int, 2)
double precision :: e_pert, delta_E, val, Hii, sum_e_pert, tmp, alpha_h_psi, coef double precision :: e_pert, delta_E, val, Hii, w, tmp, alpha_h_psi, coef
double precision, external :: diag_H_mat_elem_fock double precision, external :: diag_H_mat_elem_fock
double precision :: E_shift double precision :: E_shift
@ -726,10 +734,13 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
if (.not.is_a_1h1p(det)) cycle if (.not.is_a_1h1p(det)) cycle
endif endif
Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int) Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int)
sum_e_pert = 0d0 w = 0d0
! integer(bit_kind) :: occ(N_int,2), n
! call occ_pattern_of_det(det,occ,N_int)
! call occ_pattern_to_dets_size(occ,n,elec_alpha_num,N_int)
do istate=1,N_states do istate=1,N_states
delta_E = E0(istate) - Hii + E_shift delta_E = E0(istate) - Hii + E_shift
@ -740,27 +751,43 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
tmp = -tmp tmp = -tmp
endif endif
e_pert = 0.5d0 * (tmp - delta_E) e_pert = 0.5d0 * (tmp - delta_E)
coef = e_pert / alpha_h_psi if (dabs(alpha_h_psi) > 1.d-4) then
coef = e_pert / alpha_h_psi
else
coef = alpha_h_psi / delta_E
endif
pt2(istate) = pt2(istate) + e_pert pt2(istate) = pt2(istate) + e_pert
variance(istate) = variance(istate) + alpha_h_psi * alpha_h_psi variance(istate) = variance(istate) + alpha_h_psi * alpha_h_psi
norm(istate) = norm(istate) + coef * coef norm(istate) = norm(istate) + coef * coef
if (weight_selection /= 5) then
! Energy selection select case (weight_selection)
sum_e_pert = sum_e_pert + e_pert * selection_weight(istate)
else case(0:4)
! Variance selection ! Energy selection
sum_e_pert = sum_e_pert - alpha_h_psi * alpha_h_psi * selection_weight(istate) w = w + e_pert * selection_weight(istate)
endif
case(5)
! Variance selection
w = w - alpha_h_psi * alpha_h_psi * selection_weight(istate)
case(6)
w = w - coef * coef * selection_weight(istate)
end select
end do end do
if(pseudo_sym)then if(pseudo_sym)then
if(dabs(mat(1, p1, p2)).lt.thresh_sym)then if(dabs(mat(1, p1, p2)).lt.thresh_sym)then
sum_e_pert = 10.d0 w = 0.d0
endif endif
endif endif
if(sum_e_pert <= buf%mini) then ! w = dble(n) * w
call add_to_selection_buffer(buf, det, sum_e_pert)
if(w <= buf%mini) then
call add_to_selection_buffer(buf, det, w)
end if end if
end do end do
end do end do

View File

@ -102,7 +102,7 @@ subroutine run_stochastic_cipsi
! Add selected determinants ! Add selected determinants
call copy_H_apply_buffer_to_wf() call copy_H_apply_buffer_to_wf()
call save_wavefunction ! call save_wavefunction
PROVIDE psi_coef PROVIDE psi_coef
PROVIDE psi_det PROVIDE psi_det

View File

@ -21,6 +21,11 @@ function run() {
eq $energy3 $4 $thresh eq $energy3 $4 $thresh
} }
@test "B-B" { # 2.0s
run b2_stretched.ezfio -48.995058575280950 -48.974653655601145 -48.974653655601031
}
@test "SiH2_3B1" { # 1.23281s 1.24958s @test "SiH2_3B1" { # 1.23281s 1.24958s
run sih2_3b1.ezfio -289.969297318489 -289.766898643192 -289.737521023380 run sih2_3b1.ezfio -289.969297318489 -289.766898643192 -289.737521023380
} }

View File

@ -18,6 +18,11 @@ function run() {
} }
@test "B-B" { #
qp set_file b2_stretched.ezfio
run -49.120607088648597 -49.055152453388231
}
@test "SiH2_3B1" { # 1.53842s 3.53856s @test "SiH2_3B1" { # 1.53842s 3.53856s
qp set_file sih2_3b1.ezfio qp set_file sih2_3b1.ezfio
run -290.015949171697 -289.805036176618 run -290.015949171697 -289.805036176618

View File

@ -44,8 +44,60 @@ program cisd
! * "del" orbitals which will be never occupied ! * "del" orbitals which will be never occupied
! !
END_DOC END_DOC
PROVIDE N_states
read_wf = .False. read_wf = .False.
SOFT_TOUCH read_wf SOFT_TOUCH read_wf
call only_act_bitmask call run
call run_cisd end
subroutine run
implicit none
integer :: i,k
double precision :: cisdq(N_states), delta_e
double precision,external :: diag_h_mat_elem
if(pseudo_sym)then
call H_apply_cisd_sym
else
call H_apply_cisd
endif
psi_coef = ci_eigenvectors
SOFT_TOUCH psi_coef
call save_wavefunction
call ezfio_set_cisd_energy(CI_energy)
do i = 1,N_states
k = maxloc(dabs(psi_coef_sorted(1:N_det,i)),dim=1)
delta_E = CI_electronic_energy(i) - diag_h_mat_elem(psi_det_sorted(1,1,k),N_int)
cisdq(i) = CI_energy(i) + delta_E * (1.d0 - psi_coef_sorted(k,i)**2)
enddo
print *, 'N_det = ', N_det
print*,''
print*,'******************************'
print *, 'CISD Energies'
do i = 1,N_states
print *, i, CI_energy(i)
enddo
print*,''
print*,'******************************'
print *, 'CISD+Q Energies'
do i = 1,N_states
print *, i, cisdq(i)
enddo
if (N_states > 1) then
print*,''
print*,'******************************'
print*,'Excitation energies (au) (CISD+Q)'
do i = 2, N_states
print*, i ,CI_energy(i) - CI_energy(1), cisdq(i) - cisdq(1)
enddo
print*,''
print*,'******************************'
print*,'Excitation energies (eV) (CISD+Q)'
do i = 2, N_states
print*, i ,(CI_energy(i) - CI_energy(1))/0.0367502d0, &
(cisdq(i) - cisdq(1)) / 0.0367502d0
enddo
endif
end end

View File

@ -22,6 +22,12 @@ doc: If |true|, read the wave function from the |EZFIO| file
interface: ezfio,provider,ocaml interface: ezfio,provider,ocaml
default: False default: False
[pruning]
type: float
doc: If p>0., remove p*Ndet determinants at every iteration
interface: ezfio,provider,ocaml
default: 0.
[s2_eig] [s2_eig]
type: logical type: logical
doc: Force the wave function to be an eigenfunction of |S^2| doc: Force the wave function to be an eigenfunction of |S^2|
@ -36,7 +42,7 @@ default: 1
[weight_selection] [weight_selection]
type: integer type: integer
doc: Weight used in the selection. 0: input state-average weight, 1: 1./(c_0^2), 2: rPT2 matching, 3: variance matching, 4: variance and rPT2 matching, 5: variance minimization and matching doc: Weight used in the selection. 0: input state-average weight, 1: 1./(c_0^2), 2: rPT2 matching, 3: variance matching, 4: variance and rPT2 matching, 5: variance minimization and matching, 6: CI coefficients
interface: ezfio,provider,ocaml interface: ezfio,provider,ocaml
default: 2 default: 2

View File

@ -124,39 +124,49 @@ subroutine copy_H_apply_buffer_to_wf
PROVIDE H_apply_buffer_allocated PROVIDE H_apply_buffer_allocated
ASSERT (N_int > 0) ASSERT (N_int > 0)
ASSERT (N_det > 0) ASSERT (N_det > 0)
allocate ( buffer_det(N_int,2,N_det), buffer_coef(N_det,N_states) ) allocate ( buffer_det(N_int,2,N_det), buffer_coef(N_det,N_states) )
! Backup determinants
j=0
do i=1,N_det do i=1,N_det
do k=1,N_int if (pruned(i)) cycle ! Pruned determinants
ASSERT (sum(popcnt(psi_det(:,1,i))) == elec_alpha_num) j+=1
ASSERT (sum(popcnt(psi_det(:,2,i))) == elec_beta_num) ASSERT (sum(popcnt(psi_det(:,1,i))) == elec_alpha_num)
buffer_det(k,1,i) = psi_det(k,1,i) ASSERT (sum(popcnt(psi_det(:,2,i))) == elec_beta_num)
buffer_det(k,2,i) = psi_det(k,2,i) buffer_det(:,:,j) = psi_det(:,:,i)
enddo
enddo enddo
N_det_old = j
! Backup coefficients
do k=1,N_states do k=1,N_states
j=0
do i=1,N_det do i=1,N_det
buffer_coef(i,k) = psi_coef(i,k) if (pruned(i)) cycle ! Pruned determinants
j += 1
buffer_coef(j,k) = psi_coef(i,k)
enddo enddo
ASSERT ( j == N_det_old )
enddo enddo
N_det_old = N_det ! Update N_det
N_det = N_det_old
do j=0,nproc-1 do j=0,nproc-1
N_det = N_det + H_apply_buffer(j)%N_det N_det = N_det + H_apply_buffer(j)%N_det
enddo enddo
! Update array sizes
if (psi_det_size < N_det) then if (psi_det_size < N_det) then
psi_det_size = N_det psi_det_size = N_det
TOUCH psi_det_size TOUCH psi_det_size
endif endif
! Restore backup in resized array
do i=1,N_det_old do i=1,N_det_old
do k=1,N_int psi_det(:,:,i) = buffer_det(:,:,i)
psi_det(k,1,i) = buffer_det(k,1,i)
psi_det(k,2,i) = buffer_det(k,2,i)
enddo
ASSERT (sum(popcnt(psi_det(:,1,i))) == elec_alpha_num) ASSERT (sum(popcnt(psi_det(:,1,i))) == elec_alpha_num)
ASSERT (sum(popcnt(psi_det(:,2,i))) == elec_beta_num ) ASSERT (sum(popcnt(psi_det(:,2,i))) == elec_beta_num )
enddo enddo
@ -165,6 +175,9 @@ subroutine copy_H_apply_buffer_to_wf
psi_coef(i,k) = buffer_coef(i,k) psi_coef(i,k) = buffer_coef(i,k)
enddo enddo
enddo enddo
! Copy new buffers
!$OMP PARALLEL DEFAULT(SHARED) & !$OMP PARALLEL DEFAULT(SHARED) &
!$OMP PRIVATE(j,k,i) FIRSTPRIVATE(N_det_old) & !$OMP PRIVATE(j,k,i) FIRSTPRIVATE(N_det_old) &
!$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,psi_det_size) !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,psi_det_size)

View File

@ -409,6 +409,51 @@ BEGIN_PROVIDER [ double precision, weight_occ_pattern, (N_occ_pattern,N_states)
enddo enddo
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ double precision, weight_occ_pattern_average, (N_occ_pattern) ]
implicit none
BEGIN_DOC
! State-average weight of the occupation patterns in the wave function
END_DOC
integer :: i,j,k
weight_occ_pattern_average(:) = 0.d0
do i=1,N_det
j = det_to_occ_pattern(i)
do k=1,N_states
weight_occ_pattern_average(j) += psi_coef(i,k) * psi_coef(i,k) * state_average_weight(k)
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, psi_occ_pattern_sorted, (N_int,2,N_occ_pattern) ]
&BEGIN_PROVIDER [ double precision, weight_occ_pattern_average_sorted, (N_occ_pattern) ]
&BEGIN_PROVIDER [ integer, psi_occ_pattern_sorted_order, (N_occ_pattern) ]
&BEGIN_PROVIDER [ integer, psi_occ_pattern_sorted_order_reverse, (N_occ_pattern) ]
implicit none
BEGIN_DOC
! Occupation patterns sorted by weight
END_DOC
integer :: i,j,k
integer, allocatable :: iorder(:)
allocate ( iorder(N_occ_pattern) )
do i=1,N_occ_pattern
weight_occ_pattern_average_sorted(i) = -weight_occ_pattern_average(i)
iorder(i) = i
enddo
call dsort(weight_occ_pattern_average_sorted,iorder,N_occ_pattern)
do i=1,N_occ_pattern
do j=1,N_int
psi_occ_pattern_sorted(j,1,i) = psi_occ_pattern(j,1,iorder(i))
psi_occ_pattern_sorted(j,2,i) = psi_occ_pattern(j,2,iorder(i))
enddo
psi_occ_pattern_sorted_order(iorder(i)) = i
psi_occ_pattern_sorted_order_reverse(i) = iorder(i)
weight_occ_pattern_average_sorted(i) = -weight_occ_pattern_average_sorted(i)
enddo
deallocate(iorder)
END_PROVIDER
subroutine make_s2_eigenfunction subroutine make_s2_eigenfunction
implicit none implicit none

View File

@ -0,0 +1,35 @@
BEGIN_PROVIDER [ logical, pruned, (N_det) ]
implicit none
BEGIN_DOC
! True if determinant is removed by pruning
END_DOC
pruned(:) = .False.
if (pruning == 0.d0) then
return
endif
integer :: i,j,k,ndet_new,nsop_max
double precision :: thr
if (s2_eig) then
nsop_max = max(1,int ( dble(N_occ_pattern) * (1.d0 - pruning) + 0.5d0 ))
do i=1,N_det
k = det_to_occ_pattern(i)
pruned(i) = psi_occ_pattern_sorted_order_reverse(k) > nsop_max
enddo
else
ndet_new = max(1,int( dble(N_det) * (1.d0 - pruning) + 0.5d0 ))
thr = psi_average_norm_contrib_sorted(ndet_new)
do i=1, N_det
pruned(i) = psi_average_norm_contrib(i) < thr
enddo
endif
END_PROVIDER

View File

@ -24,6 +24,11 @@ function run {
} }
@test "B-B" {
qp set_file b2_stretched.ezfio
run b2_stretched.zmt 1 0 6-31g
}
@test "C2H2" { @test "C2H2" {
run c2h2.xyz 1 0 cc-pvdz_ecp_bfd bfd run c2h2.xyz 1 0 cc-pvdz_ecp_bfd bfd
} }

View File

@ -22,7 +22,7 @@ function run_stoch() {
thresh=$2 thresh=$2
test_exe fci || skip test_exe fci || skip
qp set perturbation do_pt2 True qp set perturbation do_pt2 True
qp set determinants n_det_max 100000 qp set determinants n_det_max $3
qp set determinants n_states 1 qp set determinants n_states 1
qp set davidson threshold_davidson 1.e-10 qp set davidson threshold_davidson 1.e-10
qp set davidson n_states_diag 1 qp set davidson n_states_diag 1
@ -31,137 +31,143 @@ function run_stoch() {
eq $energy1 $1 $thresh eq $energy1 $1 $thresh
} }
@test "B-B" {
qp set_file b2_stretched.ezfio
qp set determinants n_det_max 10000
qp set_frozen_core
run_stoch -49.14103054419 3.e-4 10000
}
@test "F2" { # 4.07m @test "F2" { # 4.07m
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file f2.ezfio qp set_file f2.ezfio
qp set_frozen_core qp set_frozen_core
run_stoch -199.30486 1.e-4 run_stoch -199.30486 1.e-4 100000
} }
@test "NH3" { # 10.6657s @test "NH3" { # 10.6657s
qp set_file nh3.ezfio qp set_file nh3.ezfio
qp set_mo_class --core="[1-4]" --act="[5-72]" qp set_mo_class --core="[1-4]" --act="[5-72]"
run -56.244753429144986 1.e-4 run -56.244753429144986 1.e-4 100000
} }
@test "DHNO" { # 11.4721s @test "DHNO" { # 11.4721s
qp set_file dhno.ezfio qp set_file dhno.ezfio
qp set_mo_class --core="[1-7]" --act="[8-64]" qp set_mo_class --core="[1-7]" --act="[8-64]"
run -130.459020029816 1.e-4 run -130.459020029816 1.e-4 100000
} }
@test "HCO" { # 12.2868s @test "HCO" { # 12.2868s
qp set_file hco.ezfio qp set_file hco.ezfio
run -113.297494345682 1.e-4 run -113.297494345682 1.e-4 100000
} }
@test "H2O2" { # 12.9214s @test "H2O2" { # 12.9214s
qp set_file h2o2.ezfio qp set_file h2o2.ezfio
qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]"
run -151.00477 1.e-4 run -151.00477 1.e-4 100000
} }
@test "HBO" { # 13.3144s @test "HBO" { # 13.3144s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file hbo.ezfio qp set_file hbo.ezfio
run -100.212829869715 1.e-4 run -100.212829869715 1.e-4 100000
} }
@test "H2O" { # 11.3727s @test "H2O" { # 11.3727s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file h2o.ezfio qp set_file h2o.ezfio
run -76.2359268957699 1.e-4 run -76.2359268957699 1.e-4 100000
} }
@test "ClO" { # 13.3755s @test "ClO" { # 13.3755s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file clo.ezfio qp set_file clo.ezfio
run -534.545881614967 1.e-4 run -534.545881614967 1.e-4 100000
} }
@test "SO" { # 13.4952s @test "SO" { # 13.4952s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file so.ezfio qp set_file so.ezfio
run -26.0158153138924 1.e-4 run -26.0126927641744 1.e-4 100000
} }
@test "H2S" { # 13.6745s @test "H2S" { # 13.6745s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file h2s.ezfio qp set_file h2s.ezfio
run -398.859168655255 1.e-4 run -398.859168655255 1.e-4 100000
} }
@test "OH" { # 13.865s @test "OH" { # 13.865s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file oh.ezfio qp set_file oh.ezfio
run -75.6120779012574 1.e-4 run -75.6120779012574 1.e-4 100000
} }
@test "SiH2_3B1" { # 13.938ss @test "SiH2_3B1" { # 13.938ss
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file sih2_3b1.ezfio qp set_file sih2_3b1.ezfio
run -290.017539006762 1.e-4 run -290.017539006762 1.e-4 100000
} }
@test "H3COH" { # 14.7299s @test "H3COH" { # 14.7299s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file h3coh.ezfio qp set_file h3coh.ezfio
run -115.205941463667 1.e-4 run -115.205941463667 1.e-4 100000
} }
@test "SiH3" { # 15.99s @test "SiH3" { # 15.99s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file sih3.ezfio qp set_file sih3.ezfio
run -5.57241217753818 1.e-4 run -5.57241217753818 1.e-4 100000
} }
@test "CH4" { # 16.1612s @test "CH4" { # 16.1612s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file ch4.ezfio qp set_file ch4.ezfio
qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]" qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]"
run -40.2409678239136 1.e-4 run -40.2409678239136 1.e-4 100000
} }
@test "ClF" { # 16.8864s @test "ClF" { # 16.8864s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file clf.ezfio qp set_file clf.ezfio
run -559.170272077166 1.e-4 run -559.170128224959 1.e-4 100000
} }
@test "SO2" { # 17.5645s @test "SO2" { # 17.5645s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file so2.ezfio qp set_file so2.ezfio
qp set_mo_class --core="[1-8]" --act="[9-87]" qp set_mo_class --core="[1-8]" --act="[9-87]"
run -41.5746738713298 1.e-4 run -41.5746738713298 1.e-4 100000
} }
@test "C2H2" { # 17.6827s @test "C2H2" { # 17.6827s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file c2h2.ezfio qp set_file c2h2.ezfio
qp set_mo_class --act="[1-30]" --del="[31-36]" qp set_mo_class --act="[1-30]" --del="[31-36]"
run -12.3656179738175 1.e-4 run -12.3658547549095 1.e-4 100000
} }
@test "N2" { # 18.0198s @test "N2" { # 18.0198s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file n2.ezfio qp set_file n2.ezfio
qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]"
run -109.291600196629 1.e-4 run -109.291711886659 1.e-4 100000
} }
@test "N2H4" { # 18.5006s @test "N2H4" { # 18.5006s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file n2h4.ezfio qp set_file n2h4.ezfio
qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-48]" qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-48]"
run -111.367332681559 1.e-4 run -111.367332681559 1.e-4 100000
} }
@test "CO2" { # 21.1748s @test "CO2" { # 21.1748s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file co2.ezfio qp set_file co2.ezfio
qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]"
run -187.968599504402 1.e-4 run -187.968599504402 1.e-4 100000
} }
@ -169,13 +175,13 @@ function run_stoch() {
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file cu_nh3_4_2plus.ezfio qp set_file cu_nh3_4_2plus.ezfio
qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]" qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]"
run -1862.98614665139 1.e-04 run -1862.98614665139 1.e-04 100000
} }
@test "HCN" { # 20.3273s @test "HCN" { # 20.3273s
[[ -n $TRAVIS ]] && skip [[ -n $TRAVIS ]] && skip
qp set_file hcn.ezfio qp set_file hcn.ezfio
qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]"
run -93.0728641601823 1.e-4 run -93.0791660745576 1.e-4 100000
} }

View File

@ -17,6 +17,10 @@ function run() {
} }
@test "B-B" { # 3s
run b2_stretched.ezfio -48.9950585752809
}
@test "SiH2_3B1" { # 0.539000 1.51094s @test "SiH2_3B1" { # 0.539000 1.51094s
run sih2_3b1.ezfio -289.9654718650881 run sih2_3b1.ezfio -289.9654718650881
} }

View File

@ -21,7 +21,6 @@ function run() {
eq $energy $3 $thresh eq $energy $3 $thresh
} }
@test "H3COH" { @test "H3COH" {
run h3coh.ezfio sr_pbe -115.50238225208 run h3coh.ezfio sr_pbe -115.50238225208
} }

View File

@ -6,6 +6,7 @@ program molden
character*(128) :: output character*(128) :: output
integer :: i_unit_output,getUnitAndOpen integer :: i_unit_output,getUnitAndOpen
integer :: i,j,k,l integer :: i,j,k,l
double precision, parameter :: a0 = 0.529177249d0
PROVIDE ezfio_filename PROVIDE ezfio_filename
@ -22,7 +23,7 @@ program molden
trim(element_name(int(nucl_charge(i)))), & trim(element_name(int(nucl_charge(i)))), &
i, & i, &
int(nucl_charge(i)), & int(nucl_charge(i)), &
nucl_coord(i,1), nucl_coord(i,2), nucl_coord(i,3) nucl_coord(i,1)*a0, nucl_coord(i,2)*a0, nucl_coord(i,3)*a0
enddo enddo
write(i_unit_output,'(A)') '[GTO]' write(i_unit_output,'(A)') '[GTO]'

View File

@ -0,0 +1,3 @@
b
b 1 3.0