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

4.9 KiB

Coordinate

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.

Type

<<<~Coordinate.t~>>>

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

Creation

val make          : 'a point -> t
val make_angstrom : 'a point -> angstrom point
val zero          : bohr point
make Creates a point in atomic units
make_angstrom Creates a point in angstrom
zero $(0., 0., 0.)$

Conversion

val bohr_to_angstrom : bohr point -> angstrom point
val angstrom_to_bohr : angstrom point -> bohr point
bohr_to_angstrom Converts a point in bohr to angstrom
angstrom_to_bohr Converts a point in angstrom to bohr

Vector operations

val neg    : t -> t
val get    : axis -> bohr point -> float
val dot    : t -> t -> float
val norm   : t -> float
val ( |. ) : float -> t -> t
val ( |+ ) : t -> t -> t
val ( |- ) : t -> t -> t
neg Negative of a point
get Extracts the projection of the coordinate on an axis
dot Dot product
norm $\ell{^2}$ norm of the vector
$\vert .$ Scales the vector by a constant
$\vert +$ Adds two vectors
$\vert -$ 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

Printers

val pp : Format.formatter -> t -> unit
val pp_bohr: Format.formatter -> t -> unit
val pp_angstrom : Format.formatter -> t -> unit

Coordinates can be printed in bohr or angstrom.