10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-08-16 01:38:30 +02:00
QCaml/mo/lib/frozen_core.ml

48 lines
782 B
OCaml
Raw Normal View History

2024-01-26 11:24:56 +01:00
(** Type *)
2021-01-01 12:52:50 +01:00
type kind =
| All_electron
| Small
| Large
type t = int array
2024-01-26 11:24:56 +01:00
(** Creation *)
2021-01-01 12:52:50 +01:00
let make_ae nuclei =
Array.map (fun _ -> 0) nuclei
let make_small nuclei =
Array.map (fun (e,_) -> Particles.Element.small_core e) nuclei
let make_large nuclei =
Array.map (fun (e,_) -> Particles.Element.large_core e) nuclei
let make = function
2024-01-26 11:24:56 +01:00
| All_electron -> make_ae
| Small -> make_small
2021-01-01 12:52:50 +01:00
| Large -> make_large
external of_int_array : int array -> t = "%identity"
let of_int_list = Array.of_list
2024-01-26 11:24:56 +01:00
(** Access *)
2021-01-01 12:52:50 +01:00
let num_elec t =
Array.fold_left ( + ) 0 t
let num_mos t =
(num_elec t) / 2
2024-01-26 11:24:56 +01:00
(** Printers *)
2021-01-01 12:52:50 +01:00
let pp ppf t =
Format.fprintf ppf "@[[|";
Array.iter (fun x -> Format.fprintf ppf "@,@[%d@]" x) t;
Format.fprintf ppf "|]@]";
2024-01-26 11:24:56 +01:00