9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-06-15 09:05:17 +02:00

Merge Master (#69)

* Changed native into SSE4.2 in gfortran.cfg

* Fixed rm opam_installer

* Fix configure

* Improving scaling of pt2 with network

* Router/dealer in qp_tunnel

* Reduced size of qp2.png

* Exclude temp files in tar

* Introduce NO_CACHE in configure for daily test

* Faster determinants in OCaml

* We always give max 10k dets in qp_edit. Read-only if more

* Fixed save_natorb

* Fixing bug in qp_edit

* Comments

* Biblio (#61)

* Biblio (#62)

* Update biblio

* Update paper

* Journal missing in research.bib

* Added paper

* Fixed Pierre Francois

* Checking number of electrons in MOs

* Biblio (#64)

* Update biblio

* Update paper

* Journal missing in research.bib

* Added paper

* Fixed Pierre Francois

* 2 papers

* Fixed 6-31G and quickstart (#65)

* Fixed 6-31 basis sets

* Bug in quickstart

* Biblio (#66)

* Bugfix (#67)

* Fixing opam installation

* Fixed 6-31 basis sets

* Bug in quickstart

* Use irpf90 v1.7.6

* Fix IRPF90 Path
This commit is contained in:
Anthony Scemama 2019-10-21 16:45:00 +02:00 committed by GitHub
parent bfe52ed56f
commit cebc19a601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 647 additions and 411 deletions

80
configure vendored
View File

@ -9,6 +9,22 @@ eval set -- "$TEMP"
export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )"
echo "QP_ROOT="$QP_ROOT
# When updating version, update also etc files
BATS_URL="https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz"
BUBBLE_URL="https://github.com/projectatomic/bubblewrap/releases/download/v0.3.3/bubblewrap-0.3.3.tar.xz"
DOCOPT_URL="https://github.com/docopt/docopt/archive/0.6.2.tar.gz"
EZFIO_URL="https://gitlab.com/scemama/EZFIO/-/archive/v1.4.0/EZFIO-v1.4.0.tar.gz"
F77ZMQ_URL="https://github.com/scemama/f77_zmq/archive/v4.2.5.tar.gz"
GMP_URL="ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2"
IRPF90_URL="https://gitlab.com/scemama/irpf90/-/archive/v1.7.6/irpf90-v1.7.6.tar.gz"
LIBCAP_URL="https://git.kernel.org/pub/scm/linux/kernel/git/morgan/libcap.git/snapshot/libcap-2.25.tar.gz"
NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip"
OCAML_URL="https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh"
RESULTS_URL="https://gitlab.com/scemama/resultsFile/-/archive/master/resultsFile-master.tar.gz"
ZEROMQ_URL="https://github.com/zeromq/libzmq/releases/download/v4.2.5/zeromq-4.2.5.tar.gz"
ZLIB_URL="https://www.zlib.net/zlib-1.2.11.tar.gz"
function help()
{
@ -183,9 +199,7 @@ for PACKAGE in ${PACKAGES} ; do
if [[ ${PACKAGE} = ninja ]] ; then
download \
"https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" \
"${QP_ROOT}"/external/ninja.zip
download ${NINJA_URL} "${QP_ROOT}"/external/ninja.zip
execute << EOF
rm -f "\${QP_ROOT}"/bin/ninja
unzip "\${QP_ROOT}"/external/ninja.zip -d "\${QP_ROOT}"/bin
@ -194,9 +208,7 @@ EOF
elif [[ ${PACKAGE} = gmp ]] ; then
download \
"ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2" \
"${QP_ROOT}"/external/gmp.tar.bz2
download ${GMP_URL} "${QP_ROOT}"/external/gmp.tar.bz2
execute << EOF
cd "\${QP_ROOT}"/external
tar --bzip2 --extract --file gmp.tar.bz2
@ -208,9 +220,7 @@ EOF
elif [[ ${PACKAGE} = libcap ]] ; then
download \
"https://git.kernel.org/pub/scm/linux/kernel/git/morgan/libcap.git/snapshot/libcap-2.25.tar.gz" \
"${QP_ROOT}"/external/libcap.tar.gz
download ${LIBCAP_URL} "${QP_ROOT}"/external/libcap.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file libcap.tar.gz
@ -221,9 +231,7 @@ EOF
elif [[ ${PACKAGE} = bwrap ]] ; then
download \
"https://github.com/projectatomic/bubblewrap/releases/download/v0.3.3/bubblewrap-0.3.3.tar.xz" \
"${QP_ROOT}"/external/bwrap.tar.xz
download ${BUBBLE_URL} "${QP_ROOT}"/external/bwrap.tar.xz
execute << EOF
cd "\${QP_ROOT}"/external
tar --xz --extract --file bwrap.tar.xz
@ -236,9 +244,7 @@ EOF
elif [[ ${PACKAGE} = irpf90 ]] ; then
# When changing version of irpf90, don't forget to update etc/irpf90.rc
download \
"https://gitlab.com/scemama/irpf90/-/archive/v1.7.5/irpf90-v1.7.5.tar.gz" \
"${QP_ROOT}"/external/irpf90.tar.gz
download ${IRPF90_URL} "${QP_ROOT}"/external/irpf90.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file irpf90.tar.gz
@ -250,9 +256,7 @@ EOF
elif [[ ${PACKAGE} = zeromq ]] ; then
download \
"https://github.com/zeromq/libzmq/releases/download/v4.2.5/zeromq-4.2.5.tar.gz" \
"${QP_ROOT}"/external/zeromq.tar.gz
download ${ZEROMQ_URL} "${QP_ROOT}"/external/zeromq.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file zeromq.tar.gz
@ -266,9 +270,7 @@ EOF
elif [[ ${PACKAGE} = f77zmq ]] ; then
download \
"https://github.com/scemama/f77_zmq/archive/v4.2.5.tar.gz" \
"${QP_ROOT}"/external/f77_zmq.tar.gz
download ${F77ZMQ_URL} "${QP_ROOT}"/external/f77_zmq.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file f77_zmq.tar.gz
@ -284,9 +286,7 @@ EOF
elif [[ ${PACKAGE} = ocaml ]] ; then
download \
"https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh" \
"${QP_ROOT}"/external/opam_installer.sh
download ${OCAML_URL} "${QP_ROOT}"/external/opam_installer.sh
if [[ -n ${TRAVIS} ]] ; then
# Special commands for Travis CI
@ -338,9 +338,7 @@ EOF
elif [[ ${PACKAGE} = ezfio ]] ; then
download \
"https://gitlab.com/scemama/EZFIO/-/archive/v1.4.0/EZFIO-v1.4.0.tar.gz" \
"${QP_ROOT}"/external/ezfio.tar.gz
download ${EZFIO_URL} "${QP_ROOT}"/external/ezfio.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file ezfio.tar.gz
@ -351,9 +349,7 @@ EOF
elif [[ ${PACKAGE} = zlib ]] ; then
download \
"https://www.zlib.net/zlib-1.2.11.tar.gz" \
"${QP_ROOT}"/external/zlib.tar.gz
download ${ZLIB_URL} "${QP_ROOT}"/external/zlib.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file zlib.tar.gz
@ -366,9 +362,7 @@ EOF
elif [[ ${PACKAGE} = docopt ]] ; then
download \
"https://github.com/docopt/docopt/archive/0.6.2.tar.gz" \
"${QP_ROOT}"/external/docopt.tar.gz
download ${DOCOPT_URL} "${QP_ROOT}"/external/docopt.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file docopt.tar.gz
@ -379,9 +373,7 @@ EOF
elif [[ ${PACKAGE} = resultsFile ]] ; then
download \
"https://gitlab.com/scemama/resultsFile/-/archive/master/resultsFile-master.tar.gz" \
"${QP_ROOT}"/external/resultsFile.tar.gz
download ${RESULTS_URL} "${QP_ROOT}"/external/resultsFile.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file resultsFile.tar.gz
@ -391,9 +383,7 @@ EOF
elif [[ ${PACKAGE} = bats ]] ; then
download \
"https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz" \
"${QP_ROOT}"/external/bats.tar.gz
download ${BATS_URL} "${QP_ROOT}"/external/bats.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar -zxf bats.tar.gz
@ -438,18 +428,18 @@ if [[ ${ZLIB} = $(not_found) ]] ; then
fail
fi
BWRAP=$(find_exe bwrap)
if [[ ${BWRAP} = $(not_found) ]] ; then
error "Bubblewrap (bwrap) is not installed."
fail
fi
LIBCAP=$(find_lib -lcap)
if [[ ${LIBCAP} = $(not_found) ]] ; then
error "Libcap (libcap) is not installed."
fail
fi
BWRAP=$(find_exe bwrap)
if [[ ${BWRAP} = $(not_found) ]] ; then
error "Bubblewrap (bwrap) is not installed."
fail
fi
OPAM=$(find_exe opam)
if [[ ${OPAM} = $(not_found) ]] ; then
error "OPAM (ocaml) package manager is not installed."

View File

@ -8,6 +8,16 @@ S 1
S 1
1 0.0360000 1.0000000
HELIUM
S 3
1 0.3842163400E+02 0.4013973935E-01
2 0.5778030000E+01 0.2612460970E+00
3 0.1241774000E+01 0.7931846246E+00
S 1
1 0.2979640000E+00 1.0000000
S 1
1 0.8600000000E-01 0.1000000000E+01
LITHIUM
S 6
1 642.4189200 0.0021426

View File

@ -1,14 +1,27 @@
HYDROGEN
S 3
1 18.7311370 0.03349460
2 2.8253937 0.23472695
3 0.6401217 0.81375733
1 0.1873113696E+02 0.3349460434E-01
2 0.2825394365E+01 0.2347269535E+00
3 0.6401216923E+00 0.8137573261E+00
S 1
1 0.1612778 1.0000000
1 0.1612777588E+00 1.0000000
S 1
1 0.0360000 1.0000000
1 0.3600000000E-01 0.1000000000E+01
P 1
1 1.1000000 1.0000000
1 0.1100000000E+01 1.0000000
HELIUM
S 3
1 0.3842163400E+02 0.4013973935E-01
2 0.5778030000E+01 0.2612460970E+00
3 0.1241774000E+01 0.7931846246E+00
S 1
1 0.2979640000E+00 1.0000000
S 1
1 0.8600000000E-01 0.1000000000E+01
P 1
1 0.1100000000E+01 1.0000000
LITHIUM
S 6

View File

@ -1,3 +1,19 @@
HYDROGEN
S 3
1 0.1873113696E+02 0.3349460434E-01
2 0.2825394365E+01 0.2347269535E+00
3 0.6401216923E+00 0.8137573261E+00
S 1
1 0.1612777588E+00 1.0000000
HELIUM
S 3
1 0.3842163400E+02 0.4013973935E-01
2 0.5778030000E+01 0.2612460970E+00
3 0.1241774000E+01 0.7931846246E+00
S 1
1 0.2979640000E+00 1.0000000
LITHIUM
S 6
1 642.4189200 0.0021426

View File

@ -14,6 +14,18 @@ P 1
P 1
1 0.3750000 1.0000000
HELIUM
S 3
1 98.12430 0.0287452
2 14.76890 0.208061
3 3.318830 0.837635
S 1
1 0.874047 1.000000
S 1
1 0.244564 1.000000
P 1
1 0.750 1.000000
LITHIUM
S 6
1 900.4600000 0.00228704

View File

@ -1,3 +1,23 @@
HYDROGEN
S 3
1 33.86500 0.0254938
2 5.094790 0.190373
3 1.158790 0.852161
S 1
1 0.325840 1.000000
S 1
1 0.102741 1.000000
HELIUM
S 3
1 98.12430 0.0287452
2 14.76890 0.208061
3 3.318830 0.837635
S 1
1 0.874047 1.000000
S 1
1 0.244564 1.000000
LITHIUM
S 6
1 900.4600000 0.00228704

View File

@ -1,3 +1,23 @@
HYDROGEN
S 3
1 33.86500 0.0254938
2 5.094790 0.190373
3 1.158790 0.852161
S 1
1 0.325840 1.000000
S 1
1 0.102741 1.000000
HELIUM
S 3
1 98.12430 0.0287452
2 14.76890 0.208061
3 3.318830 0.837635
S 1
1 0.874047 1.000000
S 1
1 0.244564 1.000000
LITHIUM
S 6
1 900.4600000 0.00228704

View File

@ -1,3 +1,19 @@
HYDROGEN
S 3
1 18.7311370 0.03349460
2 2.8253937 0.23472695
3 0.6401217 0.81375733
S 1
1 0.1612778 1.0000000
HELIUM
S 3
1 38.4216340 0.0237660
2 5.7780300 0.1546790
3 1.2417740 0.4696300
S 1
1 0.2979640 1.0000000
LITHIUM
S 6
1 642.4189200 0.0021426

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 MiB

After

Width:  |  Height:  |  Size: 351 KiB

BIN
data/qp2_hd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 MiB

View File

@ -1,41 +1,59 @@
%%% ARXIV TO BE UPDATED %%%
@article{Giner2019Jul,
author = {Giner, Emmanuel and Scemama, Anthony and Toulouse, Julien and Loos, Pierre-Fran{\c{c}}ois},
title = {{Chemically Accurate Excitation Energies With Small Basis Sets}},
@article{Hollett2019Aug,
author = {Hollett, Joshua W. and Loos, Pierre-Fran{\c{c}}ois},
title = {{Capturing static and dynamic correlation with $\Delta \text{NO}$-MP2 and $\Delta \text{NO}$-CCSD}},
journal = {arXiv},
year = {2019},
month = {Jul},
eprint = {1907.01245},
url = {https://arxiv.org/abs/1907.01245}
month = {Aug},
eprint = {1908.09914},
url = {https://arxiv.org/abs/1908.09914}
}
@article{Burton_2019,
doi = {10.1021/acs.jctc.9b00441},
url = {https://doi.org/10.1021%2Facs.jctc.9b00441},
year = 2019,
month = {aug},
publisher = {American Chemical Society ({ACS})},
author = {Hugh G. A. Burton and Alex J.W. Thom},
title = {A General Approach for Multireference Ground and Excited States using Non-Orthogonal Configuration Interaction},
journal = {Journal of Chemical Theory and Computation}
}
@article{Dash_2019,
doi = {10.1021/acs.jctc.9b00476},
url = {https://doi.org/10.1021%2Facs.jctc.9b00476},
year = 2019,
month = {aug},
publisher = {American Chemical Society ({ACS})},
author = {Monika Dash and Jonas Feldt and Saverio Moroni and Anthony Scemama and Claudia Filippi},
title = {Excited States with Selected Configuration Interaction-Quantum Monte Carlo: Chemically Accurate Excitation Energies and Geometries},
journal = {Journal of Chemical Theory and Computation}
}
%%%% PUBLISHED PAPERS
@article{Giner2019Oct,
author = {Giner, Emmanuel and Scemama, Anthony and Toulouse, Julien and Loos, Pierre-Fran{\c{c}}ois},
title = {{Chemically accurate excitation energies with small basis sets}},
journal = {J. Chem. Phys.},
volume = {151},
number = {14},
pages = {144118},
year = {2019},
month = {Oct},
issn = {0021-9606},
publisher = {American Institute of Physics},
doi = {10.1063/1.5122976}
}
@article{Burton2019Sep,
author = {Burton, Hugh G. A. and Thom, Alex J. W.},
title = {{General Approach for Multireference Ground and Excited States Using Nonorthogonal Configuration Interaction}},
journal = {J. Chem. Theory Comput.},
volume = {15},
number = {9},
pages = {4851--4861},
year = {2019},
month = {Sep},
issn = {1549-9618},
publisher = {American Chemical Society},
doi = {10.1021/acs.jctc.9b00441}
}
@article{Dash_2019,
author = {Dash, Monika and Feldt, Jonas and Moroni, Saverio and Scemama, Anthony and Filippi, Claudia},
title = {{Excited States with Selected Configuration Interaction-Quantum Monte Carlo: Chemically Accurate Excitation Energies and Geometries}},
journal = {J. Chem. Theory Comput.},
volume = {15},
number = {9},
pages = {4896--4906},
year = {2019},
month = {Sep},
issn = {1549-9618},
publisher = {American Chemical Society},
doi = {10.1021/acs.jctc.9b00476}
}
@article{Ferte_2019,
doi = {10.1063/1.5082638},
url = {https://doi.org/10.1063%2F1.5082638},

View File

@ -115,7 +115,7 @@ create an |EZFIO| database with the 6-31G basis set:
.. code:: bash
qp create_ezfio -b "6-31G" hcn.xyz -o hcn
qp create_ezfio -b "6-31g" hcn.xyz -o hcn
The EZFIO database now contains data relative to the nuclear coordinates
and the atomic basis set:

View File

@ -1,7 +1,7 @@
# Configuration of IRPF90 package
# Set the path of IRPF90 here:
export IRPF90_PATH=${QP_ROOT}/external/irpf90-v1.7.5
export IRPF90_PATH=${QP_ROOT}/external/irpf90-v1.7.6
export PATH=${PATH}:${IRPF90_PATH}/bin
export IRPF90=${IRPF90_PATH}/bin/irpf90

View File

@ -7,82 +7,61 @@ Type for bits strings
list of Bits
*)
type t = Bit.t list
type t = int64 array
let n_int = Array.length
(* Create a zero bit list *)
let zero n_int =
Array.make (N_int_number.to_int n_int) 0L
(* String representation *)
let to_string b =
let rec do_work accu = function
| [] -> accu
| head :: tail ->
let new_accu = (Bit.to_string head) ^ accu
in do_work new_accu tail
let int64_to_string x =
String.init 64 (fun i ->
if Int64.logand x @@ Int64.shift_left 1L i <> 0L then
'+'
else
'-')
in
do_work "" b
Array.map int64_to_string b
|> Array.to_list
|> String.concat ""
let of_string ?(zero='0') ?(one='1') s =
List.init (String.length s) (String.get s)
|> List.rev_map ( fun c ->
if (c = zero) then Bit.Zero
else if (c = one) then Bit.One
else (failwith ("Error in bitstring ") ) )
let n_int = ( (String.length s - 1) lsr 6 ) + 1 in
let result = Array.make n_int 0L in
String.iteri (fun i c ->
if c = one then
begin
let iint = i lsr 6 in (* i / 64 *)
let k = i - (iint lsl 6) in
result.(iint) <- Int64.logor result.(iint) @@ Int64.shift_left 1L k;
end) s;
result
let of_string_mp s =
List.init (String.length s) (String.get s)
|> List.rev_map (function
| '-' -> Bit.Zero
| '+' -> Bit.One
| _ -> failwith ("Error in bitstring ") )
let of_string_mp = of_string ~zero:'-' ~one:'+'
(* Create a bit list from an int64 *)
let of_int64 i =
let rec do_work accu = function
| 0L -> Bit.Zero :: accu |> List.rev
| 1L -> Bit.One :: accu |> List.rev
| i ->
let b =
match (Int64.logand i 1L ) with
| 0L -> Bit.Zero
| 1L -> Bit.One
| _ -> raise (Failure "i land 1 not in (0,1)")
in
do_work (b :: accu) (Int64.shift_right_logical i 1)
in
let adjust_length result =
let rec do_work accu = function
| 64 -> List.rev accu
| i when i>64 -> raise (Failure "Error in of_int64 > 64")
| i when i<0 -> raise (Failure "Error in of_int64 < 0")
| i -> do_work (Bit.Zero :: accu) (i+1)
in
do_work (List.rev result) (List.length result)
in
adjust_length (do_work [] i)
let of_int64 i = [| i |]
(* Create an int64 from a bit list *)
let to_int64 l =
assert ( (List.length l) <= 64) ;
let rec do_work accu = function
| [] -> accu
| Bit.Zero::tail -> do_work Int64.(shift_left accu 1) tail
| Bit.One::tail -> do_work Int64.(logor one (shift_left accu 1)) tail
in do_work Int64.zero (List.rev l)
let to_int64 = function
| [| i |] -> i
| _ -> failwith "N_int > 1"
(* Create a bit list from a list of int64 *)
let of_int64_list l =
List.map of_int64 l
|> List.concat
(* Create a bit list from an array of int64 *)
let of_int64_array l =
Array.map of_int64 l
|> Array.to_list
|> List.concat
external of_int64_array : int64 array -> t = "%identity"
external to_int64_array : t -> int64 array = "%identity"
(* Create a bit list from a list of int64 *)
let of_int64_list l =
Array.of_list l |> of_int64_array
(* Compute n_int *)
@ -91,101 +70,64 @@ let n_int_of_mo_num mo_num =
N_int_number.of_int ( (mo_num-1)/bit_kind_size + 1 )
(* Create a zero bit list *)
let zero n_int =
let n_int = N_int_number.to_int n_int in
let a = Array.init n_int (fun i-> 0L) in
of_int64_list ( Array.to_list a )
(* Create an int64 list from a bit list *)
let to_int64_list l =
let rec do_work accu buf counter = function
| [] ->
begin
match buf with
| [] -> accu
| _ -> (List.rev buf)::accu
end
| i::tail ->
if (counter < 64) then
do_work accu (i::buf) (counter+1) tail
else
do_work ( (List.rev (i::buf))::accu) [] 1 tail
in
let l = do_work [] [] 1 l
in
List.rev_map to_int64 l
to_int64_array l |> Array.to_list
(* Create an array of int64 from a bit list *)
let to_int64_array l =
to_int64_list l
|> Array.of_list
(* Create a bit list from a list of MO indices *)
let of_mo_number_list n_int l =
let n_int = N_int_number.to_int n_int in
let length = n_int*64 in
let a = Array.make length (Bit.Zero) in
List.iter (fun i-> a.((MO_number.to_int i)-1) <- Bit.One) l;
Array.to_list a
let result = zero n_int in
List.iter (fun j ->
let i = (MO_number.to_int j) - 1 in
let iint = i lsr 6 in (* i / 64 *)
let k = i - (iint lsl 6) in
result.(iint) <- Int64.logor result.(iint) @@ Int64.shift_left 1L k;
) l;
result
let to_mo_number_list l =
let a = Array.of_list l in
let mo_num = MO_number.get_max () in
let rec do_work accu = function
| 0 -> accu
| i ->
begin
let new_accu =
match a.(i-1) with
| Bit.One -> (MO_number.of_int ~max:mo_num i)::accu
| Bit.Zero -> accu
in
do_work new_accu (i-1)
end
let rec aux_one x shift accu = function
| -1 -> accu
| i -> if Int64.logand x (Int64.shift_left 1L i) <> 0L then
aux_one x shift ( (i+shift) ::accu) (i-1)
else
aux_one x shift accu (i-1)
in
do_work [] (List.length l)
Array.mapi (fun i x ->
let shift = (i lsr 6) lsl 6 + 1 in
aux_one x shift [] 63
) l
|> Array.to_list
|> List.concat
|> List.map MO_number.of_int
(* logical operations on bit_list *)
let logical_operator2 op a b =
let rec do_work_binary result a b =
match a, b with
| [], [] -> result
| [], _ | _ , [] -> raise (Failure "Lists should have same length")
| (ha::ta), (hb::tb) ->
let newbit = op ha hb
in do_work_binary (newbit::result) ta tb
let and_operator a b = Array.map2 Int64.logand a b
let xor_operator a b = Array.map2 Int64.logxor a b
let or_operator a b = Array.map2 Int64.logor a b
let not_operator b = Array.map Int64.lognot b
let pop_sign =
let mask =
(Int64.pred (Int64.shift_left 1L 63))
in
List.rev (do_work_binary [] a b)
let logical_operator1 op b =
let rec do_work_unary result b =
match b with
| [] -> result
| (hb::tb) ->
let newbit = op hb
in do_work_unary (newbit::result) tb
in
List.rev (do_work_unary [] b)
let and_operator a b = logical_operator2 Bit.and_operator a b
let xor_operator a b = logical_operator2 Bit.xor_operator a b
let or_operator a b = logical_operator2 Bit.or_operator a b
let not_operator b = logical_operator1 Bit.not_operator b
fun x -> Int64.logand mask x
let popcnt b =
List.fold_left (fun accu -> function
| Bit.One -> accu+1
| Bit.Zero -> accu
) 0 b
Array.fold_left (fun accu x ->
if x >= 0L then
accu + (Z.popcount @@ Z.of_int64 x)
else
accu + 1 + (Z.popcount @@ Z.of_int64 (pop_sign x))
) 0 b

View File

@ -1,4 +1,4 @@
type t = Bit.t list
type t
(** The zero bit list *)
val zero : Qptypes.N_int_number.t -> t

View File

@ -25,19 +25,6 @@ let to_bitlist_couple x =
in (xa,xb)
let bitlist_to_string ~mo_num x =
let len =
MO_number.to_int mo_num
in
let s =
List.map (function
| Bit.Zero -> "-"
| Bit.One -> "+"
) x
|> String.concat ""
in
String.sub s 0 len
let of_int64_array ~n_int ~alpha ~beta x =
@ -48,37 +35,29 @@ let of_int64_array ~n_int ~alpha ~beta x =
in
if ( (Bitlist.popcnt a) <> alpha) then
begin
let mo_num = MO_number.get_max () in
let mo_num = MO_number.of_int mo_num ~max:mo_num in
failwith (Printf.sprintf "Expected %d electrons in alpha determinant
%s" alpha (bitlist_to_string ~mo_num:mo_num a) )
%s" alpha (Bitlist.to_string a) )
end;
if ( (Bitlist.popcnt b) <> beta ) then
begin
let mo_num = MO_number.get_max () in
let mo_num = MO_number.of_int mo_num ~max:mo_num in
failwith (Printf.sprintf "Expected %d electrons in beta determinant
%s" beta (bitlist_to_string ~mo_num:mo_num b) )
%s" beta (Bitlist.to_string b) )
end;
x
let of_bitlist_couple ?n_int ~alpha ~beta (xa,xb) =
let of_bitlist_couple ~n_int ~alpha ~beta (xa,xb) =
let ba, bb =
Bitlist.to_int64_array xa ,
Bitlist.to_int64_array xb
and n_int =
match n_int with
| Some x -> x
| None -> Bitlist.n_int_of_mo_num (List.length xa)
in
of_int64_array ~n_int ~alpha ~beta (Array.concat [ba;bb])
let to_string ~mo_num x =
let (xa,xb) = to_bitlist_couple x in
[ " " ; bitlist_to_string ~mo_num xa ; "\n" ;
" " ; bitlist_to_string ~mo_num xb ]
[ " " ; Bitlist.to_string xa ; "\n" ;
" " ; Bitlist.to_string xb ]
|> String.concat ""

View File

@ -24,7 +24,7 @@ val to_alpha_beta : t -> (int64 array)*(int64 array)
val to_bitlist_couple : t -> Bitlist.t * Bitlist.t
(** Create from a bit list *)
val of_bitlist_couple : ?n_int:Qptypes.N_int_number.t ->
val of_bitlist_couple : n_int:Qptypes.N_int_number.t ->
alpha:Qptypes.Elec_alpha_number.t ->
beta:Qptypes.Elec_beta_number.t ->
Bitlist.t * Bitlist.t -> t

View File

@ -7,14 +7,14 @@ module Determinants_by_hand : sig
{ n_int : N_int_number.t;
bit_kind : Bit_kind.t;
n_det : Det_number.t;
n_det_qp_edit : Det_number.t;
n_states : States_number.t;
expected_s2 : Positive_float.t;
psi_coef : Det_coef.t array;
psi_det : Determinant.t array;
state_average_weight : Positive_float.t array;
} [@@deriving sexp]
val read : unit -> t
val read_maybe : unit -> t option
val read : ?full:bool -> unit -> t option
val write : t -> unit
val to_string : t -> string
val to_rst : t -> Rst_string.t
@ -28,6 +28,7 @@ end = struct
{ n_int : N_int_number.t;
bit_kind : Bit_kind.t;
n_det : Det_number.t;
n_det_qp_edit : Det_number.t;
n_states : States_number.t;
expected_s2 : Positive_float.t;
psi_coef : Det_coef.t array;
@ -38,8 +39,6 @@ end = struct
let get_default = Qpackage.get_ezfio_default "determinants";;
let n_det_read_max = 10_000 ;;
let read_n_int () =
if not (Ezfio.has_determinants_n_int()) then
Ezfio.get_mo_basis_mo_num ()
@ -80,11 +79,27 @@ end = struct
|> Det_number.of_int
;;
let read_n_det_qp_edit () =
if not (Ezfio.has_determinants_n_det_qp_edit ()) then
begin
let n_det = read_n_det () |> Det_number.to_int in
Ezfio.set_determinants_n_det_qp_edit n_det
end;
Ezfio.get_determinants_n_det_qp_edit ()
|> Det_number.of_int
;;
let write_n_det n =
Det_number.to_int n
|> Ezfio.set_determinants_n_det
;;
let write_n_det_qp_edit n =
let n_det = read_n_det () |> Det_number.to_int in
min n_det (Det_number.to_int n)
|> Ezfio.set_determinants_n_det_qp_edit
;;
let read_n_states () =
if not (Ezfio.has_determinants_n_states ()) then
Ezfio.set_determinants_n_states 1
@ -178,7 +193,7 @@ end = struct
|> Ezfio.set_determinants_expected_s2
;;
let read_psi_coef () =
let read_psi_coef ~read_only () =
if not (Ezfio.has_determinants_psi_coef ()) then
begin
let n_states =
@ -189,7 +204,12 @@ end = struct
~data:(List.init n_states (fun i -> if (i=0) then 1. else 0. ))
|> Ezfio.set_determinants_psi_coef
end;
Ezfio.get_determinants_psi_coef ()
begin
if read_only then
Ezfio.get_determinants_psi_coef_qp_edit ()
else
Ezfio.get_determinants_psi_coef ()
end
|> Ezfio.flattened_ezfio
|> Array.map Det_coef.of_float
;;
@ -202,12 +222,15 @@ end = struct
and n_states =
States_number.to_int n_states
in
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
|> Ezfio.set_determinants_psi_coef
let r =
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
in
Ezfio.set_determinants_psi_coef r;
Ezfio.set_determinants_psi_coef_qp_edit r
;;
let read_psi_det () =
let read_psi_det ~read_only () =
let n_int = read_n_int ()
and n_alpha = Ezfio.get_electrons_elec_alpha_num ()
|> Elec_alpha_number.of_int
@ -233,13 +256,21 @@ end = struct
|> Ezfio.set_determinants_psi_det ;
end ;
let n_int = N_int_number.to_int n_int in
let psi_det_array = Ezfio.get_determinants_psi_det () in
let psi_det_array =
if read_only then
Ezfio.get_determinants_psi_det_qp_edit ()
else
Ezfio.get_determinants_psi_det ()
in
let dim = psi_det_array.Ezfio.dim
and data = Ezfio.flattened_ezfio psi_det_array
in
assert (n_int = dim.(0));
assert (dim.(1) = 2);
assert (dim.(2) = (Det_number.to_int (read_n_det ())));
if read_only then
assert (dim.(2) = (Det_number.to_int (read_n_det_qp_edit ())))
else
assert (dim.(2) = (Det_number.to_int (read_n_det ())));
Array.init dim.(2) (fun i ->
Array.sub data (2*n_int*i) (2*n_int) )
|> Array.map (Determinant.of_int64_array
@ -252,40 +283,45 @@ end = struct
|> Array.concat
|> Array.to_list
in
Ezfio.ezfio_array_of_list ~rank:3 ~dim:[| N_int_number.to_int n_int ; 2 ; Det_number.to_int n_det |] ~data:data
|> Ezfio.set_determinants_psi_det
let r =
Ezfio.ezfio_array_of_list ~rank:3 ~dim:[| N_int_number.to_int n_int ; 2 ; Det_number.to_int n_det |] ~data:data
in
Ezfio.set_determinants_psi_det r;
Ezfio.set_determinants_psi_det_qp_edit r
;;
let read () =
let read ?(full=true) () =
let n_det_qp_edit = read_n_det_qp_edit () in
let n_det = read_n_det () in
let read_only =
if full then false else n_det_qp_edit <> n_det
in
if (Ezfio.has_mo_basis_mo_num ()) then
try
Some
{ n_int = read_n_int () ;
bit_kind = read_bit_kind () ;
n_det = read_n_det () ;
n_det_qp_edit = read_n_det_qp_edit () ;
expected_s2 = read_expected_s2 () ;
psi_coef = read_psi_coef () ;
psi_det = read_psi_det () ;
psi_coef = read_psi_coef ~read_only () ;
psi_det = read_psi_det ~read_only () ;
n_states = read_n_states () ;
state_average_weight = read_state_average_weight () ;
}
with _ -> None
else
failwith "No molecular orbitals, so no determinants"
;;
let read_maybe () =
let n_det =
read_n_det ()
in
if ( (Det_number.to_int n_det) < n_det_read_max ) then
try Some (read ()) with
| Failure _ -> None
else
(* No molecular orbitals, so no determinants *)
None
;;
let write { n_int ;
bit_kind ;
n_det ;
n_det_qp_edit ;
expected_s2 ;
psi_coef ;
psi_det ;
@ -297,9 +333,13 @@ end = struct
write_n_det n_det;
write_n_states n_states;
write_expected_s2 expected_s2;
write_psi_coef ~n_det:n_det ~n_states:n_states psi_coef ;
write_psi_det ~n_int:n_int ~n_det:n_det psi_det;
write_state_average_weight state_average_weight;
if n_det <= n_det_qp_edit then
begin
write_n_det_qp_edit n_det;
write_psi_coef ~n_det:n_det ~n_states:n_states psi_coef ;
write_psi_det ~n_int:n_int ~n_det:n_det psi_det
end;
write_state_average_weight state_average_weight
;;
@ -316,11 +356,13 @@ end = struct
|> States_number.to_int
and ndet =
Det_number.to_int b.n_det
and ndet_qp_edit =
Det_number.to_int b.n_det_qp_edit
in
let coefs_string i =
Array.init nstates (fun j ->
let ishift =
j*ndet
j*ndet_qp_edit
in
if (ishift < Array.length b.psi_coef) then
b.psi_coef.(i+ishift)
@ -331,7 +373,7 @@ end = struct
)
|> Array.to_list |> String.concat "\t"
in
Array.init ndet (fun i ->
Array.init ndet_qp_edit (fun i ->
Printf.sprintf " %s\n%s\n"
(coefs_string i)
(Determinant.to_string ~mo_num:mo_num b.psi_det.(i)
@ -472,6 +514,7 @@ psi_det = %s
(* Handle determinants *)
let psi_det =
let n_int = N_int_number.of_int @@ (MO_number.get_max () - 1) / 64 + 1 in
let n_alpha = Ezfio.get_electrons_elec_alpha_num ()
|> Elec_alpha_number.of_int
and n_beta = Ezfio.get_electrons_elec_beta_num ()
@ -483,8 +526,8 @@ psi_det = %s
begin
let newdet =
(Bitlist.of_string ~zero:'-' ~one:'+' alpha ,
Bitlist.of_string ~zero:'-' ~one:'+' beta)
|> Determinant.of_bitlist_couple ~alpha:n_alpha ~beta:n_beta
Bitlist.of_string ~zero:'-' ~one:'+' beta)
|> Determinant.of_bitlist_couple ~n_int ~alpha:n_alpha ~beta:n_beta
|> Determinant.sexp_of_t
|> Sexplib.Sexp.to_string
in
@ -492,9 +535,6 @@ psi_det = %s
end
| _::tail -> read_dets accu tail
in
let dets =
List.map String_ext.rev dets
in
let a =
read_dets [] dets
|> String.concat ""
@ -510,9 +550,11 @@ psi_det = %s
Printf.sprintf "(n_int %d)" (N_int_number.get_max ())
and n_states =
Printf.sprintf "(n_states %d)" (States_number.to_int @@ read_n_states ())
and n_det_qp_edit =
Printf.sprintf "(n_det_qp_edit %d)" (Det_number.to_int @@ read_n_det_qp_edit ())
in
let s =
String.concat "" [ header ; bitkind ; n_int ; n_states ; psi_coef ; psi_det]
String.concat "" [ header ; bitkind ; n_int ; n_states ; psi_coef ; psi_det ; n_det_qp_edit ]
in
@ -527,7 +569,9 @@ psi_det = %s
Det_number.to_int n_det_new
in
let det =
read ()
match read () with
| Some x -> x
| None -> failwith "No determinants in file"
in
let n_det_old, n_states =
Det_number.to_int det.n_det,
@ -558,7 +602,9 @@ psi_det = %s
let extract_state istate =
Printf.printf "Extracting state %d\n" (States_number.to_int istate);
let det =
read ()
match read () with
| Some x -> x
| None -> failwith "No determinants in file"
in
let n_det, n_states =
Det_number.to_int det.n_det,
@ -588,7 +634,9 @@ psi_det = %s
let extract_states range =
Printf.printf "Extracting states %s\n" (Range.to_string range);
let det =
read ()
match read () with
| Some x -> x
| None -> failwith "No determinants in file"
in
let n_det, n_states =
Det_number.to_int det.n_det,
@ -614,7 +662,8 @@ psi_det = %s
j*n_det
in
for i=0 to (n_det-1) do
det.psi_coef.(!state_shift+i) <- det.psi_coef.(i+ishift)
det.psi_coef.(!state_shift+i) <-
det.psi_coef.(i+ishift)
done
end;
state_shift := !state_shift + n_det

View File

@ -65,8 +65,15 @@ end = struct
let read_mo_num () =
Ezfio.get_mo_basis_mo_num ()
|> MO_number.of_int
let elec_alpha_num =
Ezfio.get_electrons_elec_alpha_num ()
in
let result =
Ezfio.get_mo_basis_mo_num ()
in
if result < elec_alpha_num then
failwith "More alpha electrons than MOs";
MO_number.of_int result
let read_mo_class () =

View File

@ -43,7 +43,7 @@ $(QP_ROOT)/data/executables: remake_executables element_create_db.byte Qptypes.m
$(QP_ROOT)/ocaml/element_create_db.byte
external_libs:
opam install cryptokit core
opam install cryptokit sexplib
qpackage.odocl: $(MLIFILES)
ls $(MLIFILES) | sed "s/\.mli//" > qpackage.odocl

View File

@ -1,4 +1,4 @@
true: package(cryptokit,zmq,str,sexplib,ppx_sexp_conv,ppx_deriving,getopt)
true: package(cryptokit,zarith,zmq,str,sexplib,ppx_sexp_conv,ppx_deriving,getopt)
true: thread
false: profile
<*byte> : linkdep(c_bindings.o), custom

View File

@ -44,9 +44,12 @@ let psi_det () =
let psi_det =
Input.Determinants_by_hand.read ()
in
Input.Determinants_by_hand.to_rst psi_det
|> Rst_string.to_string
|> print_endline
match psi_det with
| Some psi_det ->
Input.Determinants_by_hand.to_rst psi_det
|> Rst_string.to_string
|> print_endline
| None -> ()

View File

@ -112,9 +112,9 @@ let set ~core ~inact ~act ~virt ~del =
and av = Excitation.create_single act virt
in
let single_excitations = [ ia ; aa ; av ]
|> List.map (fun x ->
|> List.map (fun z ->
let open Excitation in
match x with
match z with
| Single (x,y) ->
( MO_class.to_bitlist n_int (Hole.to_mo_class x),
MO_class.to_bitlist n_int (Particle.to_mo_class y) )
@ -187,9 +187,10 @@ let set ~core ~inact ~act ~virt ~del =
match aa with
| Double _ -> assert false
| Single (x,y) ->
( MO_class.to_bitlist n_int (Hole.to_mo_class x) ) @
( MO_class.to_bitlist n_int (Particle.to_mo_class y) )
|> Bitlist.to_int64_list
Bitlist.to_int64_list
( MO_class.to_bitlist n_int ( Hole.to_mo_class x) ) @
Bitlist.to_int64_list
( MO_class.to_bitlist n_int (Particle.to_mo_class y) )
in
Ezfio.set_bitmasks_n_mask_cas 1;
Ezfio.ezfio_array_of_list ~rank:3 ~dim:([| (N_int_number.to_int n_int) ; 2; 1|]) ~data:result

View File

@ -6,6 +6,10 @@ type req_or_sub = REQ | SUB
let localport = 42379
let in_time_sum = ref 1.e-9
and in_size_sum = ref 0.
let () =
let open Command_line in
begin
@ -17,6 +21,10 @@ let () =
doc="Downloads the EZFIO directory." ;
arg=Without_arg; } ;
{ short='v' ; long="verbose" ; opt=Optional ;
doc="Prints the transfer speed." ;
arg=Without_arg; } ;
anonymous
"(EZFIO_DIR|ADDRESS)"
Mandatory
@ -39,6 +47,9 @@ let () =
ADDRESS x
in
let verbose =
Command_line.get_bool "verbose"
in
@ -133,8 +144,8 @@ let () =
let socket_in, socket_out =
match req_or_sub with
| REQ ->
create_socket Zmq.Socket.rep Zmq.Socket.bind addr_in,
create_socket Zmq.Socket.req Zmq.Socket.connect addr_out
create_socket Zmq.Socket.router Zmq.Socket.bind addr_in,
create_socket Zmq.Socket.dealer Zmq.Socket.connect addr_out
| SUB ->
create_socket Zmq.Socket.sub Zmq.Socket.connect addr_in,
create_socket Zmq.Socket.pub Zmq.Socket.bind addr_out
@ -144,19 +155,61 @@ let () =
Zmq.Socket.subscribe socket_in "";
(*
let action =
if verbose then
begin
match req_or_sub with
| REQ -> (fun () ->
let msg =
Zmq.Socket.recv_all socket_in
in
let t0 = Unix.gettimeofday () in
Zmq.Socket.send_all socket_out msg;
let in_size =
float_of_int ( List.fold_left (fun accu x -> accu + String.length x) 0 msg )
/. 8192. /. 1024.
in
let msg =
Zmq.Socket.recv_all socket_out
in
let t1 = Unix.gettimeofday () in
Zmq.Socket.send_all socket_in msg;
let in_time = t1 -. t0 in
in_time_sum := !in_time_sum +. in_time;
in_size_sum := !in_size_sum +. in_size;
Printf.printf " %16.2f MiB/s -- %16.2f MiB/s\n%!" (in_size /. in_time) (!in_size_sum /. !in_time_sum);
)
| SUB -> (fun () ->
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out)
end
else
begin
match req_or_sub with
| REQ -> (fun () ->
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out;
Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in )
| SUB -> (fun () ->
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out)
end
in
*)
let action_in =
match req_or_sub with
| REQ -> (fun () ->
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out;
Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in )
| SUB -> (fun () ->
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out)
| REQ -> (fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out)
| SUB -> (fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out)
in
let action_out =
match req_or_sub with
| REQ -> (fun () -> Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in )
| SUB -> (fun () -> () )
in
let pollitem =
Zmq.Poll.mask_of
[| (socket_in, Zmq.Poll.In) |]
[| (socket_in, Zmq.Poll.In) ; (socket_out, Zmq.Poll.In) |]
in
@ -166,12 +219,11 @@ let () =
Zmq.Poll.poll ~timeout:1000 pollitem
in
match polling.(0) with
| Some Zmq.Poll.In -> action ()
| None -> ()
| Some Zmq.Poll.In_out
| Some Zmq.Poll.Out -> ()
match polling with
| [| Some Zmq.Poll.In ; Some Zmq.Poll.In |] -> ( action_out () ; action_in () )
| [| _ ; Some Zmq.Poll.In |] -> action_out ()
| [| Some Zmq.Poll.In ; _ |] -> action_in ()
| _ -> ()