From 62d3de35a2317c88160f73947f2f6e765bed412d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 29 Oct 2014 18:55:31 +0100 Subject: [PATCH] Printing of xyz in qp_edit --- ocaml/Input_nuclei.ml | 21 ++++++++++++++++++++- ocaml/Point3d.ml | 2 +- ocaml/qp_edit.ml | 5 +++++ ocaml/test_input.ml | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ocaml/Input_nuclei.ml b/ocaml/Input_nuclei.ml index 7ea73970..9a285669 100644 --- a/ocaml/Input_nuclei.ml +++ b/ocaml/Input_nuclei.ml @@ -82,7 +82,26 @@ nucl_coord = %s ~f:(Point3d.to_string Units.Bohr) |> String.concat ~sep:"\n" ) ;; - let to_string = debug + let to_string b = + let nucl_num = Nucl_number.to_int b.nucl_num in + let text = + ( Printf.sprintf " %d\n " + nucl_num + ) :: ( + List.init nucl_num ~f:(fun i-> + Printf.sprintf " %-3s %d %s" + (b.nucl_label.(i) |> Element.to_string) + (b.nucl_charge.(i) |> Charge.to_int ) + (b.nucl_coord.(i) |> Point3d.to_string Units.Angstrom) ) + ) |> String.concat ~sep:"\n" + in + Printf.sprintf " +Nuclear coordinates in xyz format (Angstroms) :: + +%s + +" text + ;; end diff --git a/ocaml/Point3d.ml b/ocaml/Point3d.ml index 39f28fff..18f091f1 100644 --- a/ocaml/Point3d.ml +++ b/ocaml/Point3d.ml @@ -41,6 +41,6 @@ let to_string u p = | Units.Angstrom -> Units.bohr_to_angstrom in let { x=x ; y=y ; z=z } = p in - Printf.sprintf "%f %f %f" (x*.f) (y*.f) (z*.f) + Printf.sprintf "%16.8f %16.8f %16.8f" (x*.f) (y*.f) (z*.f) ;; diff --git a/ocaml/qp_edit.ml b/ocaml/qp_edit.ml index b451beda..410f5fa1 100644 --- a/ocaml/qp_edit.ml +++ b/ocaml/qp_edit.ml @@ -21,6 +21,7 @@ type keyword = | Full_ci | Hartree_fock | Mo_basis +| Nuclei ;; let keyword_to_string = function @@ -32,6 +33,7 @@ let keyword_to_string = function | Full_ci -> "Selected Full-CI" | Hartree_fock -> "Hartree-Fock" | Mo_basis -> "MO basis" +| Nuclei -> "Molecule" ;; let make_header kw = @@ -59,6 +61,8 @@ let get s = Input.Hartree_fock.(to_string (read ())) | Mo_basis -> Input.Mo_basis.(to_string (read ())) + | Nuclei -> + Input.Nuclei.(to_string (read ())) ) ;; @@ -82,6 +86,7 @@ let run ezfio_filename = let output = (instructions ezfio_filename) :: ( List.map ~f:get [ + Nuclei ; Electrons ; Ao_basis ; Mo_basis ; diff --git a/ocaml/test_input.ml b/ocaml/test_input.ml index a5655fcf..ee5bba60 100644 --- a/ocaml/test_input.ml +++ b/ocaml/test_input.ml @@ -96,5 +96,5 @@ test_hf ();; test_mo ();; test_nucl (); *) -test_mo();; +test_nucl();;