def main(argv):
    """Print norm of psi."""
    if len(argv) < 1 or len(argv) > 2:
        print("Usage: python3 print_error.py psi_name [max_order]")
    NAME = argv[0]
    iofvars = []
    split_orders = []
    normdict = {}
    psi = load_group(NAME,
                     iofvars=iofvars,
                     split_orders=split_orders,
                     normdict=normdict)
    max_order = int(str(argv[1])) if len(argv) > 2 else len(split_orders - 2)
    zeroth_order = psi[split_orders[0]:split_orders[1]]
    psi = substitute_group(psi, normdict)
    for order in range(max_order + 1):
        norm = trace_inner_product(
            zeroth_order, psi[split_orders[0]:split_orders[order + 1]])
        print(mstr(simplify(norm)))
示例#2
0
def main(argv):
    """Convert unitary of form U = e^i(Gs[0] + Gs[1]+...) to operator psi."""
    if len(argv) < 2 or len(argv) > 3:
        print(
            "Usage: python3 print_error.py unitary_name output_name [max_order]"
        )
    gs_name = argv[0]
    psi_name = argv[1]
    zeroth_order = []
    Gs = load_group(gs_name, zeroth_order=zeroth_order)
    max_order = int(str(argv[2])) if len(argv) > 2 else len(Gs)
    split_orders = [0, 1]
    psi = zeroth_order[:]
    for order in range(1, max_order + 1):
        psi += unitary_transform_to_order(zeroth_order, Gs, order)
        split_orders.append(len(psi))
        save_group(psi,
                   psi_name + '_r' + str(order),
                   split_orders=split_orders)
示例#3
0
fpart = [Ncproduct(I*f, [2*j+1,2*j+2]) for j in range(L-1)]
V1part = [Ncproduct(V1, [2*j+1,2*j+2,2*j+3,2*j+4]) for j in range(L-2)]
V2part = [Ncproduct(V2, [2*j+2,2*j+3,2*j+4,2*j+5]) for j in range(L-2)]
small = fpart+V1part+V2part
Jpart = [Ncproduct(I*J, [2*j+2,2*j+3]) for j in range(L-1)]
H = fpart + V1part + V2part +Jpart

START_ORDER = 7
END_ORDER = 8

START_PSI = (N(1, 'a1')
             + N(f/J, 'a2') + N(V1/(I*J), 'b1 a2 a3'))

START_IOFVARS = []
START_SPLIT_ORDERS = [0, 1, 3]
START_NORMDICT = {}

START_PSI = comm.load_group('psidual_r6', START_IOFVARS, START_SPLIT_ORDERS)#, START_NORMDICT)

orders.update(zip(START_IOFVARS,[START_ORDER-1]*len(START_IOFVARS)))

FILEHEAD = 'psidual'
NORM_AS_YOU_GO = False

START_NORMDICT = comm.check_normalisable(START_PSI,
                                         START_IOFVARS,
                                         START_ORDER-1,
                                         orders,
                                         START_SPLIT_ORDERS,
                                         update_splits = False)
示例#4
0
def main(argv):
    try:
        opts,args = getopt.getopt(argv, 'scvtbof')
    except getopt.GetoptError:
        print ("usage: print_options.py [-s][-c][-v]")
        sys.exit(2)
    iofvars = []
    split_orders = []
    normdict = {}
    sub = False
    collect = False
    convert = False
    texify = False
    extract_free = False
    bare = False
    order = False
    for opt, arg in opts:
        if opt =='-s':
            sub = True
        if opt == '-c':
            collect = True
        if opt == '-v':
            convert = True
        if opt == '-t':
            texify = True
            bare = False
        if opt == '-b':
            bare = True
            texify = False
        if opt == '-o':
            order = True
        if opt == '-f':
            extract_free = True
    if sub:
        psi = load_group(argv[1], iofvars = iofvars, normdict=normdict)
    else:
        psi = load_group(argv[1], iofvars = iofvars)
    if extract_free:
        psi = [el for el in psi if any(i in iofvars for i in el.scalar.atoms(Symbol))]
    if sub:
        psi = substitute_group(psi, normdict)
    if collect:
        psi = collect_terms(psi)
        remove_zeros(psi)
    if convert:
        psi = convert_group(psi)
    if order:
        V, f, V1, V2, X, Y = symbols('V f V1 V2 X Y')
        orders = {V:1,f:1,V1:1,V2:1, X:1, Y:1}
        psi = order_group(psi, orders)

    if texify:
        print('\\documentclass{article}\n'
              '\\usepackage{amsmath, amssymb, graphics, setspace}\n'
              '\\allowdisplaybreaks\n'
              '\\begin{document}')
        print(texify_group(psi, newlines = True))
        print('\\end{document}')
    elif bare:
        for el in psi:
            print(repr(el))
    else:
        print_group(psi)
示例#5
0
fpart = [Ncproduct(I*f, [2*j+1,2*j+2]) for j in range(L)]
V1part = [Ncproduct(V1, [2*j+1,2*j+2,2*j+3,2*j+4]) for j in range(L-2)]
V2part = [Ncproduct(V2, [2*j+2,2*j+3,2*j+4,2*j+5]) for j in range(L-2)]
small = fpart+V1part+V2part
Jpart = [Ncproduct(I*J, [2*j+2,2*j+3]) for j in range(L-1)]
H = fpart + V1part + V2part +Jpart

START_ORDER = 6
END_ORDER = 6

START_PSI = (N(1, 'a1')
             + N(f/J, 'a2') + N(V1/(I*J), 'b1 a2 a3'))
START_IOFVARS = []
START_SPLIT_ORDERS = [0, 1, 3]

START_PSI = comm.load_group('psi_dual_r5', START_IOFVARS, START_SPLIT_ORDERS)

orders.update(zip(START_IOFVARS,[START_ORDER-1]*len(START_IOFVARS)))

FILEHEAD = 'psidual'
NORM_AS_YOU_GO = True


psi = START_PSI
iofvars = START_IOFVARS
split_orders = START_SPLIT_ORDERS

for test_order in range(START_ORDER, END_ORDER+1):
    psi_sub = None
    psi_test_sub = None
示例#6
0
fpart = [N(I*f, [2*j+1,2*j+2]) for j in range(L)]
Vpart = [N(V, [2*j+1,2*j+2,2*j+3,2*j+4]) for j in range(L-2)]
small = fpart+Vpart
Jpart = [N(I, [2*j+2,2*j+3]) for j in range(L-1)]
H = fpart + Vpart +Jpart

START_ORDER = 7
END_ORDER = 8

#START_PSI = (N(1, 'a1')
#             + N(f, 'a2') + N(V/(I), 'b1 a2 a3'))

START_IOFVARS = []
START_SPLIT_ORDERS = [0, 1, 3]

START_PSI = comm.load_group('jto1psi_r6', START_IOFVARS, START_SPLIT_ORDERS)

orders.update(zip(START_IOFVARS,[START_ORDER-1]*len(START_IOFVARS)))

FILEHEAD = 'jto1psi'
NORM_AS_YOU_GO = True


psi = START_PSI
iofvars = START_IOFVARS
split_orders = START_SPLIT_ORDERS

for test_order in range(START_ORDER, END_ORDER+1):
    psi_sub = None
    psi_test_sub = None
示例#7
0
def main(argv):
    """ See flags for a description of each argument."""
    try:
        opts, args = getopt.getopt(argv, 'scvtbofzum')
    except getopt.GetoptError:
        print("usage: print_options.py [-scvtbofzum] filename")
        sys.exit(2)
    name = argv[1] if len(argv) > 1 else argv[0]
    iofvars = []
    normdict = {}
    sub = False
    collect = False
    convert = False
    texify = False
    extract_free = False
    bare = False
    order = False
    zero_free = False
    unitary = False
    simplify = False
    for opt, arg in opts:
        if opt == '-s':
            sub = True
        if opt == '-c':
            collect = True
        if opt == '-v':
            convert = True
        if opt == '-t':
            texify = True
            bare = False
        if opt == '-b':
            bare = True
            texify = False
        if opt == '-o':
            order = True
        if opt == '-f':
            extract_free = True
        if opt == '-z':
            zero_free = True
        if opt == '-u':
            unitary = True
        if opt == '-m':
            simplify = True
    if sub or zero_free:
        psi = load_group(name, iofvars=iofvars, normdict=normdict)
    elif unitary:
        gs = load_group(name)
        psi = []
        for g in gs:
            psi += g
    else:
        psi = load_group(name, iofvars=iofvars)
    if extract_free:
        psi = [
            el for el in psi
            if any(i in iofvars for i in el.scalar.atoms(Symbol))
        ]
    if sub:
        psi = substitute_group(psi, normdict)
    if zero_free:
        psi = substitute_group(psi, dict(zip(iofvars, [0] * len(iofvars))))
        remove_zeros(psi)
    if collect:
        psi = collect_terms(psi)
        remove_zeros(psi)
    if convert:
        psi = convert_group(psi)
    if order:
        V, f, V1, V2, X, Y, Vy = symbols('V f V1 V2 X Y Vy')
        orders = {V: 1, f: 1, V1: 1, V2: 1, X: 1, Y: 1, Vy: 1}
        psi = order_group(psi, orders)
    if simplify:
        psi = full_simplify_group(psi)
    if texify:
        print('\\documentclass{article}\n'
              '\\usepackage{amsmath, amssymb, graphics, setspace}\n'
              '\\allowdisplaybreaks\n'
              '\\begin{document}')
        print(texify_group(psi, newlines=True))
        print('\\end{document}')
    elif bare:
        for el in psi:
            print(repr(el))
    else:
        print_group(psi)
示例#8
0
comm.mathematica_parser.vardict = {'J2':J2, 'f': f}
p.orders = orders
fpart = [Ncproduct(I*f, [2*j+1,2*j+2]) for j in range(L-1)]
V2part = [Ncproduct(J2, [2*j+2,2*j+3,2*j+4,2*j+5]) for j in range(L-2)]
small = fpart+V2part
Jpart = [Ncproduct(I, [2*j+2,2*j+3]) for j in range(L-1)]
H = small +Jpart

START_ORDER = 8
END_ORDER = 10

START_PSI = [N(1, 'a1')]

START_IOFVARS = []
START_SPLIT_ORDERS = []
START_NORMDICT = {}

START_PSI = comm.load_group('psi_j2_r8', START_IOFVARS, START_SPLIT_ORDERS, START_NORMDICT)

orders.update(zip(START_IOFVARS,[START_ORDER-1]*len(START_IOFVARS)))

FILEHEAD = 'psi_j2_test'
NORM_AS_YOU_GO = True

# START_NORMDICT = comm.check_normalisable(START_PSI,
#                                          START_IOFVARS,
#                                          START_ORDER-1,
#                                          orders,
#                                          START_SPLIT_ORDERS,
#                                          update_splits = False)
示例#9
0
#!/home/kempj/py343ve/bin/python

from sys import argv
from commutator import load_group, print_group, square_to_find_identity_scalar_up_to_order
from sympy import latex

iofvars = []
split_orders = []
normdict = {}
psi = load_group(argv[1], iofvars = iofvars, split_orders = split_orders, normdict=normdict)
prop = square_to_find_identity_scalar_up_to_order(psi, int(argv[2]), split_orders)
print(str(prop)+'\n\n')
print(latex(prop).replace('\\\\', '\\'))
示例#10
0
p.orders = orders
fpart = [Ncproduct(I * f, [2 * j + 1, 2 * j + 2]) for j in range(L - 1)]
V1part = [Ncproduct(V1, [2 * j + 1, 2 * j + 2, 2 * j + 3, 2 * j + 4]) for j in range(L - 2)]
V2part = [Ncproduct(V2, [2 * j + 2, 2 * j + 3, 2 * j + 4, 2 * j + 5]) for j in range(L - 2)]
small = fpart + V1part + V2part
Jpart = [Ncproduct(I * J, [2 * j + 2, 2 * j + 3]) for j in range(L - 1)]
H = fpart + V1part + V2part + Jpart

START_ORDER = 11
END_ORDER = 50

START_PSI = N(1, "a1") + N(f / J, "a2") + N(V1 / (I * J), "b1 a2 a3")

START_IOFVARS = []
START_SPLIT_ORDERS = [0, 1, 3]
START_NORMDICT = {}

START_PSI = comm.load_group("finitedual_r10", START_IOFVARS, START_SPLIT_ORDERS, START_NORMDICT)

orders.update(zip(START_IOFVARS, [START_ORDER - 1] * len(START_IOFVARS)))

FILEHEAD = "finitedual"
NORM_AS_YOU_GO = False

# START_NORMDICT = comm.check_normalisable(START_PSI,
#                                         START_IOFVARS,
#                                         START_ORDER-1,
#                                         orders,
#                                         START_SPLIT_ORDERS,
#                                         update_splits = False)