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)))
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
0
    psi_test = comm.sparse_solve_for_commuting_term(cvector,
                                                    psi,
                                                    test_order,
                                                    orders,
                                                    matrixrows,
                                                    subspace,
                                                    norm = False,
                                                    subs_rules = subs_rules,
                                                    iofvars = iofvars,
                                                    split_orders = split_orders,
                                                    fvarname = 'F' + str(test_order) + '_')

    for x in sorted(subs_rules.keys(), key = lambda x: int(str(x)[2+len(str(test_order)):])):
        print(str(x)+': ' +str(subs_rules[x]))
    print('\n')
    psi = comm.substitute_group(psi, subs_rules, split_orders)

    orders.update(zip(iofvars,[test_order]*len(iofvars)))
    normdict = comm.check_normalisable(psi+psi_test, iofvars, test_order, orders, split_orders)
    for x in sorted(normdict.keys(), key = lambda x: int(str(x)[2+len(str(test_order)):])):
        print(str(x)+': ' +str(normdict[x]))
    psi_test_sub = comm.substitute_group(psi_test, normdict)
    psi_sub = psi + psi_test_sub
    comm.save_group(psi_sub, FILEHEAD)

    psi += psi_test
    comm.save_group(psi,
                    FILEHEAD + '_r' + str(test_order), iofvars=iofvars, split_orders=split_orders)

    if NORM_AS_YOU_GO:
        prop = comm.square_to_find_identity(psi_sub)[0].scalar
Esempio n. 5
0
    psi_test = comm.sparse_solve_for_commuting_term(cvector,
                                                    psi,
                                                    test_order,
                                                    orders,
                                                    matrixrows,
                                                    subspace,
                                                    norm = False,
                                                    subs_rules = subs_rules,
                                                    iofvars = iofvars,
                                                    split_orders = split_orders,
                                                    fvarname = 'F' + str(test_order) + '_')

    for x in sorted(subs_rules.keys(), key = lambda x: int(str(x)[2+len(str(test_order)):])):
        print(str(x)+': ' +str(subs_rules[x]))
    print('\n')
    psi = comm.substitute_group(psi, subs_rules, split_orders)

    orders.update(zip(iofvars,[test_order]*len(iofvars)))
    try:
        normdict = comm.check_normalisable(psi+psi_test, iofvars, test_order, orders, split_orders)
        for x in sorted(normdict.keys(), key = lambda x: int(str(x)[2+len(str(test_order)):])):
            print(str(x)+': ' +str(normdict[x]))
    except ValueError as e:
        print(str(e))

    psi += psi_test
    comm.save_group(psi,
                    FILEHEAD + '_r' + str(test_order), iofvars=iofvars, split_orders=split_orders)

    if NORM_AS_YOU_GO:
        prop = comm.square_to_find_identity_scalar_up_to_order(psi, test_order, split_orders)