10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-25 05:43:47 +01:00

Updated OCaml

This commit is contained in:
Anthony Scemama 2018-10-17 19:27:58 +02:00
parent bfa9fa8637
commit a289df5503
15 changed files with 508 additions and 292 deletions

View File

@ -5,7 +5,7 @@ QP_ROOT=$PWD
cd - cd -
# Normal installation # Normal installation
PACKAGES="core.v0.10.0 cryptokit ocamlfind sexplib.v0.10.0 zmq ppx_sexp_conv ppx_deriving" PACKAGES="core cryptokit ocamlfind sexplib zmq ppx_sexp_conv ppx_deriving"
# Needed for ZeroMQ # Needed for ZeroMQ
export C_INCLUDE_PATH="${QP_ROOT}"/include:"${C_INCLUDE_PATH}" export C_INCLUDE_PATH="${QP_ROOT}"/include:"${C_INCLUDE_PATH}"
@ -65,7 +65,7 @@ fi
cd Downloads || exit 1 cd Downloads || exit 1
chmod +x ocaml.sh || exit 1 chmod +x ocaml.sh || exit 1
echo N | ./ocaml.sh ${QP_ROOT}/bin/ 4.06.0 || exit 1 echo N | ./ocaml.sh ${QP_ROOT}/bin/ 4.07.1 || exit 1
${QP_ROOT}/bin/opam config setup -a -q || exit 1 ${QP_ROOT}/bin/opam config setup -a -q || exit 1

View File

@ -79,14 +79,14 @@ let read_until_found f tries =
begin begin
try try
Some (read_mos x f) Some (read_mos x f)
with Not_found -> with Caml.Not_found ->
None None
end end
) None tries ) None tries
in in
match result with match result with
| Some mos -> mos | Some mos -> mos
| None -> raise Not_found | None -> raise Caml.Not_found
let read_natural_mos f = let read_natural_mos f =
let tries = [ let tries = [
@ -430,7 +430,7 @@ let create_cas_input ?(vecfile="") ~guess ~nstate s n_e n_a =
in in
try try
string_of_guess (Natural (norb, vecfile)) string_of_guess (Natural (norb, vecfile))
with Not_found -> with Caml.Not_found ->
string_of_guess (Canonical (norb, vecfile)) string_of_guess (Canonical (norb, vecfile))
end end
; ;

View File

@ -1,38 +1,101 @@
(* =~=~ *)
(* Init *)
(* =~=~ *)
open Qptypes;; open Qptypes;;
open Qputils;; open Qputils;;
open Core;; open Core;;
module Ao_basis : sig module Ao_basis : sig
(* Generate type *) type t =
type t = { ao_basis : AO_basis_name.t;
{ ao_num : AO_number.t ;
disk_access_ao_one_integrals : Disk_access.t; ao_prim_num : AO_prim_number.t array;
} [@@deriving sexp] ao_prim_num_max : AO_prim_number.t;
;; ao_nucl : Nucl_number.t array;
val read : unit -> t option ao_power : Symmetry.Xyz.t array;
val write : t-> unit ao_coef : AO_coef.t array;
ao_expo : AO_expo.t array;
ao_cartesian : bool;
} [@@deriving sexp]
;;
val read : unit -> t option
val to_string : t -> string val to_string : t -> string
val to_basis : t -> Basis.t
val write : t -> unit
val to_md5 : t -> MD5.t
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t option
end = struct end = struct
(* Generate type *) type t =
type t = { ao_basis : AO_basis_name.t;
{ ao_num : AO_number.t ;
disk_access_ao_one_integrals : Disk_access.t; ao_prim_num : AO_prim_number.t array;
} [@@deriving sexp] ao_prim_num_max : AO_prim_number.t;
;; ao_nucl : Nucl_number.t array;
ao_power : Symmetry.Xyz.t array;
ao_coef : AO_coef.t array;
ao_expo : AO_expo.t array;
ao_cartesian : bool;
} [@@deriving sexp]
;;
let get_default = Qpackage.get_ezfio_default "ao_basis";; let get_default = Qpackage.get_ezfio_default "ao_basis";;
(* =~=~=~=~=~=~==~=~=~=~=~=~ *) let read_ao_basis () =
(* Generate Special Function *) Ezfio.get_ao_basis_ao_basis ()
(* =~=~=~==~=~~=~=~=~=~=~=~=~ *) |> AO_basis_name.of_string
;;
let read_ao_num () =
Ezfio.get_ao_basis_ao_num ()
|> AO_number.of_int
;;
let read_ao_prim_num () =
Ezfio.get_ao_basis_ao_prim_num ()
|> Ezfio.flattened_ezfio
|> Array.map ~f:AO_prim_number.of_int
;;
let read_ao_prim_num_max () =
Ezfio.get_ao_basis_ao_prim_num ()
|> Ezfio.flattened_ezfio
|> Array.fold ~f:(fun x y -> if x>y then x else y) ~init:0
|> AO_prim_number.of_int
;;
let read_ao_nucl () =
let nmax = Nucl_number.get_max () in
Ezfio.get_ao_basis_ao_nucl ()
|> Ezfio.flattened_ezfio
|> Array.map ~f:(fun x-> Nucl_number.of_int ~max:nmax x)
;;
let read_ao_power () =
let x = Ezfio.get_ao_basis_ao_power () in
let dim = x.Ezfio.dim.(0) in
let data = Ezfio.flattened_ezfio x in
let result = Array.init dim ~f:(fun x -> "") in
for i=1 to dim
do
if (data.(i-1) > 0) then
result.(i-1) <- result.(i-1)^"x"^(Int.to_string data.(i-1));
if (data.(dim+i-1) > 0) then
result.(i-1) <- result.(i-1)^"y"^(Int.to_string data.(dim+i-1));
if (data.(2*dim+i-1) > 0) then
result.(i-1) <- result.(i-1)^"z"^(Int.to_string data.(2*dim+i-1));
done;
Array.map ~f:Symmetry.Xyz.of_string result
;;
let read_ao_coef () =
Ezfio.get_ao_basis_ao_coef ()
|> Ezfio.flattened_ezfio
|> Array.map ~f:AO_coef.of_float
;;
let read_ao_expo () =
Ezfio.get_ao_basis_ao_expo ()
|> Ezfio.flattened_ezfio
|> Array.map ~f:AO_expo.of_float
;;
(* Read snippet for ao_cartesian *)
let read_ao_cartesian () = let read_ao_cartesian () =
if not (Ezfio.has_ao_basis_ao_cartesian ()) then if not (Ezfio.has_ao_basis_ao_cartesian ()) then
get_default "ao_cartesian" get_default "ao_cartesian"
@ -41,133 +104,191 @@ end = struct
; ;
Ezfio.get_ao_basis_ao_cartesian () Ezfio.get_ao_basis_ao_cartesian ()
;; ;;
(* Write snippet for ao_cartesian *)
let write_ao_cartesian = let to_long_basis b =
Ezfio.set_ao_basis_ao_cartesian let ao_num = AO_number.to_int b.ao_num in
let gto_array = Array.init (AO_number.to_int b.ao_num)
~f:(fun i ->
let s = Symmetry.Xyz.to_symmetry b.ao_power.(i) in
let ao_prim_num = AO_prim_number.to_int b.ao_prim_num.(i) in
let prims = List.init ao_prim_num ~f:(fun j ->
let prim = { GaussianPrimitive.sym = s ;
GaussianPrimitive.expo = b.ao_expo.(ao_num*j+i)
}
in
let coef = b.ao_coef.(ao_num*j+i) in
(prim,coef)
) in
Gto.of_prim_coef_list prims
)
in
let rec do_work accu sym gto nucl =
match (sym, gto, nucl) with
| (s::srest, g::grest, n::nrest) ->
do_work ((s,g,n)::accu) srest grest nrest
| ([],[],[]) -> List.rev accu
| _ -> assert false
in
do_work []
(Array.to_list b.ao_power)
(Array.to_list gto_array)
(Array.to_list b.ao_nucl)
;;
let to_basis b =
to_long_basis b
|> Long_basis.to_basis
;;
let to_md5 b =
let short_basis = to_basis b in
Basis.to_md5 short_basis
;;
let write_md5 b =
to_md5 b
|> MD5.to_string
|> Ezfio.set_ao_basis_ao_md5
;; ;;
(* Read snippet for ao_prim_num_max *) let write_ao_basis name =
let read_ao_prim_num_max () = AO_basis_name.to_string name
if not (Ezfio.has_ao_basis_ao_prim_num_max ()) then |> Ezfio.set_ao_basis_ao_basis
get_default "ao_prim_num_max"
|> Int.of_string
|> Ezfio.set_ao_basis_ao_prim_num_max
;
Ezfio.get_ao_basis_ao_prim_num_max ()
;;
(* Write snippet for ao_prim_num_max *)
let write_ao_prim_num_max =
Ezfio.set_ao_basis_ao_prim_num_max
;; ;;
(* Read snippet for disk_access_ao_one_integrals *) let write b =
let read_disk_access_ao_one_integrals () = let { ao_basis ;
if not (Ezfio.has_ao_basis_disk_access_ao_one_integrals ()) then ao_num ;
get_default "disk_access_ao_one_integrals" ao_prim_num ;
|> String.of_string ao_prim_num_max ;
|> Ezfio.set_ao_basis_disk_access_ao_one_integrals ao_nucl ;
; ao_power ;
Ezfio.get_ao_basis_disk_access_ao_one_integrals () ao_coef ;
|> Disk_access.of_string ao_expo ;
;; ao_cartesian ;
(* Write snippet for disk_access_ao_one_integrals *) } = b
let write_disk_access_ao_one_integrals var = in
Disk_access.to_string var write_md5 b ;
|> Ezfio.set_ao_basis_disk_access_ao_one_integrals write_ao_basis ao_basis;
;; ;;
(* Read snippet for integral_kinetic *)
let read_integral_kinetic () = let read () =
if not (Ezfio.has_ao_basis_integral_kinetic ()) then if (Ezfio.has_ao_basis_ao_basis ()) then
get_default "integral_kinetic" begin
|> Float.of_string let result =
|> Ezfio.set_ao_basis_integral_kinetic { ao_basis = read_ao_basis ();
; ao_num = read_ao_num () ;
Ezfio.get_ao_basis_integral_kinetic () ao_prim_num = read_ao_prim_num ();
ao_prim_num_max = read_ao_prim_num_max ();
ao_nucl = read_ao_nucl ();
ao_power = read_ao_power ();
ao_coef = read_ao_coef () ;
ao_expo = read_ao_expo () ;
ao_cartesian = read_ao_cartesian () ;
}
in
to_md5 result
|> MD5.to_string
|> Ezfio.set_ao_basis_ao_md5 ;
Some result
end
else
None
;; ;;
(* Write snippet for integral_kinetic *)
let write_integral_kinetic =
Ezfio.set_ao_basis_integral_kinetic let to_rst b =
let print_sym =
let l = List.init (Array.length b.ao_power) ~f:(
fun i -> ( (i+1),b.ao_nucl.(i),b.ao_power.(i) ) ) in
let rec do_work = function
| [] -> []
| (i,n,x)::tail ->
(Printf.sprintf " %5d %6d %-8s\n" i (Nucl_number.to_int n) (Symmetry.Xyz.to_string x))::
(do_work tail)
in do_work l
|> String.concat
in
let short_basis = to_basis b in
Printf.sprintf "
Name of the AO basis ::
ao_basis = %s
Cartesian coordinates (6d,10f,...) ::
ao_cartesian = %s
Basis set (read-only) ::
%s
======= ========= ===========
Basis Nucleus Symmetries
======= ========= ===========
%s
======= ========= ===========
" (AO_basis_name.to_string b.ao_basis)
(Bool.to_string b.ao_cartesian)
(Basis.to_string short_basis
|> String.split ~on:'\n'
|> List.map ~f:(fun x-> " "^x)
|> String.concat ~sep:"\n"
) print_sym
|> Rst_string.of_string
;; ;;
(* Read snippet for integral_nuclear *) let read_rst s =
let read_integral_nuclear () = let s = Rst_string.to_string s
if not (Ezfio.has_ao_basis_integral_nuclear ()) then |> String.split ~on:'\n'
get_default "integral_nuclear" in
|> Float.of_string let rec extract_basis = function
|> Ezfio.set_ao_basis_integral_nuclear | [] -> failwith "Error in basis set"
; | line :: tail ->
Ezfio.get_ao_basis_integral_nuclear () let line = String.strip line in
;; if line = "Basis set (read-only) ::" then
(* Write snippet for integral_nuclear *) String.concat tail ~sep:"\n"
let write_integral_nuclear = else
Ezfio.set_ao_basis_integral_nuclear extract_basis tail
in
extract_basis s
;; ;;
(* Read snippet for integral_overlap *) let to_string b =
let read_integral_overlap () = Printf.sprintf "
if not (Ezfio.has_ao_basis_integral_overlap ()) then ao_basis = %s
get_default "integral_overlap" ao_num = %s
|> Float.of_string ao_prim_num = %s
|> Ezfio.set_ao_basis_integral_overlap ao_prim_num_max = %s
; ao_nucl = %s
Ezfio.get_ao_basis_integral_overlap () ao_power = %s
;; ao_coef = %s
(* Write snippet for integral_overlap *) ao_expo = %s
let write_integral_overlap = ao_cartesian = %s
Ezfio.set_ao_basis_integral_overlap md5 = %s
;; "
(AO_basis_name.to_string b.ao_basis)
(AO_number.to_string b.ao_num)
(b.ao_prim_num |> Array.to_list |> List.map
~f:(AO_prim_number.to_string) |> String.concat ~sep:", " )
(AO_prim_number.to_string b.ao_prim_num_max)
(b.ao_nucl |> Array.to_list |> List.map ~f:Nucl_number.to_string |>
String.concat ~sep:", ")
(b.ao_power |> Array.to_list |> List.map ~f:(fun x->
"("^(Symmetry.Xyz.to_string x)^")" )|> String.concat ~sep:", ")
(b.ao_coef |> Array.to_list |> List.map ~f:AO_coef.to_string
|> String.concat ~sep:", ")
(b.ao_expo |> Array.to_list |> List.map ~f:AO_expo.to_string
|> String.concat ~sep:", ")
(b.ao_cartesian |> Bool.to_string)
(to_md5 b |> MD5.to_string )
(* Read snippet for integral_pseudo *)
let read_integral_pseudo () =
if not (Ezfio.has_ao_basis_integral_pseudo ()) then
get_default "integral_pseudo"
|> Float.of_string
|> Ezfio.set_ao_basis_integral_pseudo
;
Ezfio.get_ao_basis_integral_pseudo ()
;;
(* Write snippet for integral_pseudo *)
let write_integral_pseudo =
Ezfio.set_ao_basis_integral_pseudo
;; ;;
end
(* =~=~=~=~=~=~=~=~=~=~=~=~ *)
(* Generate Global Function *)
(* =~=~=~=~=~=~=~=~=~=~=~=~ *)
(* Read all *)
let read() =
Some
{
disk_access_ao_one_integrals = read_disk_access_ao_one_integrals ();
}
;;
(* Write all *)
let write{
disk_access_ao_one_integrals;
} =
write_disk_access_ao_one_integrals disk_access_ao_one_integrals;
;;
(* to_string*)
let to_string b =
Printf.sprintf "
disk_access_ao_one_integrals = %s
"
(Disk_access.to_string b.disk_access_ao_one_integrals)
;;
(* to_rst*)
let to_rst b =
Printf.sprintf "
Read/Write AO one-electron integrals from/to disk [ Write | Read | None ] ::
disk_access_ao_one_integrals = %s
"
(Disk_access.to_string b.disk_access_ao_one_integrals)
|> Rst_string.of_string
;;
include Generic_input_of_rst;;
let of_rst = of_rst t_of_sexp;;
end

View File

@ -1,131 +1,229 @@
(* =~=~ *) open Qptypes
(* Init *) open Qputils
(* =~=~ *) open Core
open Qptypes;;
open Qputils;;
open Core;;
module Mo_basis : sig module Mo_basis : sig
(* Generate type *) type t =
type t = { mo_tot_num : MO_number.t ;
{ mo_label : MO_label.t;
disk_access_mo_one_integrals : Disk_access.t; mo_class : MO_class.t array;
} [@@deriving sexp] mo_occ : MO_occ.t array;
;; mo_coef : (MO_coef.t array) array;
val read : unit -> t option ao_md5 : MD5.t;
val write : t-> unit } [@@deriving sexp]
val read : unit -> t option
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
end = struct end = struct
(* Generate type *) type t =
type t = { mo_tot_num : MO_number.t ;
{ mo_label : MO_label.t;
disk_access_mo_one_integrals : Disk_access.t; mo_class : MO_class.t array;
} [@@deriving sexp] mo_occ : MO_occ.t array;
;; mo_coef : (MO_coef.t array) array;
ao_md5 : MD5.t;
} [@@deriving sexp]
let get_default = Qpackage.get_ezfio_default "mo_basis"
let get_default = Qpackage.get_ezfio_default "mo_basis";; let read_mo_label () =
if not (Ezfio.has_mo_basis_mo_label ()) then
(* =~=~=~=~=~=~==~=~=~=~=~=~ *) Ezfio.set_mo_basis_mo_label "None"
(* Generate Special Function *)
(* =~=~=~==~=~~=~=~=~=~=~=~=~ *)
(* Read snippet for disk_access_mo_one_integrals *)
let read_disk_access_mo_one_integrals () =
if not (Ezfio.has_mo_basis_disk_access_mo_one_integrals ()) then
get_default "disk_access_mo_one_integrals"
|> String.of_string
|> Ezfio.set_mo_basis_disk_access_mo_one_integrals
; ;
Ezfio.get_mo_basis_disk_access_mo_one_integrals () Ezfio.get_mo_basis_mo_label ()
|> Disk_access.of_string |> MO_label.of_string
;;
(* Write snippet for disk_access_mo_one_integrals *)
let write_disk_access_mo_one_integrals var =
Disk_access.to_string var
|> Ezfio.set_mo_basis_disk_access_mo_one_integrals
;;
(* Read snippet for integral_kinetic *)
let read_integral_kinetic () =
if not (Ezfio.has_mo_basis_integral_kinetic ()) then
get_default "integral_kinetic"
|> Float.of_string
|> Ezfio.set_mo_basis_integral_kinetic
;
Ezfio.get_mo_basis_integral_kinetic ()
;;
(* Write snippet for integral_kinetic *)
let write_integral_kinetic =
Ezfio.set_mo_basis_integral_kinetic
;;
(* Read snippet for integral_nuclear *) let read_ao_md5 () =
let read_integral_nuclear () = let ao_md5 =
if not (Ezfio.has_mo_basis_integral_nuclear ()) then match (Input_ao_basis.Ao_basis.read ()) with
get_default "integral_nuclear" | None -> failwith "Unable to read AO basis"
|> Float.of_string | Some result -> Input_ao_basis.Ao_basis.to_md5 result
|> Ezfio.set_mo_basis_integral_nuclear in
; let result =
Ezfio.get_mo_basis_integral_nuclear () if not (Ezfio.has_mo_basis_ao_md5 ()) then
;; begin
(* Write snippet for integral_nuclear *) MD5.to_string ao_md5
let write_integral_nuclear = |> Ezfio.set_mo_basis_ao_md5
Ezfio.set_mo_basis_integral_nuclear end;
;; Ezfio.get_mo_basis_ao_md5 ()
|> MD5.of_string
in
if (ao_md5 <> result) then
failwith "The current MOs don't correspond to the current AOs.";
result
(* Read snippet for integral_pseudo *)
let read_integral_pseudo () =
if not (Ezfio.has_mo_basis_integral_pseudo ()) then
get_default "integral_pseudo"
|> Float.of_string
|> Ezfio.set_mo_basis_integral_pseudo
;
Ezfio.get_mo_basis_integral_pseudo ()
;;
(* Write snippet for integral_pseudo *)
let write_integral_pseudo =
Ezfio.set_mo_basis_integral_pseudo
;;
(* =~=~=~=~=~=~=~=~=~=~=~=~ *) let read_mo_tot_num () =
(* Generate Global Function *) Ezfio.get_mo_basis_mo_tot_num ()
(* =~=~=~=~=~=~=~=~=~=~=~=~ *) |> MO_number.of_int
let read_mo_class () =
if not (Ezfio.has_mo_basis_mo_class ()) then
begin
let mo_tot_num = MO_number.to_int (read_mo_tot_num ()) in
let data =
Array.init mo_tot_num ~f:(fun _ -> MO_class.(to_string (Active [])))
|> Array.to_list
in
Ezfio.ezfio_array_of_list ~rank:1
~dim:[| mo_tot_num |] ~data:data
|> Ezfio.set_mo_basis_mo_class
end;
Ezfio.flattened_ezfio (Ezfio.get_mo_basis_mo_class () )
|> Array.map ~f:MO_class.of_string
let read_mo_occ () =
if not (Ezfio.has_mo_basis_mo_label ()) then
begin
let elec_alpha_num = Ezfio.get_electrons_elec_alpha_num ()
and elec_beta_num = Ezfio.get_electrons_elec_beta_num ()
and mo_tot_num = MO_number.to_int (read_mo_tot_num ()) in
let data = Array.init mo_tot_num ~f:(fun i ->
if (i<elec_beta_num) then 2.
else if (i < elec_alpha_num) then 1.
else 0.) |> Array.to_list in
Ezfio.ezfio_array_of_list ~rank:1
~dim:[| mo_tot_num |] ~data:data
|> Ezfio.set_mo_basis_mo_occ
end;
Ezfio.flattened_ezfio (Ezfio.get_mo_basis_mo_occ () )
|> Array.map ~f:MO_occ.of_float
let read_mo_coef () =
let a = Ezfio.get_mo_basis_mo_coef ()
|> Ezfio.flattened_ezfio
|> Array.map ~f:MO_coef.of_float
in
let mo_tot_num = read_mo_tot_num () |> MO_number.to_int in
let ao_num = (Array.length a)/mo_tot_num in
Array.init mo_tot_num ~f:(fun j ->
Array.sub ~pos:(j*ao_num) ~len:(ao_num) a
)
let read () =
if (Ezfio.has_mo_basis_mo_tot_num ()) then
Some
{ mo_tot_num = read_mo_tot_num ();
mo_label = read_mo_label () ;
mo_class = read_mo_class ();
mo_occ = read_mo_occ ();
mo_coef = read_mo_coef ();
ao_md5 = read_ao_md5 ();
}
else
None
let mo_coef_to_string mo_coef =
let ao_num = Array.length mo_coef.(0)
and mo_tot_num = Array.length mo_coef in
let rec print_five imin imax =
match (imax-imin+1) with
| 1 ->
let header = [ Printf.sprintf " #%15d" (imin+1) ; ] in
let new_lines =
List.init ao_num ~f:(fun i ->
Printf.sprintf " %3d %15.10f " (i+1)
(MO_coef.to_float mo_coef.(imin ).(i)) )
in header @ new_lines
| 2 ->
let header = [ Printf.sprintf " #%15d %15d" (imin+1) (imin+2) ; ] in
let new_lines =
List.init ao_num ~f:(fun i ->
Printf.sprintf " %3d %15.10f %15.10f" (i+1)
(MO_coef.to_float mo_coef.(imin ).(i))
(MO_coef.to_float mo_coef.(imin+1).(i)) )
in header @ new_lines
| 3 ->
let header = [ Printf.sprintf " #%15d %15d %15d"
(imin+1) (imin+2) (imin+3); ] in
let new_lines =
List.init ao_num ~f:(fun i ->
Printf.sprintf " %3d %15.10f %15.10f %15.10f" (i+1)
(MO_coef.to_float mo_coef.(imin ).(i))
(MO_coef.to_float mo_coef.(imin+1).(i))
(MO_coef.to_float mo_coef.(imin+2).(i)) )
in header @ new_lines
| 4 ->
let header = [ Printf.sprintf " #%15d %15d %15d %15d"
(imin+1) (imin+2) (imin+3) (imin+4) ; ] in
let new_lines =
List.init ao_num ~f:(fun i ->
Printf.sprintf " %3d %15.10f %15.10f %15.10f %15.10f" (i+1)
(MO_coef.to_float mo_coef.(imin ).(i))
(MO_coef.to_float mo_coef.(imin+1).(i))
(MO_coef.to_float mo_coef.(imin+2).(i))
(MO_coef.to_float mo_coef.(imin+3).(i)) )
in header @ new_lines
| 5 ->
let header = [ Printf.sprintf " #%15d %15d %15d %15d %15d"
(imin+1) (imin+2) (imin+3) (imin+4) (imin+5) ; ] in
let new_lines =
List.init ao_num ~f:(fun i ->
Printf.sprintf " %3d %15.10f %15.10f %15.10f %15.10f %15.10f" (i+1)
(MO_coef.to_float mo_coef.(imin ).(i))
(MO_coef.to_float mo_coef.(imin+1).(i))
(MO_coef.to_float mo_coef.(imin+2).(i))
(MO_coef.to_float mo_coef.(imin+3).(i))
(MO_coef.to_float mo_coef.(imin+4).(i)) )
in header @ new_lines
| _ -> assert false
in
let rec create_list accu i =
if (i+4 < mo_tot_num) then
create_list ( (print_five i (i+3) |> String.concat ~sep:"\n")::accu ) (i+4)
else
(print_five i (mo_tot_num-1) |> String.concat ~sep:"\n")::accu |> List.rev
in
create_list [] 0 |> String.concat ~sep:"\n\n"
let to_rst b =
Printf.sprintf "
Label of the molecular orbitals ::
mo_label = %s
Total number of MOs ::
mo_tot_num = %s
MO coefficients ::
%s
"
(MO_label.to_string b.mo_label)
(MO_number.to_string b.mo_tot_num)
(mo_coef_to_string b.mo_coef)
|> Rst_string.of_string
let to_string b =
Printf.sprintf "
mo_label = %s
mo_tot_num = \"%s\"
mo_clas = %s
mo_occ = %s
mo_coef = %s
"
(MO_label.to_string b.mo_label)
(MO_number.to_string b.mo_tot_num)
(b.mo_class |> Array.to_list |> List.map
~f:(MO_class.to_string) |> String.concat ~sep:", " )
(b.mo_occ |> Array.to_list |> List.map
~f:(MO_occ.to_string) |> String.concat ~sep:", " )
(b.mo_coef |> Array.map
~f:(fun x-> Array.map ~f:MO_coef.to_string x |> String.concat_array
~sep:"," ) |>
String.concat_array ~sep:"\n" )
end
(* Read all *)
let read() =
Some
{
disk_access_mo_one_integrals = read_disk_access_mo_one_integrals ();
}
;;
(* Write all *)
let write{
disk_access_mo_one_integrals;
} =
write_disk_access_mo_one_integrals disk_access_mo_one_integrals;
;;
(* to_string*)
let to_string b =
Printf.sprintf "
disk_access_mo_one_integrals = %s
"
(Disk_access.to_string b.disk_access_mo_one_integrals)
;;
(* to_rst*)
let to_rst b =
Printf.sprintf "
Read/Write MO one-electron integrals from/to disk [ Write | Read | None ] ::
disk_access_mo_one_integrals = %s
"
(Disk_access.to_string b.disk_access_mo_one_integrals)
|> Rst_string.of_string
;;
include Generic_input_of_rst;;
let of_rst = of_rst t_of_sexp;;
end

View File

@ -196,7 +196,7 @@ Nuclear coordinates in xyz format (Angstroms) ::
in in
(* Find lines containing the xyz data *) (* Find lines containing the xyz data *)
let rec extract_begin = function let rec extract_begin = function
| [] -> raise Not_found | [] -> raise Caml.Not_found
| line::tail -> | line::tail ->
let line = String.strip line in let line = String.strip line in
if (String.length line > 3) && if (String.length line > 3) &&

View File

@ -62,7 +62,7 @@ let name m =
try try
let i = List.assoc e accu in let i = List.assoc e accu in
build_list ( (e,i+1)::(List.remove_assoc e accu) ) rest build_list ( (e,i+1)::(List.remove_assoc e accu) ) rest
with Not_found -> build_list ( (e,1)::accu ) rest with Caml.Not_found -> build_list ( (e,1)::accu ) rest
end end
| [] -> accu | [] -> accu
in in

View File

@ -63,7 +63,7 @@ let executables = lazy (
) )
in in
In_channel.with_file filename ~f:func In_channel.with_file filename ~f:func
|> List.sort ~cmp:(fun (x,_) (y,_) -> |> List.sort ~compare:(fun (x,_) (y,_) ->
if x < y then -1 if x < y then -1
else if x > y then 1 else if x > y then 1
else 0) else 0)
@ -80,14 +80,14 @@ let get_ezfio_default_in_file ~directory ~data ~filename =
rest rest
else else
find_dir rest find_dir rest
| [] -> raise Not_found | [] -> raise Caml.Not_found
in in
let rec find_data = function let rec find_data = function
| line :: rest -> | line :: rest ->
if (line = "") then if (line = "") then
raise Not_found raise Caml.Not_found
else if (line.[0] <> ' ') then else if (line.[0] <> ' ') then
raise Not_found raise Caml.Not_found
else else
begin begin
match (String.lsplit2 ~on:' ' (String.strip line)) with match (String.lsplit2 ~on:' ' (String.strip line)) with
@ -96,9 +96,9 @@ let get_ezfio_default_in_file ~directory ~data ~filename =
String.strip r String.strip r
else else
find_data rest find_data rest
| None -> raise Not_found | None -> raise Caml.Not_found
end end
| [] -> raise Not_found | [] -> raise Caml.Not_found
in in
find_dir lines find_dir lines
|> find_data ; |> find_data ;
@ -111,7 +111,7 @@ let get_ezfio_default directory data =
| [] -> | [] ->
begin begin
Printf.printf "%s/%s not found\n%!" directory data; Printf.printf "%s/%s not found\n%!" directory data;
raise Not_found raise Caml.Not_found
end end
| filename :: tail -> | filename :: tail ->
let filename = let filename =
@ -120,7 +120,7 @@ let get_ezfio_default directory data =
try try
get_ezfio_default_in_file ~directory ~data ~filename get_ezfio_default_in_file ~directory ~data ~filename
with with
| Not_found -> aux tail | Caml.Not_found -> aux tail
in in
Sys.readdir dirname Sys.readdir dirname
|> Array.to_list |> Array.to_list

View File

@ -83,7 +83,7 @@ let pop_task ~client_id q =
} }
and found = and found =
try Some (TasksMap.find task_id q.tasks) try Some (TasksMap.find task_id q.tasks)
with Not_found -> None with Caml.Not_found -> None
in new_q, Some task_id, found in new_q, Some task_id, found
| [] -> q, None, None | [] -> q, None, None
@ -104,7 +104,7 @@ let end_task ~task_id ~client_id q =
let () = let () =
let client_id_check = let client_id_check =
try RunningMap.find task_id running with try RunningMap.find task_id running with
Not_found -> failwith "Task already finished" Caml.Not_found -> failwith "Task already finished"
in in
assert (client_id_check = client_id) assert (client_id_check = client_id)
in in

View File

@ -89,7 +89,7 @@ let list_basis () =
| _ :: a :: _ -> String.strip a | _ :: a :: _ -> String.strip a
) )
in in
List.sort basis_list ~cmp:String.ascending List.sort basis_list ~compare:String.ascending
|> String.concat ~sep:"\n" |> String.concat ~sep:"\n"
@ -131,7 +131,7 @@ let run ?o b au c d m p cart xyz_file =
match Hashtbl.find basis_table key with match Hashtbl.find basis_table key with
| Some in_channel -> | Some in_channel ->
in_channel in_channel
| None -> raise Not_found | None -> raise Caml.Not_found
in in
let temp_filename = let temp_filename =
@ -563,13 +563,13 @@ let run ?o b au c d m p cart xyz_file =
in in
try try
Basis.read_element (basis_channel key) i e Basis.read_element (basis_channel key) i e
with Not_found -> with Caml.Not_found ->
let key = let key =
Element x.Atom.element Element x.Atom.element
in in
try try
Basis.read_element (basis_channel key) i e Basis.read_element (basis_channel key) i e
with Not_found -> with Caml.Not_found ->
failwith (Printf.sprintf "Basis not found for atom %d (%s)" (Nucl_number.to_int i) failwith (Printf.sprintf "Basis not found for atom %d (%s)" (Nucl_number.to_int i)
(Element.to_string x.Atom.element) ) (Element.to_string x.Atom.element) )
with with

View File

@ -99,8 +99,12 @@ let run ?(sym="None") ?(apply="no") fc ezfio_filename =
let ic = let ic =
Unix.open_process_in ("qp_set_frozen_core.py -q "^ezfio_filename) Unix.open_process_in ("qp_set_frozen_core.py -q "^ezfio_filename)
in in
let result = int_of_string @@ input_line ic in let result = int_of_string @@
close_in ic; result match In_channel.input_line ic with
| Some line -> line
| None -> failwith "Failed in qp_set_frozen_core"
in
In_channel.close ic; result
else 0 else 0
in in
let command = let command =

View File

@ -54,7 +54,7 @@ let () =
Hashtbl.fold (fun k c (accu,norm,norm') -> Hashtbl.fold (fun k c (accu,norm,norm') ->
let (c',c) = let (c',c) =
try (Hashtbl.find wf' k, c) try (Hashtbl.find wf' k, c)
with Not_found -> (0.,0.) with Caml.Not_found -> (0.,0.)
in in
(accu +. c *. c' , (accu +. c *. c' ,
norm +. c *. c , norm +. c *. c ,

View File

@ -17,7 +17,7 @@ END_PROVIDER
e = elec_num - n_core_orb * 2 e = elec_num - n_core_orb * 2
pt2_n_tasks_max = 1+min((e*(e-1))/2, int(dsqrt(dble(N_det_selectors)))/10) pt2_n_tasks_max = 1+min((e*(e-1))/2, int(dsqrt(dble(N_det_selectors)))/10)
do i=1,N_det_generators do i=1,N_det_generators
pt2_F(i) = 1 + dble(pt2_n_tasks_max)*maxval(dsqrt(dabs(psi_coef_sorted_gen(i,1:N_states)))) pt2_F(i) = 1 + int(dble(pt2_n_tasks_max)*maxval(dsqrt(dabs(psi_coef_sorted_gen(i,1:N_states)))))
enddo enddo
if(N_det_generators < 1024) then if(N_det_generators < 1024) then

View File

@ -86,10 +86,10 @@ double precision function get_phase_bi(phasemask, s1, s2, h1, p1, h2, p2, Nint)
! Put the phasemask bits at position 0, and add them all ! Put the phasemask bits at position 0, and add them all
h1_bit = ishft(phasemask(h1_int,s1),-h1_bit) h1_bit = int(ishft(phasemask(h1_int,s1),-h1_bit))
p1_bit = ishft(phasemask(p1_int,s1),-p1_bit) p1_bit = int(ishft(phasemask(p1_int,s1),-p1_bit))
h2_bit = ishft(phasemask(h2_int,s2),-h2_bit) h2_bit = int(ishft(phasemask(h2_int,s2),-h2_bit))
p2_bit = ishft(phasemask(p2_int,s2),-p2_bit) p2_bit = int(ishft(phasemask(p2_int,s2),-p2_bit))
np = h1_bit + p1_bit + h2_bit + p2_bit np = h1_bit + p1_bit + h2_bit + p2_bit

View File

@ -3,28 +3,24 @@ type: double precision
doc: Nucleus-electron integrals in AO basis set doc: Nucleus-electron integrals in AO basis set
size: (ao_basis.ao_num,ao_basis.ao_num) size: (ao_basis.ao_num,ao_basis.ao_num)
interface: ezfio interface: ezfio
default: false
[integral_kinetic] [integral_kinetic]
type: double precision type: double precision
doc: Kinetic energy integrals in AO basis set doc: Kinetic energy integrals in AO basis set
size: (ao_basis.ao_num,ao_basis.ao_num) size: (ao_basis.ao_num,ao_basis.ao_num)
interface: ezfio interface: ezfio
default: false
[integral_pseudo] [integral_pseudo]
type: double precision type: double precision
doc: Pseudopotential integrals in AO basis set doc: Pseudopotential integrals in AO basis set
size: (ao_basis.ao_num,ao_basis.ao_num) size: (ao_basis.ao_num,ao_basis.ao_num)
interface: ezfio interface: ezfio
default: false
[integral_overlap] [integral_overlap]
type: double precision type: double precision
doc: Overlap integrals in AO basis set doc: Overlap integrals in AO basis set
size: (ao_basis.ao_num,ao_basis.ao_num) size: (ao_basis.ao_num,ao_basis.ao_num)
interface: ezfio interface: ezfio
default: false
[disk_access_ao_one_integrals] [disk_access_ao_one_integrals]
type: Disk_access type: Disk_access

View File

@ -3,21 +3,18 @@ type: double precision
doc: Nucleus-electron integrals in MO basis set doc: Nucleus-electron integrals in MO basis set
size: (mo_basis.mo_tot_num,mo_basis.mo_tot_num) size: (mo_basis.mo_tot_num,mo_basis.mo_tot_num)
interface: ezfio interface: ezfio
default: false
[integral_kinetic] [integral_kinetic]
type: double precision type: double precision
doc: Kinetic energy integrals in MO basis set doc: Kinetic energy integrals in MO basis set
size: (mo_basis.mo_tot_num,mo_basis.mo_tot_num) size: (mo_basis.mo_tot_num,mo_basis.mo_tot_num)
interface: ezfio interface: ezfio
default: false
[integral_pseudo] [integral_pseudo]
type: double precision type: double precision
doc: Pseudopotential integrals in MO basis set doc: Pseudopotential integrals in MO basis set
size: (mo_basis.mo_tot_num,mo_basis.mo_tot_num) size: (mo_basis.mo_tot_num,mo_basis.mo_tot_num)
interface: ezfio interface: ezfio
default: false
[disk_access_mo_one_integrals] [disk_access_mo_one_integrals]