10
0
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:
Anthony Scemama 2017-06-13 12:20:55 +02:00
parent b65846597a
commit e986a3cd44
7 changed files with 209 additions and 457 deletions

View File

@ -1,32 +1,32 @@
open Qptypes;;
open Qputils;;
open Core.Std;;
open Qptypes
open Qputils
open Core.Std
type t_mo =
{ mo_tot_num : MO_number.t ;
mo_label : MO_label.t;
mo_occ : MO_occ.t array;
mo_coef : (MO_coef.t array) array;
ao_md5 : MD5.t;
} with sexp
{ mo_tot_num : MO_number.t ;
mo_label : MO_label.t;
mo_class : MO_class.t array;
mo_occ : MO_occ.t array;
mo_coef : (MO_coef.t array) array;
ao_md5 : MD5.t;
} with sexp
module Mo_basis : sig
type t = t_mo
type t = t_mo
val read : unit -> t option
val to_string : t -> string
val to_rst : t -> Rst_string.t
end = struct
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 () =
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 ()
|> MO_label.of_string
;;
let read_ao_md5 () =
let ao_md5 =
@ -46,12 +46,28 @@ end = struct
if (ao_md5 <> result) then
failwith "The current MOs don't correspond to the current AOs.";
result
;;
let read_mo_tot_num () =
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
@ -60,41 +76,42 @@ end = struct
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
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
|> 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
)
;;
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_occ = read_mo_occ ();
mo_coef = read_mo_coef ();
ao_md5 = read_ao_md5 ();
}
{ 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)
@ -102,53 +119,53 @@ end = struct
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 ->
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
(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 ->
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
(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 ->
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
(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 ->
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
(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 ->
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
(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 =
@ -158,7 +175,7 @@ end = struct
(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 "
@ -174,29 +191,32 @@ 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)
(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_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" )
;;
(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

View File

@ -1,46 +1,63 @@
open Core.Std;;
open Qptypes ;;
open Core.Std
open Qptypes
type t =
| Core of MO_number.t list
| Inactive of MO_number.t list
| Active of MO_number.t list
| Virtual of MO_number.t list
| Deleted of MO_number.t list
| Core of MO_number.t list
| Inactive of MO_number.t list
| Active of MO_number.t list
| Virtual of MO_number.t list
| Deleted of MO_number.t list
with sexp
let to_string x =
let print_list l =
let s = List.map ~f:(fun x-> MO_number.to_int x |> string_of_int )l
|> (String.concat ~sep:", ")
|> (String.concat ~sep:", ")
in
"("^s^")"
in
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)
| Active l -> "Active : "^(print_list l)
| Virtual l -> "Virtual : "^(print_list l)
| Deleted l -> "Deleted : "^(print_list l)
;;
| Active l -> "Active : "^(print_list l)
| Virtual l -> "Virtual : "^(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 =
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 =
match x with
| Core l
| Inactive l
| Active l
| Virtual l
| Deleted l -> Bitlist.of_mo_number_list n_int l
;;
match x with
| Core l
| Inactive l
| Active l
| Virtual l
| Deleted l -> Bitlist.of_mo_number_list n_int l

View File

@ -19,3 +19,6 @@ val to_bitlist : Qptypes.N_int_number.t -> t -> Bitlist.t
(** Convert to string for printing *)
val to_string : t -> string
val of_string : string -> t

View File

@ -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

View File

@ -1,6 +1,6 @@
open Qputils;;
open Qptypes;;
open Core.Std;;
open Qputils
open Qptypes
open Core.Std
(*
* Command-line arguments
@ -28,7 +28,7 @@ let build_mask from upto n_int =
in
build_mask starting_bit (n_int*64)
|> List.rev
;;
type t =
@ -38,7 +38,7 @@ type t =
| Virtual
| Deleted
| None
;;
let t_to_string = function
| Core -> "core"
@ -47,7 +47,7 @@ let t_to_string = function
| Virtual -> "virtual"
| Deleted -> "deleted"
| None -> assert false
;;
let set ~core ~inact ~act ~virt ~del =
@ -193,51 +193,66 @@ let set ~core ~inact ~act ~virt ~del =
in
Ezfio.set_bitmasks_n_mask_cas 1;
Ezfio.ezfio_array_of_list ~rank:3 ~dim:([| (N_int_number.to_int n_int) ; 2; 1|]) ~data:result
|> Ezfio.set_bitmasks_cas;
;;
|> Ezfio.set_bitmasks_cas
let get () =
let data =
match Input.Mo_basis.read () with
| None -> failwith "Unable to read MOs"
| Some x -> x
in
let mo_tot_num =
Ezfio.get_mo_basis_mo_tot_num ()
MO_number.to_int data.Input_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 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
try N_int_number.of_int (Ezfio.get_determinants_n_int ())
with _ -> Bitlist.n_int_of_mo_tot_num mo_tot_num
in
Printf.printf "MO : %d\n" mo_tot_num;
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 ;
if not (Ezfio.has_mo_basis_mo_tot_num ()) then
failwith "mo_basis/mo_tot_num not found" ;
if print then
if q then
get ()
else
set ~core ~inact ~act ~virt ~del
;;
let ezfio_file =
let failure filename =
@ -255,7 +270,7 @@ let ezfio_file =
end
| _ -> failure filename
)
;;
let default range =
let failure filename =
@ -273,7 +288,7 @@ let default range =
end
| _ -> failure filename
)
;;
let spec =
let open Command.Spec in
@ -283,9 +298,9 @@ let spec =
+> 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"
+> flag "print" no_arg ~doc:" Print the current masks"
+> flag "q" no_arg ~doc:" Query: print the current masks"
+> anon ("ezfio_filename" %: ezfio_file)
;;
let command =
Command.basic
@ -295,8 +310,8 @@ let command =
The range of MOs has the form : \"[36-53,72-107,126-131]\"
")
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 () =
Command.run command

View File

@ -183,6 +183,8 @@ def get_type_dict():
str_ocaml_type,
str_fortran_type)
fancy_type["MO_class"] = Type("MO_class", "MO_class", "character*(32)")
# ~#~#~#~#~#~#~#~ #
# F i n a l i z e #
# ~#~#~#~#~#~#~#~ #

View File

@ -21,8 +21,8 @@ interface: ezfio
size: (mo_basis.mo_tot_num)
[mo_class]
type: character*(32)
doc: c: core, i: inactive, a: active, v: virtual, d: deleted
type: MO_class
doc: Core|Inactive|Active|Virtual|Deleted
interface: ezfio, provider
size: (mo_basis.mo_tot_num)