10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-30 00:44:28 +02:00

Input_cisd_sc2 reads rst

This commit is contained in:
Anthony Scemama 2014-10-31 19:26:27 +01:00
parent c84c7c3054
commit dc29b0144c
2 changed files with 27 additions and 1 deletions

View File

@ -12,6 +12,7 @@ module Cisd_sc2 : sig
val read : unit -> t val read : unit -> t
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t
end = struct end = struct
type t = type t =
{ n_det_max_cisd_sc2 : Det_number_max.t; { n_det_max_cisd_sc2 : Det_number_max.t;
@ -91,6 +92,24 @@ Compute E(PT2) at the end ::
(PT2_energy.to_string b.pt2_max) (PT2_energy.to_string b.pt2_max)
(Bool.to_string b.do_pt2_end) (Bool.to_string b.do_pt2_end)
|> Rst_string.of_string |> 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 end

View File

@ -49,6 +49,13 @@ let test_cisd_sc2 () =
let b = Input.Cisd_sc2.read () let b = Input.Cisd_sc2.read ()
in in
print_endline (Input.Cisd_sc2.to_string b); print_endline (Input.Cisd_sc2.to_string b);
let rst = Input.Cisd_sc2.to_rst b in
let b2 = Input.Cisd_sc2.of_rst rst in
if (b = b2) then
print_endline "OK"
else
print_endline "rst failed";
;; ;;
let test_electrons () = let test_electrons () =
@ -102,5 +109,5 @@ test_mo ();;
test_nucl (); test_nucl ();
test_bielec_intergals ();; test_bielec_intergals ();;
*) *)
test_bielec_intergals ();;
test_cisd_sc2 ();