mirror of
https://github.com/LCPQ/quantum_package
synced 2024-07-03 09:55:59 +02:00
Introduced mo_class in EZFIO
This commit is contained in:
parent
b65846597a
commit
e986a3cd44
|
@ -1,32 +1,32 @@
|
||||||
open Qptypes;;
|
open Qptypes
|
||||||
open Qputils;;
|
open Qputils
|
||||||
open Core.Std;;
|
open Core.Std
|
||||||
|
|
||||||
type t_mo =
|
type t_mo =
|
||||||
{ mo_tot_num : MO_number.t ;
|
{ mo_tot_num : MO_number.t ;
|
||||||
mo_label : MO_label.t;
|
mo_label : MO_label.t;
|
||||||
mo_occ : MO_occ.t array;
|
mo_class : MO_class.t array;
|
||||||
mo_coef : (MO_coef.t array) array;
|
mo_occ : MO_occ.t array;
|
||||||
ao_md5 : MD5.t;
|
mo_coef : (MO_coef.t array) array;
|
||||||
} with sexp
|
ao_md5 : MD5.t;
|
||||||
|
} with sexp
|
||||||
|
|
||||||
module Mo_basis : sig
|
module Mo_basis : sig
|
||||||
type t = t_mo
|
type t = t_mo
|
||||||
val read : unit -> t option
|
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
|
||||||
end = struct
|
end = struct
|
||||||
type t = t_mo
|
type t = t_mo
|
||||||
|
let get_default = Qpackage.get_ezfio_default "mo_basis"
|
||||||
let get_default = Qpackage.get_ezfio_default "mo_basis";;
|
|
||||||
|
|
||||||
let read_mo_label () =
|
let read_mo_label () =
|
||||||
if not (Ezfio.has_mo_basis_mo_label ()) then
|
if not (Ezfio.has_mo_basis_mo_label ()) then
|
||||||
Ezfio.set_mo_basis_mo_label "None"
|
Ezfio.set_mo_basis_mo_label "None"
|
||||||
;
|
;
|
||||||
Ezfio.get_mo_basis_mo_label ()
|
Ezfio.get_mo_basis_mo_label ()
|
||||||
|> MO_label.of_string
|
|> MO_label.of_string
|
||||||
;;
|
|
||||||
|
|
||||||
let read_ao_md5 () =
|
let read_ao_md5 () =
|
||||||
let ao_md5 =
|
let ao_md5 =
|
||||||
|
@ -46,12 +46,28 @@ end = struct
|
||||||
if (ao_md5 <> result) then
|
if (ao_md5 <> result) then
|
||||||
failwith "The current MOs don't correspond to the current AOs.";
|
failwith "The current MOs don't correspond to the current AOs.";
|
||||||
result
|
result
|
||||||
;;
|
|
||||||
|
|
||||||
let read_mo_tot_num () =
|
let read_mo_tot_num () =
|
||||||
Ezfio.get_mo_basis_mo_tot_num ()
|
Ezfio.get_mo_basis_mo_tot_num ()
|
||||||
|> MO_number.of_int
|
|> 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 () =
|
let read_mo_occ () =
|
||||||
if not (Ezfio.has_mo_basis_mo_label ()) then
|
if not (Ezfio.has_mo_basis_mo_label ()) then
|
||||||
|
@ -60,41 +76,42 @@ end = struct
|
||||||
and elec_beta_num = Ezfio.get_electrons_elec_beta_num ()
|
and elec_beta_num = Ezfio.get_electrons_elec_beta_num ()
|
||||||
and mo_tot_num = MO_number.to_int (read_mo_tot_num ()) in
|
and mo_tot_num = MO_number.to_int (read_mo_tot_num ()) in
|
||||||
let data = Array.init mo_tot_num ~f:(fun i ->
|
let data = Array.init mo_tot_num ~f:(fun i ->
|
||||||
if (i<elec_beta_num) then 2.
|
if (i<elec_beta_num) then 2.
|
||||||
else if (i < elec_alpha_num) then 1.
|
else if (i < elec_alpha_num) then 1.
|
||||||
else 0.) |> Array.to_list in
|
else 0.) |> Array.to_list in
|
||||||
Ezfio.ezfio_array_of_list ~rank:1
|
Ezfio.ezfio_array_of_list ~rank:1
|
||||||
~dim:[| mo_tot_num |] ~data:data
|
~dim:[| mo_tot_num |] ~data:data
|
||||||
|> Ezfio.set_mo_basis_mo_occ
|
|> Ezfio.set_mo_basis_mo_occ
|
||||||
end;
|
end;
|
||||||
Ezfio.flattened_ezfio (Ezfio.get_mo_basis_mo_occ () )
|
Ezfio.flattened_ezfio (Ezfio.get_mo_basis_mo_occ () )
|
||||||
|> Array.map ~f:MO_occ.of_float
|
|> Array.map ~f:MO_occ.of_float
|
||||||
;;
|
|
||||||
|
|
||||||
let read_mo_coef () =
|
let read_mo_coef () =
|
||||||
let a = Ezfio.get_mo_basis_mo_coef ()
|
let a = Ezfio.get_mo_basis_mo_coef ()
|
||||||
|> Ezfio.flattened_ezfio
|
|> Ezfio.flattened_ezfio
|
||||||
|> Array.map ~f:MO_coef.of_float
|
|> Array.map ~f:MO_coef.of_float
|
||||||
in
|
in
|
||||||
let mo_tot_num = read_mo_tot_num () |> MO_number.to_int in
|
let mo_tot_num = read_mo_tot_num () |> MO_number.to_int in
|
||||||
let ao_num = (Array.length a)/mo_tot_num in
|
let ao_num = (Array.length a)/mo_tot_num in
|
||||||
Array.init mo_tot_num ~f:(fun j ->
|
Array.init mo_tot_num ~f:(fun j ->
|
||||||
Array.sub ~pos:(j*ao_num) ~len:(ao_num) a
|
Array.sub ~pos:(j*ao_num) ~len:(ao_num) a
|
||||||
)
|
)
|
||||||
;;
|
|
||||||
|
|
||||||
let read () =
|
let read () =
|
||||||
if (Ezfio.has_mo_basis_mo_tot_num ()) then
|
if (Ezfio.has_mo_basis_mo_tot_num ()) then
|
||||||
Some
|
Some
|
||||||
{ mo_tot_num = read_mo_tot_num ();
|
{ mo_tot_num = read_mo_tot_num ();
|
||||||
mo_label = read_mo_label () ;
|
mo_label = read_mo_label () ;
|
||||||
mo_occ = read_mo_occ ();
|
mo_class = read_mo_class ();
|
||||||
mo_coef = read_mo_coef ();
|
mo_occ = read_mo_occ ();
|
||||||
ao_md5 = read_ao_md5 ();
|
mo_coef = read_mo_coef ();
|
||||||
}
|
ao_md5 = read_ao_md5 ();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
None
|
None
|
||||||
;;
|
|
||||||
|
|
||||||
let mo_coef_to_string mo_coef =
|
let mo_coef_to_string mo_coef =
|
||||||
let ao_num = Array.length mo_coef.(0)
|
let ao_num = Array.length mo_coef.(0)
|
||||||
|
@ -102,53 +119,53 @@ end = struct
|
||||||
let rec print_five imin imax =
|
let rec print_five imin imax =
|
||||||
match (imax-imin+1) with
|
match (imax-imin+1) with
|
||||||
| 1 ->
|
| 1 ->
|
||||||
let header = [ Printf.sprintf " #%15d" (imin+1) ; ] in
|
let header = [ Printf.sprintf " #%15d" (imin+1) ; ] in
|
||||||
let new_lines =
|
let new_lines =
|
||||||
List.init ao_num ~f:(fun i ->
|
List.init ao_num ~f:(fun i ->
|
||||||
Printf.sprintf " %3d %15.10f " (i+1)
|
Printf.sprintf " %3d %15.10f " (i+1)
|
||||||
(MO_coef.to_float mo_coef.(imin ).(i)) )
|
(MO_coef.to_float mo_coef.(imin ).(i)) )
|
||||||
in header @ new_lines
|
in header @ new_lines
|
||||||
| 2 ->
|
| 2 ->
|
||||||
let header = [ Printf.sprintf " #%15d %15d" (imin+1) (imin+2) ; ] in
|
let header = [ Printf.sprintf " #%15d %15d" (imin+1) (imin+2) ; ] in
|
||||||
let new_lines =
|
let new_lines =
|
||||||
List.init ao_num ~f:(fun i ->
|
List.init ao_num ~f:(fun i ->
|
||||||
Printf.sprintf " %3d %15.10f %15.10f" (i+1)
|
Printf.sprintf " %3d %15.10f %15.10f" (i+1)
|
||||||
(MO_coef.to_float mo_coef.(imin ).(i))
|
(MO_coef.to_float mo_coef.(imin ).(i))
|
||||||
(MO_coef.to_float mo_coef.(imin+1).(i)) )
|
(MO_coef.to_float mo_coef.(imin+1).(i)) )
|
||||||
in header @ new_lines
|
in header @ new_lines
|
||||||
| 3 ->
|
| 3 ->
|
||||||
let header = [ Printf.sprintf " #%15d %15d %15d"
|
let header = [ Printf.sprintf " #%15d %15d %15d"
|
||||||
(imin+1) (imin+2) (imin+3); ] in
|
(imin+1) (imin+2) (imin+3); ] in
|
||||||
let new_lines =
|
let new_lines =
|
||||||
List.init ao_num ~f:(fun i ->
|
List.init ao_num ~f:(fun i ->
|
||||||
Printf.sprintf " %3d %15.10f %15.10f %15.10f" (i+1)
|
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 ).(i))
|
||||||
(MO_coef.to_float mo_coef.(imin+1).(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+2).(i)) )
|
||||||
in header @ new_lines
|
in header @ new_lines
|
||||||
| 4 ->
|
| 4 ->
|
||||||
let header = [ Printf.sprintf " #%15d %15d %15d %15d"
|
let header = [ Printf.sprintf " #%15d %15d %15d %15d"
|
||||||
(imin+1) (imin+2) (imin+3) (imin+4) ; ] in
|
(imin+1) (imin+2) (imin+3) (imin+4) ; ] in
|
||||||
let new_lines =
|
let new_lines =
|
||||||
List.init ao_num ~f:(fun i ->
|
List.init ao_num ~f:(fun i ->
|
||||||
Printf.sprintf " %3d %15.10f %15.10f %15.10f %15.10f" (i+1)
|
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 ).(i))
|
||||||
(MO_coef.to_float mo_coef.(imin+1).(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+2).(i))
|
||||||
(MO_coef.to_float mo_coef.(imin+3).(i)) )
|
(MO_coef.to_float mo_coef.(imin+3).(i)) )
|
||||||
in header @ new_lines
|
in header @ new_lines
|
||||||
| 5 ->
|
| 5 ->
|
||||||
let header = [ Printf.sprintf " #%15d %15d %15d %15d %15d"
|
let header = [ Printf.sprintf " #%15d %15d %15d %15d %15d"
|
||||||
(imin+1) (imin+2) (imin+3) (imin+4) (imin+5) ; ] in
|
(imin+1) (imin+2) (imin+3) (imin+4) (imin+5) ; ] in
|
||||||
let new_lines =
|
let new_lines =
|
||||||
List.init ao_num ~f:(fun i ->
|
List.init ao_num ~f:(fun i ->
|
||||||
Printf.sprintf " %3d %15.10f %15.10f %15.10f %15.10f %15.10f" (i+1)
|
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 ).(i))
|
||||||
(MO_coef.to_float mo_coef.(imin+1).(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+2).(i))
|
||||||
(MO_coef.to_float mo_coef.(imin+3).(i))
|
(MO_coef.to_float mo_coef.(imin+3).(i))
|
||||||
(MO_coef.to_float mo_coef.(imin+4).(i)) )
|
(MO_coef.to_float mo_coef.(imin+4).(i)) )
|
||||||
in header @ new_lines
|
in header @ new_lines
|
||||||
| _ -> assert false
|
| _ -> assert false
|
||||||
in
|
in
|
||||||
let rec create_list accu i =
|
let rec create_list accu i =
|
||||||
|
@ -158,7 +175,7 @@ end = struct
|
||||||
(print_five i (mo_tot_num-1) |> String.concat ~sep:"\n")::accu |> List.rev
|
(print_five i (mo_tot_num-1) |> String.concat ~sep:"\n")::accu |> List.rev
|
||||||
in
|
in
|
||||||
create_list [] 0 |> String.concat ~sep:"\n\n"
|
create_list [] 0 |> String.concat ~sep:"\n\n"
|
||||||
;;
|
|
||||||
|
|
||||||
let to_rst b =
|
let to_rst b =
|
||||||
Printf.sprintf "
|
Printf.sprintf "
|
||||||
|
@ -174,29 +191,32 @@ MO coefficients ::
|
||||||
|
|
||||||
%s
|
%s
|
||||||
"
|
"
|
||||||
(MO_label.to_string b.mo_label)
|
(MO_label.to_string b.mo_label)
|
||||||
(MO_number.to_string b.mo_tot_num)
|
(MO_number.to_string b.mo_tot_num)
|
||||||
(mo_coef_to_string b.mo_coef)
|
(mo_coef_to_string b.mo_coef)
|
||||||
|> Rst_string.of_string
|
|> Rst_string.of_string
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
let to_string b =
|
let to_string b =
|
||||||
Printf.sprintf "
|
Printf.sprintf "
|
||||||
mo_label = %s
|
mo_label = %s
|
||||||
mo_tot_num = \"%s\"
|
mo_tot_num = \"%s\"
|
||||||
|
mo_clas = %s
|
||||||
mo_occ = %s
|
mo_occ = %s
|
||||||
mo_coef = %s
|
mo_coef = %s
|
||||||
"
|
"
|
||||||
(MO_label.to_string b.mo_label)
|
(MO_label.to_string b.mo_label)
|
||||||
(MO_number.to_string b.mo_tot_num)
|
(MO_number.to_string b.mo_tot_num)
|
||||||
(b.mo_occ |> Array.to_list |> List.map
|
(b.mo_class |> Array.to_list |> List.map
|
||||||
~f:(MO_occ.to_string) |> String.concat ~sep:", " )
|
~f:(MO_class.to_string) |> String.concat ~sep:", " )
|
||||||
(b.mo_coef |> Array.map
|
(b.mo_occ |> Array.to_list |> List.map
|
||||||
~f:(fun x-> Array.map ~f:MO_coef.to_string x |> String.concat_array
|
~f:(MO_occ.to_string) |> String.concat ~sep:", " )
|
||||||
~sep:"," ) |>
|
(b.mo_coef |> Array.map
|
||||||
String.concat_array ~sep:"\n" )
|
~f:(fun x-> Array.map ~f:MO_coef.to_string x |> String.concat_array
|
||||||
;;
|
~sep:"," ) |>
|
||||||
|
String.concat_array ~sep:"\n" )
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,63 @@
|
||||||
open Core.Std;;
|
open Core.Std
|
||||||
open Qptypes ;;
|
open Qptypes
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
| Core of MO_number.t list
|
| Core of MO_number.t list
|
||||||
| Inactive of MO_number.t list
|
| Inactive of MO_number.t list
|
||||||
| Active of MO_number.t list
|
| Active of MO_number.t list
|
||||||
| Virtual of MO_number.t list
|
| Virtual of MO_number.t list
|
||||||
| Deleted of MO_number.t list
|
| Deleted of MO_number.t list
|
||||||
with sexp
|
with sexp
|
||||||
|
|
||||||
|
|
||||||
let to_string x =
|
let to_string x =
|
||||||
let print_list l =
|
let print_list l =
|
||||||
let s = List.map ~f:(fun x-> MO_number.to_int x |> string_of_int )l
|
let s = List.map ~f:(fun x-> MO_number.to_int x |> string_of_int )l
|
||||||
|> (String.concat ~sep:", ")
|
|> (String.concat ~sep:", ")
|
||||||
in
|
in
|
||||||
"("^s^")"
|
"("^s^")"
|
||||||
in
|
in
|
||||||
|
|
||||||
match x with
|
match x with
|
||||||
| Core l -> "Core : "^(print_list l)
|
| Core [] -> "Core"
|
||||||
|
| Inactive [] -> "Inactive"
|
||||||
|
| Active [] -> "Active"
|
||||||
|
| Virtual [] -> "Virtual"
|
||||||
|
| Deleted [] -> "Deleted"
|
||||||
|
| Core l -> "Core : "^(print_list l)
|
||||||
| Inactive l -> "Inactive : "^(print_list l)
|
| Inactive l -> "Inactive : "^(print_list l)
|
||||||
| Active l -> "Active : "^(print_list l)
|
| Active l -> "Active : "^(print_list l)
|
||||||
| Virtual l -> "Virtual : "^(print_list l)
|
| Virtual l -> "Virtual : "^(print_list l)
|
||||||
| Deleted l -> "Deleted : "^(print_list l)
|
| Deleted l -> "Deleted : "^(print_list l)
|
||||||
;;
|
|
||||||
|
|
||||||
|
let of_string s =
|
||||||
|
match (String.lowercase s) with
|
||||||
|
| "core" -> Core []
|
||||||
|
| "inactive" -> Inactive []
|
||||||
|
| "active" -> Active []
|
||||||
|
| "virtual" -> Virtual []
|
||||||
|
| "deleted" -> Deleted []
|
||||||
|
| _ -> failwith "MO_class should be (Core|Inactive|Active|Virtual|Deleted)"
|
||||||
|
|
||||||
|
|
||||||
let _mo_number_list_of_range range =
|
let _mo_number_list_of_range range =
|
||||||
Range.of_string range |> List.map ~f:MO_number.of_int
|
Range.of_string range |> List.map ~f:MO_number.of_int
|
||||||
;;
|
|
||||||
|
|
||||||
|
let create_core range = Core (_mo_number_list_of_range range)
|
||||||
|
let create_inactive range = Inactive (_mo_number_list_of_range range)
|
||||||
|
let create_active range = Active (_mo_number_list_of_range range)
|
||||||
|
let create_virtual range = Virtual (_mo_number_list_of_range range)
|
||||||
|
let create_deleted range = Deleted (_mo_number_list_of_range range)
|
||||||
|
|
||||||
let create_core range = Core (_mo_number_list_of_range range) ;;
|
|
||||||
let create_inactive range = Inactive (_mo_number_list_of_range range) ;;
|
|
||||||
let create_active range = Active (_mo_number_list_of_range range) ;;
|
|
||||||
let create_virtual range = Virtual (_mo_number_list_of_range range) ;;
|
|
||||||
let create_deleted range = Deleted (_mo_number_list_of_range range) ;;
|
|
||||||
|
|
||||||
let to_bitlist n_int x =
|
let to_bitlist n_int x =
|
||||||
match x with
|
match x with
|
||||||
| Core l
|
| Core l
|
||||||
| Inactive l
|
| Inactive l
|
||||||
| Active l
|
| Active l
|
||||||
| Virtual l
|
| Virtual l
|
||||||
| Deleted l -> Bitlist.of_mo_number_list n_int l
|
| Deleted l -> Bitlist.of_mo_number_list n_int l
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,6 @@ val to_bitlist : Qptypes.N_int_number.t -> t -> Bitlist.t
|
||||||
|
|
||||||
(** Convert to string for printing *)
|
(** Convert to string for printing *)
|
||||||
val to_string : t -> string
|
val to_string : t -> string
|
||||||
|
|
||||||
|
val of_string : string -> t
|
||||||
|
|
||||||
|
|
|
@ -1,305 +0,0 @@
|
||||||
open Qputils;;
|
|
||||||
open Qptypes;;
|
|
||||||
open Core.Std;;
|
|
||||||
|
|
||||||
(*
|
|
||||||
* Command-line arguments
|
|
||||||
* ----------------------
|
|
||||||
*)
|
|
||||||
|
|
||||||
let build_mask from upto n_int =
|
|
||||||
let from = MO_number.to_int from
|
|
||||||
and upto = MO_number.to_int upto
|
|
||||||
and n_int = N_int_number.to_int n_int
|
|
||||||
in
|
|
||||||
let rec build_mask bit = function
|
|
||||||
| 0 -> []
|
|
||||||
| i ->
|
|
||||||
if ( i = upto ) then
|
|
||||||
Bit.One::(build_mask Bit.One (i-1))
|
|
||||||
else if ( i = from ) then
|
|
||||||
Bit.One::(build_mask Bit.Zero (i-1))
|
|
||||||
else
|
|
||||||
bit::(build_mask bit (i-1))
|
|
||||||
in
|
|
||||||
let starting_bit =
|
|
||||||
if ( (upto >= n_int*64) || (upto < 0) ) then Bit.One
|
|
||||||
else Bit.Zero
|
|
||||||
in
|
|
||||||
build_mask starting_bit (n_int*64)
|
|
||||||
|> List.rev
|
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
let failure s = raise (Failure s)
|
|
||||||
;;
|
|
||||||
|
|
||||||
type t =
|
|
||||||
| Core
|
|
||||||
| Inactive
|
|
||||||
| Active
|
|
||||||
| Virtual
|
|
||||||
| Deleted
|
|
||||||
| None
|
|
||||||
;;
|
|
||||||
|
|
||||||
let t_to_string = function
|
|
||||||
| Core -> "core"
|
|
||||||
| Inactive -> "inactive"
|
|
||||||
| Active -> "active"
|
|
||||||
| Virtual -> "virtual"
|
|
||||||
| Deleted -> "deleted"
|
|
||||||
| None -> assert false
|
|
||||||
;;
|
|
||||||
|
|
||||||
let run ?(core="[]") ?(inact="[]") ?(act="[]") ?(virt="[]") ?(del="[]") ezfio_filename =
|
|
||||||
|
|
||||||
Ezfio.set_file ezfio_filename ;
|
|
||||||
if not (Ezfio.has_mo_basis_mo_tot_num ()) then
|
|
||||||
failure "mo_basis/mo_tot_num not found" ;
|
|
||||||
|
|
||||||
let mo_tot_num = Ezfio.get_mo_basis_mo_tot_num () in
|
|
||||||
let n_int =
|
|
||||||
try N_int_number.of_int (Ezfio.get_determinants_n_int ())
|
|
||||||
with _ -> Bitlist.n_int_of_mo_tot_num mo_tot_num
|
|
||||||
in
|
|
||||||
|
|
||||||
|
|
||||||
let mo_class = Array.init mo_tot_num ~f:(fun i -> None) in
|
|
||||||
|
|
||||||
(* Check input data *)
|
|
||||||
let apply_class l =
|
|
||||||
let rec apply_class t = function
|
|
||||||
| [] -> ()
|
|
||||||
| k::tail -> let i = MO_number.to_int k in
|
|
||||||
begin
|
|
||||||
match mo_class.(i-1) with
|
|
||||||
| None -> mo_class.(i-1) <- t ;
|
|
||||||
apply_class t tail;
|
|
||||||
| x -> failure
|
|
||||||
(Printf.sprintf "Orbital %d is defined both in the %s and %s spaces"
|
|
||||||
i (t_to_string x) (t_to_string t))
|
|
||||||
end
|
|
||||||
in
|
|
||||||
match l with
|
|
||||||
| MO_class.Core x -> apply_class Core x
|
|
||||||
| MO_class.Inactive x -> apply_class Inactive x
|
|
||||||
| MO_class.Active x -> apply_class Active x
|
|
||||||
| MO_class.Virtual x -> apply_class Virtual x
|
|
||||||
| MO_class.Deleted x -> apply_class Deleted x
|
|
||||||
in
|
|
||||||
|
|
||||||
let core_input = core in
|
|
||||||
let core = MO_class.create_core core in
|
|
||||||
let inact = MO_class.create_inactive inact in
|
|
||||||
let act = MO_class.create_active act in
|
|
||||||
let virt = MO_class.create_virtual virt in
|
|
||||||
let del = MO_class.create_deleted del in
|
|
||||||
|
|
||||||
apply_class core ;
|
|
||||||
apply_class inact ;
|
|
||||||
apply_class act ;
|
|
||||||
apply_class virt ;
|
|
||||||
apply_class del ;
|
|
||||||
|
|
||||||
for i=1 to (Array.length mo_class)
|
|
||||||
do
|
|
||||||
if (mo_class.(i-1) = None) then
|
|
||||||
failure (Printf.sprintf "Orbital %d is not specified (mo_tot_num = %d)" i mo_tot_num)
|
|
||||||
done;
|
|
||||||
|
|
||||||
|
|
||||||
(* Debug output *)
|
|
||||||
MO_class.to_string core |> print_endline ;
|
|
||||||
MO_class.to_string inact |> print_endline ;
|
|
||||||
MO_class.to_string act |> print_endline ;
|
|
||||||
MO_class.to_string virt |> print_endline ;
|
|
||||||
MO_class.to_string del |> print_endline ;
|
|
||||||
|
|
||||||
(* Create masks *)
|
|
||||||
let ia = Excitation.create_single inact act
|
|
||||||
and aa = Excitation.create_single act act
|
|
||||||
and av = Excitation.create_single act virt
|
|
||||||
and iv = Excitation.create_single inact virt
|
|
||||||
in
|
|
||||||
let single_excitations = [| ia ; aa ; av ; iv |]
|
|
||||||
|> Array.map ~f:Excitation.(fun x ->
|
|
||||||
match x 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) )
|
|
||||||
| Double _ -> assert false
|
|
||||||
)
|
|
||||||
|
|
||||||
and double_excitations = [|
|
|
||||||
Excitation.double_of_singles ia ia ;
|
|
||||||
Excitation.double_of_singles ia aa ;
|
|
||||||
Excitation.double_of_singles ia iv ;
|
|
||||||
Excitation.double_of_singles ia av ;
|
|
||||||
|
|
||||||
Excitation.double_of_singles aa aa ;
|
|
||||||
Excitation.double_of_singles aa iv ;
|
|
||||||
Excitation.double_of_singles aa av ;
|
|
||||||
|
|
||||||
Excitation.double_of_singles iv aa ;
|
|
||||||
Excitation.double_of_singles iv av ;
|
|
||||||
|
|
||||||
(* Excitation.double_of_singles iv iv ; *)
|
|
||||||
|]
|
|
||||||
|
|
||||||
|> Array.map ~f:Excitation.(fun x ->
|
|
||||||
match x with
|
|
||||||
| Single _ -> assert false
|
|
||||||
| Double (x,y,z,t) ->
|
|
||||||
( MO_class.to_bitlist n_int (Hole.to_mo_class x),
|
|
||||||
MO_class.to_bitlist n_int (Particle.to_mo_class y) ,
|
|
||||||
MO_class.to_bitlist n_int (Hole.to_mo_class z),
|
|
||||||
MO_class.to_bitlist n_int (Particle.to_mo_class t) )
|
|
||||||
)
|
|
||||||
in
|
|
||||||
|
|
||||||
let extract_hole (h,_) = h
|
|
||||||
and extract_particle (_,p) = p
|
|
||||||
and extract_hole1 (h,_,_,_) = h
|
|
||||||
and extract_particle1 (_,p,_,_) = p
|
|
||||||
and extract_hole2 (_,_,h,_) = h
|
|
||||||
and extract_particle2 (_,_,_,p) = p
|
|
||||||
in
|
|
||||||
(* --> TODO : This might be wrong *)
|
|
||||||
let result_ref =
|
|
||||||
let core = MO_class.create_inactive core_input in
|
|
||||||
let cv = Excitation.create_single core virt in
|
|
||||||
let cv = match cv with
|
|
||||||
| Excitation.Single (x,y) ->
|
|
||||||
( MO_class.to_bitlist n_int (Excitation.Hole.to_mo_class x),
|
|
||||||
MO_class.to_bitlist n_int (Excitation.Particle.to_mo_class y) )
|
|
||||||
| Excitation.Double _ -> assert false
|
|
||||||
in
|
|
||||||
let iv = match iv with
|
|
||||||
| Excitation.Single (x,y) ->
|
|
||||||
( MO_class.to_bitlist n_int (Excitation.Hole.to_mo_class x),
|
|
||||||
MO_class.to_bitlist n_int (Excitation.Particle.to_mo_class y) )
|
|
||||||
| Excitation.Double _ -> assert false
|
|
||||||
in
|
|
||||||
[ Bitlist.or_operator (extract_hole iv) (extract_hole cv);
|
|
||||||
extract_particle iv ]
|
|
||||||
in
|
|
||||||
(* <-- TODO : This might be wrong *)
|
|
||||||
|
|
||||||
let n_single = Array.length single_excitations in
|
|
||||||
let n_mask = Array.length double_excitations in
|
|
||||||
let zero = List.init (N_int_number.to_int n_int) ~f:(fun i -> 0L)
|
|
||||||
|> Bitlist.of_int64_list in
|
|
||||||
let result_gen = (List.init n_single ~f:(fun i-> [
|
|
||||||
extract_hole single_excitations.(i) ;
|
|
||||||
extract_particle single_excitations.(i) ;
|
|
||||||
extract_hole1 double_excitations.(i) ;
|
|
||||||
extract_particle1 double_excitations.(i) ;
|
|
||||||
extract_hole2 double_excitations.(i) ;
|
|
||||||
extract_particle2 double_excitations.(i) ; ])
|
|
||||||
)@(List.init (n_mask-n_single) ~f:(fun i-> [
|
|
||||||
zero ; zero ;
|
|
||||||
extract_hole1 double_excitations.(n_single+i) ;
|
|
||||||
extract_particle1 double_excitations.(n_single+i) ;
|
|
||||||
extract_hole2 double_excitations.(n_single+i) ;
|
|
||||||
extract_particle2 double_excitations.(n_single+i) ; ])
|
|
||||||
)
|
|
||||||
|> List.concat
|
|
||||||
in
|
|
||||||
|
|
||||||
(* Print bitmasks *)
|
|
||||||
print_endline "Reference Bitmasks:";
|
|
||||||
List.iter ~f:(fun x-> print_endline (Bitlist.to_string x)) result_ref;
|
|
||||||
|
|
||||||
print_endline "Generators Bitmasks:";
|
|
||||||
List.iter ~f:(fun x-> print_endline (Bitlist.to_string x)) result_gen;
|
|
||||||
|
|
||||||
(* Transform to int64 *)
|
|
||||||
let result_gen = List.map ~f:(fun x ->
|
|
||||||
let y = Bitlist.to_int64_list x in y@y )
|
|
||||||
result_gen
|
|
||||||
|> List.concat
|
|
||||||
in
|
|
||||||
let result_ref = List.map ~f:(fun x ->
|
|
||||||
let y = Bitlist.to_int64_list x in y@y )
|
|
||||||
result_ref
|
|
||||||
|> List.concat
|
|
||||||
in
|
|
||||||
|
|
||||||
(* Write generators masks *)
|
|
||||||
Ezfio.set_bitmasks_n_int (N_int_number.to_int n_int);
|
|
||||||
Ezfio.set_bitmasks_bit_kind 8;
|
|
||||||
Ezfio.set_bitmasks_n_mask_gen n_mask;
|
|
||||||
Ezfio.ezfio_array_of_list ~rank:4 ~dim:([| (N_int_number.to_int n_int) ; 2; 6; n_mask|]) ~data:result_gen
|
|
||||||
|> Ezfio.set_bitmasks_generators ;
|
|
||||||
|
|
||||||
(* Write CAS reference masks *)
|
|
||||||
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_ref
|
|
||||||
|> Ezfio.set_bitmasks_cas ;
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
let ezfio_file =
|
|
||||||
let failure filename =
|
|
||||||
eprintf "'%s' is not an EZFIO file.\n%!" filename;
|
|
||||||
exit 1
|
|
||||||
in
|
|
||||||
Command.Spec.Arg_type.create
|
|
||||||
(fun filename ->
|
|
||||||
match Sys.is_directory filename with
|
|
||||||
| `Yes ->
|
|
||||||
begin
|
|
||||||
match Sys.is_file (filename ^ "/.version") with
|
|
||||||
| `Yes -> filename
|
|
||||||
| _ -> failure filename
|
|
||||||
end
|
|
||||||
| _ -> failure filename
|
|
||||||
)
|
|
||||||
;;
|
|
||||||
|
|
||||||
let default range =
|
|
||||||
let failure filename =
|
|
||||||
eprintf "'%s' is not a regular file.\n%!" filename;
|
|
||||||
exit 1
|
|
||||||
in
|
|
||||||
Command.Spec.Arg_type.create
|
|
||||||
(fun filename ->
|
|
||||||
match Sys.is_directory filename with
|
|
||||||
| `Yes ->
|
|
||||||
begin
|
|
||||||
match Sys.is_file (filename^"/.version") with
|
|
||||||
| `Yes -> filename
|
|
||||||
| _ -> failure filename
|
|
||||||
end
|
|
||||||
| _ -> failure filename
|
|
||||||
)
|
|
||||||
;;
|
|
||||||
|
|
||||||
let spec =
|
|
||||||
let open Command.Spec in
|
|
||||||
empty
|
|
||||||
+> flag "core" (optional string) ~doc:"range Range of core orbitals"
|
|
||||||
+> flag "inact" (optional string) ~doc:"range Range of inactive orbitals"
|
|
||||||
+> flag "act" (optional string) ~doc:"range Range of active orbitals"
|
|
||||||
+> flag "virt" (optional string) ~doc:"range Range of virtual orbitals"
|
|
||||||
+> flag "del" (optional string) ~doc:"range Range of deleted orbitals"
|
|
||||||
+> anon ("ezfio_filename" %: ezfio_file)
|
|
||||||
;;
|
|
||||||
|
|
||||||
let command =
|
|
||||||
Command.basic
|
|
||||||
~summary: "Quantum Package command"
|
|
||||||
~readme:(fun () ->
|
|
||||||
"Set the orbital classes in an EZFIO directory
|
|
||||||
The range of MOs has the form : \"[36-53,72-107,126-131]\"
|
|
||||||
")
|
|
||||||
spec
|
|
||||||
(fun core inact act virt del ezfio_filename () -> run ?core ?inact ?act ?virt ?del ezfio_filename )
|
|
||||||
;;
|
|
||||||
|
|
||||||
let () =
|
|
||||||
Command.run command
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
open Qputils;;
|
open Qputils
|
||||||
open Qptypes;;
|
open Qptypes
|
||||||
open Core.Std;;
|
open Core.Std
|
||||||
|
|
||||||
(*
|
(*
|
||||||
* Command-line arguments
|
* Command-line arguments
|
||||||
|
@ -28,7 +28,7 @@ let build_mask from upto n_int =
|
||||||
in
|
in
|
||||||
build_mask starting_bit (n_int*64)
|
build_mask starting_bit (n_int*64)
|
||||||
|> List.rev
|
|> List.rev
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
|
@ -38,7 +38,7 @@ type t =
|
||||||
| Virtual
|
| Virtual
|
||||||
| Deleted
|
| Deleted
|
||||||
| None
|
| None
|
||||||
;;
|
|
||||||
|
|
||||||
let t_to_string = function
|
let t_to_string = function
|
||||||
| Core -> "core"
|
| Core -> "core"
|
||||||
|
@ -47,7 +47,7 @@ let t_to_string = function
|
||||||
| Virtual -> "virtual"
|
| Virtual -> "virtual"
|
||||||
| Deleted -> "deleted"
|
| Deleted -> "deleted"
|
||||||
| None -> assert false
|
| None -> assert false
|
||||||
;;
|
|
||||||
|
|
||||||
let set ~core ~inact ~act ~virt ~del =
|
let set ~core ~inact ~act ~virt ~del =
|
||||||
|
|
||||||
|
@ -193,51 +193,66 @@ let set ~core ~inact ~act ~virt ~del =
|
||||||
in
|
in
|
||||||
Ezfio.set_bitmasks_n_mask_cas 1;
|
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
|
Ezfio.ezfio_array_of_list ~rank:3 ~dim:([| (N_int_number.to_int n_int) ; 2; 1|]) ~data:result
|
||||||
|> Ezfio.set_bitmasks_cas;
|
|> Ezfio.set_bitmasks_cas
|
||||||
;;
|
|
||||||
|
|
||||||
let get () =
|
let get () =
|
||||||
|
let data =
|
||||||
|
match Input.Mo_basis.read () with
|
||||||
|
| None -> failwith "Unable to read MOs"
|
||||||
|
| Some x -> x
|
||||||
|
in
|
||||||
|
|
||||||
let mo_tot_num =
|
let mo_tot_num =
|
||||||
Ezfio.get_mo_basis_mo_tot_num ()
|
MO_number.to_int data.Input_mo_basis.mo_tot_num
|
||||||
in
|
in
|
||||||
|
|
||||||
let n_int =
|
let n_int =
|
||||||
try N_int_number.of_int (Ezfio.get_determinants_n_int ())
|
try N_int_number.of_int (Ezfio.get_determinants_n_int ())
|
||||||
with _ -> Bitlist.n_int_of_mo_tot_num mo_tot_num
|
with _ -> Bitlist.n_int_of_mo_tot_num mo_tot_num
|
||||||
in
|
|
||||||
|
|
||||||
let bitmasks =
|
|
||||||
match Input.Bitmasks.read () with
|
|
||||||
| Some x -> x
|
|
||||||
| None -> failwith "No data to print"
|
|
||||||
in
|
|
||||||
assert (bitmasks.Input.Bitmasks.n_mask_gen |> Bitmask_number.to_int = 1);
|
|
||||||
assert (bitmasks.Input.Bitmasks.n_mask_cas |> Bitmask_number.to_int = 1);
|
|
||||||
|
|
||||||
let (generators,cas) =
|
|
||||||
Bitlist.of_int64_array bitmasks.Input.Bitmasks.generators,
|
|
||||||
Bitlist.of_int64_array bitmasks.Input.Bitmasks.cas
|
|
||||||
in
|
in
|
||||||
|
|
||||||
Printf.printf "MO : %d\n" mo_tot_num;
|
Printf.printf "MO : %d\n" mo_tot_num;
|
||||||
Printf.printf "n_int: %d\n" (N_int_number.to_int n_int);
|
Printf.printf "n_int: %d\n" (N_int_number.to_int n_int);
|
||||||
Printf.printf "Gen : %s\nCAS : %s\n"
|
|
||||||
(Bitlist.to_string generators)
|
|
||||||
(Bitlist.to_string cas)
|
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
let run ~print ?(core="[]") ?(inact="[]") ?(act="[]") ?(virt="[]") ?(del="[]") ezfio_filename =
|
let rec work ?(core="[") ?(inact="[") ?(act="[") ?(virt="[") ?(del="[") i l =
|
||||||
|
match l with
|
||||||
|
| [] ->
|
||||||
|
let (core, inact, act, virt, del) =
|
||||||
|
(core ^"]",
|
||||||
|
inact ^"]",
|
||||||
|
act ^"]",
|
||||||
|
virt ^"]",
|
||||||
|
del ^"]")
|
||||||
|
in
|
||||||
|
set ~core ~inact ~act ~virt ~del
|
||||||
|
| (MO_class.Core _) :: rest ->
|
||||||
|
work ~core:(Printf.sprintf "%s,%d" core i) ~inact ~act ~virt ~del (i-1) rest
|
||||||
|
| (MO_class.Inactive _) :: rest ->
|
||||||
|
work ~inact:(Printf.sprintf "%s,%d" inact i) ~core ~act ~virt ~del (i-1) rest
|
||||||
|
| (MO_class.Active _) :: rest ->
|
||||||
|
work ~act:(Printf.sprintf "%s,%d" act i) ~inact ~core ~virt ~del (i-1) rest
|
||||||
|
| (MO_class.Virtual _) :: rest ->
|
||||||
|
work ~virt:(Printf.sprintf "%s,%d" virt i) ~inact ~act ~core ~del (i-1) rest
|
||||||
|
| (MO_class.Deleted _) :: rest ->
|
||||||
|
work ~del:(Printf.sprintf "%s,%d" del i) ~inact ~act ~virt ~core (i-1) rest
|
||||||
|
in
|
||||||
|
work (Array.length data.Input_mo_basis.mo_class) (Array.to_list data.Input_mo_basis.mo_class)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let run ~q ?(core="[]") ?(inact="[]") ?(act="[]") ?(virt="[]") ?(del="[]") ezfio_filename =
|
||||||
|
|
||||||
Ezfio.set_file ezfio_filename ;
|
Ezfio.set_file ezfio_filename ;
|
||||||
if not (Ezfio.has_mo_basis_mo_tot_num ()) then
|
if not (Ezfio.has_mo_basis_mo_tot_num ()) then
|
||||||
failwith "mo_basis/mo_tot_num not found" ;
|
failwith "mo_basis/mo_tot_num not found" ;
|
||||||
|
|
||||||
if print then
|
if q then
|
||||||
get ()
|
get ()
|
||||||
else
|
else
|
||||||
set ~core ~inact ~act ~virt ~del
|
set ~core ~inact ~act ~virt ~del
|
||||||
;;
|
|
||||||
|
|
||||||
let ezfio_file =
|
let ezfio_file =
|
||||||
let failure filename =
|
let failure filename =
|
||||||
|
@ -255,7 +270,7 @@ let ezfio_file =
|
||||||
end
|
end
|
||||||
| _ -> failure filename
|
| _ -> failure filename
|
||||||
)
|
)
|
||||||
;;
|
|
||||||
|
|
||||||
let default range =
|
let default range =
|
||||||
let failure filename =
|
let failure filename =
|
||||||
|
@ -273,7 +288,7 @@ let default range =
|
||||||
end
|
end
|
||||||
| _ -> failure filename
|
| _ -> failure filename
|
||||||
)
|
)
|
||||||
;;
|
|
||||||
|
|
||||||
let spec =
|
let spec =
|
||||||
let open Command.Spec in
|
let open Command.Spec in
|
||||||
|
@ -283,9 +298,9 @@ let spec =
|
||||||
+> flag "act" (optional string) ~doc:"range Range of active orbitals"
|
+> flag "act" (optional string) ~doc:"range Range of active orbitals"
|
||||||
+> flag "virt" (optional string) ~doc:"range Range of virtual orbitals"
|
+> flag "virt" (optional string) ~doc:"range Range of virtual orbitals"
|
||||||
+> flag "del" (optional string) ~doc:"range Range of deleted orbitals"
|
+> flag "del" (optional string) ~doc:"range Range of deleted orbitals"
|
||||||
+> flag "print" no_arg ~doc:" Print the current masks"
|
+> flag "q" no_arg ~doc:" Query: print the current masks"
|
||||||
+> anon ("ezfio_filename" %: ezfio_file)
|
+> anon ("ezfio_filename" %: ezfio_file)
|
||||||
;;
|
|
||||||
|
|
||||||
let command =
|
let command =
|
||||||
Command.basic
|
Command.basic
|
||||||
|
@ -295,8 +310,8 @@ let command =
|
||||||
The range of MOs has the form : \"[36-53,72-107,126-131]\"
|
The range of MOs has the form : \"[36-53,72-107,126-131]\"
|
||||||
")
|
")
|
||||||
spec
|
spec
|
||||||
(fun core inact act virt del print ezfio_filename () -> run ~print ?core ?inact ?act ?virt ?del ezfio_filename )
|
(fun core inact act virt del q ezfio_filename () -> run ~q ?core ?inact ?act ?virt ?del ezfio_filename )
|
||||||
;;
|
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
Command.run command
|
Command.run command
|
||||||
|
|
|
@ -183,6 +183,8 @@ def get_type_dict():
|
||||||
str_ocaml_type,
|
str_ocaml_type,
|
||||||
str_fortran_type)
|
str_fortran_type)
|
||||||
|
|
||||||
|
fancy_type["MO_class"] = Type("MO_class", "MO_class", "character*(32)")
|
||||||
|
|
||||||
# ~#~#~#~#~#~#~#~ #
|
# ~#~#~#~#~#~#~#~ #
|
||||||
# F i n a l i z e #
|
# F i n a l i z e #
|
||||||
# ~#~#~#~#~#~#~#~ #
|
# ~#~#~#~#~#~#~#~ #
|
||||||
|
|
|
@ -21,8 +21,8 @@ interface: ezfio
|
||||||
size: (mo_basis.mo_tot_num)
|
size: (mo_basis.mo_tot_num)
|
||||||
|
|
||||||
[mo_class]
|
[mo_class]
|
||||||
type: character*(32)
|
type: MO_class
|
||||||
doc: c: core, i: inactive, a: active, v: virtual, d: deleted
|
doc: Core|Inactive|Active|Virtual|Deleted
|
||||||
interface: ezfio, provider
|
interface: ezfio, provider
|
||||||
size: (mo_basis.mo_tot_num)
|
size: (mo_basis.mo_tot_num)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user