9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-13 00:43:39 +01:00
qp2/ocaml/Multiplicity.ml

38 lines
736 B
OCaml
Raw Normal View History

2019-03-13 13:02:29 +01:00
open Qptypes
open Sexplib.Std
2019-01-25 11:39:31 +01:00
type t = Strictly_positive_int.t [@@deriving sexp]
2019-03-13 13:02:29 +01:00
let of_int = Strictly_positive_int.of_int
let to_int = Strictly_positive_int.to_int
2019-01-25 11:39:31 +01:00
let to_string m =
match (to_int m) with
| 1 -> "Singlet"
| 2 -> "Doublet"
| 3 -> "Triplet"
| 4 -> "Quartet"
| 5 -> "Quintet"
| 6 -> "Sextet"
| 7 -> "Septet"
| 8 -> "Octet"
| 9 -> "Nonet"
| i -> Printf.sprintf "%d-et" i
2019-03-13 13:02:29 +01:00
2019-01-25 11:39:31 +01:00
let of_alpha_beta a b =
let a = Elec_alpha_number.to_int a
and b = Elec_beta_number.to_int b
in
assert (a >= b);
of_int (1 + a - b)
2019-03-13 13:02:29 +01:00
2019-01-25 11:39:31 +01:00
let to_alpha_beta ne m =
let ne = Elec_number.to_int ne in
let nb = (ne-(to_int m)+1)/2 in
let na = ne - nb in
(Elec_alpha_number.of_int na, Elec_beta_number.of_int nb)
2019-03-13 13:02:29 +01:00