Documentation

This commit is contained in:
Anthony Scemama 2018-02-26 10:43:21 +01:00
parent 47a85dec71
commit eb2d7998e2
4 changed files with 80 additions and 48 deletions

View File

@ -1,19 +1,83 @@
type bohr = Bohr.t
type angstrom = Angstrom.t
(** Type for coordinates in 3D space.
All operations on points are done in atomic units. Therefore,
all coordinates are given in {!Bohr.t} and manipulated with this
module.
*)
type t = Bohr.t
type t = bohr
type axis = X | Y | Z
val bohr_to_angstrom : bohr -> angstrom
val angstrom_to_bohr : angstrom -> bohr
val bohr_to_angstrom : Bohr.t -> Angstrom.t
(** Converts a point in Bohr to Angstrom. *)
val zero : bohr
val ( |. ) : float -> bohr -> bohr
val ( |+ ) : bohr -> bohr -> bohr
val ( |- ) : bohr -> bohr -> bohr
val neg : bohr -> bohr
val dot : bohr -> bohr -> float
val norm : bohr -> float
val get : axis -> bohr -> float
val angstrom_to_bohr : Angstrom.t -> Bohr.t
(** Converts a point in Angstrom to Bohr. *)
val zero : Bohr.t
(** [zero = { Bohr.x = 0. ; y=0. ; z=0. }] *)
val get : axis -> Bohr.t -> float
(** Extracts the projection of the coordinate on an axis.
Example:
[Coordinate.(get Y) { Bohr.x=1. ; y=2. ; z=3. } -> 2.]
*)
(** {1 Vector operations} *)
val ( |. ) : float -> Bohr.t -> Bohr.t
(** Scale by a float.
Example:
[ 2. |. { Bohr.x=1. ; y=2. ; z=3. } -> { Bohr.x=2. ; y=4. ; z=6. } ]
*)
val ( |+ ) : Bohr.t -> Bohr.t -> Bohr.t
(** Add two vectors.
Example:
{[{ Bohr.x=1. ; y=2. ; z=3. } |+ { Bohr.x=2. ; y=3. ; z=1. } ->
{ Bohr.x=3. ; y=5. ; z=4. }]}
*)
val ( |- ) : Bohr.t -> Bohr.t -> Bohr.t
(** Subtract two vectors.
Example:
{[{ Bohr.x=1. ; y=2. ; z=3. } |- { Bohr.x=2. ; y=3. ; z=1. } ->
{ Bohr.x=-1. ; y=-1. ; z=2. }]}
*)
val neg : Bohr.t -> Bohr.t
(** Example:
{[Coordinate.neg { Bohr.x=1. ; y=2. ; z=-3. } ->
{ Bohr.x=-1. ; y=-2. ; z=3. }]}
*)
val dot : Bohr.t -> Bohr.t -> float
(** Dot product. *)
val norm : Bohr.t -> float
(** L{^2} norm of the vector. *)

View File

@ -1,24 +0,0 @@
let bohr_to_angstrom { Bohr.x ; y ; z } =
let b_to_a b = Constants.a0 *. b in
Angstrom.make
{
Point.
x = b_to_a x ;
y = b_to_a y ;
z = b_to_a z ;
}
let angstrom_to_bohr { Angstrom.x ; y ; z } =
let a_to_b a = Constants.a0_inv *. a in
Bohr.make
{
Point.
x = a_to_b x ;
y = a_to_b y ;
z = a_to_b z ;
}

View File

@ -1,11 +0,0 @@
(** Coordinate_type can be Bohr or Angstrom. This module provides the conversion
functions from {!Bohr.t} to {!Angstrom.t} and from {!Angstrom.t} to {!Bohr.t} *)
type bohr = Bohr.t
type angstrom = Angstrom.t
val bohr_to_angstrom : bohr -> angstrom
val angstrom_to_bohr : angstrom -> bohr

View File

@ -1,3 +1,6 @@
(** A point in a 3D space. Used by {!Angstrom.t} and {!Bohr.t}.
*)
type t = {
x : float ;
y : float ;