mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-13 07:03:29 +01:00
Merge branch 'dev' into dev-lct
This commit is contained in:
commit
24acfa6938
@ -291,7 +291,7 @@ OCaml
|
||||
|
||||
.. code:: bash
|
||||
|
||||
opam install ocamlbuild cryptokit zmq core sexplib ppx_sexp_conv ppx_deriving getopt
|
||||
opam install ocamlbuild cryptokit zmq sexplib ppx_sexp_conv ppx_deriving getopt
|
||||
|
||||
|
||||
EZFIO
|
||||
|
2
configure
vendored
2
configure
vendored
@ -60,7 +60,7 @@ function execute () {
|
||||
}
|
||||
|
||||
PACKAGES=""
|
||||
OCAML_PACKAGES="ocamlbuild cryptokit zmq core.v0.11.3 sexplib ppx_sexp_conv ppx_deriving getopt"
|
||||
OCAML_PACKAGES="ocamlbuild cryptokit zmq sexplib ppx_sexp_conv ppx_deriving getopt"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
|
43
ocaml/.gitignore
vendored
43
ocaml/.gitignore
vendored
@ -1,43 +0,0 @@
|
||||
_build
|
||||
element_create_db
|
||||
element_create_db.byte
|
||||
ezfio.ml
|
||||
.gitignore
|
||||
Git.ml
|
||||
Input_ao_one_e_ints.ml
|
||||
Input_ao_two_e_erf_ints.ml
|
||||
Input_ao_two_e_ints.ml
|
||||
Input_auto_generated.ml
|
||||
Input_becke_numerical_grid.ml
|
||||
Input_davidson.ml
|
||||
Input_density_for_dft.ml
|
||||
Input_determinants.ml
|
||||
Input_dft_keywords.ml
|
||||
Input_dft_mu_of_r.ml
|
||||
Input_dressing.ml
|
||||
Input_firth_order_der.ml
|
||||
Input_ijkl_ints_in_r3.ml
|
||||
Input_mo_one_e_ints.ml
|
||||
Input_mo_two_e_erf_ints.ml
|
||||
Input_mo_two_e_ints.ml
|
||||
Input_mu_of_r_ints.ml
|
||||
Input_mu_of_r.ml
|
||||
Input_nuclei.ml
|
||||
Input_perturbation.ml
|
||||
Input_pseudo.ml
|
||||
Input_rsdft_ecmd.ml
|
||||
Input_scf_utils.ml
|
||||
Input_two_body_dm.ml
|
||||
qp_create_ezfio
|
||||
qp_create_ezfio.native
|
||||
qp_edit
|
||||
qp_edit.ml
|
||||
qp_edit.native
|
||||
qp_print_basis
|
||||
qp_print_basis.native
|
||||
qp_run
|
||||
qp_run.native
|
||||
qp_set_mo_class
|
||||
qp_set_mo_class.native
|
||||
qptypes_generator.byte
|
||||
Qptypes.ml
|
@ -1,4 +1,4 @@
|
||||
open Core
|
||||
open Sexplib.Std
|
||||
|
||||
exception AtomError of string
|
||||
|
||||
@ -11,20 +11,20 @@ type t =
|
||||
(** Read xyz coordinates of the atom *)
|
||||
let of_string ~units s =
|
||||
let buffer = s
|
||||
|> String.split ~on:' '
|
||||
|> List.filter ~f:(fun x -> x <> "")
|
||||
|> String_ext.split ~on:' '
|
||||
|> List.filter (fun x -> x <> "")
|
||||
in
|
||||
match buffer with
|
||||
| [ name; charge; x; y; z ] ->
|
||||
{ element = Element.of_string name ;
|
||||
charge = Charge.of_string charge ;
|
||||
coord = Point3d.of_string ~units (String.concat [x; y; z] ~sep:" ")
|
||||
coord = Point3d.of_string ~units (String.concat " " [x; y; z] )
|
||||
}
|
||||
| [ name; x; y; z ] ->
|
||||
let e = Element.of_string name in
|
||||
{ element = e ;
|
||||
charge = Element.to_charge e;
|
||||
coord = Point3d.of_string ~units (String.concat [x; y; z] ~sep:" ")
|
||||
coord = Point3d.of_string ~units (String.concat " " [x; y; z])
|
||||
}
|
||||
| _ -> raise (AtomError s)
|
||||
|
||||
@ -33,7 +33,7 @@ let to_string ~units a =
|
||||
[ Element.to_string a.element ;
|
||||
Charge.to_string a.charge ;
|
||||
Point3d.to_string ~units a.coord ]
|
||||
|> String.concat ~sep:" "
|
||||
|> String.concat " "
|
||||
|
||||
|
||||
let to_xyz a =
|
||||
|
12
ocaml/Bit.ml
12
ocaml/Bit.ml
@ -1,4 +1,4 @@
|
||||
open Core;;
|
||||
open Sexplib.Std
|
||||
|
||||
(*
|
||||
Type for bits
|
||||
@ -16,31 +16,31 @@ type t =
|
||||
let to_string = function
|
||||
| Zero -> "0"
|
||||
| One -> "1"
|
||||
;;
|
||||
|
||||
|
||||
let and_operator a b =
|
||||
match a, b with
|
||||
| Zero, _ -> Zero
|
||||
| _, Zero -> Zero
|
||||
| _, _ -> One
|
||||
;;
|
||||
|
||||
|
||||
let or_operator a b =
|
||||
match a, b with
|
||||
| One, _ -> One
|
||||
| _, One -> One
|
||||
| _, _ -> Zero
|
||||
;;
|
||||
|
||||
|
||||
let xor_operator a b =
|
||||
match a, b with
|
||||
| One, Zero -> One
|
||||
| Zero, One -> One
|
||||
| _, _ -> Zero
|
||||
;;
|
||||
|
||||
|
||||
let not_operator = function
|
||||
| One -> Zero
|
||||
| Zero -> One
|
||||
;;
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
open Qptypes
|
||||
open Core
|
||||
|
||||
(*
|
||||
Type for bits strings
|
||||
@ -22,15 +21,15 @@ let to_string b =
|
||||
|
||||
|
||||
let of_string ?(zero='0') ?(one='1') s =
|
||||
String.to_list s
|
||||
|> List.rev_map ~f:( fun c ->
|
||||
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 of_string_mp s =
|
||||
String.to_list s
|
||||
|> List.rev_map ~f:(function
|
||||
List.init (String.length s) (String.get s)
|
||||
|> List.rev_map (function
|
||||
| '-' -> Bit.Zero
|
||||
| '+' -> Bit.One
|
||||
| _ -> failwith ("Error in bitstring ") )
|
||||
@ -44,7 +43,7 @@ let of_int64 i =
|
||||
| 1L -> Bit.One :: accu |> List.rev
|
||||
| i ->
|
||||
let b =
|
||||
match (Int64.bit_and i 1L ) with
|
||||
match (Int64.logand i 1L ) with
|
||||
| 0L -> Bit.Zero
|
||||
| 1L -> Bit.One
|
||||
| _ -> raise (Failure "i land 1 not in (0,1)")
|
||||
@ -70,18 +69,18 @@ let to_int64 l =
|
||||
let rec do_work accu = function
|
||||
| [] -> accu
|
||||
| Bit.Zero::tail -> do_work Int64.(shift_left accu 1) tail
|
||||
| Bit.One::tail -> do_work Int64.(bit_or one (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)
|
||||
|
||||
|
||||
(* Create a bit list from a list of int64 *)
|
||||
let of_int64_list l =
|
||||
List.map ~f:of_int64 l
|
||||
List.map of_int64 l
|
||||
|> List.concat
|
||||
|
||||
(* Create a bit list from an array of int64 *)
|
||||
let of_int64_array l =
|
||||
Array.map ~f:of_int64 l
|
||||
Array.map of_int64 l
|
||||
|> Array.to_list
|
||||
|> List.concat
|
||||
|
||||
@ -116,7 +115,7 @@ let to_int64_list l =
|
||||
in
|
||||
let l = do_work [] [] 1 l
|
||||
in
|
||||
List.rev_map ~f:to_int64 l
|
||||
List.rev_map to_int64 l
|
||||
|
||||
(* Create an array of int64 from a bit list *)
|
||||
let to_int64_array l =
|
||||
@ -127,8 +126,8 @@ let to_int64_array l =
|
||||
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.create length (Bit.Zero) in
|
||||
List.iter ~f:(fun i-> a.((MO_number.to_int i)-1) <- Bit.One) l;
|
||||
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
|
||||
|
||||
|
||||
@ -183,10 +182,10 @@ let not_operator b = logical_operator1 Bit.not_operator b
|
||||
|
||||
|
||||
let popcnt b =
|
||||
List.fold_left b ~init:0 ~f:(fun accu -> function
|
||||
List.fold_left (fun accu -> function
|
||||
| Bit.One -> accu+1
|
||||
| Bit.Zero -> accu
|
||||
)
|
||||
) 0 b
|
||||
|
||||
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
open Core
|
||||
open Sexplib.Std
|
||||
|
||||
type t = float [@@deriving sexp]
|
||||
|
||||
let of_float x = x
|
||||
let of_int i = Float.of_int i
|
||||
let of_string s = Float.of_string s
|
||||
let of_float x = x
|
||||
let of_int i = float_of_int i
|
||||
let of_string s = float_of_string s
|
||||
|
||||
|
||||
let to_float x = x
|
||||
let to_int x = Float.to_int x
|
||||
let to_float x = x
|
||||
let to_int x = int_of_float x
|
||||
let to_string x =
|
||||
if x >= 0. then
|
||||
Printf.sprintf "+%f" x
|
||||
|
@ -1,4 +1,4 @@
|
||||
open Core
|
||||
open Sexplib.Std
|
||||
open Qptypes
|
||||
|
||||
exception ElementError of string
|
||||
@ -14,7 +14,7 @@ type t =
|
||||
[@@deriving sexp]
|
||||
|
||||
let of_string x =
|
||||
match (String.capitalize (String.lowercase x)) with
|
||||
match (String.capitalize_ascii (String.lowercase_ascii x)) with
|
||||
| "X" | "Dummy" -> X
|
||||
| "H" | "Hydrogen" -> H
|
||||
| "He" | "Helium" -> He
|
||||
|
@ -1,4 +1,3 @@
|
||||
open Core
|
||||
open Qptypes
|
||||
|
||||
module Hole = struct
|
||||
@ -56,7 +55,7 @@ let to_string = function
|
||||
"," ;
|
||||
(MO_class.to_string (Particle.to_mo_class p));
|
||||
"]"]
|
||||
|> String.concat ~sep:" "
|
||||
|> String.concat " "
|
||||
| Double (h1,p1,h2,p2) ->
|
||||
[ "Double Exc. : [" ;
|
||||
(MO_class.to_string (Hole.to_mo_class h1));
|
||||
@ -67,6 +66,6 @@ let to_string = function
|
||||
"," ;
|
||||
(MO_class.to_string (Particle.to_mo_class p2));
|
||||
"]"]
|
||||
|> String.concat ~sep:" "
|
||||
|> String.concat " "
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
(** CONTRL *)
|
||||
type scftyp_t = RHF | ROHF | MCSCF | NONE
|
||||
|
||||
let string_of_scftyp = function
|
||||
| RHF -> "RHF"
|
||||
| ROHF -> "ROHF"
|
||||
@ -79,14 +80,14 @@ let read_until_found f tries =
|
||||
begin
|
||||
try
|
||||
Some (read_mos x f)
|
||||
with Caml.Not_found ->
|
||||
with Not_found ->
|
||||
None
|
||||
end
|
||||
) None tries
|
||||
in
|
||||
match result with
|
||||
| Some mos -> mos
|
||||
| None -> raise Caml.Not_found
|
||||
| None -> raise Not_found
|
||||
|
||||
let read_natural_mos f =
|
||||
let tries = [
|
||||
@ -116,7 +117,7 @@ type guess_t =
|
||||
| Natural of (int*string)
|
||||
|
||||
let guess_of_string s =
|
||||
match String.lowercase s with
|
||||
match String.lowercase_ascii s with
|
||||
| "huckel" -> Huckel
|
||||
| "hcore" -> Hcore
|
||||
| _ -> raise (Invalid_argument "Bad MO guess")
|
||||
@ -430,7 +431,7 @@ let create_cas_input ?(vecfile="") ~guess ~nstate s n_e n_a =
|
||||
in
|
||||
try
|
||||
string_of_guess (Natural (norb, vecfile))
|
||||
with Caml.Not_found ->
|
||||
with Not_found ->
|
||||
string_of_guess (Canonical (norb, vecfile))
|
||||
end
|
||||
;
|
||||
|
@ -1,16 +1,16 @@
|
||||
open Qptypes
|
||||
open Core
|
||||
open Sexplib.Std
|
||||
|
||||
type t =
|
||||
{ sym : Symmetry.t ;
|
||||
expo : AO_expo.t ;
|
||||
} [@@deriving sexp]
|
||||
{ sym : Symmetry.t ;
|
||||
expo : AO_expo.t ;
|
||||
} [@@deriving sexp]
|
||||
|
||||
let to_string p =
|
||||
let { sym = s ; expo = e } = p in
|
||||
Printf.sprintf "(%s, %22e)"
|
||||
(Symmetry.to_string s)
|
||||
(AO_expo.to_float e)
|
||||
(Symmetry.to_string s)
|
||||
(AO_expo.to_float e)
|
||||
|
||||
|
||||
let of_sym_expo s e =
|
||||
|
@ -1,5 +1,6 @@
|
||||
open Core;;
|
||||
open Qptypes;;
|
||||
open Sexplib
|
||||
open Sexplib.Std
|
||||
open Qptypes
|
||||
|
||||
|
||||
let fail_msg str (ex,range) =
|
||||
@ -15,25 +16,25 @@ let fail_msg str (ex,range) =
|
||||
let start_pos = range.start_pos.offset
|
||||
and end_pos = range.end_pos.offset
|
||||
in
|
||||
let pre = String.sub ~pos:0 ~len:start_pos str
|
||||
and mid = String.sub ~pos:start_pos ~len:(end_pos-start_pos) str
|
||||
and post = String.sub ~pos:(end_pos)
|
||||
~len:((String.length str)-(end_pos)) str
|
||||
let pre = String.sub str 0 start_pos
|
||||
and mid = String.sub str start_pos (end_pos-start_pos)
|
||||
and post = String.sub str (end_pos)
|
||||
((String.length str)-(end_pos))
|
||||
in
|
||||
let str = Printf.sprintf "%s ## %s ## %s" pre mid post
|
||||
in
|
||||
let str = String.tr str ~target:'(' ~replacement:' '
|
||||
|> String.split ~on:')'
|
||||
|> List.map ~f:String.strip
|
||||
|> List.filter ~f:(fun x ->
|
||||
match String.substr_index x ~pos:0 ~pattern:"##" with
|
||||
let str = String_ext.tr str ~target:'(' ~replacement:' '
|
||||
|> String_ext.split ~on:')'
|
||||
|> List.map String_ext.strip
|
||||
|> List.filter (fun x ->
|
||||
match String_ext.substr_index ~pos:0 ~pattern:"##" x with
|
||||
| None -> false
|
||||
| Some _ -> true
|
||||
)
|
||||
|> String.concat ~sep:"\n"
|
||||
|> String.concat "\n"
|
||||
in
|
||||
Printf.eprintf "Error: (%s)\n\n %s\n\n" msg str;
|
||||
;;
|
||||
Printf.eprintf "Error: (%s)\n\n %s\n\n" msg str
|
||||
|
||||
|
||||
|
||||
let evaluate_sexp t_of_sexp s =
|
||||
@ -41,20 +42,19 @@ let evaluate_sexp t_of_sexp s =
|
||||
match ( Sexp.of_string_conv sexp t_of_sexp ) with
|
||||
| `Result r -> Some r
|
||||
| `Error ex -> ( fail_msg sexp ex; None)
|
||||
;;
|
||||
|
||||
|
||||
let of_rst t_of_sexp s =
|
||||
Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
|> String_ext.split ~on:'\n'
|
||||
|> List.filter (fun line -> String.contains line '=')
|
||||
|> List.map (fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
String_ext.tr ~target:'=' ~replacement:' ' line
|
||||
)^")" )
|
||||
|> String.concat
|
||||
|> String.concat ""
|
||||
|> evaluate_sexp t_of_sexp
|
||||
;;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
open Qputils;;
|
||||
open Qptypes;;
|
||||
open Core;;
|
||||
|
||||
include Input_ao_basis;;
|
||||
include Input_bitmasks;;
|
||||
|
@ -1,6 +1,6 @@
|
||||
open Qptypes;;
|
||||
open Qputils;;
|
||||
open Core;;
|
||||
open Sexplib.Std;;
|
||||
|
||||
module Ao_basis : sig
|
||||
type t =
|
||||
@ -52,13 +52,13 @@ end = struct
|
||||
let read_ao_prim_num () =
|
||||
Ezfio.get_ao_basis_ao_prim_num ()
|
||||
|> Ezfio.flattened_ezfio
|
||||
|> Array.map ~f:AO_prim_number.of_int
|
||||
|> Array.map 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
|
||||
|> Array.fold_left (fun x y -> if x>y then x else y) 0
|
||||
|> AO_prim_number.of_int
|
||||
;;
|
||||
|
||||
@ -66,42 +66,42 @@ end = struct
|
||||
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)
|
||||
|> Array.map (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
|
||||
let result = Array.init dim (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));
|
||||
result.(i-1) <- result.(i-1)^"x"^(string_of_int data.(i-1));
|
||||
if (data.(dim+i-1) > 0) then
|
||||
result.(i-1) <- result.(i-1)^"y"^(Int.to_string data.(dim+i-1));
|
||||
result.(i-1) <- result.(i-1)^"y"^(string_of_int 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));
|
||||
result.(i-1) <- result.(i-1)^"z"^(string_of_int data.(2*dim+i-1));
|
||||
done;
|
||||
Array.map ~f:Symmetry.Xyz.of_string result
|
||||
Array.map 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
|
||||
|> Array.map AO_coef.of_float
|
||||
;;
|
||||
|
||||
let read_ao_expo () =
|
||||
Ezfio.get_ao_basis_ao_expo ()
|
||||
|> Ezfio.flattened_ezfio
|
||||
|> Array.map ~f:AO_expo.of_float
|
||||
|> Array.map AO_expo.of_float
|
||||
;;
|
||||
|
||||
let read_ao_cartesian () =
|
||||
if not (Ezfio.has_ao_basis_ao_cartesian ()) then
|
||||
get_default "ao_cartesian"
|
||||
|> Bool.of_string
|
||||
|> bool_of_string
|
||||
|> Ezfio.set_ao_basis_ao_cartesian
|
||||
;
|
||||
Ezfio.get_ao_basis_ao_cartesian ()
|
||||
@ -110,10 +110,10 @@ end = struct
|
||||
let to_long_basis b =
|
||||
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 ->
|
||||
(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 prims = List.init ao_prim_num (fun j ->
|
||||
let prim = { GaussianPrimitive.sym = s ;
|
||||
GaussianPrimitive.expo = b.ao_expo.(ao_num*j+i)
|
||||
}
|
||||
@ -178,14 +178,14 @@ end = struct
|
||||
in
|
||||
let ao_prim_num =
|
||||
Array.to_list ao_prim_num
|
||||
|> List.map ~f:AO_prim_number.to_int
|
||||
|> List.map AO_prim_number.to_int
|
||||
in
|
||||
Ezfio.set_ao_basis_ao_prim_num (Ezfio.ezfio_array_of_list
|
||||
~rank:1 ~dim:[| ao_num |] ~data:ao_prim_num) ;
|
||||
|
||||
let ao_nucl =
|
||||
Array.to_list ao_nucl
|
||||
|> List.map ~f:Nucl_number.to_int
|
||||
|> List.map Nucl_number.to_int
|
||||
in
|
||||
Ezfio.set_ao_basis_ao_nucl(Ezfio.ezfio_array_of_list
|
||||
~rank:1 ~dim:[| ao_num |] ~data:ao_nucl) ;
|
||||
@ -193,9 +193,9 @@ end = struct
|
||||
let ao_power =
|
||||
let l = Array.to_list ao_power in
|
||||
List.concat [
|
||||
(List.map ~f:(fun a -> Positive_int.to_int a.Symmetry.Xyz.x) l) ;
|
||||
(List.map ~f:(fun a -> Positive_int.to_int a.Symmetry.Xyz.y) l) ;
|
||||
(List.map ~f:(fun a -> Positive_int.to_int a.Symmetry.Xyz.z) l) ]
|
||||
(List.map (fun a -> Positive_int.to_int a.Symmetry.Xyz.x) l) ;
|
||||
(List.map (fun a -> Positive_int.to_int a.Symmetry.Xyz.y) l) ;
|
||||
(List.map (fun a -> Positive_int.to_int a.Symmetry.Xyz.z) l) ]
|
||||
in
|
||||
Ezfio.set_ao_basis_ao_power(Ezfio.ezfio_array_of_list
|
||||
~rank:2 ~dim:[| ao_num ; 3 |] ~data:ao_power) ;
|
||||
@ -204,14 +204,14 @@ end = struct
|
||||
|
||||
let ao_coef =
|
||||
Array.to_list ao_coef
|
||||
|> List.map ~f:AO_coef.to_float
|
||||
|> List.map AO_coef.to_float
|
||||
in
|
||||
Ezfio.set_ao_basis_ao_coef(Ezfio.ezfio_array_of_list
|
||||
~rank:2 ~dim:[| ao_num ; ao_prim_num_max |] ~data:ao_coef) ;
|
||||
|
||||
let ao_expo =
|
||||
Array.to_list ao_expo
|
||||
|> List.map ~f:AO_expo.to_float
|
||||
|> List.map AO_expo.to_float
|
||||
in
|
||||
Ezfio.set_ao_basis_ao_expo(Ezfio.ezfio_array_of_list
|
||||
~rank:2 ~dim:[| ao_num ; ao_prim_num_max |] ~data:ao_expo) ;
|
||||
@ -271,58 +271,56 @@ end = struct
|
||||
| Some (s', g', n') ->
|
||||
if s <> s' || n <> n' then find2 (s,g,n) a (i+1)
|
||||
else
|
||||
let lc = List.map ~f:(fun (prim, _) -> prim) g.Gto.lc
|
||||
and lc' = List.map ~f:(fun (prim, _) -> prim) g'.Gto.lc
|
||||
let lc = List.map (fun (prim, _) -> prim) g.Gto.lc
|
||||
and lc' = List.map (fun (prim, _) -> prim) g'.Gto.lc
|
||||
in
|
||||
if lc <> lc' then find2 (s,g,n) a (i+1) else (a.(i) <- None ; i)
|
||||
in
|
||||
find x a 0
|
||||
in
|
||||
let search_array = Array.map ~f:(fun i -> Some i) unordered_basis in
|
||||
Array.map ~f:(fun x -> find x search_array) ordered_basis
|
||||
let search_array = Array.map (fun i -> Some i) unordered_basis in
|
||||
Array.map (fun x -> find x search_array) ordered_basis
|
||||
;;
|
||||
|
||||
|
||||
let of_long_basis long_basis name ao_cartesian =
|
||||
let ao_num = List.length long_basis |> AO_number.of_int in
|
||||
let ao_prim_num =
|
||||
List.map long_basis ~f:(fun (_,g,_) -> List.length g.Gto.lc
|
||||
|> AO_prim_number.of_int )
|
||||
List.map (fun (_,g,_) -> List.length g.Gto.lc
|
||||
|> AO_prim_number.of_int ) long_basis
|
||||
|> Array.of_list
|
||||
and ao_nucl =
|
||||
List.map long_basis ~f:(fun (_,_,n) -> n)
|
||||
List.map (fun (_,_,n) -> n) long_basis
|
||||
|> Array.of_list
|
||||
and ao_power =
|
||||
List.map ~f:(fun (x,_,_) -> x) long_basis
|
||||
List.map (fun (x,_,_) -> x) long_basis
|
||||
|> Array.of_list
|
||||
in
|
||||
let ao_prim_num_max = Array.fold ~init:0 ~f:(fun s x ->
|
||||
if AO_prim_number.to_int x > s then AO_prim_number.to_int x else s)
|
||||
let ao_prim_num_max = Array.fold_left (fun s x ->
|
||||
if AO_prim_number.to_int x > s then AO_prim_number.to_int x else s) 0
|
||||
ao_prim_num
|
||||
|> AO_prim_number.of_int
|
||||
in
|
||||
|
||||
let gtos =
|
||||
List.map long_basis ~f:(fun (_,x,_) -> x)
|
||||
List.map (fun (_,x,_) -> x) long_basis
|
||||
in
|
||||
let create_expo_coef ec =
|
||||
let coefs =
|
||||
begin match ec with
|
||||
| `Coefs -> List.map gtos ~f:(fun x->
|
||||
List.map x.Gto.lc ~f:(fun (_,coef) -> AO_coef.to_float coef) )
|
||||
| `Expos -> List.map gtos ~f:(fun x->
|
||||
List.map x.Gto.lc ~f:(fun (prim,_) -> AO_expo.to_float
|
||||
prim.GaussianPrimitive.expo) )
|
||||
| `Coefs -> List.map (fun x->
|
||||
List.map (fun (_,coef) -> AO_coef.to_float coef) x.Gto.lc ) gtos
|
||||
| `Expos -> List.map (fun x->
|
||||
List.map (fun (prim,_) -> AO_expo.to_float
|
||||
prim.GaussianPrimitive.expo) x.Gto.lc ) gtos
|
||||
end
|
||||
in
|
||||
let rec get_n n accu = function
|
||||
| [] -> List.rev accu
|
||||
| h::tail ->
|
||||
let y =
|
||||
begin match List.nth h n with
|
||||
| Some x -> x
|
||||
| None -> 0.
|
||||
end
|
||||
try List.nth h n
|
||||
with _ -> 0.
|
||||
in
|
||||
get_n n (y::accu) tail
|
||||
in
|
||||
@ -335,10 +333,10 @@ end = struct
|
||||
|
||||
let ao_coef = create_expo_coef `Coefs
|
||||
|> Array.of_list
|
||||
|> Array.map ~f:AO_coef.of_float
|
||||
|> Array.map AO_coef.of_float
|
||||
and ao_expo = create_expo_coef `Expos
|
||||
|> Array.of_list
|
||||
|> Array.map ~f:AO_expo.of_float
|
||||
|> Array.map AO_expo.of_float
|
||||
in
|
||||
{ ao_basis = name ;
|
||||
ao_num ; ao_prim_num ; ao_prim_num_max ; ao_nucl ;
|
||||
@ -347,17 +345,17 @@ end = struct
|
||||
|
||||
let reorder b =
|
||||
let order = ordering b in
|
||||
let f a = Array.init (Array.length a) ~f:(fun i -> a.(order.(i))) in
|
||||
let f a = Array.init (Array.length a) (fun i -> a.(order.(i))) in
|
||||
let ao_prim_num_max = AO_prim_number.to_int b.ao_prim_num_max
|
||||
and ao_num = AO_number.to_int b.ao_num in
|
||||
let ao_coef =
|
||||
Array.init ao_prim_num_max ~f:(fun i ->
|
||||
f @@ Array.init ao_num ~f:(fun j -> b.ao_coef.(i*ao_num + j) )
|
||||
Array.init ao_prim_num_max (fun i ->
|
||||
f @@ Array.init ao_num (fun j -> b.ao_coef.(i*ao_num + j) )
|
||||
) |> Array.to_list |> Array.concat
|
||||
in
|
||||
let ao_expo =
|
||||
Array.init ao_prim_num_max ~f:(fun i ->
|
||||
f @@ Array.init ao_num ~f:(fun j -> b.ao_expo.(i*ao_num + j) )
|
||||
Array.init ao_prim_num_max (fun i ->
|
||||
f @@ Array.init ao_num (fun j -> b.ao_expo.(i*ao_num + j) )
|
||||
) |> Array.to_list |> Array.concat
|
||||
in
|
||||
{ b with
|
||||
@ -373,7 +371,7 @@ end = struct
|
||||
|
||||
let to_rst b =
|
||||
let print_sym =
|
||||
let l = List.init (Array.length b.ao_power) ~f:(
|
||||
let l = List.init (Array.length b.ao_power) (
|
||||
fun i -> ( (i+1),b.ao_nucl.(i),b.ao_power.(i) ) )
|
||||
in
|
||||
let rec do_work = function
|
||||
@ -383,7 +381,7 @@ end = struct
|
||||
(Symmetry.Xyz.to_string x)
|
||||
)::(do_work tail)
|
||||
in do_work l
|
||||
|> String.concat
|
||||
|> String.concat ""
|
||||
in
|
||||
|
||||
let short_basis = to_basis b in
|
||||
@ -408,11 +406,11 @@ Basis set (read-only) ::
|
||||
======= ========= ===========
|
||||
|
||||
" (AO_basis_name.to_string b.ao_basis)
|
||||
(Bool.to_string b.ao_cartesian)
|
||||
(string_of_bool b.ao_cartesian)
|
||||
(Basis.to_string short_basis
|
||||
|> String.split ~on:'\n'
|
||||
|> List.map ~f:(fun x-> " "^x)
|
||||
|> String.concat ~sep:"\n"
|
||||
|> String_ext.split ~on:'\n'
|
||||
|> List.map (fun x-> " "^x)
|
||||
|> String.concat "\n"
|
||||
) print_sym
|
||||
|
||||
|> Rst_string.of_string
|
||||
@ -420,14 +418,14 @@ Basis set (read-only) ::
|
||||
|
||||
let read_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> String_ext.split ~on:'\n'
|
||||
in
|
||||
let rec extract_basis = function
|
||||
| [] -> failwith "Error in basis set"
|
||||
| line :: tail ->
|
||||
let line = String.strip line in
|
||||
let line = String.trim line in
|
||||
if line = "Basis set (read-only) ::" then
|
||||
String.concat tail ~sep:"\n"
|
||||
String.concat "\n" tail
|
||||
else
|
||||
extract_basis tail
|
||||
in
|
||||
@ -450,17 +448,17 @@ 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) |> String.concat ", " )
|
||||
(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)
|
||||
(b.ao_nucl |> Array.to_list |> List.map Nucl_number.to_string |>
|
||||
String.concat ", ")
|
||||
(b.ao_power |> Array.to_list |> List.map (fun x->
|
||||
"("^(Symmetry.Xyz.to_string x)^")" )|> String.concat ", ")
|
||||
(b.ao_coef |> Array.to_list |> List.map AO_coef.to_string
|
||||
|> String.concat ", ")
|
||||
(b.ao_expo |> Array.to_list |> List.map AO_expo.to_string
|
||||
|> String.concat ", ")
|
||||
(b.ao_cartesian |> string_of_bool)
|
||||
(to_md5 b |> MD5.to_string )
|
||||
|
||||
;;
|
||||
|
@ -1,228 +0,0 @@
|
||||
open Qptypes;;
|
||||
open Qputils;;
|
||||
open Core;;
|
||||
|
||||
module Bielec_integrals : sig
|
||||
type t =
|
||||
{ read_ao_integrals : bool;
|
||||
read_mo_integrals : bool;
|
||||
write_ao_integrals : bool;
|
||||
write_mo_integrals : bool;
|
||||
threshold_ao : Threshold.t;
|
||||
threshold_mo : Threshold.t;
|
||||
direct : bool;
|
||||
} [@@deriving sexp]
|
||||
;;
|
||||
val read : unit -> t option
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ read_ao_integrals : bool;
|
||||
read_mo_integrals : bool;
|
||||
write_ao_integrals : bool;
|
||||
write_mo_integrals : bool;
|
||||
threshold_ao : Threshold.t;
|
||||
threshold_mo : Threshold.t;
|
||||
direct : bool;
|
||||
} [@@deriving sexp]
|
||||
;;
|
||||
|
||||
let get_default = Qpackage.get_ezfio_default "bielec_integrals";;
|
||||
|
||||
let read_read_ao_integrals () =
|
||||
if not (Ezfio.has_bielec_integrals_read_ao_integrals ()) then
|
||||
get_default "read_ao_integrals"
|
||||
|> Bool.of_string
|
||||
|> Ezfio.set_bielec_integrals_read_ao_integrals
|
||||
;
|
||||
Ezfio.get_bielec_integrals_read_ao_integrals ()
|
||||
;;
|
||||
|
||||
let write_read_ao_integrals =
|
||||
Ezfio.set_bielec_integrals_read_ao_integrals
|
||||
;;
|
||||
|
||||
|
||||
let read_read_mo_integrals () =
|
||||
if not (Ezfio.has_bielec_integrals_read_mo_integrals ()) then
|
||||
get_default "read_mo_integrals"
|
||||
|> Bool.of_string
|
||||
|> Ezfio.set_bielec_integrals_read_mo_integrals
|
||||
;
|
||||
Ezfio.get_bielec_integrals_read_mo_integrals ()
|
||||
;;
|
||||
|
||||
let write_read_mo_integrals =
|
||||
Ezfio.set_bielec_integrals_read_mo_integrals
|
||||
;;
|
||||
|
||||
|
||||
let read_write_ao_integrals () =
|
||||
if not (Ezfio.has_bielec_integrals_write_ao_integrals ()) then
|
||||
get_default "write_ao_integrals"
|
||||
|> Bool.of_string
|
||||
|> Ezfio.set_bielec_integrals_write_ao_integrals
|
||||
;
|
||||
Ezfio.get_bielec_integrals_write_ao_integrals ()
|
||||
;;
|
||||
|
||||
let write_write_ao_integrals =
|
||||
Ezfio.set_bielec_integrals_write_ao_integrals
|
||||
;;
|
||||
|
||||
|
||||
let read_write_mo_integrals () =
|
||||
if not (Ezfio.has_bielec_integrals_write_mo_integrals ()) then
|
||||
get_default "write_mo_integrals"
|
||||
|> Bool.of_string
|
||||
|> Ezfio.set_bielec_integrals_write_mo_integrals
|
||||
;
|
||||
Ezfio.get_bielec_integrals_write_mo_integrals ()
|
||||
;;
|
||||
|
||||
let write_write_mo_integrals =
|
||||
Ezfio.set_bielec_integrals_write_mo_integrals
|
||||
;;
|
||||
|
||||
|
||||
let read_direct () =
|
||||
if not (Ezfio.has_bielec_integrals_direct ()) then
|
||||
get_default "direct"
|
||||
|> Bool.of_string
|
||||
|> Ezfio.set_bielec_integrals_direct
|
||||
;
|
||||
Ezfio.get_bielec_integrals_direct ()
|
||||
;;
|
||||
|
||||
let write_direct =
|
||||
Ezfio.set_bielec_integrals_direct
|
||||
;;
|
||||
|
||||
|
||||
let read_threshold_ao () =
|
||||
if not (Ezfio.has_bielec_integrals_threshold_ao ()) then
|
||||
get_default "threshold_ao"
|
||||
|> Float.of_string
|
||||
|> Ezfio.set_bielec_integrals_threshold_ao
|
||||
;
|
||||
Ezfio.get_bielec_integrals_threshold_ao ()
|
||||
|> Threshold.of_float
|
||||
;;
|
||||
|
||||
let write_threshold_ao t =
|
||||
Threshold.to_float t
|
||||
|> Ezfio.set_bielec_integrals_threshold_ao
|
||||
;;
|
||||
|
||||
|
||||
let read_threshold_mo () =
|
||||
if not (Ezfio.has_bielec_integrals_threshold_mo ()) then
|
||||
get_default "threshold_mo"
|
||||
|> Float.of_string
|
||||
|> Ezfio.set_bielec_integrals_threshold_mo
|
||||
;
|
||||
Ezfio.get_bielec_integrals_threshold_mo ()
|
||||
|> Threshold.of_float
|
||||
;;
|
||||
|
||||
let write_threshold_mo t =
|
||||
Threshold.to_float t
|
||||
|> Ezfio.set_bielec_integrals_threshold_mo
|
||||
;;
|
||||
|
||||
|
||||
let read ()=
|
||||
let result =
|
||||
{ read_ao_integrals = read_read_ao_integrals();
|
||||
read_mo_integrals = read_read_mo_integrals () ;
|
||||
write_ao_integrals = read_write_ao_integrals ();
|
||||
write_mo_integrals = read_write_mo_integrals ();
|
||||
threshold_ao = read_threshold_ao ();
|
||||
threshold_mo = read_threshold_mo ();
|
||||
direct = read_direct () ;
|
||||
} in
|
||||
if (result.read_ao_integrals &&
|
||||
result.write_ao_integrals) then
|
||||
failwith "Read and Write AO integrals are both true.";
|
||||
if (result.read_mo_integrals &&
|
||||
result.write_mo_integrals) then
|
||||
failwith "Read and Write MO integrals are both true.";
|
||||
Some result
|
||||
;;
|
||||
|
||||
let write b =
|
||||
if (b.read_ao_integrals &&
|
||||
b.write_ao_integrals) then
|
||||
failwith "Read and Write AO integrals are both true.";
|
||||
if (b.read_mo_integrals &&
|
||||
b.write_mo_integrals) then
|
||||
failwith "Read and Write MO integrals are both true.";
|
||||
write_read_ao_integrals b.read_ao_integrals;
|
||||
write_read_mo_integrals b.read_mo_integrals;
|
||||
write_write_ao_integrals b.write_ao_integrals ;
|
||||
write_write_mo_integrals b.write_mo_integrals ;
|
||||
write_threshold_ao b.threshold_ao;
|
||||
write_threshold_mo b.threshold_mo;
|
||||
write_direct b.direct;
|
||||
;;
|
||||
|
||||
let to_string b =
|
||||
Printf.sprintf "
|
||||
read_ao_integrals = %s
|
||||
read_mo_integrals = %s
|
||||
write_ao_integrals = %s
|
||||
write_mo_integrals = %s
|
||||
threshold_ao = %s
|
||||
threshold_mo = %s
|
||||
direct = %s
|
||||
"
|
||||
(Bool.to_string b.read_ao_integrals)
|
||||
(Bool.to_string b.read_mo_integrals)
|
||||
(Bool.to_string b.write_ao_integrals)
|
||||
(Bool.to_string b.write_mo_integrals)
|
||||
(Threshold.to_string b.threshold_ao)
|
||||
(Threshold.to_string b.threshold_mo)
|
||||
(Bool.to_string b.direct)
|
||||
;;
|
||||
|
||||
let to_rst b =
|
||||
Printf.sprintf "
|
||||
Read AO/MO integrals from disk ::
|
||||
|
||||
read_ao_integrals = %s
|
||||
read_mo_integrals = %s
|
||||
|
||||
Write AO/MO integrals to disk ::
|
||||
|
||||
write_ao_integrals = %s
|
||||
write_mo_integrals = %s
|
||||
|
||||
Thresholds on integrals ::
|
||||
|
||||
threshold_ao = %s
|
||||
threshold_mo = %s
|
||||
|
||||
Direct calculation of integrals ::
|
||||
|
||||
direct = %s
|
||||
|
||||
"
|
||||
(Bool.to_string b.read_ao_integrals)
|
||||
(Bool.to_string b.read_mo_integrals)
|
||||
(Bool.to_string b.write_ao_integrals)
|
||||
(Bool.to_string b.write_mo_integrals)
|
||||
(Threshold.to_string b.threshold_ao)
|
||||
(Threshold.to_string b.threshold_mo)
|
||||
(Bool.to_string b.direct)
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
open Qptypes;;
|
||||
open Qputils;;
|
||||
open Core;;
|
||||
open Qptypes
|
||||
open Qputils
|
||||
open Sexplib.Std
|
||||
|
||||
module Bitmasks : sig
|
||||
type t =
|
||||
@ -59,7 +59,7 @@ end = struct
|
||||
|
||||
let full_mask n_int =
|
||||
let range = "[1-"^
|
||||
(Int.to_string (Ezfio.get_mo_basis_mo_num ()))^"]"
|
||||
(string_of_int (Ezfio.get_mo_basis_mo_num ()))^"]"
|
||||
in
|
||||
MO_class.create_active range
|
||||
|> MO_class.to_bitlist n_int
|
||||
@ -75,7 +75,7 @@ end = struct
|
||||
full_mask n_int
|
||||
in
|
||||
let result = [ act ; act ; act ; act ; act ; act ]
|
||||
|> List.map ~f:(fun x ->
|
||||
|> List.map (fun x ->
|
||||
let y = Bitlist.to_int64_list x in y@y )
|
||||
|> List.concat
|
||||
in
|
||||
@ -107,7 +107,7 @@ end = struct
|
||||
full_mask n_int
|
||||
in
|
||||
let result = [ act ; act ]
|
||||
|> List.map ~f:(fun x ->
|
||||
|> List.map (fun x ->
|
||||
let y = Bitlist.to_int64_list x in y@y )
|
||||
|> List.concat
|
||||
in
|
||||
@ -147,12 +147,12 @@ cas = %s
|
||||
(Bit_kind.to_string b.bit_kind)
|
||||
(Bitmask_number.to_string b.n_mask_gen)
|
||||
(Array.to_list b.generators
|
||||
|> List.map ~f:(fun x-> Int64.to_string x)
|
||||
|> String.concat ~sep:", ")
|
||||
|> List.map (fun x-> Int64.to_string x)
|
||||
|> String.concat ", ")
|
||||
(Bitmask_number.to_string b.n_mask_cas)
|
||||
(Array.to_list b.cas
|
||||
|> List.map ~f:(fun x-> Int64.to_string x)
|
||||
|> String.concat ~sep:", ")
|
||||
|> List.map (fun x-> Int64.to_string x)
|
||||
|> String.concat ", ")
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
open Qptypes;;
|
||||
open Qputils;;
|
||||
open Core;;
|
||||
open Sexplib.Std;;
|
||||
|
||||
module Determinants_by_hand : sig
|
||||
type t =
|
||||
@ -112,7 +112,7 @@ end = struct
|
||||
begin
|
||||
Ezfio.set_determinants_n_states n_states;
|
||||
let data =
|
||||
Array.create n_states 1.
|
||||
Array.make n_states 1.
|
||||
|> Array.to_list
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| n_states |] ~data
|
||||
@ -126,7 +126,7 @@ end = struct
|
||||
|> States_number.to_int
|
||||
in
|
||||
let data =
|
||||
Array.map ~f:Positive_float.to_float data
|
||||
Array.map Positive_float.to_float data
|
||||
|> Array.to_list
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| n_states |] ~data
|
||||
@ -142,21 +142,21 @@ end = struct
|
||||
begin
|
||||
let data =
|
||||
Array.init n_states (fun _ -> 1./.(float_of_int n_states))
|
||||
|> Array.map ~f:Positive_float.of_float
|
||||
|> Array.map Positive_float.of_float
|
||||
in
|
||||
write_state_average_weight data
|
||||
end;
|
||||
let result =
|
||||
Ezfio.get_determinants_state_average_weight ()
|
||||
|> Ezfio.flattened_ezfio
|
||||
|> Array.map ~f:Positive_float.of_float
|
||||
|> Array.map Positive_float.of_float
|
||||
in
|
||||
if Array.length result = n_states then
|
||||
result
|
||||
else
|
||||
let data =
|
||||
Array.init n_states (fun _ -> 1./.(float_of_int n_states))
|
||||
|> Array.map ~f:Positive_float.of_float
|
||||
|> Array.map Positive_float.of_float
|
||||
in
|
||||
(write_state_average_weight data; data)
|
||||
;;
|
||||
@ -189,18 +189,18 @@ end = struct
|
||||
|> States_number.to_int
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| 1 ; n_states |]
|
||||
~data:(List.init n_states ~f:(fun i -> if (i=0) then 1. else 0. ))
|
||||
~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 ()
|
||||
|> Ezfio.flattened_ezfio
|
||||
|> Array.map ~f:Det_coef.of_float
|
||||
|> Array.map Det_coef.of_float
|
||||
;;
|
||||
|
||||
let write_psi_coef ~n_det ~n_states c =
|
||||
let n_det = Det_number.to_int n_det
|
||||
and c = Array.to_list c
|
||||
|> List.map ~f:Det_coef.to_float
|
||||
|> List.map Det_coef.to_float
|
||||
and n_states =
|
||||
States_number.to_int n_states
|
||||
in
|
||||
@ -242,9 +242,9 @@ end = struct
|
||||
assert (n_int = dim.(0));
|
||||
assert (dim.(1) = 2);
|
||||
assert (dim.(2) = (Det_number.to_int (read_n_det ())));
|
||||
List.init dim.(2) ~f:(fun i ->
|
||||
Array.sub ~pos:(2*n_int*i) ~len:(2*n_int) data)
|
||||
|> List.map ~f:(Determinant.of_int64_array
|
||||
List.init dim.(2) (fun i ->
|
||||
Array.sub data (2*n_int*i) (2*n_int) )
|
||||
|> List.map (Determinant.of_int64_array
|
||||
~n_int:(N_int_number.of_int n_int)
|
||||
~alpha:n_alpha ~beta:n_beta )
|
||||
|> Array.of_list
|
||||
@ -332,18 +332,19 @@ end = struct
|
||||
else
|
||||
"0."
|
||||
)
|
||||
|> String.concat_array ~sep:"\t"
|
||||
|> Array.to_list |> String.concat "\t"
|
||||
in
|
||||
Array.init ndet ~f:(fun i ->
|
||||
Array.init ndet (fun i ->
|
||||
Printf.sprintf " %s\n%s\n"
|
||||
(coefs_string i)
|
||||
(Determinant.to_string ~mo_num:mo_num b.psi_det.(i)
|
||||
|> String.split ~on:'\n'
|
||||
|> List.map ~f:(fun x -> " "^x)
|
||||
|> String.concat ~sep:"\n"
|
||||
|> String_ext.split ~on:'\n'
|
||||
|> List.map (fun x -> " "^x)
|
||||
|> String.concat "\n"
|
||||
)
|
||||
)
|
||||
|> String.concat_array ~sep:"\n"
|
||||
|> Array.to_list
|
||||
|> String.concat "\n"
|
||||
in
|
||||
Printf.sprintf "
|
||||
Force the selected wave function to be an eigenfunction of S^2.
|
||||
@ -365,7 +366,7 @@ Determinants ::
|
||||
"
|
||||
(b.expected_s2 |> Positive_float.to_string)
|
||||
(b.n_det |> Det_number.to_string)
|
||||
(b.state_average_weight |> Array.to_list |> List.map ~f:Positive_float.to_string |> String.concat ~sep:"\t")
|
||||
(b.state_average_weight |> Array.to_list |> List.map Positive_float.to_string |> String.concat "\t")
|
||||
det_text
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
@ -388,11 +389,11 @@ psi_det = %s
|
||||
(b.n_det |> Det_number.to_string)
|
||||
(b.n_states |> States_number.to_string)
|
||||
(b.expected_s2 |> Positive_float.to_string)
|
||||
(b.state_average_weight |> Array.to_list |> List.map ~f:Positive_float.to_string |> String.concat ~sep:",")
|
||||
(b.psi_coef |> Array.to_list |> List.map ~f:Det_coef.to_string
|
||||
|> String.concat ~sep:", ")
|
||||
(b.psi_det |> Array.to_list |> List.map ~f:(Determinant.to_string
|
||||
~mo_num) |> String.concat ~sep:"\n\n")
|
||||
(b.state_average_weight |> Array.to_list |> List.map Positive_float.to_string |> String.concat ",")
|
||||
(b.psi_coef |> Array.to_list |> List.map Det_coef.to_string
|
||||
|> String.concat ", ")
|
||||
(b.psi_det |> Array.to_list |> List.map (Determinant.to_string
|
||||
~mo_num) |> String.concat "\n\n")
|
||||
;;
|
||||
|
||||
let of_rst r =
|
||||
@ -400,33 +401,36 @@ psi_det = %s
|
||||
in
|
||||
|
||||
(* Split into header and determinants data *)
|
||||
let idx = String.substr_index_exn r ~pos:0 ~pattern:"\nDeterminants"
|
||||
let idx =
|
||||
match String_ext.substr_index r ~pos:0 ~pattern:"\nDeterminants" with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
let (header, dets) =
|
||||
(String.prefix r idx, String.suffix r ((String.length r)-idx) )
|
||||
(String.sub r 0 idx, String.sub r idx (String.length r - idx) )
|
||||
in
|
||||
|
||||
(* Handle header *)
|
||||
let header = r
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
|> String_ext.split ~on:'\n'
|
||||
|> List.filter (fun line ->
|
||||
if (line = "") then
|
||||
false
|
||||
else
|
||||
( (String.contains line '=') && (line.[0] = ' ') )
|
||||
)
|
||||
|> List.map ~f:(fun line ->
|
||||
|> List.map (fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
|> String.strip
|
||||
String_ext.tr line ~target:'=' ~replacement:' '
|
||||
|> String.trim
|
||||
)^")" )
|
||||
|> String.concat
|
||||
|> String.concat ""
|
||||
in
|
||||
|
||||
(* Handle determinant coefs *)
|
||||
let dets = match ( dets
|
||||
|> String.split ~on:'\n'
|
||||
|> List.map ~f:(String.strip)
|
||||
|> String_ext.split ~on:'\n'
|
||||
|> List.map String.trim
|
||||
) with
|
||||
| _::lines -> lines
|
||||
| _ -> failwith "Error in determinants"
|
||||
@ -438,8 +442,8 @@ psi_det = %s
|
||||
| ""::""::tail -> read_coefs accu tail
|
||||
| ""::c::tail ->
|
||||
let c =
|
||||
String.split ~on:'\t' c
|
||||
|> List.map ~f:(fun x -> Det_coef.of_float (Float.of_string x))
|
||||
String_ext.split ~on:'\t' c
|
||||
|> List.map (fun x -> Det_coef.of_float (Float.of_string x))
|
||||
|> Array.of_list
|
||||
in
|
||||
read_coefs (c::accu) tail
|
||||
@ -450,15 +454,15 @@ psi_det = %s
|
||||
read_coefs [] dets
|
||||
in
|
||||
let nstates =
|
||||