10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-13 09:34:02 +01:00
quantum_package/ocaml/Input_electrons.ml

61 lines
1.3 KiB
OCaml
Raw Normal View History

2014-10-21 23:23:37 +02:00
open Qptypes;;
open Qputils;;
open Core.Std;;
module Electrons : sig
type t =
2014-10-22 00:12:23 +02:00
{ elec_alpha_num : Elec_alpha_number.t;
elec_beta_num : Elec_beta_number.t;
elec_num : Elec_number.t;
2014-10-21 23:23:37 +02:00
}
;;
val read : unit -> t
val to_string : t -> string
end = struct
type t =
2014-10-22 00:12:23 +02:00
{ elec_alpha_num : Elec_alpha_number.t;
elec_beta_num : Elec_beta_number.t;
elec_num : Elec_number.t;
2014-10-21 23:23:37 +02:00
}
;;
let get_default = Qpackage.get_ezfio_default "electrons";;
let read_elec_alpha_num() =
Ezfio.get_electrons_elec_alpha_num ()
2014-10-22 00:12:23 +02:00
|> Elec_alpha_number.of_int
2014-10-21 23:23:37 +02:00
;;
let read_elec_beta_num() =
Ezfio.get_electrons_elec_beta_num ()
2014-10-22 00:12:23 +02:00
|> Elec_beta_number.of_int
2014-10-21 23:23:37 +02:00
;;
let read_elec_num () =
let na = Ezfio.get_electrons_elec_alpha_num ()
and nb = Ezfio.get_electrons_elec_beta_num ()
in assert (na >= nb);
2014-10-22 00:12:23 +02:00
Elec_number.of_int (na + nb)
2014-10-21 23:23:37 +02:00
;;
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
"
2014-10-22 00:12:23 +02:00
(Elec_alpha_number.to_string b.elec_alpha_num)
(Elec_beta_number.to_string b.elec_beta_num)
(Elec_number.to_string b.elec_num)
2014-10-21 23:23:37 +02:00
end