10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-23 12:55:37 +01:00
QuantumPackage/ocaml/Long_basis.ml

56 lines
1.0 KiB
OCaml
Raw Normal View History

2019-01-25 11:39:31 +01:00
open Qptypes
2020-05-25 11:31:28 +02:00
open Qputils
2019-01-25 11:39:31 +01:00
open Sexplib.Std
2021-05-21 16:42:48 +02:00
type t = (Angmom.Xyz.t * Gto.t * Nucl_number.t ) list [@@deriving sexp]
2019-01-25 11:39:31 +01:00
let of_basis b =
let rec do_work accu = function
| [] -> accu
| (g,n)::tail ->
begin
let new_accu =
2021-05-21 16:42:48 +02:00
Angmom.Xyz.of_symmetry g.Gto.sym
2019-01-25 11:39:31 +01:00
|> List.rev_map (fun x-> (x,g,n))
in
do_work (new_accu@accu) tail
end
in
do_work [] b
|> List.rev
let to_basis b =
let rec do_work accu = function
| [] -> List.rev accu
| (s,g,n)::tail ->
let first_sym =
2021-05-21 16:42:48 +02:00
Angmom.Xyz.of_symmetry g.Gto.sym
2019-01-25 11:39:31 +01:00
|> List.hd
in
let new_accu =
if ( s = first_sym ) then
(g,n)::accu
else
accu
in
do_work new_accu tail
in
do_work [] b
let to_string b =
2020-05-25 11:31:28 +02:00
let middle = list_map (fun (x,y,z) ->
2019-01-25 11:39:31 +01:00
"( "^((string_of_int (Nucl_number.to_int z)))^", "^
2021-05-21 16:42:48 +02:00
(Angmom.Xyz.to_string x)^", "^(Gto.to_string y)
2019-01-25 11:39:31 +01:00
^" )"
) b
|> String.concat ",\n"
in "("^middle^")"
include To_md5
let to_md5 = to_md5 sexp_of_t