Table of Contents

PartialOperator

PartialOperator(op,indices,mode) takes an operator and a list of indices and depending on mode removes or keeps specific terms.

Mode “include” keeps all terms whereby at least one of the creation or annihilation operators acts on the orbitals included in the list indices.

Mode “exclude” removes all terms whereby at least one of the creation or annihilation operators acts on the orbitals included in the list indices.

Mode “conserve” removes all terms that do not keep the occupation conserved from the orbitals listed in the table indices. In this case the table indices is allowed to include tables. In the latter case the sum of the occupation all orbitals in the list needs to be conserved

Input

Output

Example

Input

Example.Quanty
NF = 3
NB = 0
 
opp1cr = NewOperator(NF,NB, {{ 0,1},{ 1,1},{ 2,1}})
opp1an = NewOperator(NF,NB, {{-0,1},{-1,1},{-2,1}})
opp2 = opp1cr * opp1an
opp3 = opp1an * opp2
opp4 = opp1cr * opp3
 
opp = 1 + opp1cr + opp1an + opp2 + opp3 + opp4
 
-- The operatore contains strings of creation and annihilation operators of length 0 to 4
-- l=0  1 term
-- l=1  6 terms (3 creation, 3 annihilation)
-- l=2  9 terms (3 creation * 3 annihilation)
-- l=3  9 terms (cr an an) note that an0 an1 = - an1 an0
-- l=4  9 terms 
-- the full operator is
print("================ opp =============")
print(opp)
 
-- We only keep terms that at least act once on orbital 1
print("================ PartialOperator  {1} include =============")
print(PartialOperator(opp,{1},"include"))
 
-- We only keep terms that at least act once on orbital 0 or at orbital 1
print("================ PartialOperator  {0,2} include =============")
print(PartialOperator(opp,{0,2},"include"))
 
-- We remove all terms that act on orbital 1
print("================ PartialOperator  {1} exclude =============")
print(PartialOperator(opp,{1},"exclude"))
 
-- We exclude all terms that act on orbital 0 and we exclude all terms that act on orbital 2
print("================ PartialOperator  {0,2} exclude =============")
print(PartialOperator(opp,{0,2},"exclude"))
 
-- We only keep the terms that keep the occupation of orbital 1 conserved
print("================ PartialOperator  {1} conserve =============")
print(PartialOperator(opp,{1},"conserve"))
 
-- We only keep the terms that keep the occupation of orbital 0 conserved and that keep
-- the occupation of orbital 2 conserved
print("================ PartialOperator  {0,2} conserve =============")
print(PartialOperator(opp,{0,2},"conserve"))
 
-- We only keep those terms that keep the sum of the occupation of orbital 0 and 2 conserved
print("================ PartialOperator  {{0,2}} conserve =============")
print(PartialOperator(opp,{{0,2}},"conserve"))

Result

================ opp =============
 
Operator: Operator
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   0
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   0)
|  1.00000000000000E+00
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          6 (number of operators of length   1)
C  0 |  1.00000000000000E+00
C  1 |  1.00000000000000E+00
C  2 |  1.00000000000000E+00
A  0 |  4.00000000000000E+00
A  1 |  4.00000000000000E+00
A  2 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          9 (number of operators of length   2)
C  0 A  0 |  4.00000000000000E+00
C  1 A  0 |  4.00000000000000E+00
C  2 A  0 |  4.00000000000000E+00
C  0 A  1 |  4.00000000000000E+00
C  1 A  1 |  4.00000000000000E+00
C  2 A  1 |  4.00000000000000E+00
C  0 A  2 |  4.00000000000000E+00
C  1 A  2 |  4.00000000000000E+00
C  2 A  2 |  4.00000000000000E+00
 
Operator of Length   3
QComplex      =          0 (Real==0 or Complex==1)
N             =          9 (number of operators of length   3)
C  0 A  1 A  0 |  0.00000000000000E+00
C  0 A  2 A  0 |  0.00000000000000E+00
C  1 A  1 A  0 |  0.00000000000000E+00
C  1 A  2 A  0 |  0.00000000000000E+00
C  2 A  1 A  0 |  0.00000000000000E+00
C  2 A  2 A  0 |  0.00000000000000E+00
C  0 A  2 A  1 |  0.00000000000000E+00
C  1 A  2 A  1 |  0.00000000000000E+00
C  2 A  2 A  1 |  0.00000000000000E+00
 
Operator of Length   4
QComplex      =          0 (Real==0 or Complex==1)
N             =          9 (number of operators of length   4)
C  1 C  0 A  1 A  0 |  0.00000000000000E+00
C  2 C  0 A  1 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  1 A  1 A  0 |  0.00000000000000E+00
C  2 C  1 A  2 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  1 A  2 A  1 |  0.00000000000000E+00
 
 
================ PartialOperator  {1} include =============
 
Operator: 
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   1)
C  1 |  1.00000000000000E+00
A  1 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          5 (number of operators of length   2)
C  1 A  0 |  4.00000000000000E+00
C  0 A  1 |  4.00000000000000E+00
C  1 A  1 |  4.00000000000000E+00
C  2 A  1 |  4.00000000000000E+00
C  1 A  2 |  4.00000000000000E+00
 
Operator of Length   3
QComplex      =          0 (Real==0 or Complex==1)
N             =          7 (number of operators of length   3)
C  0 A  1 A  0 |  0.00000000000000E+00
C  1 A  1 A  0 |  0.00000000000000E+00
C  1 A  2 A  0 |  0.00000000000000E+00
C  2 A  1 A  0 |  0.00000000000000E+00
C  0 A  2 A  1 |  0.00000000000000E+00
C  1 A  2 A  1 |  0.00000000000000E+00
C  2 A  2 A  1 |  0.00000000000000E+00
 
Operator of Length   4
QComplex      =          0 (Real==0 or Complex==1)
N             =          8 (number of operators of length   4)
C  1 C  0 A  1 A  0 |  0.00000000000000E+00
C  2 C  0 A  1 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  1 A  1 A  0 |  0.00000000000000E+00
C  2 C  1 A  2 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  1 A  2 A  1 |  0.00000000000000E+00
 
 
================ PartialOperator  {0,2} include =============
 
Operator: 
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          4 (number of operators of length   1)
C  0 |  1.00000000000000E+00
C  2 |  1.00000000000000E+00
A  0 |  4.00000000000000E+00
A  2 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          8 (number of operators of length   2)
C  0 A  0 |  4.00000000000000E+00
C  1 A  0 |  4.00000000000000E+00
C  2 A  0 |  4.00000000000000E+00
C  0 A  1 |  4.00000000000000E+00
C  2 A  1 |  4.00000000000000E+00
C  0 A  2 |  4.00000000000000E+00
C  1 A  2 |  4.00000000000000E+00
C  2 A  2 |  4.00000000000000E+00
 
Operator of Length   3
QComplex      =          0 (Real==0 or Complex==1)
N             =          9 (number of operators of length   3)
C  0 A  1 A  0 |  0.00000000000000E+00
C  0 A  2 A  0 |  0.00000000000000E+00
C  1 A  1 A  0 |  0.00000000000000E+00
C  1 A  2 A  0 |  0.00000000000000E+00
C  2 A  1 A  0 |  0.00000000000000E+00
C  2 A  2 A  0 |  0.00000000000000E+00
C  0 A  2 A  1 |  0.00000000000000E+00
C  1 A  2 A  1 |  0.00000000000000E+00
C  2 A  2 A  1 |  0.00000000000000E+00
 
Operator of Length   4
QComplex      =          0 (Real==0 or Complex==1)
N             =          9 (number of operators of length   4)
C  1 C  0 A  1 A  0 |  0.00000000000000E+00
C  2 C  0 A  1 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  1 A  1 A  0 |  0.00000000000000E+00
C  2 C  1 A  2 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  1 A  2 A  1 |  0.00000000000000E+00
 
 
================ PartialOperator  {1} exclude =============
 
Operator: 
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   0
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   0)
|  1.00000000000000E+00
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          4 (number of operators of length   1)
C  0 |  1.00000000000000E+00
C  2 |  1.00000000000000E+00
A  0 |  4.00000000000000E+00
A  2 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          4 (number of operators of length   2)
C  0 A  0 |  4.00000000000000E+00
C  2 A  0 |  4.00000000000000E+00
C  0 A  2 |  4.00000000000000E+00
C  2 A  2 |  4.00000000000000E+00
 
Operator of Length   3
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   3)
C  0 A  2 A  0 |  0.00000000000000E+00
C  2 A  2 A  0 |  0.00000000000000E+00
 
Operator of Length   4
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   4)
C  2 C  0 A  2 A  0 |  0.00000000000000E+00
 
 
================ PartialOperator  {0,2} exclude =============
 
Operator: 
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   0
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   0)
|  1.00000000000000E+00
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   1)
C  1 |  1.00000000000000E+00
A  1 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   2)
C  1 A  1 |  4.00000000000000E+00
 
 
================ PartialOperator  {1} conserve =============
 
Operator: 
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   0
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   0)
|  1.00000000000000E+00
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          4 (number of operators of length   1)
C  0 |  1.00000000000000E+00
C  2 |  1.00000000000000E+00
A  0 |  4.00000000000000E+00
A  2 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          5 (number of operators of length   2)
C  0 A  0 |  4.00000000000000E+00
C  2 A  0 |  4.00000000000000E+00
C  1 A  1 |  4.00000000000000E+00
C  0 A  2 |  4.00000000000000E+00
C  2 A  2 |  4.00000000000000E+00
 
Operator of Length   3
QComplex      =          0 (Real==0 or Complex==1)
N             =          4 (number of operators of length   3)
C  0 A  2 A  0 |  0.00000000000000E+00
C  1 A  1 A  0 |  0.00000000000000E+00
C  2 A  2 A  0 |  0.00000000000000E+00
C  1 A  2 A  1 |  0.00000000000000E+00
 
Operator of Length   4
QComplex      =          0 (Real==0 or Complex==1)
N             =          5 (number of operators of length   4)
C  1 C  0 A  1 A  0 |  0.00000000000000E+00
C  2 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  1 A  1 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  1 A  2 A  1 |  0.00000000000000E+00
 
 
================ PartialOperator  {0,2} conserve =============
 
Operator: 
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   0
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   0)
|  1.00000000000000E+00
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   1)
C  1 |  1.00000000000000E+00
A  1 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          3 (number of operators of length   2)
C  0 A  0 |  4.00000000000000E+00
C  1 A  1 |  4.00000000000000E+00
C  2 A  2 |  4.00000000000000E+00
 
Operator of Length   3
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   3)
C  0 A  1 A  0 |  0.00000000000000E+00
C  2 A  2 A  1 |  0.00000000000000E+00
 
Operator of Length   4
QComplex      =          0 (Real==0 or Complex==1)
N             =          3 (number of operators of length   4)
C  1 C  0 A  1 A  0 |  0.00000000000000E+00
C  2 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  1 A  2 A  1 |  0.00000000000000E+00
 
 
================ PartialOperator  {{0,2}} conserve =============
 
Operator: 
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =          3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)
 
Operator of Length   0
QComplex      =          0 (Real==0 or Complex==1)
N             =          1 (number of operators of length   0)
|  1.00000000000000E+00
 
Operator of Length   1
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   1)
C  1 |  1.00000000000000E+00
A  1 |  4.00000000000000E+00
 
Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          5 (number of operators of length   2)
C  0 A  0 |  4.00000000000000E+00
C  2 A  0 |  4.00000000000000E+00
C  1 A  1 |  4.00000000000000E+00
C  0 A  2 |  4.00000000000000E+00
C  2 A  2 |  4.00000000000000E+00
 
Operator of Length   3
QComplex      =          0 (Real==0 or Complex==1)
N             =          4 (number of operators of length   3)
C  0 A  1 A  0 |  0.00000000000000E+00
C  2 A  1 A  0 |  0.00000000000000E+00
C  0 A  2 A  1 |  0.00000000000000E+00
C  2 A  2 A  1 |  0.00000000000000E+00
 
Operator of Length   4
QComplex      =          0 (Real==0 or Complex==1)
N             =          5 (number of operators of length   4)
C  1 C  0 A  1 A  0 |  0.00000000000000E+00
C  2 C  0 A  2 A  0 |  0.00000000000000E+00
C  2 C  1 A  1 A  0 |  0.00000000000000E+00
C  1 C  0 A  2 A  1 |  0.00000000000000E+00
C  2 C  1 A  2 A  1 |  0.00000000000000E+00

Table of contents