mirror of
https://github.com/LCPQ/quantum_package
synced 2025-01-03 01:56:05 +01:00
Introduced mo_class in EZFIO
This commit is contained in:
parent
b65846597a
commit
e986a3cd44
@ -1,10 +1,11 @@
|
||||
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_class : MO_class.t array;
|
||||
mo_occ : MO_occ.t array;
|
||||
mo_coef : (MO_coef.t array) array;
|
||||
ao_md5 : MD5.t;
|
||||
@ -17,8 +18,7 @@ module Mo_basis : sig
|
||||
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
|
||||
@ -26,7 +26,7 @@ end = struct
|
||||
;
|
||||
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
|
||||
@ -69,7 +85,7 @@ end = struct
|
||||
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 ()
|
||||
@ -81,20 +97,21 @@ end = struct
|
||||
Array.init mo_tot_num ~f:(fun j ->
|
||||
Array.sub ~pos:(j*ao_num) ~len:(ao_num) a
|
||||
)
|
||||
;;
|
||||
|
||||
|
||||
let read () =
|
||||
if (Ezfio.has_mo_basis_mo_tot_num ()) then
|
||||
Some
|
||||
{ mo_tot_num = read_mo_tot_num ();
|
||||
mo_label = read_mo_label () ;
|
||||
mo_class = read_mo_class ();
|
||||
mo_occ = read_mo_occ ();
|
||||
mo_coef = read_mo_coef ();
|
||||
ao_md5 = read_ao_md5 ();
|
||||
}
|
||||
else
|
||||
None
|
||||
;;
|
||||
|
||||
|
||||
let mo_coef_to_string mo_coef =
|
||||
let ao_num = Array.length mo_coef.(0)
|
||||
@ -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 "
|
||||
@ -179,24 +196,27 @@ MO coefficients ::
|
||||
(mo_coef_to_string b.mo_coef)
|
||||
|> Rst_string.of_string
|
||||
|
||||
;;
|
||||
|
||||
|
||||
let to_string b =
|
||||
Printf.sprintf "
|
||||
mo_label = %s
|
||||
mo_tot_num = \"%s\"
|
||||
mo_clas = %s
|
||||
mo_occ = %s
|
||||
mo_coef = %s
|
||||
"
|
||||
(MO_label.to_string b.mo_label)
|
||||
(MO_number.to_string b.mo_tot_num)
|
||||
(b.mo_class |> Array.to_list |> List.map
|
||||
~f:(MO_class.to_string) |> String.concat ~sep:", " )
|
||||
(b.mo_occ |> Array.to_list |> List.map
|
||||
~f:(MO_occ.to_string) |> String.concat ~sep:", " )
|
||||
(b.mo_coef |> Array.map
|
||||
~f:(fun x-> Array.map ~f:MO_coef.to_string x |> String.concat_array
|
||||
~sep:"," ) |>
|
||||
String.concat_array ~sep:"\n" )
|
||||
;;
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
open Core.Std;;
|
||||
open Qptypes ;;
|
||||
open Core.Std
|
||||
open Qptypes
|
||||
|
||||
type t =
|
||||
| Core of MO_number.t list
|
||||
@ -19,22 +19,38 @@ let to_string x =
|
||||
in
|
||||
|
||||
match x with
|
||||
| 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)
|
||||
;;
|
||||
|
||||
|
||||
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
|
||||
;;
|
||||
|
||||
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
|
||||
@ -43,4 +59,5 @@ let to_bitlist n_int x =
|
||||
| Active l
|
||||
| Virtual 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 *)
|
||||
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 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
|
||||
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
|
||||
|
@ -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 #
|
||||
# ~#~#~#~#~#~#~#~ #
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user