mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-19 04:22:21 +01:00
143 lines
3.3 KiB
OCaml
143 lines
3.3 KiB
OCaml
(* Type
|
|
*
|
|
* #+NAME: types *)
|
|
|
|
(* [[file:../angular_momentum.org::types][types]] *)
|
|
type t =
|
|
| S | P | D | F | G | H | I | J | K | L | M | N | O
|
|
| Int of int
|
|
|
|
exception Angular_momentum_error of string
|
|
|
|
type kind =
|
|
Singlet of t
|
|
| Doublet of (t * t)
|
|
| Triplet of (t * t * t)
|
|
| Quartet of (t * t * t * t)
|
|
(* types ends here *)
|
|
|
|
(* ~of_char~
|
|
*
|
|
* Returns an ~Angular_momentum.t~ when a shell is given as a character
|
|
* (case insensitive):
|
|
*
|
|
* #+begin_example
|
|
* Angular_momentum.of_char 'p' -> Angular_momentum.P
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*~of_char~][~of_char~:1]] *)
|
|
val of_char : char -> t
|
|
(* ~of_char~:1 ends here *)
|
|
|
|
(* ~to_string~
|
|
*
|
|
* Converts the angular momentum into a string:
|
|
*
|
|
* #+begin_example
|
|
* Angular_momentum.(to_string D) -> "D"
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*~to_string~][~to_string~:1]] *)
|
|
val to_string : t -> string
|
|
(* ~to_string~:1 ends here *)
|
|
|
|
(* ~to_char~
|
|
*
|
|
* Converts the angular momentum into a char:
|
|
*
|
|
* #+begin_example
|
|
* Angular_momentum.(to_char D) -> 'D'
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*~to_char~][~to_char~:1]] *)
|
|
val to_char : t -> char
|
|
(* ~to_char~:1 ends here *)
|
|
|
|
(* ~to_int~
|
|
*
|
|
* Returns the $l_{max}$ value of the shell:
|
|
*
|
|
* #+begin_example
|
|
* Angular_momentum.(to_char D) -> 2
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*~to_int~][~to_int~:1]] *)
|
|
val to_int : t -> int
|
|
(* ~to_int~:1 ends here *)
|
|
|
|
(* ~of_int~
|
|
*
|
|
* Returns a shell given an $l$ value.
|
|
*
|
|
* #+begin_example
|
|
* Angular_momentum.of_int 3 -> Angular_momentum.F
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*~of_int~][~of_int~:1]] *)
|
|
val of_int : int -> t
|
|
(* ~of_int~:1 ends here *)
|
|
|
|
(* ~n_functions~
|
|
*
|
|
* Returns the number of cartesian functions in a shell.
|
|
*
|
|
* #+begin_example
|
|
* Angular_momentum.n_functions D -> 6
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*~n_functions~][~n_functions~:1]] *)
|
|
val n_functions : t -> int
|
|
(* ~n_functions~:1 ends here *)
|
|
|
|
(* ~zkey_array~
|
|
*
|
|
* Array of ~Zkey.t~, where each element is a a key associated with the
|
|
* the powers of $x,y,z$.
|
|
*
|
|
* #+begin_example
|
|
* Angular_momentum.( zkey_array Doublet (P,S) ) ->
|
|
* [| {Zkey.left = 0; right = 1125899906842624} ;
|
|
* {Zkey.left = 0; right = 1099511627776} ;
|
|
* {Zkey.left = 0; right = 1073741824} |]
|
|
* =
|
|
*
|
|
* let s,x,y,z =
|
|
* Powers.( of_int_tuple (0,0,0),
|
|
* of_int_tuple (1,0,0),
|
|
* of_int_tuple (0,1,0),
|
|
* of_int_tuple (0,0,1) )
|
|
* in
|
|
* Array.map (fun (a,b) -> {!Zkey.of_powers_six} a b)
|
|
* [| (x,s) ; (y,s) ; (z,s) |]
|
|
*
|
|
* #+end_example *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*~zkey_array~][~zkey_array~:1]] *)
|
|
val zkey_array : kind -> Zkey.t array
|
|
(* ~zkey_array~:1 ends here *)
|
|
|
|
(* Arithmetic *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*Arithmetic][Arithmetic:1]] *)
|
|
val ( + ) : t -> t -> t
|
|
val ( - ) : t -> t -> t
|
|
(* Arithmetic:1 ends here *)
|
|
|
|
(* Printers
|
|
*
|
|
* Printers can print as a string (~pp_string~) or as an integer (~pp_int~). *)
|
|
|
|
|
|
(* [[file:../angular_momentum.org::*Printers][Printers:1]] *)
|
|
val pp_string : Format.formatter -> t -> unit
|
|
val pp_int : Format.formatter -> t -> unit
|
|
(* Printers:1 ends here *)
|