10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-23 04:43:32 +01:00
QCaml/common/lib/coordinate.mli

108 lines
2.0 KiB
OCaml
Raw Normal View History

2024-01-17 10:30:24 +01:00
(** Coordinates
*
* Coordinates in 3D space.
*
* All operations on points are done in atomic units.
* Therefore, all coordinates are given in bohr and
* manipulated with this module.
*)
2018-02-26 10:43:21 +01:00
2024-01-17 10:30:24 +01:00
(** Types *)
type bohr
type angstrom
type xyz = {
x : float ;
y : float ;
z : float ;
}
type 'a point = xyz
type t = bohr point
2020-12-27 17:23:47 +01:00
type axis = X | Y | Z
2018-02-26 10:43:21 +01:00
2024-01-17 10:30:24 +01:00
(** Creation *)
2018-02-26 10:43:21 +01:00
2020-12-27 23:08:12 +01:00
val make : 'a point -> t
2024-01-17 10:30:24 +01:00
(** Creates a point in atomic units *)
2020-12-27 17:23:47 +01:00
val make_angstrom : 'a point -> angstrom point
2024-01-17 10:30:24 +01:00
(** Creates a point in angstrom *)
2021-01-28 00:34:26 +01:00
val zero : bohr point
2024-01-17 10:30:24 +01:00
(** (0., 0., 0.) *)
2018-02-26 10:43:21 +01:00
2024-01-17 10:30:24 +01:00
(** Conversion *)
2018-02-26 10:43:21 +01:00
2020-12-27 17:23:47 +01:00
val bohr_to_angstrom : bohr point -> angstrom point
2024-01-17 10:30:24 +01:00
(** Converts a point in bohr to angstrom *)
2020-12-27 17:23:47 +01:00
val angstrom_to_bohr : angstrom point -> bohr point
2024-01-17 10:30:24 +01:00
(** Converts a point in angstrom to bohr *)
2018-02-26 10:43:21 +01:00
2020-12-27 23:08:12 +01:00
(* Vector operations *)
2018-02-26 10:43:21 +01:00
2024-01-17 10:30:24 +01:00
(** Vector operations *)
2020-12-27 23:08:12 +01:00
val neg : t -> t
2024-01-17 10:30:24 +01:00
(** Negative of a point *)
2020-12-27 23:08:12 +01:00
val get : axis -> bohr point -> float
2024-01-17 10:30:24 +01:00
(** Extracts the projection of the coordinate on an axis *)
2020-12-27 23:08:12 +01:00
val dot : t -> t -> float
2024-01-17 10:30:24 +01:00
(** Dot product *)
2020-12-27 23:08:12 +01:00
val norm : t -> float
2024-01-17 10:30:24 +01:00
(** $\ell{^2}$ norm of the vector *)
2020-12-27 17:23:47 +01:00
val ( |. ) : float -> t -> t
2024-01-17 10:30:24 +01:00
(** Scales the vector by a constant *)
2020-12-27 17:23:47 +01:00
val ( |+ ) : t -> t -> t
2024-01-17 10:30:24 +01:00
(** Adds two vectors *)
2020-12-27 17:23:47 +01:00
val ( |- ) : t -> t -> t
2024-01-17 10:30:24 +01:00
(** Subtracts two vectors *)
(** Example
* Coordinate.neg { x=1. ; y=2. ; z=3. } ;;
* - : Coordinate.t = -1.0000 -2.0000 -3.0000
*
* Coordinate.(get Y { x=1. ; y=2. ; z=3. }) ;;
* - : float = 2.
*
* Coordinate.(
* 2. |. { x=1. ; y=2. ; z=3. }
* ) ;;
* - : Coordinate.t = 2.0000 4.0000 6.0000
*
* Coordinate.(
* { x=1. ; y=2. ; z=3. } |+ { x=2. ; y=3. ; z=1. }
* );;
* - : Coordinate.t = 3.0000 5.0000 4.0000
*
* Coordinate.(
* { x=1. ; y=2. ; z=3. } |- { x=2. ; y=3. ; z=1. }
* );;
* - : Coordinate.t = -1.0000 -1.0000 2.0000
*)
2018-02-26 10:43:21 +01:00
2024-01-17 10:30:24 +01:00
(** Printers *)
2018-03-15 15:25:49 +01:00
2024-01-17 10:30:24 +01:00
(* Coordinates can be printed in bohr or angstrom. *)
2018-03-16 00:23:47 +01:00
2020-12-27 17:23:47 +01:00
val pp : Format.formatter -> t -> unit
val pp_bohr: Format.formatter -> t -> unit
val pp_angstrom : Format.formatter -> t -> unit