mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-08-28 23:42:00 +02:00
Documentation
This commit is contained in:
parent
ac3f079330
commit
f95d9740b6
@ -1,4 +1,4 @@
|
||||
(** Chemical elements. *)
|
||||
(** Chemical elements. *)
|
||||
|
||||
exception ElementError of string
|
||||
|
||||
@ -42,11 +42,25 @@ Example:
|
||||
[Element.(to_long_string Fe) -> "Iron"]
|
||||
*)
|
||||
|
||||
(** Properties *)
|
||||
val to_int : t -> int
|
||||
(** Convert to the atomic charge, with [int] type. *)
|
||||
|
||||
val of_int : int -> t
|
||||
(** Create from the atomic charge, with [int] type. *)
|
||||
|
||||
val to_charge : t -> Charge.t
|
||||
(** Convert to the atomic charge, with {!Charge.t} type. *)
|
||||
|
||||
val of_charge : Charge.t -> t
|
||||
(** Create from the atomic charge, with {!Charge.t} type. *)
|
||||
|
||||
val covalent_radius : t -> NonNegativeFloat.t
|
||||
(** Covalent radii of the elements, in atomic units. *)
|
||||
|
||||
val vdw_radius : t -> NonNegativeFloat.t
|
||||
(** Van der Waals radii of the elements, in atomic units. *)
|
||||
|
||||
val mass : t -> Mass.t
|
||||
(** Atomic mass of the elements, in atomic units. *)
|
||||
|
||||
|
||||
|
@ -1 +1,3 @@
|
||||
(** Atomic mass. *)
|
||||
|
||||
include NonNegativeFloat
|
||||
|
3
Nuclei/Mass.mli
Normal file
3
Nuclei/Mass.mli
Normal file
@ -0,0 +1,3 @@
|
||||
(** Atomic mass. *)
|
||||
|
||||
include module type of NonNegativeFloat
|
@ -3,7 +3,7 @@ open Xyz_ast
|
||||
|
||||
type t = (Element.t * Coordinate.t) array
|
||||
|
||||
let of_xyz_file ~filename =
|
||||
let of_xyz_file filename =
|
||||
let lexbuf =
|
||||
let ic = open_in filename in
|
||||
Lexing.from_channel ic
|
||||
@ -25,7 +25,7 @@ let of_xyz_file ~filename =
|
||||
|
||||
|
||||
|
||||
let of_zmt_file ~filename =
|
||||
let of_zmt_file filename =
|
||||
let ic = open_in filename in
|
||||
let rec aux accu =
|
||||
try
|
||||
@ -38,7 +38,7 @@ let of_zmt_file ~filename =
|
||||
in aux []
|
||||
|> Zmatrix.of_string
|
||||
|> Zmatrix.to_xyz
|
||||
|> Array.map (fun (e,x,y,z) -> (e, (Angstrom.make {Point.x ; y ; z} )))
|
||||
|> Array.map (fun (e,x,y,z) -> (e, Coordinate.angstrom_to_bohr (Angstrom.make {Point.x ; y ; z} )))
|
||||
|
||||
|
||||
let to_string atoms =
|
||||
@ -67,11 +67,11 @@ let to_string atoms =
|
||||
"
|
||||
|
||||
|
||||
let of_filename ~filename =
|
||||
let of_filename filename =
|
||||
of_xyz_file filename
|
||||
|
||||
|
||||
let repulsion ~nuclei =
|
||||
let repulsion nuclei =
|
||||
let get_charge e =
|
||||
Element.to_charge e
|
||||
|> Charge.to_float
|
||||
@ -86,3 +86,9 @@ let repulsion ~nuclei =
|
||||
) 0. nuclei
|
||||
) 0. nuclei
|
||||
|
||||
|
||||
let charge nuclei =
|
||||
Array.fold_left (fun accu (e, _) -> accu + Charge.to_int (Element.to_charge e) )
|
||||
0 nuclei
|
||||
|> Charge.of_int
|
||||
|
||||
|
26
Nuclei/Nuclei.mli
Normal file
26
Nuclei/Nuclei.mli
Normal file
@ -0,0 +1,26 @@
|
||||
(** Data structure for the molecular geometry, represented as an array
|
||||
of tuples ({!Element.t}, {!Coordinate.t}).
|
||||
*)
|
||||
|
||||
type t = (Element.t * Bohr.t) array
|
||||
|
||||
|
||||
val of_xyz_file : string -> t
|
||||
(** Create from a file, in [xyz] format. *)
|
||||
|
||||
val of_zmt_file : string -> t
|
||||
(** Create from a file, in z-matrix format. *)
|
||||
|
||||
val to_string : t -> string
|
||||
(** Transform to a string, for printing. *)
|
||||
|
||||
val of_filename : string -> t
|
||||
(** Detects the type of file ([xyz], z-matrix) and reads the file. *)
|
||||
|
||||
|
||||
val repulsion : t -> float
|
||||
(** Nuclear repulsion energy, in atomic units. *)
|
||||
|
||||
val charge : t -> Charge.t
|
||||
(** Sum of the charges of the nuclei. *)
|
||||
|
@ -1,13 +1,16 @@
|
||||
(** When an [xyz] file is read by the [Xyz_parser.mly], it is converted into
|
||||
an {!xyz_file} data structure. *)
|
||||
|
||||
type nucleus =
|
||||
{
|
||||
element: Element.t ;
|
||||
coord: Angstrom.t;
|
||||
coord : Angstrom.t;
|
||||
}
|
||||
|
||||
type xyz_file =
|
||||
{
|
||||
number_of_atoms : int;
|
||||
file_title : string;
|
||||
nuclei : nucleus list;
|
||||
number_of_atoms : int ;
|
||||
file_title : string ;
|
||||
nuclei : nucleus list ;
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,7 @@ let make ?multiplicity:(multiplicity=1) ?charge:(charge=0) ~nuclei basis =
|
||||
Electrons.make ~multiplicity ~charge nuclei
|
||||
in
|
||||
let charge =
|
||||
Array.fold_left (fun accu (e, _) -> accu + Charge.to_int (Element.to_charge e) )
|
||||
0 nuclei - Electrons.(electrons.n_alpha + electrons.n_beta)
|
||||
|> Charge.of_int
|
||||
Charge.(Nuclei.charge nuclei + Electrons.charge electrons)
|
||||
in
|
||||
let overlap =
|
||||
lazy (Overlap.of_basis basis)
|
||||
@ -41,7 +39,7 @@ let make ?multiplicity:(multiplicity=1) ?charge:(charge=0) ~nuclei basis =
|
||||
|
||||
let of_filenames ?multiplicity:(multiplicity=1) ?charge:(charge=0) ~nuclei basis =
|
||||
let nuclei =
|
||||
Nuclei.of_filename ~filename:nuclei
|
||||
Nuclei.of_filename nuclei
|
||||
in
|
||||
let basis =
|
||||
Basis.of_nuclei_and_basis_filename ~nuclei ~filename:basis
|
||||
|
@ -12,3 +12,14 @@ let to_string x =
|
||||
else
|
||||
Printf.sprintf "%f" x
|
||||
|
||||
let ( + ) a b =
|
||||
(to_float a) +. (to_float b) |> of_float
|
||||
|
||||
let ( - ) a b =
|
||||
(to_float a) -. (to_float b) |> of_float
|
||||
|
||||
let ( * ) a b =
|
||||
(to_float a) *. b |> of_float
|
||||
|
||||
let ( / ) a b =
|
||||
(to_float a) /. b |> of_float
|
@ -10,3 +10,9 @@ val of_int : int -> t
|
||||
|
||||
val to_string: t -> string
|
||||
val of_string: string -> t
|
||||
|
||||
val ( + ) : t -> t -> t
|
||||
val ( - ) : t -> t -> t
|
||||
val ( * ) : t -> float -> t
|
||||
val ( / ) : t -> float -> t
|
||||
|
@ -21,3 +21,7 @@ let make ?multiplicity:(multiplicity=1) ?charge:(charge=0) nuclei =
|
||||
invalid_arg (__FILE__^": make");
|
||||
result
|
||||
|
||||
let charge e =
|
||||
- (e.n_alpha + e.n_beta)
|
||||
|> Charge.of_int
|
||||
|
||||
|
@ -15,3 +15,7 @@ val make : ?multiplicity:int -> ?charge:int -> Nuclei.t -> t
|
||||
@raise Invalid_argument if the spin multiplicity is not compatible with
|
||||
the molecule and the total charge.
|
||||
*)
|
||||
|
||||
val charge : t -> Charge.t
|
||||
(** Sum of the charges of the electrons. *)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user