mirror of
https://github.com/triqs/dft_tools
synced 2024-10-31 19:23:45 +01:00
Add python test for operators
This commit is contained in:
parent
31d8120b64
commit
a56f490492
@ -1,23 +1,19 @@
|
|||||||
#if (MPI_FOUND)
|
|
||||||
# MESSAGE(STATUS "MPI launch command is : ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS")
|
|
||||||
#endif (MPI_FOUND)
|
|
||||||
|
|
||||||
# A sample test with text output
|
# A sample test with text output
|
||||||
add_triqs_test_txt(test_example )
|
add_triqs_test_txt(test_example)
|
||||||
|
add_triqs_test_txt(operator_python_test)
|
||||||
|
|
||||||
# A sample test with hdf5 output
|
# A sample test with hdf5 output
|
||||||
add_triqs_test_hdf(h5_example " -p 1.e-6" )
|
add_triqs_test_hdf(h5_example " -p 1.e-6")
|
||||||
#add_triqs_test_hdf(ExampleTestH5-2 " -p 1.e-6" )
|
|
||||||
|
|
||||||
# Some basic HDF IO stuff:
|
# Some basic HDF IO stuff:
|
||||||
add_triqs_test_hdf(hdf5_io " -p 1.e-6" )
|
add_triqs_test_hdf(hdf5_io " -p 1.e-6")
|
||||||
|
|
||||||
# Greens functions:
|
# Greens functions:
|
||||||
add_triqs_test_hdf(gf_init " -d 1.e-6" )
|
add_triqs_test_hdf(gf_init " -d 1.e-6")
|
||||||
add_triqs_test_hdf(gf_base_op " -d 1.e-6" )
|
add_triqs_test_hdf(gf_base_op " -d 1.e-6")
|
||||||
|
|
||||||
# a simple dos on square lattice
|
# a simple dos on square lattice
|
||||||
add_triqs_test_hdf(dos " -d 1.e-6" )
|
add_triqs_test_hdf(dos " -d 1.e-6")
|
||||||
|
|
||||||
# Pade approximation
|
# Pade approximation
|
||||||
add_triqs_test_hdf(pade " -d 1.e-6" )
|
add_triqs_test_hdf(pade " -d 1.e-6")
|
||||||
|
38
test/pytriqs/base/operator_python_test.output
Normal file
38
test/pytriqs/base/operator_python_test.output
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
Anticommutators:
|
||||||
|
{ 1*C^+(1,0) , 1*C(1,0) } = 1
|
||||||
|
{ 1*C^+(1,0) , 1*C(2,0) } = 0
|
||||||
|
{ 1*C^+(1,0) , 1*C(3,0) } = 0
|
||||||
|
{ 1*C^+(2,0) , 1*C(1,0) } = 0
|
||||||
|
{ 1*C^+(2,0) , 1*C(2,0) } = 1
|
||||||
|
{ 1*C^+(2,0) , 1*C(3,0) } = 0
|
||||||
|
{ 1*C^+(3,0) , 1*C(1,0) } = 0
|
||||||
|
{ 1*C^+(3,0) , 1*C(2,0) } = 0
|
||||||
|
{ 1*C^+(3,0) , 1*C(3,0) } = 1
|
||||||
|
Commutators:
|
||||||
|
[ 1*C^+(1,0) , 1*C(1,0) ] = -1 + 2*C^+(1,0)C(1,0)
|
||||||
|
[ 1*C^+(1,0) , 1*C(2,0) ] = 2*C^+(1,0)C(2,0)
|
||||||
|
[ 1*C^+(1,0) , 1*C(3,0) ] = 2*C^+(1,0)C(3,0)
|
||||||
|
[ 1*C^+(2,0) , 1*C(1,0) ] = 2*C^+(2,0)C(1,0)
|
||||||
|
[ 1*C^+(2,0) , 1*C(2,0) ] = -1 + 2*C^+(2,0)C(2,0)
|
||||||
|
[ 1*C^+(2,0) , 1*C(3,0) ] = 2*C^+(2,0)C(3,0)
|
||||||
|
[ 1*C^+(3,0) , 1*C(1,0) ] = 2*C^+(3,0)C(1,0)
|
||||||
|
[ 1*C^+(3,0) , 1*C(2,0) ] = 2*C^+(3,0)C(2,0)
|
||||||
|
[ 1*C^+(3,0) , 1*C(3,0) ] = -1 + 2*C^+(3,0)C(3,0)
|
||||||
|
|
||||||
|
Algebra:
|
||||||
|
x = 1*C(0,0)
|
||||||
|
y = 1*C^+(1,0)
|
||||||
|
-x = -1*C(0,0)
|
||||||
|
x + 2.0 = 2 + 1*C(0,0)
|
||||||
|
2.0 + x = 2 + 1*C(0,0)
|
||||||
|
x - 2.0 = -2 + 1*C(0,0)
|
||||||
|
2.0 - x = 2 + -1*C(0,0)
|
||||||
|
3.0*y = 3*C^+(1,0)
|
||||||
|
y*3.0 = 3*C^+(1,0)
|
||||||
|
x + y = 1*C^+(1,0) + 1*C(0,0)
|
||||||
|
x - y = -1*C^+(1,0) + 1*C(0,0)
|
||||||
|
(x + y)*(x - y) = 2*C^+(1,0)C(0,0)
|
||||||
|
|
||||||
|
N^3:
|
||||||
|
N = 1*C^+(0,dn)C(0,dn) + 1*C^+(0,up)C(0,up)
|
||||||
|
N^3 = 1*C^+(0,dn)C(0,dn) + 1*C^+(0,up)C(0,up) + 6*C^+(0,dn)C^+(0,up)C(0,up)C(0,dn)
|
42
test/pytriqs/base/operator_python_test.py
Normal file
42
test/pytriqs/base/operator_python_test.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
from pytriqs.operators.operators2 import *
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
C_list = [c(1,0),c(2,0),c(3,0)]
|
||||||
|
Cd_list = [c_dag(1,0), c_dag(2,0), c_dag(3,0)]
|
||||||
|
|
||||||
|
print "Anticommutators:"
|
||||||
|
for Cd,C in itertools.product(Cd_list,C_list):
|
||||||
|
print "{", Cd, ",", C, "} =", Cd*C + C*Cd
|
||||||
|
|
||||||
|
print "Commutators:"
|
||||||
|
for Cd,C in itertools.product(Cd_list,C_list):
|
||||||
|
print "[", Cd, ",", C, "] =", Cd*C - C*Cd
|
||||||
|
|
||||||
|
|
||||||
|
# Algebra
|
||||||
|
x = c(0,0)
|
||||||
|
y = c_dag(1,0)
|
||||||
|
|
||||||
|
print
|
||||||
|
print "Algebra:"
|
||||||
|
print "x =", x
|
||||||
|
print "y =", y
|
||||||
|
|
||||||
|
print "-x =", -x
|
||||||
|
print "x + 2.0 =", x + 2.0
|
||||||
|
print "2.0 + x =", 2.0 + x
|
||||||
|
print "x - 2.0 =", x - 2.0
|
||||||
|
print "2.0 - x =", 2.0 - x
|
||||||
|
print "3.0*y =", 3.0*y
|
||||||
|
print "y*3.0 =", y*3.0
|
||||||
|
print "x + y =", x + y
|
||||||
|
print "x - y =", x - y
|
||||||
|
print "(x + y)*(x - y) =", (x + y)*(x - y)
|
||||||
|
|
||||||
|
# N^3
|
||||||
|
print
|
||||||
|
print "N^3:"
|
||||||
|
N = n(0,'up') + n(0,'dn')
|
||||||
|
N3 = N*N*N
|
||||||
|
print "N =", N
|
||||||
|
print "N^3 =", N3
|
Loading…
Reference in New Issue
Block a user