10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-18 20:12:26 +01:00
QCaml/common/coordinate.org

5.7 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

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 / conversion

make

val make : 'a point -> t

Creates a point in atomic units.

make_angstrom

val make_angstrom : 'a point -> angstrom point

Creates a point in angstrom.

bohr_to_angstrom

val bohr_to_angstrom : bohr point -> angstrom point

Converts a point in bohr to angstrom.

angstrom_to_bohr

val angstrom_to_bohr : angstrom point -> bohr point

Converts a point in angstrom to bohr.

zero

val zero : bohr point

zero = (0., 0., 0.)

get

val get : axis -> bohr point -> float

Extracts the projection of the coordinate on an axis.

Coordinate.(get Y { x=1. ; y=2. ; z=3. }) ;;
- : float = 2.

Vector operations

Scale

val ( |. ) : float -> t -> t
Coordinate.(
2. |. { x=1. ; y=2. ; z=3. }
) ;;
- : Coordinate.t = {Qcaml.Common.Coordinate.x = 2.; y = 4.; z = 6.}

Add

val ( |+ ) : t -> t -> t
Coordinate.(
{ x=1. ; y=2. ; z=3. } |+ { x=2. ; y=3. ; z=1. } 
);;
- : Coordinate.t = {Qcaml.Common.Coordinate.x = 3.; y = 5.; z = 4.}

Subtract

val ( |- ) : t -> t -> t
Coordinate.(
{ x=1. ; y=2. ; z=3. } |- { x=2. ; y=3. ; z=1. } 
);;
- : Coordinate.t = {Qcaml.Common.Coordinate.x = -1.; y = -1.; z = 2.}

Negative

val neg : t -> t
Coordinate.neg { x=1. ; y=2. ; z=3. } ;;
- : Coordinate.t = {Qcaml.Common.Coordinate.x = -1.; y = -2.; z = -3.}

Dot product

val dot : t -> t -> float

Norm

val norm : t -> float

$\ell{^2}$ norm of the vector.

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.