예제 #1
0
    def test_6(self):
        from phenum.phonons import enum_sys
        from numpy import array
        groupfile = None
        concs = [3, 1, 2]
        a_cons = [0.0, 0.5, 0.25]
        num_wanted = 6
        HNF = array([1, 0, 1, 0, 0, 6])
        params = {
            'bulk':
            True,
            'nspecies':
            3,
            'concs': [[1.0, 6.0, 12.0, 0.0], [1.0, 9.0, 12.0, 0.5],
                      [1.0, 12.0, 12.0, 0.25]],
            'basis_vecs': [[0.0, 0.0, 0.0]],
            'sizes': [6, 6],
            'lat_vecs': [[0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5]],
            'arrows':
            True,
            'is_crestricted':
            True
        }
        out = _read_output("enum_sys.out.6")

        self.assertEqual(
            enum_sys(groupfile, concs, a_cons, num_wanted, HNF, params, True),
            out)
예제 #2
0
 def test_5(self):
     from phenum.phonons import enum_sys
     from numpy import array
     groupfile = "tests/phonons/test_group.5"
     concs = [4,4]
     a_cons = [0,0]
     num_wanted = 10
     HNF = array([1,0,2,0,0,4])
     params = {'bulk': True, 'nspecies': 2, 'concs': [], 'basis_vecs': [[0.0, 0.0, 0.0]], 'sizes': [1, 11], 'lat_vecs': [[0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5]], 'arrows': False, 'is_crestricted': False}
     out = [[[-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 2], [-1, 2]], [[-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 2], [-1, 2]], [[-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2], [-1, 2]], [[-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 2], [-1, 2], [-1, 1]], [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 1], [-1, 2], [-1, 2]], [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2], [-1, 1], [-1, 2]], [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2], [-1, 2], [-1, 1]], [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 2], [-1, 2], [-1, 1], [-1, 1]], [[-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 1], [-1, 2]], [[-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2], [-1, 1]]]
     self.assertEqual(enum_sys(groupfile,concs,a_cons,num_wanted,HNF,params,True),out)
예제 #3
0
 def test_5(self):
     from phenum.phonons import enum_sys
     from numpy import array
     groupfile = "tests/phonons/test_group.5"
     concs = [4, 4]
     a_cons = [0, 0]
     num_wanted = 10
     HNF = array([1, 0, 2, 0, 0, 4])
     params = {
         'bulk': True,
         'nspecies': 2,
         'concs': [],
         'basis_vecs': [[0.0, 0.0, 0.0]],
         'sizes': [1, 11],
         'lat_vecs': [[0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5]],
         'arrows': False,
         'is_crestricted': False
     }
     out = [[[-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 2],
             [-1, 2]],
            [[-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 2],
             [-1, 2]],
            [[-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2],
             [-1, 2]],
            [[-1, 1], [-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 2], [-1, 2],
             [-1, 1]],
            [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 1], [-1, 2],
             [-1, 2]],
            [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2], [-1, 1],
             [-1, 2]],
            [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2], [-1, 2],
             [-1, 1]],
            [[-1, 1], [-1, 1], [-1, 2], [-1, 2], [-1, 2], [-1, 2], [-1, 1],
             [-1, 1]],
            [[-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 1],
             [-1, 2]],
            [[-1, 1], [-1, 2], [-1, 1], [-1, 2], [-1, 2], [-1, 1], [-1, 2],
             [-1, 1]]]
     self.assertEqual(
         enum_sys(groupfile, concs, a_cons, num_wanted, HNF, params, True),
         out)
예제 #4
0
    def test_3(self):
        from numpy import array
        from phenum.phonons import enum_sys
        groupfile = "tests/phonons/test_group.3"
        concs = [4, 3]
        a_cons = [0, 0]
        num_wanted = 4
        HNF = array([1, 0, 1, 1, 2, 7])
        params = {
            'bulk': True,
            'nspecies': 2,
            'concs': [],
            'basis_vecs': [[0.0, 0.0, 0.0]],
            'sizes': [1, 11],
            'lat_vecs': [[0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5]],
            'arrows': False,
            'is_crestricted': False
        }
        out = _read_output("enum_sys.out.3")

        self.assertEqual(
            enum_sys(groupfile, concs, a_cons, num_wanted, HNF, params, True),
            out)
예제 #5
0
def _enum_out(args):
    """Produce the enumerations of a subset of the total number of possible 
    arrangements for the desired HNFs. It assumes that all the information 
    used in the polya part above is still available.

    Args:
        args (dict): The command line inputs.
    """

    import phenum.io_utils as io
    import phenum.phonons as pb
    from phenum.msg import verbosity
    from random import seed
    from phenum.grouptheory import get_full_HNF, SmithNormalForm
    from os.path import isfile
    from glob import glob
    from copy import deepcopy

    if args["seed"] is not None:
        seed(a=args["seed"])
    keep_supers = False
    if args["super"]:
        keep_supers = True

    params = io.read_lattice(args["lattice"])

    if not isfile(args["input"]):
        if not len(glob("polya.out.*")) >= 1:
            temp_args = deepcopy(args)
            temp_args["outfile"] = "polya.out"
            _polya_out(temp_args)

        temp_args = deepcopy(args)
        temp_args["input"] = "polya.out"
        temp_args["outfile"] = args["input"]
        if args["distribution"] is None:
            temp_args["distribution"] = ["all", "all"]
        else:
            temp_args["distribution"] = args["distribution"]
        _enum_in(temp_args)

    systems = io.read_enum(args["input"])
    io.write_enum(params, outfile=args["outfile"])

    count_t = 1
    count_s = 0
    from operator import itemgetter
    sfmt = (
        "{0: >10d}{1: >10d}{2: >8d}{3: >9d}{4: >9d}{5: >12d}{6: >4d}{7: >6d}"
        "{8: >10}  {9: >18}  {10: >44}    {11}    {12: >21}\n")

    def fmtn(l, n):
        l = [int(i) for i in l]
        return (''.join([
            "{{{0:d}: >{1:d}d}}".format(i, n) for i in range(len(l))
        ])).format(*l)

    with open(args["outfile"], 'a') as f:
        enumlist = []
        for hnf, conc, num_wanted in systems:
            if verbosity is not None and verbosity >= 1:  #pragma: no cover
                from tqdm import tqdm
                pbar = tqdm(total=len(systems))
            (SNF, L, R) = SmithNormalForm(get_full_HNF(hnf))
            SNF = [SNF[0][0], SNF[1][1], SNF[2][2]]
            LT = [item for row in L for item in row]
            a_concs = pb.get_arrow_concs(params)
            configs = pb.enum_sys(None, list(conc), a_concs, num_wanted, hnf,
                                  params, keep_supers, args["acceptrate"])

            for config in configs:
                labeling, arrowing = io.create_labeling(config)
                enumlist.append(((hnf[0] * hnf[2] * hnf[5]), hnf, SNF, LT,
                                 labeling, arrowing))

            sortenum = sorted(enumlist, key=itemgetter(0, 4))
            if len(sortenum) > 0:
                last_sz = sortenum[0][0]
            if verbosity is not None and verbosity >= 1:  #pragma: no cover
                pbar.update(1)

        for (size, hnf, SNF, LT, labeling, arrowing) in sortenum:
            if size != last_sz:
                count_s = 1
                last_sz = size
            else:
                count_s += 1

            o = sfmt.format(count_t, 1, 1, 1, 1,
                            count_s, size, 1, fmtn(SNF, 3), fmtn(hnf, 3),
                            fmtn(LT, 5), labeling, arrowing)

            f.write(o)

            count_t += 1