mirror of
https://github.com/LCPQ/quantum_package
synced 2025-04-16 05:29:35 +02:00
Added Input_electrons.ml
This commit is contained in:
parent
c1cbf80080
commit
64022d88d7
@ -9,5 +9,6 @@ include Input_bitmasks;;
|
|||||||
include Input_cis;;
|
include Input_cis;;
|
||||||
include Input_cisd_sc2;;
|
include Input_cisd_sc2;;
|
||||||
include Input_determinants;;
|
include Input_determinants;;
|
||||||
|
include Input_electrons;;
|
||||||
|
|
||||||
|
|
||||||
|
60
ocaml/Input_electrons.ml
Normal file
60
ocaml/Input_electrons.ml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
open Qptypes;;
|
||||||
|
open Qputils;;
|
||||||
|
open Core.Std;;
|
||||||
|
|
||||||
|
module Electrons : sig
|
||||||
|
type t =
|
||||||
|
{ elec_alpha_num : Strictly_positive_int.t;
|
||||||
|
elec_beta_num : Positive_int.t;
|
||||||
|
elec_num : Strictly_positive_int.t;
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
val read : unit -> t
|
||||||
|
val to_string : t -> string
|
||||||
|
end = struct
|
||||||
|
type t =
|
||||||
|
{ elec_alpha_num : Strictly_positive_int.t;
|
||||||
|
elec_beta_num : Positive_int.t;
|
||||||
|
elec_num : Strictly_positive_int.t;
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
|
||||||
|
let get_default = Qpackage.get_ezfio_default "electrons";;
|
||||||
|
|
||||||
|
let read_elec_alpha_num() =
|
||||||
|
Ezfio.get_electrons_elec_alpha_num ()
|
||||||
|
|> Strictly_positive_int.of_int
|
||||||
|
;;
|
||||||
|
|
||||||
|
let read_elec_beta_num() =
|
||||||
|
Ezfio.get_electrons_elec_beta_num ()
|
||||||
|
|> Positive_int.of_int
|
||||||
|
;;
|
||||||
|
|
||||||
|
let read_elec_num () =
|
||||||
|
let na = Ezfio.get_electrons_elec_alpha_num ()
|
||||||
|
and nb = Ezfio.get_electrons_elec_beta_num ()
|
||||||
|
in assert (na >= nb);
|
||||||
|
Strictly_positive_int.of_int (na + nb)
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
let read () =
|
||||||
|
{ elec_alpha_num = read_elec_alpha_num ();
|
||||||
|
elec_beta_num = read_elec_beta_num ();
|
||||||
|
elec_num = read_elec_num ();
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
|
||||||
|
let to_string b =
|
||||||
|
Printf.sprintf "
|
||||||
|
elec_alpha_num = %s
|
||||||
|
elec_beta_num = %s
|
||||||
|
elec_num = %s
|
||||||
|
"
|
||||||
|
(Strictly_positive_int.to_string b.elec_alpha_num)
|
||||||
|
(Positive_int.to_string b.elec_beta_num)
|
||||||
|
(Strictly_positive_int.to_string b.elec_num)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
@ -19,7 +19,10 @@ let get_charge { nuclei ; elec_alpha ; elec_beta } =
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
let get_multiplicity m =
|
let get_multiplicity m =
|
||||||
Multiplicity.of_alpha_beta m.elec_alpha m.elec_beta
|
let elec_alpha = m.elec_alpha
|
||||||
|
|> Positive_int.to_int
|
||||||
|
|> Strictly_positive_int.of_int in
|
||||||
|
Multiplicity.of_alpha_beta elec_alpha m.elec_beta
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let get_nucl_num m =
|
let get_nucl_num m =
|
||||||
|
@ -19,7 +19,7 @@ let to_string m =
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
let of_alpha_beta a b =
|
let of_alpha_beta a b =
|
||||||
let a = Positive_int.to_int a
|
let a = Strictly_positive_int.to_int a
|
||||||
and b = Positive_int.to_int b
|
and b = Positive_int.to_int b
|
||||||
in
|
in
|
||||||
assert (a >= b);
|
assert (a >= b);
|
||||||
|
@ -51,16 +51,20 @@ let run_i ~action ezfio_filename =
|
|||||||
|
|
||||||
|
|
||||||
let compute_charge () =
|
let compute_charge () =
|
||||||
|
let input = Input.Electrons.read () in
|
||||||
let nucl_charge = Ezfio.((get_nuclei_nucl_charge ()).data)
|
let nucl_charge = Ezfio.((get_nuclei_nucl_charge ()).data)
|
||||||
|> Ezfio.flattened_ezfio_data |> Array.map ~f:(Float.to_int)
|
|> Ezfio.flattened_ezfio_data |> Array.map ~f:(Float.to_int)
|
||||||
and n_alpha = Ezfio.get_electrons_elec_alpha_num ()
|
and n_alpha = input.Input.Electrons.elec_alpha_num
|
||||||
and n_beta = Ezfio.get_electrons_elec_beta_num ()
|
|> Strictly_positive_int.to_int
|
||||||
|
and n_beta = input.Input.Electrons.elec_beta_num
|
||||||
|
|> Positive_int.to_int
|
||||||
in Array.fold ~init:(-n_alpha-n_beta) ~f:(fun x y -> x+y) nucl_charge
|
in Array.fold ~init:(-n_alpha-n_beta) ~f:(fun x y -> x+y) nucl_charge
|
||||||
in
|
in
|
||||||
|
|
||||||
let compute_multiplicity () =
|
let compute_multiplicity () =
|
||||||
let n_alpha = Positive_int.of_int (Ezfio.get_electrons_elec_alpha_num ())
|
let input = Input.Electrons.read () in
|
||||||
and n_beta = Positive_int.of_int (Ezfio.get_electrons_elec_beta_num ())
|
let n_alpha = input.Input.Electrons.elec_alpha_num
|
||||||
|
and n_beta = input.Input.Electrons.elec_beta_num
|
||||||
in Multiplicity.of_alpha_beta n_alpha n_beta
|
in Multiplicity.of_alpha_beta n_alpha n_beta
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -139,10 +143,10 @@ Prints data contained into the EZFIO file.
|
|||||||
Input data :
|
Input data :
|
||||||
|
|
||||||
* basis
|
* basis
|
||||||
* nuclei
|
* nucl
|
||||||
* charge
|
* charge
|
||||||
* multiplicity
|
* mult
|
||||||
* electrons
|
* elec
|
||||||
|
|
||||||
Output data :
|
Output data :
|
||||||
|
|
||||||
@ -150,6 +154,7 @@ Output data :
|
|||||||
")
|
")
|
||||||
spec
|
spec
|
||||||
(fun i o ezfio_file () ->
|
(fun i o ezfio_file () ->
|
||||||
|
try
|
||||||
match (i,o) with
|
match (i,o) with
|
||||||
| (Some i, None) -> run_i ~action:i ezfio_file
|
| (Some i, None) -> run_i ~action:i ezfio_file
|
||||||
| (None, Some o) -> run_o ~action:o ezfio_file
|
| (None, Some o) -> run_o ~action:o ezfio_file
|
||||||
@ -157,6 +162,9 @@ Output data :
|
|||||||
raise (Failure "Error : please specify -i or -o but not both.")
|
raise (Failure "Error : please specify -i or -o but not both.")
|
||||||
| (None, None) ->
|
| (None, None) ->
|
||||||
raise (Failure "Error : please specify -i or -o.")
|
raise (Failure "Error : please specify -i or -o.")
|
||||||
|
with
|
||||||
|
| Failure msg -> print_string ("Error\n"^msg)
|
||||||
|
| _ -> ()
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ let () =
|
|||||||
Command.basic
|
Command.basic
|
||||||
~summary: "Quantum Package command"
|
~summary: "Quantum Package command"
|
||||||
~readme:( fun () -> "
|
~readme:( fun () -> "
|
||||||
Executes a Quantum Package binary file among these:\ni\n"
|
Executes a Quantum Package binary file among these:\n\n"
|
||||||
^ (Lazy.force Qpackage.executables
|
^ (Lazy.force Qpackage.executables
|
||||||
|> List.map ~f:(fun (x,_) -> Printf.sprintf " * %s" x )
|
|> List.map ~f:(fun (x,_) -> Printf.sprintf " * %s" x )
|
||||||
|> String.concat ~sep:"\n"
|
|> String.concat ~sep:"\n"
|
||||||
|
@ -40,4 +40,11 @@ let test_cisd_sc2 () =
|
|||||||
print_endline (Input.Cisd_sc2.to_string b);
|
print_endline (Input.Cisd_sc2.to_string b);
|
||||||
;;
|
;;
|
||||||
|
|
||||||
test_cisd_sc2();;
|
let test_electrons () =
|
||||||
|
Ezfio.set_file "F2.ezfio" ;
|
||||||
|
let b = Input.Electrons.read ()
|
||||||
|
in
|
||||||
|
print_endline (Input.Electrons.to_string b);
|
||||||
|
;;
|
||||||
|
|
||||||
|
test_electrons();;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user