mirror of
https://github.com/LCPQ/quantum_package
synced 2024-08-31 00:23:42 +02:00
Added read rst for Full-CI/Hartree-Fock.ml
This commit is contained in:
parent
a292070721
commit
39a8d4101f
@ -12,6 +12,7 @@ module Full_ci : sig
|
||||
val read : unit -> t
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
end = struct
|
||||
type t =
|
||||
{ n_det_max_fci : Det_number_max.t;
|
||||
@ -90,6 +91,23 @@ Compute E(PT2) at the end ::
|
||||
(Bool.to_string b.do_pt2_end)
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
@ -76,6 +76,13 @@ let test_fci () =
|
||||
let b = Input.Full_ci.read ()
|
||||
in
|
||||
print_endline (Input.Full_ci.to_string b);
|
||||
let rst = Input.Full_ci.to_rst b in
|
||||
let new_b = Input.Full_ci.of_rst rst in
|
||||
print_endline (Input.Full_ci.to_string b);
|
||||
if (b = new_b) then
|
||||
print_endline "OK"
|
||||
else
|
||||
print_endline "Failed in rst"
|
||||
;;
|
||||
|
||||
let test_hf () =
|
||||
@ -124,4 +131,4 @@ test_bielec_intergals ();;
|
||||
test_electrons();
|
||||
*)
|
||||
|
||||
test_hf();
|
||||
test_fci();
|
||||
|
Loading…
Reference in New Issue
Block a user