mirror of
https://github.com/LCPQ/quantum_package
synced 2024-12-31 16:45:54 +01:00
Working on ocaml input
This commit is contained in:
parent
844553e9e2
commit
161e54ad15
@ -5,5 +5,6 @@ open Core.Std;;
|
||||
|
||||
include Input_ao_basis;;
|
||||
include Input_bi_integrals;;
|
||||
include Input_bitmasks;;
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@ end = struct
|
||||
}
|
||||
;;
|
||||
|
||||
let get_default = Qpackage.get_ezfio_default "ao_basis";;
|
||||
|
||||
let read_ao_basis () =
|
||||
if not (Ezfio.has_ao_basis_ao_basis ()) then
|
||||
Ezfio.set_ao_basis_ao_basis ""
|
||||
|
100
ocaml/Input_bitmasks.ml
Normal file
100
ocaml/Input_bitmasks.ml
Normal file
@ -0,0 +1,100 @@
|
||||
open Qptypes;;
|
||||
open Qputils;;
|
||||
open Core.Std;;
|
||||
|
||||
module Bitmasks : sig
|
||||
type t
|
||||
val read : unit -> t
|
||||
val to_string : t -> string
|
||||
end = struct
|
||||
type t =
|
||||
{ n_int : N_int_number.t;
|
||||
bit_kind : Bit_kind.t;
|
||||
n_mask_gen : Strictly_positive_int.t;
|
||||
generators : int64 array;
|
||||
(*
|
||||
n_mask_ref : Strictly_positive_int.t;
|
||||
reference : int64 array;
|
||||
*)
|
||||
}
|
||||
;;
|
||||
|
||||
let get_default = Qpackage.get_ezfio_default "bitmasks";;
|
||||
|
||||
let read_n_int () =
|
||||
if not (Ezfio.has_bitmasks_n_int()) then
|
||||
Ezfio.get_mo_basis_mo_tot_num ()
|
||||
|> Bitlist.n_int_of_mo_tot_num
|
||||
|> N_int_number.to_int
|
||||
|> Ezfio.set_bitmasks_n_int
|
||||
;
|
||||
Ezfio.get_bitmasks_n_int ()
|
||||
|> N_int_number.of_int
|
||||
;;
|
||||
|
||||
let read_bit_kind () =
|
||||
if not (Ezfio.has_bitmasks_bit_kind ()) then
|
||||
Lazy.force Qpackage.bit_kind
|
||||
|> Bit_kind.to_int
|
||||
|> Ezfio.set_bitmasks_bit_kind
|
||||
;
|
||||
Ezfio.get_bitmasks_bit_kind ()
|
||||
|> Bit_kind.of_int
|
||||
;;
|
||||
|
||||
let read_n_mask_gen () =
|
||||
if not (Ezfio.has_bitmasks_n_mask_gen ()) then
|
||||
Ezfio.set_bitmasks_n_mask_gen 1
|
||||
;
|
||||
Ezfio.get_bitmasks_n_mask_gen ()
|
||||
|> Strictly_positive_int.of_int
|
||||
;;
|
||||
|
||||
|
||||
let read_generators () =
|
||||
if not (Ezfio.has_bitmasks_generators ()) then
|
||||
begin
|
||||
let n_int = read_n_int () in
|
||||
let range = "[1-"^
|
||||
(Int.to_string (Ezfio.get_mo_basis_mo_tot_num ()))^"]" in
|
||||
let act = MO_class.create_active range
|
||||
|> MO_class.to_bitlist n_int
|
||||
in
|
||||
let result = [ act ; act ; act ; act ; act ; act ]
|
||||
|> List.map ~f:(fun x ->
|
||||
let y = Bitlist.to_int64_list x in y@y )
|
||||
|> List.concat
|
||||
in
|
||||
let generators = Ezfio.ezfio_array_of_list ~rank:4
|
||||
~dim:([| (N_int_number.to_int n_int) ; 2; 6; 1|]) ~data:result
|
||||
in
|
||||
Ezfio.set_bitmasks_generators generators
|
||||
end;
|
||||
(Ezfio.get_bitmasks_generators ()).Ezfio.data
|
||||
|> Ezfio.flattened_ezfio_data
|
||||
;;
|
||||
|
||||
let read () =
|
||||
{ n_int = read_n_int ();
|
||||
bit_kind = read_bit_kind ();
|
||||
n_mask_gen = read_n_mask_gen ();
|
||||
generators = read_generators ();
|
||||
}
|
||||
;;
|
||||
|
||||
let to_string b =
|
||||
Printf.sprintf "
|
||||
n_int = %s
|
||||
bit_kind = %s
|
||||
n_mask_gen = %s
|
||||
generators = %s
|
||||
"
|
||||
(N_int_number.to_string b.n_int)
|
||||
(Bit_kind.to_string b.bit_kind)
|
||||
(Strictly_positive_int.to_string b.n_mask_gen)
|
||||
(Array.to_list b.generators
|
||||
|> List.map ~f:(fun x-> Int64.to_string x)
|
||||
|> String.concat ~sep:", ")
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,7 @@ Please source the quantum_package.rc file."
|
||||
;;
|
||||
|
||||
let bit_kind_size = lazy (
|
||||
let filename = root / "src/Bitmask/bitmasks_module.f90" in
|
||||
let filename = root^"/src/Bitmask/bitmasks_module.f90" in
|
||||
if not (Sys.file_exists_exn filename) then
|
||||
raise (Failure ("File "^filename^" not found"));
|
||||
|
||||
@ -41,8 +41,16 @@ let bit_kind_size = lazy (
|
||||
get_data lines )
|
||||
;;
|
||||
|
||||
let bit_kind = lazy (
|
||||
Lazy.force bit_kind_size
|
||||
|> Bit_kind_size.to_int
|
||||
|> fun x -> x / 8
|
||||
|> Bit_kind.of_int
|
||||
)
|
||||
;;
|
||||
|
||||
let executables = lazy (
|
||||
let filename = root / "data/executables"
|
||||
let filename = root^"/data/executables"
|
||||
and func in_channel =
|
||||
In_channel.input_lines in_channel
|
||||
|> List.map ~f:(fun x ->
|
||||
@ -64,7 +72,7 @@ let executables = lazy (
|
||||
|
||||
|
||||
let get_ezfio_default directory data =
|
||||
let filename = root / "data/ezfio_defaults" in
|
||||
let filename = root^"/data/ezfio_defaults" in
|
||||
let lines = In_channel.with_file filename ~f:(fun in_channel ->
|
||||
In_channel.input_lines in_channel) in
|
||||
let rec find_dir = function
|
||||
|
@ -1,5 +1,3 @@
|
||||
let (/) (a:string) (b:string) = a^"/"^b;;
|
||||
|
||||
let rec transpose = function
|
||||
| [] -> []
|
||||
| []::tail -> transpose tail
|
||||
|
@ -21,7 +21,7 @@ let run ?o b c m xyz_file =
|
||||
(* Open basis set channel *)
|
||||
let basis_channel =
|
||||
In_channel.create
|
||||
(Qpackage.root / "data/basis" / (String.lowercase b))
|
||||
(Qpackage.root ^ "/data/basis/" ^ (String.lowercase b))
|
||||
in
|
||||
|
||||
(* Read molecule *)
|
||||
|
@ -20,15 +20,15 @@ let run exe ezfio_file =
|
||||
Printf.printf "===============\nQuantum Package\n===============\n\n";
|
||||
Printf.printf "Date : %s\n\n%!" (Time.to_string time_start);
|
||||
|
||||
let output_dir = ezfio_file / "output" in
|
||||
let output_dir = ezfio_file^"/output" in
|
||||
if (Sys.file_exists_exn output_dir) then
|
||||
begin
|
||||
Sys.ls_dir output_dir
|
||||
|> List.iter ~f:(fun x -> Sys.remove (output_dir / x));
|
||||
|> List.iter ~f:(fun x -> Sys.remove (output_dir^"/"^x));
|
||||
Unix.rmdir output_dir
|
||||
end;
|
||||
|
||||
let fifo_name = ezfio_file / ".fifo" in
|
||||
let fifo_name = ezfio_file^"/.fifo" in
|
||||
if (Sys.file_exists_exn fifo_name) then
|
||||
Sys.remove fifo_name;
|
||||
Unix.mkfifo ~perm:0o664 fifo_name;
|
||||
|
@ -195,7 +195,7 @@ let ezfio_file =
|
||||
match Sys.is_directory filename with
|
||||
| `Yes ->
|
||||
begin
|
||||
match Sys.is_file (filename / ".version") with
|
||||
match Sys.is_file (filename ^ "/.version") with
|
||||
| `Yes -> filename
|
||||
| _ -> failure filename
|
||||
end
|
||||
@ -213,7 +213,7 @@ let default range =
|
||||
match Sys.is_directory filename with
|
||||
| `Yes ->
|
||||
begin
|
||||
match Sys.is_file (filename / ".version") with
|
||||
match Sys.is_file (filename^"/.version") with
|
||||
| `Yes -> filename
|
||||
| _ -> failure filename
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ let test_module () =
|
||||
|
||||
let basis_channel =
|
||||
let b = "cc-pvdz" in
|
||||
In_channel.create (Qpackage.root / "data/basis" / (String.lowercase b))
|
||||
In_channel.create (Qpackage.root^"/data/basis/"^(String.lowercase b))
|
||||
in
|
||||
|
||||
let molecule =
|
||||
|
@ -12,4 +12,11 @@ let test_bielec_intergals () =
|
||||
print_endline (Input.Bielec_integrals.to_string b);
|
||||
;;
|
||||
|
||||
test_bielec_intergals ();;
|
||||
let test_bitmasks () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Bitmasks.read ()
|
||||
in
|
||||
print_endline (Input.Bitmasks.to_string b);
|
||||
;;
|
||||
|
||||
test_bitmasks ();;
|
||||
|
Loading…
Reference in New Issue
Block a user