10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-05 13:43:57 +01:00
quantum_package/ocaml/Long_basis.ml

55 lines
1.0 KiB
OCaml
Raw Normal View History

2017-08-18 19:43:52 +02:00
open Qptypes
open Sexplib.Std
2014-09-17 14:57:12 +02:00
2017-08-18 18:28:33 +02:00
type t = (Symmetry.Xyz.t * Gto.t * Nucl_number.t ) list [@@deriving sexp]
2014-09-17 14:57:12 +02:00
let of_basis b =
let rec do_work accu = function
| [] -> accu
2014-09-17 23:47:13 +02:00
| (g,n)::tail ->
2014-09-17 14:57:12 +02:00
begin
let new_accu =
Symmetry.Xyz.of_symmetry g.Gto.sym
2017-08-18 19:43:52 +02:00
|> List.rev_map (fun x-> (x,g,n))
2014-09-17 14:57:12 +02:00
in
do_work (new_accu@accu) tail
end
in
do_work [] b
|> List.rev
2017-08-18 19:43:52 +02:00
2014-09-17 14:57:12 +02:00
2014-10-26 12:46:17 +01:00
let to_basis b =
let rec do_work accu = function
| [] -> List.rev accu
| (s,g,n)::tail ->
let first_sym =
Symmetry.Xyz.of_symmetry g.Gto.sym
2017-08-18 19:43:52 +02:00
|> List.hd
2014-10-26 12:46:17 +01:00
in
let new_accu =
if ( s = first_sym ) then
(g,n)::accu
else
accu
in
do_work new_accu tail
in
do_work [] b
2017-08-18 19:43:52 +02:00
2014-09-17 14:57:12 +02:00
let to_string b =
2017-08-18 19:43:52 +02:00
let middle = List.map (fun (x,y,z) ->
"( "^((string_of_int (Nucl_number.to_int z)))^", "^
2014-10-25 21:24:21 +02:00
(Symmetry.Xyz.to_string x)^", "^(Gto.to_string y)
^" )"
2014-09-17 14:57:12 +02:00
) b
2017-08-18 19:43:52 +02:00
|> String.concat ",\n"
2014-10-25 21:24:21 +02:00
in "("^middle^")"
2017-08-18 19:43:52 +02:00
include To_md5
let to_md5 = to_md5 sexp_of_t
2017-08-18 19:43:52 +02:00