diff --git a/test/pytriqs/base/CMakeLists.txt b/test/pytriqs/base/CMakeLists.txt index 00813070..870f7fd5 100644 --- a/test/pytriqs/base/CMakeLists.txt +++ b/test/pytriqs/base/CMakeLists.txt @@ -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 -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 -add_triqs_test_hdf(h5_example " -p 1.e-6" ) -#add_triqs_test_hdf(ExampleTestH5-2 " -p 1.e-6" ) +add_triqs_test_hdf(h5_example " -p 1.e-6") # 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: -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_init " -d 1.e-6") +add_triqs_test_hdf(gf_base_op " -d 1.e-6") # 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 -add_triqs_test_hdf(pade " -d 1.e-6" ) +add_triqs_test_hdf(pade " -d 1.e-6") diff --git a/test/pytriqs/base/operator_python_test.output b/test/pytriqs/base/operator_python_test.output new file mode 100644 index 00000000..17c27b53 --- /dev/null +++ b/test/pytriqs/base/operator_python_test.output @@ -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) diff --git a/test/pytriqs/base/operator_python_test.py b/test/pytriqs/base/operator_python_test.py new file mode 100644 index 00000000..86fe7014 --- /dev/null +++ b/test/pytriqs/base/operator_python_test.py @@ -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