mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-07 06:33:39 +01:00
Single excitation operator
This commit is contained in:
parent
e34208f00f
commit
1c5cca608f
@ -5,6 +5,8 @@ type s =
|
|||||||
}
|
}
|
||||||
|
|
||||||
type t = s option
|
type t = s option
|
||||||
|
type hole = int
|
||||||
|
type particle = int
|
||||||
|
|
||||||
let phase = function
|
let phase = function
|
||||||
| Some s -> s.phase
|
| Some s -> s.phase
|
||||||
@ -42,10 +44,10 @@ let creation p = function
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
let annihilation q = function
|
let annihilation h = function
|
||||||
| None -> None
|
| None -> None
|
||||||
| Some spindet ->
|
| Some spindet ->
|
||||||
let i = pred q in
|
let i = pred h in
|
||||||
if not (Z.testbit spindet.bitstring i) then
|
if not (Z.testbit spindet.bitstring i) then
|
||||||
None
|
None
|
||||||
else
|
else
|
||||||
@ -58,7 +60,11 @@ let annihilation q = function
|
|||||||
Some { bitstring ; phase }
|
Some { bitstring ; phase }
|
||||||
end
|
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 =
|
let of_list l =
|
||||||
List.rev l
|
List.rev l
|
||||||
@ -105,7 +111,7 @@ let test_case () =
|
|||||||
Alcotest.(check bool) "phase 2" true (phase det = Phase.Neg);
|
Alcotest.(check bool) "phase 2" true (phase det = Phase.Neg);
|
||||||
in
|
in
|
||||||
|
|
||||||
let test_operators () =
|
let test_a_operators () =
|
||||||
let det =
|
let det =
|
||||||
creation 5 @@ creation 2 @@ creation 2 @@ creation 1 @@ vac
|
creation 5 @@ creation 2 @@ creation 2 @@ creation 1 @@ vac
|
||||||
in
|
in
|
||||||
@ -150,9 +156,19 @@ let test_case () =
|
|||||||
Alcotest.(check bool) "phase 6" true (phase det = Phase.Pos);
|
Alcotest.(check bool) "phase 6" true (phase det = Phase.Pos);
|
||||||
|
|
||||||
in
|
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;
|
"Creation", `Quick, test_creation;
|
||||||
"Operators", `Quick, test_operators;
|
"Creation/Annihilation Operators", `Quick, test_a_operators;
|
||||||
|
"Excitation Operators", `Quick, test_exc_operators;
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ as a bit string and a phase factor.
|
|||||||
*)
|
*)
|
||||||
|
|
||||||
type t
|
type t
|
||||||
|
type hole = int
|
||||||
|
type particle = int
|
||||||
|
|
||||||
(** {1 Accessors}. *)
|
(** {1 Accessors}. *)
|
||||||
|
|
||||||
@ -27,11 +29,15 @@ val is_none : t -> bool
|
|||||||
val vac : t
|
val vac : t
|
||||||
(** Vacuum state, [vac = Some ]{% $|\rangle$ %} *)
|
(** Vacuum state, [vac = Some ]{% $|\rangle$ %} *)
|
||||||
|
|
||||||
val creation : int -> t -> t
|
val creation : particle -> t -> t
|
||||||
(** [creation p] is the creation operator {% $a^\dagger_p$ %}. *)
|
(** [creation p] is the creation operator {% $a^\dagger_p$ %}. *)
|
||||||
|
|
||||||
val annihilation : int -> t -> t
|
val annihilation : hole -> t -> t
|
||||||
(** [annihilation q] is the annihilation operator {% $a_q$ %}. *)
|
(** [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
|
val of_list : int list -> t
|
||||||
(** Builds a spin-determinant from a list of orbital indices. If the creation of the
|
(** Builds a spin-determinant from a list of orbital indices. If the creation of the
|
||||||
|
Loading…
Reference in New Issue
Block a user