10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-23 04:43:32 +01:00
QCaml/ci/test/determinant.ml

112 lines
3.8 KiB
OCaml
Raw Normal View History

2024-06-24 14:28:30 +02:00
open Common
open Ci
let tests =
let test_creation () =
let l_a = [ 1 ; 2 ; 3 ; 5 ; 64 ]
and l_b = [ 2 ; 3 ; 5 ; 65 ] in
let det = Determinant.of_lists 66 l_a l_b in
let z_a = Determinant.alfa det
and z_b = Determinant.beta det in
Alcotest.(check (list int )) "alfa" (Spindeterminant.to_list z_a) l_a;
Alcotest.(check (list int )) "beta" (Spindeterminant.to_list z_b) l_b;
Alcotest.(check bool) "phase" (Determinant.phase det = Phase.Pos) true;
in
let test_phase () =
let l_a = [ 1 ; 2 ; 3 ; 64 ; 5 ]
and l_b = [ 2 ; 3 ; 5 ; 65 ] in
let det = Determinant.of_lists 66 l_a l_b in
Alcotest.(check bool) "phase" (Determinant.phase det = Phase.Neg) true;
let l_a = [ 1 ; 2 ; 3 ; 64 ; 5 ]
and l_b = [ 3 ; 2 ; 5 ; 65 ] in
let det = Determinant.of_lists 66 l_a l_b in
Alcotest.(check bool) "phase" (Determinant.phase det = Phase.Pos) true;
let l_a = [ 1 ; 3 ; 2 ; 64 ; 5 ]
and l_b = [ 3 ; 2 ; 5 ; 65 ] in
let det = Determinant.of_lists 66 l_a l_b in
Alcotest.(check bool) "phase" (Determinant.phase det = Phase.Neg) true;
let l_a = [ 1 ; 3 ; 2 ; 64 ; 5 ]
and l_b = [ 3 ; 2 ; 65 ; 5 ] in
let det = Determinant.of_lists 66 l_a l_b in
Alcotest.(check bool) "phase" (Determinant.phase det = Phase.Pos) true;
in
let test_operators () =
let det =
let open Determinant in
let open Spin in
creation Alfa 1 @@ creation Alfa 3 @@ creation Alfa 2 @@ creation Alfa 5 @@
creation Beta 1 @@ creation Beta 3 @@ creation Beta 4 @@ creation Beta 5 @@ vac 10
in
Alcotest.(check bool) "creation 1" true
(det = Determinant.of_lists 10 [ 1 ; 3 ; 2 ; 5 ] [1 ; 3 ; 4 ; 5 ] );
let det' =
Determinant.single_excitation Spin.Alfa 3 6 det
in
Alcotest.(check bool) "single_exc 1" true
(det' = Determinant.of_lists 10 [ 1 ; 6 ; 2 ; 5 ] [1 ; 3 ; 4 ; 5 ] );
let det' =
Determinant.single_excitation Spin.Beta 3 6 det
in
Alcotest.(check bool) "single_exc 2" true
(det' = Determinant.of_lists 10 [ 1 ; 3 ; 2 ; 5 ] [1 ; 6 ; 4 ; 5 ] );
let det' =
Determinant.single_excitation Spin.Alfa 4 6 det
in
Alcotest.(check bool) "single_exc 3" true (Determinant.is_none det');
let det' =
Determinant.single_excitation Spin.Beta 1 5 det
in
Alcotest.(check bool) "single_exc 4" true (Determinant.is_none det');
let det' =
Determinant.double_excitation Spin.Alfa 3 6 Spin.Alfa 2 7 det
in
let det'' = Determinant.of_lists 10 [ 1 ; 6 ; 7 ; 5 ] [1 ; 3 ; 4 ; 5 ] in
Alcotest.(check bool) "double_exc 1" true (det' = det'');
let det' =
Determinant.double_excitation Spin.Beta 3 6 Spin.Beta 5 7 det
in
Alcotest.(check bool) "double_exc 2" true
(det' = Determinant.of_lists 10 [ 1 ; 3 ; 2 ; 5 ] [1 ; 6 ; 4 ; 7 ] );
let det' =
Determinant.double_excitation Spin.Alfa 3 6 Spin.Beta 5 7 det
in
Alcotest.(check bool) "double_exc 3" true
(det' = Determinant.of_lists 10 [ 1 ; 6 ; 2 ; 5 ] [1 ; 3 ; 4 ; 7 ] );
let det' =
Determinant.double_excitation Spin.Beta 5 7 Spin.Alfa 3 6 det
in
Alcotest.(check bool) "double_exc 4" true
(det' = Determinant.of_lists 10 [ 1 ; 6 ; 2 ; 5 ] [1 ; 3 ; 4 ; 7 ] );
let det' =
Determinant.double_excitation Spin.Alfa 4 6 Spin.Alfa 2 7 det
in
Alcotest.(check bool) "double_exc 5" true (Determinant.is_none det');
let det' =
Determinant.double_excitation Spin.Beta 1 5 Spin.Alfa 2 7 det
in
Alcotest.(check bool) "double_exc 6" true (Determinant.is_none det');
in
[
"Creation", `Quick, test_creation;
"Phase", `Quick, test_phase;
"Operators",`Quick, test_operators;
]