diff --git a/particles/lib/mass.ml b/particles/lib/mass.ml index f7fc492..576640d 100644 --- a/particles/lib/mass.ml +++ b/particles/lib/mass.ml @@ -1,3 +1,3 @@ -(* [[file:../mass.org::*Atomic mass][Atomic mass:2]] *) +(* [[file:~/QCaml/particles/mass.org::*Atomic%20mass][Atomic mass:2]] *) include Common.Non_negative_float (* Atomic mass:2 ends here *) diff --git a/particles/lib/mass.mli b/particles/lib/mass.mli index 9d91dd3..f6948d0 100644 --- a/particles/lib/mass.mli +++ b/particles/lib/mass.mli @@ -7,6 +7,6 @@ * * #+NAME: types *) -(* [[file:../mass.org::types][types]] *) +(* [[file:~/QCaml/particles/mass.org::types][types]] *) include module type of Common.Non_negative_float (* types ends here *) diff --git a/particles/lib/zmatrix.ml b/particles/lib/zmatrix.ml index d404a0b..e82fe89 100644 --- a/particles/lib/zmatrix.ml +++ b/particles/lib/zmatrix.ml @@ -1,4 +1,4 @@ -(* [[file:../zmatrix.org::*Type][Type:2]] *) +(* [[file:~/QCaml/particles/zmatrix.org::*Type][Type:2]] *) module StringMap = Map.Make(String) type atom_id = int @@ -18,12 +18,55 @@ type t = (line array * float StringMap.t) -(* | ~of_string~ | Reads a z-matrix from a string | - * | ~to_xyz~ | Converts to xyz format, as in the ~Nuclei~ module | - * | ~to_xyz_string~ | Converts to xyz format, as a string | *) +(* | ~of_string~ | Reads a z-matrix from a string | + * | ~to_xyz~ | Converts to xyz format, as in the ~Nuclei~ module | + * | ~to_xyz_string~ | Converts to xyz format, as a string | + * + * #+begin_example + * let zmt = Zmatrix.of_string " + * n + * n 1 nn + * h 1 hn 2 hnn + * h 2 hn 1 hnn 3 dih4 + * h 1 hn 2 hnn 4 dih5 + * h 2 hn 1 hnn 3 dih5 + * + * nn 1.446 + * hn 1.016 + * hnn 106.0 + * dih4 -54.38 + * dih5 54.38 + * " ;; + * - : Zmatrix.t = N + * N 1 1.446000 + * H 1 1.016000 2 106.000000 + * H 2 1.016000 1 106.000000 3 -54.380000 + * H 1 1.016000 2 106.000000 4 54.380000 + * H 2 1.016000 1 106.000000 3 54.380000 + * + * + * Zmatrix.to_xyz zmt ;; + * - : (Element.t * float * float * float) array = + * [|(N, 0., 0., 0.); (N, 0., 0., 1.446); + * (H, -0.976641883073332107, 0., -0.280047553510071046); + * (H, -0.568802835186988709, 0.793909757123734683, 1.726047553510071); + * (H, 0.314092649983635563, 0.924756819385119, -0.280047553510071101); + * (H, -0.568802835186988709, -0.793909757123734683, 1.726047553510071)|] + * + * + * Zmatrix.to_xyz_string zmt ;; + * - : string = + * "N 0.000000 0.000000 0.000000 + * N 0.000000 0.000000 1.446000 + * H -0.976642 0.000000 -0.280048 + * H -0.568803 0.793910 1.726048 + * H 0.314093 0.924757 -0.280048 + * H -0.568803 -0.793910 1.726048" + * #+end_example *) + -(* [[file:../zmatrix.org::*Conversion][Conversion:2]] *) +(* [[file:~/QCaml/particles/zmatrix.org::*Conversion][Conversion:2]] *) let pi = Common.Constants.pi let to_radian = pi /. 180. @@ -301,12 +344,12 @@ let to_xyz_string (l,map) = String.concat "\n" ( to_xyz (l,map) |> Array.map (fun (e,x,y,z) -> - Printf.sprintf "%s %f %f %f\n" (Element.to_string e) x y z) + Printf.sprintf "%s %f %f %f" (Element.to_string e) x y z) |> Array.to_list ) (* Conversion:2 ends here *) -(* [[file:../zmatrix.org::*Printers][Printers:2]] *) +(* [[file:~/QCaml/particles/zmatrix.org::*Printers][Printers:2]] *) let pp ppf (a, map) = let f = string_of_line map in Format.fprintf ppf "@["; diff --git a/particles/lib/zmatrix.mli b/particles/lib/zmatrix.mli index f964ea4..663a790 100644 --- a/particles/lib/zmatrix.mli +++ b/particles/lib/zmatrix.mli @@ -2,14 +2,14 @@ * * #+NAME: types *) -(* [[file:../zmatrix.org::types][types]] *) +(* [[file:~/QCaml/particles/zmatrix.org::types][types]] *) type t (* types ends here *) (* Conversion *) -(* [[file:../zmatrix.org::*Conversion][Conversion:1]] *) +(* [[file:~/QCaml/particles/zmatrix.org::*Conversion][Conversion:1]] *) val of_string : string -> t val to_xyz : t -> (Element.t * float * float * float) array val to_xyz_string : t -> string @@ -18,6 +18,6 @@ val to_xyz_string : t -> string (* Printers *) -(* [[file:../zmatrix.org::*Printers][Printers:1]] *) +(* [[file:~/QCaml/particles/zmatrix.org::*Printers][Printers:1]] *) val pp : Format.formatter -> t -> unit (* Printers:1 ends here *) diff --git a/particles/zmatrix.org b/particles/zmatrix.org index a54f98b..610da5b 100644 --- a/particles/zmatrix.org +++ b/particles/zmatrix.org @@ -53,6 +53,49 @@ val to_xyz_string : t -> string | ~to_xyz~ | Converts to xyz format, as in the ~Nuclei~ module | | ~to_xyz_string~ | Converts to xyz format, as a string | + #+begin_example +let zmt = Zmatrix.of_string " + n + n 1 nn + h 1 hn 2 hnn + h 2 hn 1 hnn 3 dih4 + h 1 hn 2 hnn 4 dih5 + h 2 hn 1 hnn 3 dih5 + +nn 1.446 +hn 1.016 +hnn 106.0 +dih4 -54.38 +dih5 54.38 +" ;; +- : Zmatrix.t = N +N 1 1.446000 +H 1 1.016000 2 106.000000 +H 2 1.016000 1 106.000000 3 -54.380000 +H 1 1.016000 2 106.000000 4 54.380000 +H 2 1.016000 1 106.000000 3 54.380000 + + +Zmatrix.to_xyz zmt ;; +- : (Element.t * float * float * float) array = +[|(N, 0., 0., 0.); (N, 0., 0., 1.446); + (H, -0.976641883073332107, 0., -0.280047553510071046); + (H, -0.568802835186988709, 0.793909757123734683, 1.726047553510071); + (H, 0.314092649983635563, 0.924756819385119, -0.280047553510071101); + (H, -0.568802835186988709, -0.793909757123734683, 1.726047553510071)|] + + +Zmatrix.to_xyz_string zmt ;; +- : string = +"N 0.000000 0.000000 0.000000 +N 0.000000 0.000000 1.446000 +H -0.976642 0.000000 -0.280048 +H -0.568803 0.793910 1.726048 +H 0.314093 0.924757 -0.280048 +H -0.568803 -0.793910 1.726048" + #+end_example + + #+begin_src ocaml :tangle (eval ml) :exports none let pi = Common.Constants.pi let to_radian = pi /. 180. @@ -331,7 +374,7 @@ let to_xyz_string (l,map) = String.concat "\n" ( to_xyz (l,map) |> Array.map (fun (e,x,y,z) -> - Printf.sprintf "%s %f %f %f\n" (Element.to_string e) x y z) + Printf.sprintf "%s %f %f %f" (Element.to_string e) x y z) |> Array.to_list ) #+end_src