mirror of
https://github.com/LCPQ/quantum_package
synced 2024-12-23 04:43:50 +01:00
Input_electrons.ml reads rst
This commit is contained in:
parent
dc29b0144c
commit
e476d845f5
@ -6,17 +6,17 @@ module Electrons : sig
|
||||
type t =
|
||||
{ elec_alpha_num : Elec_alpha_number.t;
|
||||
elec_beta_num : Elec_beta_number.t;
|
||||
elec_num : Elec_number.t;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read_elec_num : unit -> Elec_number.t
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
end = struct
|
||||
type t =
|
||||
{ elec_alpha_num : Elec_alpha_number.t;
|
||||
elec_beta_num : Elec_beta_number.t;
|
||||
elec_num : Elec_number.t;
|
||||
} with sexp
|
||||
;;
|
||||
|
||||
@ -43,7 +43,6 @@ end = struct
|
||||
let read () =
|
||||
{ elec_alpha_num = read_elec_alpha_num ();
|
||||
elec_beta_num = read_elec_beta_num ();
|
||||
elec_num = read_elec_num ();
|
||||
}
|
||||
;;
|
||||
|
||||
@ -71,8 +70,24 @@ elec_num = %s
|
||||
"
|
||||
(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)
|
||||
(Elec_number.to_string (read_elec_num ()))
|
||||
;;
|
||||
|
||||
let of_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
;;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -63,6 +63,12 @@ let test_electrons () =
|
||||
let b = Input.Electrons.read ()
|
||||
in
|
||||
print_endline (Input.Electrons.to_string b);
|
||||
let rst = Input.Electrons.to_rst b in
|
||||
let new_b = Input.Electrons.of_rst rst in
|
||||
if (b = new_b) then
|
||||
print_endline "OK"
|
||||
else
|
||||
print_endline "Failed in rst"
|
||||
;;
|
||||
|
||||
let test_fci () =
|
||||
@ -108,6 +114,7 @@ test_hf ();;
|
||||
test_mo ();;
|
||||
test_nucl ();
|
||||
test_bielec_intergals ();;
|
||||
test_electrons();
|
||||
*)
|
||||
|
||||
test_cisd_sc2 ();
|
||||
test_electrons();
|
||||
|
Loading…
Reference in New Issue
Block a user