mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-19 12:32:21 +01:00
133 lines
2.5 KiB
OCaml
133 lines
2.5 KiB
OCaml
(* Type
|
|
*
|
|
* #+NAME: types *)
|
|
|
|
(* [[file:../coordinate.org::types][types]] *)
|
|
type bohr
|
|
type angstrom
|
|
|
|
type xyz = {
|
|
x : float ;
|
|
y : float ;
|
|
z : float ;
|
|
}
|
|
|
|
type 'a point = xyz
|
|
|
|
type t = bohr point
|
|
|
|
type axis = X | Y | Z
|
|
(* types ends here *)
|
|
|
|
(* ~make~
|
|
*
|
|
* Creates a point in atomic units. *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*~make~][~make~:1]] *)
|
|
val make : 'a point -> t
|
|
(* ~make~:1 ends here *)
|
|
|
|
(* ~make_angstrom~
|
|
*
|
|
* Creates a point in angstrom. *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*~make_angstrom~][~make_angstrom~:1]] *)
|
|
val make_angstrom : 'a point -> angstrom point
|
|
(* ~make_angstrom~:1 ends here *)
|
|
|
|
(* ~bohr_to_angstrom~
|
|
*
|
|
* Converts a point in bohr to angstrom. *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*~bohr_to_angstrom~][~bohr_to_angstrom~:1]] *)
|
|
val bohr_to_angstrom : bohr point -> angstrom point
|
|
(* ~bohr_to_angstrom~:1 ends here *)
|
|
|
|
(* ~angstrom_to_bohr~
|
|
*
|
|
* Converts a point in angstrom to bohr. *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*~angstrom_to_bohr~][~angstrom_to_bohr~:1]] *)
|
|
val angstrom_to_bohr : angstrom point -> bohr point
|
|
(* ~angstrom_to_bohr~:1 ends here *)
|
|
|
|
(* ~zero~
|
|
*
|
|
* ~zero~ = (0., 0., 0.) *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*~zero~][~zero~:1]] *)
|
|
val zero : bohr point
|
|
(* ~zero~:1 ends here *)
|
|
|
|
(* ~get~
|
|
*
|
|
* Extracts the projection of the coordinate on an axis.
|
|
*
|
|
* #+begin_example
|
|
* Coordinate.(get Y { x=1. ; y=2. ; z=3. })
|
|
* - float: 2.
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*~get~][~get~:1]] *)
|
|
val get : axis -> bohr point -> float
|
|
(* ~get~:1 ends here *)
|
|
|
|
(* Scale *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*Scale][Scale:1]] *)
|
|
val ( |. ) : float -> t -> t
|
|
(* Scale:1 ends here *)
|
|
|
|
(* Add *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*Add][Add:1]] *)
|
|
val ( |+ ) : t -> t -> t
|
|
(* Add:1 ends here *)
|
|
|
|
(* Subtract *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*Subtract][Subtract:1]] *)
|
|
val ( |- ) : t -> t -> t
|
|
(* Subtract:1 ends here *)
|
|
|
|
(* Negative *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*Negative][Negative:1]] *)
|
|
val neg : t -> t
|
|
(* Negative:1 ends here *)
|
|
|
|
(* Dot product *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*Dot product][Dot product:1]] *)
|
|
val dot : t -> t -> float
|
|
(* Dot product:1 ends here *)
|
|
|
|
(* Norm *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*Norm][Norm:1]] *)
|
|
val norm : t -> float
|
|
(* Norm:1 ends here *)
|
|
|
|
(* Printers
|
|
*
|
|
* Coordinates can be printed in bohr or angstrom. *)
|
|
|
|
|
|
(* [[file:../coordinate.org::*Printers][Printers:1]] *)
|
|
val pp : Format.formatter -> t -> unit
|
|
val pp_bohr: Format.formatter -> t -> unit
|
|
val pp_angstrom : Format.formatter -> t -> unit
|
|
(* Printers:1 ends here *)
|