+
6.3 Printers
val pp : Format.formatter -> t -> unit
@@ -1066,7 +1079,7 @@ H -0.568803 -0.793910 1.726048"
Author: Anthony Scemama
-
Created: 2021-10-19 Tue 16:20
+
Created: 2023-04-24 Mon 14:13
Validate
diff --git a/docs/top.html b/docs/top.html
index 5bf78f4..54a8721 100644
--- a/docs/top.html
+++ b/docs/top.html
@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
+
Top-level
@@ -250,18 +250,18 @@ org_html_manager.setup(); // activate after the parameters are set
Table of Contents
-
Author: Anthony Scemama
-
Created: 2023-04-24 Mon 12:58
+
Created: 2023-04-24 Mon 14:13
Validate
diff --git a/gaussian_integrals/README.org b/gaussian_integrals/README.org
index a124315..68f2d74 100644
--- a/gaussian_integrals/README.org
+++ b/gaussian_integrals/README.org
@@ -48,6 +48,8 @@ with open(dunetest,'w') as f:
(synopsis "Test for {name} library")
(libraries
alcotest
+ unix
+ trexio
qcaml.{name}
)
)
diff --git a/particles/README.org b/particles/README.org
index 92d27ab..15f1aa8 100644
--- a/particles/README.org
+++ b/particles/README.org
@@ -48,6 +48,7 @@ with open(dunetest,'w') as f:
(synopsis "Test for {name} library")
(libraries
alcotest
+ trexio
qcaml.{name}
)
)
@@ -59,6 +60,7 @@ with open(dunetest,'w') as f:
#+name: dependencies
#+begin_src elisp
(libraries
+ trexio
qcaml.common
)
#+end_src
diff --git a/particles/lib/dune b/particles/lib/dune
index 7a7c994..f1aac6c 100644
--- a/particles/lib/dune
+++ b/particles/lib/dune
@@ -3,9 +3,10 @@
(name particles)
(public_name qcaml.particles)
(synopsis
-"Information relative to particles (electrons and nuclei)."
+"Information relative to particles (electrons and nuclei)"
)
(libraries
+ trexio
qcaml.common
)
(modules_without_implementation
diff --git a/particles/lib/mass.ml b/particles/lib/mass.ml
index 576640d..8c27f97 100644
--- a/particles/lib/mass.ml
+++ b/particles/lib/mass.ml
@@ -1,3 +1,3 @@
-(* [[file:~/QCaml/particles/mass.org::*Atomic%20mass][Atomic mass:2]] *)
+(* [[file:~/QCaml/particles/mass.org::*Atomic mass][Atomic mass:2]] *)
include Common.Non_negative_float
(* Atomic mass:2 ends here *)
diff --git a/particles/lib/nuclei.ml b/particles/lib/nuclei.ml
index c40fdc0..b62f966 100644
--- a/particles/lib/nuclei.ml
+++ b/particles/lib/nuclei.ml
@@ -12,7 +12,9 @@ open Xyz_ast
* | ~of_zmt_string~ | Create from a string, in z-matrix format |
* | ~of_zmt_file~ | Create from a file, in z-matrix format |
* | ~to_string~ | Transform to a string, for printing |
- * | ~of_filename~ | Detects the type of file (xyz, z-matrix) and reads the file | *)
+ * | ~of_filename~ | Detects the type of file (xyz, z-matrix) and reads the file |
+ * | ~of_trexio~ | Reads the geometry from a TREXIO file |
+ * | ~to_trexio~ | Writes the geometry in a TREXIO file | *)
(* [[file:~/QCaml/particles/nuclei.org::*Conversion][Conversion:2]] *)
@@ -115,6 +117,19 @@ let to_xyz_string t =
) t
|> Array.to_list )
|> String.concat "\n"
+
+
+let of_trexio f =
+ let num = Trexio.read_nucleus_num f in
+ let charge = Trexio.read_nucleus_charge f
+ |> Array.map Charge.of_float in
+ let coord = Trexio.read_nucleus_coord f in
+ Array.init num (fun i ->
+ let coord = Coordinate.{ x = coord.(3*i) ;
+ y = coord.(3*i+1) ;
+ z = coord.(3*i+2) } in
+ (Element.of_charge charge.(i), Coordinate.make coord)
+ )
(* Conversion:2 ends here *)
@@ -174,6 +189,26 @@ let small_core a =
let large_core a =
Array.fold_left (fun accu (e,_) -> accu + (Element.large_core e)) 0 a
+
+let to_trexio f t =
+ let num = Array.length t in
+ Trexio.write_nucleus_num f num;
+
+ Array.map (fun (e, _) -> Element.to_charge e |> Charge.to_float) t
+ |> Trexio.write_nucleus_charge f;
+
+ Array.map (fun (e, _) -> Element.to_string e) t
+ |> Trexio.write_nucleus_label f;
+
+ let coord = Array.init (num*3) (fun _ -> 0.) in
+ Array.iteri (fun i (_, xyz) ->
+ coord.(3*i) <- Coordinate.(get X xyz) ;
+ coord.(3*i+1) <- Coordinate.(get Y xyz) ;
+ coord.(3*i+2) <- Coordinate.(get Z xyz) ) t;
+ Trexio.write_nucleus_coord f coord;
+
+ repulsion t
+ |> Trexio.write_nucleus_repulsion f
(* Query:2 ends here *)
(* [[file:~/QCaml/particles/nuclei.org::*Printers][Printers:2]] *)
diff --git a/particles/lib/nuclei.mli b/particles/lib/nuclei.mli
index 24ab6be..3c2e9a0 100644
--- a/particles/lib/nuclei.mli
+++ b/particles/lib/nuclei.mli
@@ -23,9 +23,12 @@ val of_zmt_file : string -> t
val to_string : t -> string
val of_filename : string -> t
+
+val of_trexio : Trexio.trexio_file -> t
+val to_trexio : Trexio.trexio_file -> t -> unit
(* Conversion:1 ends here *)
-(* TODO Query *)
+(* Query *)
(* [[file:~/QCaml/particles/nuclei.org::*Query][Query:1]] *)
diff --git a/particles/nuclei.org b/particles/nuclei.org
index c4d7109..6aaa19c 100644
--- a/particles/nuclei.org
+++ b/particles/nuclei.org
@@ -204,6 +204,9 @@ val of_zmt_file : string -> t
val to_string : t -> string
val of_filename : string -> t
+
+val of_trexio : Trexio.trexio_file -> t
+val to_trexio : Trexio.trexio_file -> t -> unit
#+end_src
| ~of_xyz_string~ | Create from a string, in xyz format |
@@ -212,6 +215,8 @@ val of_filename : string -> t
| ~of_zmt_file~ | Create from a file, in z-matrix format |
| ~to_string~ | Transform to a string, for printing |
| ~of_filename~ | Detects the type of file (xyz, z-matrix) and reads the file |
+ | ~of_trexio~ | Reads the geometry from a TREXIO file |
+ | ~to_trexio~ | Writes the geometry in a TREXIO file |
#+begin_src ocaml :tangle (eval ml) :exports none
let of_xyz_lexbuf lexbuf =
@@ -313,9 +318,48 @@ let to_xyz_string t =
) t
|> Array.to_list )
|> String.concat "\n"
+
+
+let of_trexio f =
+ let num = Trexio.read_nucleus_num f in
+ let charge = Trexio.read_nucleus_charge f
+ |> Array.map Charge.of_float in
+ let coord = Trexio.read_nucleus_coord f in
+ Array.init num (fun i ->
+ let coord = Coordinate.{ x = coord.(3*i) ;
+ y = coord.(3*i+1) ;
+ z = coord.(3*i+2) } in
+ (Element.of_charge charge.(i), Coordinate.make coord)
+ )
+
+
#+end_src
-** TODO Query
+ #+NAME: trexio_export
+ #+begin_src ocaml :tangle no :exports none
+let to_trexio f t =
+ let num = Array.length t in
+ Trexio.write_nucleus_num f num;
+
+ Array.map (fun (e, _) -> Element.to_charge e |> Charge.to_float) t
+ |> Trexio.write_nucleus_charge f;
+
+ Array.map (fun (e, _) -> Element.to_string e) t
+ |> Trexio.write_nucleus_label f;
+
+ let coord = Array.init (num*3) (fun _ -> 0.) in
+ Array.iteri (fun i (_, xyz) ->
+ coord.(3*i) <- Coordinate.(get X xyz) ;
+ coord.(3*i+1) <- Coordinate.(get Y xyz) ;
+ coord.(3*i+2) <- Coordinate.(get Z xyz) ) t;
+ Trexio.write_nucleus_coord f coord;
+
+ repulsion t
+ |> Trexio.write_nucleus_repulsion f
+
+ #+end_src
+
+** Query
#+begin_src ocaml :tangle (eval mli)
val formula : t -> string
@@ -331,7 +375,7 @@ val large_core : t -> int
| ~small_core~ | Number of core electrons in the small core model |
| ~large_core~ | Number of core electrons in the large core model |
- #+begin_src ocaml :tangle (eval ml) :exports none
+ #+begin_src ocaml :tangle (eval ml) :exports none :noweb yes
let formula t =
let dict = Hashtbl.create 67 in
Array.iter (fun (e,_) ->
@@ -379,6 +423,8 @@ let small_core a =
let large_core a =
Array.fold_left (fun accu (e,_) -> accu + (Element.large_core e)) 0 a
+
+<
>
#+end_src
** Printers
diff --git a/particles/test/dune b/particles/test/dune
index d74d00d..75f03bc 100644
--- a/particles/test/dune
+++ b/particles/test/dune
@@ -4,6 +4,7 @@
(synopsis "Test for particles library")
(libraries
alcotest
+ trexio
qcaml.particles
)
)