9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-06 21:43:39 +01:00

Fixed OCaml

This commit is contained in:
Anthony Scemama 2019-12-02 23:53:10 +01:00
parent eb3a8a679c
commit ff209ff451

View File

@ -10,7 +10,7 @@ module Mo_basis : sig
mo_class : MO_class.t array; mo_class : MO_class.t array;
mo_occ : MO_occ.t array; mo_occ : MO_occ.t array;
mo_coef : (MO_coef.t array) array; mo_coef : (MO_coef.t array) array;
mo_coef_imag : (MO_coef.t array) array; mo_coef_imag : (MO_coef.t array) array option;
ao_md5 : MD5.t; ao_md5 : MD5.t;
} [@@deriving sexp] } [@@deriving sexp]
val read : unit -> t option val read : unit -> t option
@ -25,7 +25,7 @@ end = struct
mo_class : MO_class.t array; mo_class : MO_class.t array;
mo_occ : MO_occ.t array; mo_occ : MO_occ.t array;
mo_coef : (MO_coef.t array) array; mo_coef : (MO_coef.t array) array;
mo_coef_imag : (MO_coef.t array) array; mo_coef_imag : (MO_coef.t array) array option;
ao_md5 : MD5.t; ao_md5 : MD5.t;
} [@@deriving sexp] } [@@deriving sexp]
let get_default = Qpackage.get_ezfio_default "mo_basis" let get_default = Qpackage.get_ezfio_default "mo_basis"
@ -40,16 +40,17 @@ end = struct
let reorder b ordering = let reorder b ordering =
{ b with { b with
mo_coef = mo_coef = Array.map (fun mo ->
Array.map (fun mo -> Array.init (Array.length mo)
Array.init (Array.length mo) (fun i -> mo.(ordering.(i)))
(fun i -> mo.(ordering.(i))) ) b.mo_coef ;
) b.mo_coef ;
mo_coef_imag = mo_coef_imag =
Array.map (fun mo -> match b.mo_coef_imag with
Array.init (Array.length mo) | None -> None
(fun i -> mo.(ordering.(i))) | Some x -> Some ( Array.map (fun mo ->
) b.mo_coef_imag Array.init (Array.length mo)
(fun i -> mo.(ordering.(i)))
) x )
} }
let read_ao_md5 () = let read_ao_md5 () =
@ -130,15 +131,18 @@ end = struct
) )
let read_mo_coef_imag () = let read_mo_coef_imag () =
let a = Ezfio.get_mo_basis_mo_coef_imag () if Ezfio.has_mo_basis_mo_coef_imag () then
|> Ezfio.flattened_ezfio let a =
|> Array.map MO_coef.of_float Ezfio.get_mo_basis_mo_coef_imag ()
in |> Ezfio.flattened_ezfio
let mo_num = read_mo_num () |> MO_number.to_int in |> Array.map MO_coef.of_float
let ao_num = (Array.length a)/mo_num in in
Array.init mo_num (fun j -> let mo_num = read_mo_num () |> MO_number.to_int in
Array.sub a (j*ao_num) (ao_num) let ao_num = (Array.length a)/mo_num in
) Some (Array.init mo_num (fun j ->
Array.sub a (j*ao_num) (ao_num)
) )
else None
let read () = let read () =
@ -266,12 +270,12 @@ mo_coef = %s
let write_mo_num n = let write_mo_num n =
MO_number.to_int n MO_number.to_int n
|> Ezfio.set_mo_basis_mo_num |> Ezfio.set_mo_basis_mo_num
;;
let write_mo_label a = let write_mo_label a =
MO_label.to_string a MO_label.to_string a
|> Ezfio.set_mo_basis_mo_label |> Ezfio.set_mo_basis_mo_label
;;
let write_mo_class a = let write_mo_class a =
let mo_num = Array.length a in let mo_num = Array.length a in
@ -279,7 +283,7 @@ mo_coef = %s
|> Array.to_list |> Array.to_list
in Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| mo_num |] ~data in Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| mo_num |] ~data
|> Ezfio.set_mo_basis_mo_class |> Ezfio.set_mo_basis_mo_class
;;
let write_mo_occ a = let write_mo_occ a =
let mo_num = Array.length a in let mo_num = Array.length a in
@ -287,12 +291,12 @@ mo_coef = %s
|> Array.to_list |> Array.to_list
in Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| mo_num |] ~data in Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| mo_num |] ~data
|> Ezfio.set_mo_basis_mo_occ |> Ezfio.set_mo_basis_mo_occ
;;
let write_md5 a = let write_md5 a =
MD5.to_string a MD5.to_string a
|> Ezfio.set_mo_basis_ao_md5 |> Ezfio.set_mo_basis_ao_md5
;;
let write_mo_coef a = let write_mo_coef a =
let mo_num = Array.length a in let mo_num = Array.length a in
@ -303,20 +307,25 @@ mo_coef = %s
|> Array.to_list |> Array.to_list
|> List.concat |> List.concat
in Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| ao_num ; mo_num |] ~data in Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| ao_num ; mo_num |] ~data
|> Ezfio.set_mo_basis_mo_coef; |> Ezfio.set_mo_basis_mo_coef
;;
let write_mo_coef_imag a = let write_mo_coef_imag a =
let mo_num = Array.length a in match a with
let ao_num = Array.length a.(0) in | None -> ()
let data = | Some a ->
Array.map (fun mo -> Array.map MO_coef.to_float mo begin
|> Array.to_list) a let mo_num = Array.length a in
|> Array.to_list let ao_num = Array.length a.(0) in
|> List.concat let data =
in Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| ao_num ; mo_num |] ~data Array.map (fun mo -> Array.map MO_coef.to_float mo
|> Ezfio.set_mo_basis_mo_coef_imag; |> Array.to_list) a
;; |> Array.to_list
|> List.concat
in Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| ao_num ; mo_num |] ~data
|> Ezfio.set_mo_basis_mo_coef_imag
end
let write let write
{ mo_num : MO_number.t ; { mo_num : MO_number.t ;
@ -324,7 +333,7 @@ mo_coef = %s
mo_class : MO_class.t array; mo_class : MO_class.t array;
mo_occ : MO_occ.t array; mo_occ : MO_occ.t array;
mo_coef : (MO_coef.t array) array; mo_coef : (MO_coef.t array) array;
mo_coef_imag : (MO_coef.t array) array; mo_coef_imag : (MO_coef.t array) array option;
ao_md5 : MD5.t; ao_md5 : MD5.t;
} = } =
write_mo_num mo_num; write_mo_num mo_num;
@ -334,7 +343,7 @@ mo_coef = %s
write_mo_coef mo_coef; write_mo_coef mo_coef;
write_mo_coef_imag mo_coef_imag; write_mo_coef_imag mo_coef_imag;
write_md5 ao_md5 write_md5 ao_md5
;;
end end