10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-07 06:33:39 +01:00

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 for coordinates in 3D space.
type angstrom = Angstrom.t
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 type axis = X | Y | Z
val bohr_to_angstrom : bohr -> angstrom val bohr_to_angstrom : Bohr.t -> Angstrom.t
val angstrom_to_bohr : angstrom -> bohr (** Converts a point in Bohr to Angstrom. *)
val zero : bohr
val ( |. ) : float -> bohr -> bohr val angstrom_to_bohr : Angstrom.t -> Bohr.t
val ( |+ ) : bohr -> bohr -> bohr (** Converts a point in Angstrom to Bohr. *)
val ( |- ) : bohr -> bohr -> bohr
val neg : bohr -> bohr
val dot : bohr -> bohr -> float val zero : Bohr.t
val norm : bohr -> float (** [zero = { Bohr.x = 0. ; y=0. ; z=0. }] *)
val get : axis -> bohr -> float
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 = { type t = {
x : float ; x : float ;
y : float ; y : float ;