mirror of
https://github.com/LCPQ/quantum_package
synced 2024-12-23 04:43:50 +01:00
Added read rst for Hartree-Fock.ml
This commit is contained in:
parent
e476d845f5
commit
a292070721
@ -11,6 +11,7 @@ module Hartree_fock : 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_it_scf_max : Strictly_positive_int.t;
|
||||
@ -71,6 +72,22 @@ SCF convergence criterion (on energy) ::
|
||||
|> 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
|
||||
|
||||
|
||||
|
@ -83,6 +83,13 @@ let test_hf () =
|
||||
let b = Input.Hartree_fock.read ()
|
||||
in
|
||||
print_endline (Input.Hartree_fock.to_string b);
|
||||
let rst = Input.Hartree_fock.to_rst b in
|
||||
let new_b = Input.Hartree_fock.of_rst rst in
|
||||
print_endline (Input.Hartree_fock.to_string b);
|
||||
if (b = new_b) then
|
||||
print_endline "OK"
|
||||
else
|
||||
print_endline "Failed in rst"
|
||||
;;
|
||||
|
||||
let test_mo () =
|
||||
@ -117,4 +124,4 @@ test_bielec_intergals ();;
|
||||
test_electrons();
|
||||
*)
|
||||
|
||||
test_electrons();
|
||||
test_hf();
|
||||
|
Loading…
Reference in New Issue
Block a user