YtoKMatrix

YtoKMatrix($orb$) takes the angular momentum $l$ or the name of a non-relativistic atomic orbital and returns the corresponding matrix to rotate from a basis of spherical harmonics to cubic harmonics. It is also possible to give a list of $l$ numbers or orbital names, in which case the output is a block diagonal matrix with the rotation matrices as entries.

Input

• $orb$ : An integer number, or a list of integer numbers, or a string that can be interpreted as a non-relativistic atomic orbital, or a list or strings.
• Options:
• “addSpin” : bool determining if spin-space is considered in the matrix (resulting in matrices double in size). (Default true)

Output

• $R$ : Rotation Matrix from a basis of spherical to cubic harmonics.

Example

Input

Example.Quanty
print("")
print("YtoKMatrix(0)")
print(YtoKMatrix(0))

print("")

print("")
print("YtoKMatrix(1)")
print(YtoKMatrix(1))

print("")
print("YtoKMatrix(\"p\")")
print(YtoKMatrix("p"))

print("")
print("YtoKMatrix(2)")
print(YtoKMatrix(2))

print("")
print("YtoKMatrix(\"d\")")
print(YtoKMatrix("d"))

print("")

print("")

print("\n\n")
print("A more realistic example")
Orbitals = {"1s","2s","2p"}
Indices, NF = CreateAtomicIndicesDict(Orbitals)

--Some Operator definition on spherical harmonics
op = NewOperator("U", NF, Indices["2p_Up"], Indices["2p_Dn"],{0,1})
print("Operator on a basis of spherical harmonics")
print(op)

opK = Rotate(op, YtoKMatrix(Orbitals))
print("Operator on a basis of cubic harmonics")
print(opK)

Result

YtoKMatrix(0)
{ { 1 , 0 } ,
{ 0 , 1 } }

{ { 1 } }

YtoKMatrix(1)
{ { 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 , 0 } ,
{ 0 , 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 } ,
{ (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 } ,
{ 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) } ,
{ 0 , 0 , 1 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 1 , 0 , 0 } }

YtoKMatrix("p")
{ { 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 , 0 } ,
{ 0 , 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 } ,
{ (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 } ,
{ 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) } ,
{ 0 , 0 , 1 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 1 , 0 , 0 } }

YtoKMatrix(2)
{ { 0.70710678118655 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0.70710678118655 , 0 } ,
{ 0 , 0.70710678118655 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0.70710678118655 } ,
{ 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 } ,
{ 0 , 0 , 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 , 0 , 0 } ,
{ (0 + 0.70710678118655 I) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , (0 - 0.70710678118655 I) , 0 } ,
{ 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , (0 - 0.70710678118655 I) } }

YtoKMatrix("d")
{ { 0.70710678118655 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0.70710678118655 , 0 } ,
{ 0 , 0.70710678118655 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0.70710678118655 } ,
{ 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 } ,
{ 0 , 0 , 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 , 0 , 0 } ,
{ (0 + 0.70710678118655 I) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , (0 - 0.70710678118655 I) , 0 } ,
{ 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , (0 - 0.70710678118655 I) } }

{ { 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0.70710678118655 , 0 , -0.70710678118655 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , (0 + 0.70710678118655 I) , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 0 , 0.70710678118655 , 0 , 0 , 0 , 0.70710678118655 } ,
{ 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 } ,
{ 0 , 0 , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , (0 + 0.70710678118655 I) , 0 } ,
{ 0 , 0 , 0 , 0 , 0 , 0.70710678118655 , 0 , -0.70710678118655 , 0 } ,
{ 0 , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 - 0.70710678118655 I) } }

{ { 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0.70710678118655 , 0 , -0.70710678118655 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , (0 + 0.70710678118655 I) , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 0 , 0.70710678118655 , 0 , 0 , 0 , 0.70710678118655 } ,
{ 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 } ,
{ 0 , 0 , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , (0 + 0.70710678118655 I) , 0 } ,
{ 0 , 0 , 0 , 0 , 0 , 0.70710678118655 , 0 , -0.70710678118655 , 0 } ,
{ 0 , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 - 0.70710678118655 I) } }

A more realistic example
Operator on a basis of spherical harmonics

Operator: Coulomb Operator
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =         10 (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   4
QComplex      =          0 (Real==0 or Complex==1)
N             =         25 (number of operators of length   4)
C  5 C  4 A  5 A  4 | -3.999999999999999E-02
C  7 C  5 A  7 A  5 |  2.000000000000000E-01
C  6 C  5 A  6 A  5 |  7.999999999999999E-02
C  7 C  4 A  7 A  4 |  7.999999999999999E-02
C  6 C  4 A  6 A  4 |  2.000000000000000E-01
C  9 C  5 A  9 A  5 |  2.000000000000000E-01
C  8 C  5 A  8 A  5 | -3.999999999999999E-02
C  9 C  4 A  9 A  4 | -3.999999999999999E-02
C  8 C  4 A  8 A  4 |  2.000000000000000E-01
C  7 C  6 A  7 A  6 | -1.600000000000000E-01
C  9 C  7 A  9 A  7 |  2.000000000000000E-01
C  8 C  7 A  8 A  7 |  7.999999999999999E-02
C  9 C  6 A  9 A  6 |  7.999999999999999E-02
C  8 C  6 A  8 A  6 |  2.000000000000000E-01
C  9 C  8 A  9 A  8 | -3.999999999999999E-02
C  6 C  5 A  7 A  4 |  1.200000000000000E-01
C  7 C  4 A  6 A  5 |  1.200000000000000E-01
C  8 C  5 A  7 A  6 | -1.200000000000000E-01
C  9 C  4 A  7 A  6 |  1.200000000000000E-01
C  8 C  5 A  9 A  4 |  2.400000000000000E-01
C  9 C  4 A  8 A  5 |  2.400000000000000E-01
C  7 C  6 A  8 A  5 | -1.200000000000000E-01
C  7 C  6 A  9 A  4 |  1.200000000000000E-01
C  8 C  7 A  9 A  6 |  1.200000000000000E-01
C  9 C  6 A  8 A  7 |  1.200000000000000E-01

Operator on a basis of cubic harmonics

Operator: Coulomb Operator
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          4 (largest number of product of lader operators)
NFermionic modes =         10 (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   4
QComplex      =          0 (Real==0 or Complex==1)
N             =         27 (number of operators of length   4)
C  5 C  4 A  5 A  4 | -1.599999999999999E-01
C  7 C  6 A  5 A  4 | -1.200000000000000E-01
C  7 C  4 A  7 A  4 |  7.999999999999997E-02
C  6 C  5 A  7 A  4 |  1.200000000000000E-01
C  7 C  4 A  6 A  5 |  1.200000000000000E-01
C  6 C  5 A  6 A  5 |  7.999999999999997E-02
C  5 C  4 A  7 A  6 | -1.200000000000000E-01
C  7 C  6 A  7 A  6 | -1.599999999999999E-01
C  9 C  5 A  9 A  5 |  1.999999999999999E-01
C  9 C  7 A  9 A  7 |  1.999999999999999E-01
C  8 C  5 A  8 A  5 |  7.999999999999997E-02
C  8 C  7 A  8 A  7 |  7.999999999999997E-02
C  9 C  4 A  9 A  4 |  7.999999999999997E-02
C  9 C  6 A  9 A  6 |  7.999999999999997E-02
C  8 C  4 A  8 A  4 |  1.999999999999999E-01
C  8 C  6 A  8 A  6 |  1.999999999999999E-01
C  7 C  5 A  7 A  5 |  1.999999999999999E-01
C  6 C  4 A  6 A  4 |  1.999999999999999E-01
C  9 C  8 A  9 A  8 | -1.600000000000000E-01
C  8 C  5 A  9 A  4 |  1.200000000000000E-01
C  8 C  7 A  9 A  6 |  1.200000000000000E-01
C  9 C  4 A  8 A  5 |  1.200000000000000E-01
C  9 C  6 A  8 A  7 |  1.200000000000000E-01
C  5 C  4 A  9 A  8 | -1.200000000000000E-01
C  7 C  6 A  9 A  8 | -1.200000000000000E-01
C  9 C  8 A  5 A  4 | -1.200000000000000E-01
C  9 C  8 A  7 A  6 | -1.200000000000000E-01