diff --git a/CI/Spindeterminant.ml b/CI/Spindeterminant.ml index dccd981..c12d774 100644 --- a/CI/Spindeterminant.ml +++ b/CI/Spindeterminant.ml @@ -5,6 +5,8 @@ type s = } type t = s option +type hole = int +type particle = int let phase = function | Some s -> s.phase @@ -42,10 +44,10 @@ let creation p = function end -let annihilation q = function +let annihilation h = function | None -> None | Some spindet -> - let i = pred q in + let i = pred h in if not (Z.testbit spindet.bitstring i) then None else @@ -58,7 +60,11 @@ let annihilation q = function Some { bitstring ; phase } end +let single_excitation_reference h p spindet = + creation p @@ annihilation h @@ spindet +let single_excitation p q = + single_excitation_reference p q let of_list l = List.rev l @@ -105,7 +111,7 @@ let test_case () = Alcotest.(check bool) "phase 2" true (phase det = Phase.Neg); in - let test_operators () = + let test_a_operators () = let det = creation 5 @@ creation 2 @@ creation 2 @@ creation 1 @@ vac in @@ -150,9 +156,19 @@ let test_case () = Alcotest.(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 l_a in + let l_b = [ 1 ; 7 ; 3 ; 5 ] in + let det2 = of_list l_b in + Alcotest.(check bool) "single 1" true (single_excitation 2 7 det = det2); + Alcotest.(check bool) "single 1" true (single_excitation 4 7 det |> is_none); + in [ "Creation", `Quick, test_creation; - "Operators", `Quick, test_operators; + "Creation/Annihilation Operators", `Quick, test_a_operators; + "Excitation Operators", `Quick, test_exc_operators; ] diff --git a/CI/Spindeterminant.mli b/CI/Spindeterminant.mli index b266e06..de49a5f 100644 --- a/CI/Spindeterminant.mli +++ b/CI/Spindeterminant.mli @@ -5,6 +5,8 @@ as a bit string and a phase factor. *) type t +type hole = int +type particle = int (** {1 Accessors}. *) @@ -27,11 +29,15 @@ val is_none : t -> bool val vac : t (** Vacuum state, [vac = Some ]{% $|\rangle$ %} *) -val creation : int -> t -> t +val creation : particle -> t -> t (** [creation p] is the creation operator {% $a^\dagger_p$ %}. *) -val annihilation : int -> t -> t -(** [annihilation q] is the annihilation operator {% $a_q$ %}. *) +val annihilation : hole -> t -> t +(** [annihilation h] is the annihilation operator {% $a_h$ %}. *) + +val single_excitation : hole -> particle -> t -> t +(** Single excitation operator {% $T_h^p = a^\dagger_p a_h$ %}. *) + val of_list : int list -> t (** Builds a spin-determinant from a list of orbital indices. If the creation of the