3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-27 06:43:40 +01:00
dft_tools/test/pytriqs/base/gf_inplace_112.py

56 lines
1.4 KiB
Python
Raw Normal View History

# Test from I. Krivenko.
from __future__ import print_function
from pytriqs.gf.local import *
from pytriqs.gf.local.descriptors import *
import sys
def print_err(*x) : print (*x, file= sys.stderr)
g_up = GfImFreq(indices = [0], beta = 1)
g_dn = GfImFreq(indices = [0], beta = 1)
g_up <<= iOmega_n
g_dn <<= iOmega_n
G = BlockGf(name_list=['up','dn'], block_list=[g_up,g_dn], make_copies=False)
print("Before:")
print("G['up'] =", G['up'].data[0,0,0])
print("G['dn'] =", G['dn'].data[0,0,0])
print_err('id(g_up) =', id(g_up))
print_err('id(g_dn) =', id(g_dn))
print_err ("(id=", id(G['up']),")")
print_err ("(id=", id(G['dn']),")")
G['up'] += G['dn']
print("After G['up'] += G['dn']:")
print("G['up'] =", G['up'].data[0,0,0])
print("G['dn'] =", G['dn'].data[0,0,0])
print_err('id(g_up) =', id(g_up))
print_err('id(g_dn) =', id(g_dn))
print_err ("(id=", id(G['up']),")")
print_err ("(id=", id(G['dn']),")")
g_up += g_dn
print("After g_up += g_dn:")
print("G['up'] =", G['up'].data[0,0,0])
print("G['dn'] =", G['dn'].data[0,0,0])
print_err('id(g_up) =', id(g_up))
print_err('id(g_dn) =', id(g_dn))
print_err ("(id=", id(G['up']),")")
print_err ("(id=", id(G['dn']),")")
G += G
print("After G += G:")
print("G['up'] =", G['up'].data[0,0,0])
print("G['dn'] =", G['dn'].data[0,0,0])
print_err('id(g_up) =', id(g_up))
print_err('id(g_dn) =', id(g_dn))
print_err ("(id=", id(G['up']),")")
print_err ("(id=", id(G['dn']),")")