mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 20:33:36 +01:00
103 lines
3.2 KiB
OCaml
103 lines
3.2 KiB
OCaml
|
open Alcotest
|
||
|
open Ci
|
||
|
open Ci.Spindeterminant
|
||
|
|
||
|
let tests =
|
||
|
|
||
|
let test_creation () =
|
||
|
let l_a = [ 1 ; 2 ; 3 ; 5 ] in
|
||
|
let det = of_list 10 l_a in
|
||
|
check (list int ) "bitstring 1" l_a (to_list det);
|
||
|
check bool "phase 2" true (phase det = Phase.Pos);
|
||
|
let l_b = [ 1 ; 3 ; 2 ; 5 ] in
|
||
|
let det = of_list 10 l_b in
|
||
|
check (list int ) "bitstring 2" l_a (to_list det);
|
||
|
check bool "phase 2" true (phase det = Phase.Neg);
|
||
|
in
|
||
|
|
||
|
let test_a_operators () =
|
||
|
let det =
|
||
|
creation 5 @@ creation 2 @@ creation 2 @@ creation 1 @@ (vac 10)
|
||
|
in
|
||
|
check bool "none 1" true (is_none det);
|
||
|
|
||
|
let det =
|
||
|
creation 5 @@ creation 3 @@ creation 2 @@ creation 1 @@ (vac 10)
|
||
|
in
|
||
|
let l_a = [ 1 ; 2 ; 3 ; 5 ] in
|
||
|
check (list int) "bitstring 1" l_a (to_list det);
|
||
|
check bool "phase 1" true (phase det = Phase.Pos);
|
||
|
|
||
|
let det =
|
||
|
creation 1 @@ creation 3 @@ creation 2 @@ creation 5 @@ (vac 10)
|
||
|
in
|
||
|
check (list int) "bitstring 2" l_a (to_list det);
|
||
|
check bool "phase 2" true (phase det = Phase.Neg);
|
||
|
|
||
|
let l_b = [ 1 ; 3 ; 2 ; 5 ] in
|
||
|
let det = of_list 10 l_b in
|
||
|
check (list int ) "bitstring 3" l_a (to_list det);
|
||
|
check bool "phase 3" true (phase det = Phase.Neg);
|
||
|
|
||
|
check bool "none 1" true (annihilation 4 det |> is_none);
|
||
|
|
||
|
let det =
|
||
|
annihilation 1 det
|
||
|
in
|
||
|
check (list int ) "bitstring 4" (List.tl l_a) (to_list det);
|
||
|
check bool "phase 4" true (phase det = Phase.Neg);
|
||
|
|
||
|
let det =
|
||
|
annihilation 3 det
|
||
|
in
|
||
|
check (list int ) "bitstring 5" [ 2 ; 5 ] (to_list det);
|
||
|
check bool "phase 5" true (phase det = Phase.Pos);
|
||
|
|
||
|
let det =
|
||
|
annihilation 5 @@ annihilation 2 det
|
||
|
in
|
||
|
check (list int ) "bitstring 6" [] (to_list det);
|
||
|
check bool "phase 6" true (phase det = Phase.Pos);
|
||
|
|
||
|
in
|
||
|
|
||
|
let test_exc_operators () =
|
||
|
let l_a = [ 1 ; 2 ; 3 ; 5 ] in
|
||
|
let det = of_list 10 l_a in
|
||
|
let l_b = [ 1 ; 7 ; 3 ; 5 ] in
|
||
|
let det2 = of_list 10 l_b in
|
||
|
Format.printf "%a@." pp det;
|
||
|
Format.printf "%a@." pp det2;
|
||
|
Format.printf "%a@." pp (Spindeterminant.single_excitation 2 7 det);
|
||
|
check bool "single 1" true (Spindeterminant.single_excitation 2 7 det = det2);
|
||
|
check bool "single 2" true (Spindeterminant.single_excitation 4 7 det |> is_none);
|
||
|
|
||
|
let l_c = [ 1 ; 7 ; 6 ; 5 ] in
|
||
|
let det3 = of_list 10 l_c in
|
||
|
check bool "double 1" true (double_excitation 2 7 3 6 det = det3);
|
||
|
check bool "double 2" true (double_excitation 4 7 3 6 det |> is_none);
|
||
|
in
|
||
|
|
||
|
let test_exc_spindet () =
|
||
|
let l_a = [ 1 ; 2 ; 3 ; 5 ] in
|
||
|
let det = of_list 10 l_a in
|
||
|
let l_b = [ 1 ; 7 ; 3 ; 5 ] in
|
||
|
let det2 = of_list 10 l_b in
|
||
|
check int "single" 1 (excitation_level det det2);
|
||
|
check (list int) "holes" [2] (holes_of det det2);
|
||
|
check (list int) "particles" [7] (particles_of det det2);
|
||
|
let l_b = [ 1 ; 7 ; 3 ; 6 ] in
|
||
|
let det2 = of_list 10 l_b in
|
||
|
check int "double" 2 (excitation_level det det2);
|
||
|
check (list int) "holes" [2 ; 5] (holes_of det det2);
|
||
|
check (list int) "particles" [6 ; 7] (particles_of det det2);
|
||
|
in
|
||
|
[
|
||
|
"Creation", `Quick, test_creation;
|
||
|
"Creation/Annihilation Operators", `Quick, test_a_operators;
|
||
|
"Excitation Operators", `Quick, test_exc_operators;
|
||
|
"Excitation of spindet", `Quick, test_exc_spindet;
|
||
|
]
|
||
|
|
||
|
|