def test_1(self):
        from phenum.phonons import arrow_concs

        cList = [1, 2, 1]
        aconcs = [0, 0.4245868629437351, 0]

        self.assertEqual(arrow_concs(cList,aconcs),[[-1, 1], [-1, 3], [-1, 2], [-1, 2]])
Esempio n. 2
0
    def test_2(self):
        from phenum.phonons import arrow_concs

        cList = [3]
        aconcs = [0.8205195542173467]
        out = [[-1, 1], [1, 1], [1, 1]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
Esempio n. 3
0
    def test_5(self):
        from phenum.phonons import arrow_concs

        cList = [3]
        aconcs = [0.2871674398220775]
        out = [[-1, 1], [-1, 1], [-1, 1]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
Esempio n. 4
0
    def test_6(self):
        from phenum.phonons import arrow_concs

        cList = [3, 1]
        aconcs = [0.32514696876724436, 0]
        out = [[-1, 2], [-1, 1], [-1, 1], [-1, 1]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
Esempio n. 5
0
    def test_1(self):
        from phenum.phonons import arrow_concs

        cList = [1, 2, 1]
        aconcs = [0, 0.4245868629437351, 0]

        self.assertEqual(arrow_concs(cList, aconcs),
                         [[-1, 1], [-1, 3], [-1, 2], [-1, 2]])
Esempio n. 6
0
    def test_12(self):
        from phenum.phonons import arrow_concs

        cList = [3, 0, 2]
        aconcs = [0, 0, 0.5]
        out = [[-1, 3], [-1, 1], [-1, 1], [-1, 1], [1, 3]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
    def test_2(self):
        from phenum.phonons import arrow_concs

        cList = [3]
        aconcs = [0.8205195542173467]
        out = [[-1, 1], [1, 1], [1, 1]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
    def test_11(self):
        from phenum.phonons import arrow_concs

        cList = [2, 0, 1]
        aconcs = [0,0,0]
        out = [[-1, 3], [-1, 1], [-1,1]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
    def test_12(self):
        from phenum.phonons import arrow_concs

        cList = [3, 0, 2]
        aconcs = [0,0,0.5]
        out = [[-1, 3], [-1, 1], [-1, 1], [-1, 1], [1, 3]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
Esempio n. 10
0
    def test_6(self):
        from phenum.phonons import arrow_concs

        cList = [3, 1]
        aconcs = [0.32514696876724436, 0]
        out = [[-1, 2], [-1, 1], [-1, 1], [-1, 1]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
Esempio n. 11
0
    def test_5(self):
        from phenum.phonons import arrow_concs

        cList = [3]
        aconcs = [0.2871674398220775]
        out = [[-1, 1], [-1, 1], [-1, 1]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
Esempio n. 12
0
    def test_11(self):
        from phenum.phonons import arrow_concs

        cList = [2, 0, 1]
        aconcs = [0, 0, 0]
        out = [[-1, 3], [-1, 1], [-1, 1]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
Esempio n. 13
0
    def test_4(self):
        from phenum.phonons import arrow_concs

        cList = [2, 4, 1, 5, 2, 1, 1]
        aconcs = [0.9068065455664464, 0.2858477549741846, 0, 0, 0.6957735268097871, 0, 0]
        out = [[-1, 1], [-1, 3], [-1, 5], [-1, 6], [-1, 7], [-1, 2], [-1, 2], [-1, 2], [-1, 4],
               [-1, 4], [-1, 4], [-1, 4], [-1, 4], [1, 1], [1, 2], [1, 5]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
Esempio n. 14
0
    def test_8(self):
        from phenum.phonons import arrow_concs

        cList = [2, 8, 3, 1]
        aconcs = [0.8244881520042212, 0.33517966472359717, 0.677253228566329, 0]
        out = [[-1, 1], [-1, 3], [-1, 4], [-1, 2], [-1, 2], [-1, 2], [-1, 2], [-1, 2], [-1, 2],
               [1, 1], [1, 2], [1, 2], [1, 3], [1, 3]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
Esempio n. 15
0
    def test_3(self):
        from phenum.phonons import arrow_concs

        cList = [10, 3, 1]
        aconcs = [0, 0.4989661535030203, 0]
        out = [[-1, 3], [-1, 2], [-1, 2], [-1, 1], [-1, 1], [-1, 1], [-1, 1],
               [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [1, 2]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
Esempio n. 16
0
    def test_3(self):
        from phenum.phonons import arrow_concs

        cList = [10, 3, 1]
        aconcs = [0, 0.4989661535030203, 0]
        out = [[-1, 3], [-1, 2], [-1, 2], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1],
               [-1, 1], [-1, 1], [-1, 1], [-1, 1], [1, 2]]
        
        self.assertEqual(arrow_concs(cList,aconcs),out)
Esempio n. 17
0
    def test_8(self):
        from phenum.phonons import arrow_concs

        cList = [2, 8, 3, 1]
        aconcs = [
            0.8244881520042212, 0.33517966472359717, 0.677253228566329, 0
        ]
        out = [[-1, 1], [-1, 3], [-1, 4], [-1, 2], [-1, 2], [-1, 2], [-1, 2],
               [-1, 2], [-1, 2], [1, 1], [1, 2], [1, 2], [1, 3], [1, 3]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
Esempio n. 18
0
    def test_4(self):
        from phenum.phonons import arrow_concs

        cList = [2, 4, 1, 5, 2, 1, 1]
        aconcs = [
            0.9068065455664464, 0.2858477549741846, 0, 0, 0.6957735268097871,
            0, 0
        ]
        out = [[-1, 1], [-1, 3], [-1, 5], [-1, 6], [-1, 7], [-1, 2], [-1, 2],
               [-1, 2], [-1, 4], [-1, 4], [-1, 4], [-1, 4], [-1, 4], [1, 1],
               [1, 2], [1, 5]]

        self.assertEqual(arrow_concs(cList, aconcs), out)
Esempio n. 19
0
def _polya_out(args):
    """Generates the 'polya.out' files for the cell sizes specified in 'lattice.in'
    (or other specified input file).

    Args:
        args (dict): The command line inputs.
    """
    from phenum.HNFs import get_HNFs
    from phenum.grouptheory import get_sym_group
    from phenum.symmetry import get_concs_for_size
    from phenum.io_utils import read_lattice
    import phenum.phonons as pb
    from phenum.polyaburnside import polya
    params = read_lattice(args["lattice"])

    for s in range(params["sizes"][0], params["sizes"][1]+1):
        # get HNFs
        hnfs = get_HNFs(s,params["lat_vecs"],params["basis_vecs"],3)
        out = open(args["outfile"]+"."+str(s), 'w+')
        # find the concentrations available for the desired cell sizes.
        c_list = get_concs_for_size(s, params["nspecies"], params["is_crestricted"],
                                   len(params["basis_vecs"]), params["concs"])
        
        # We need to write the concs in c_list to the output file.
        out.write('{0: <28}'.format("# HNF"))
        for conc in c_list:
            out.write("{0: <50}".format(':'.join(map(str, conc))))
        out.write('{0: <50}\n'.format("Total"))

        a_concs = pb.get_arrow_concs(params)
        conc_totals = [0 for i in range(len(c_list))]
        for thnf in hnfs:
            hnf = [thnf[0][0],thnf[1][0],thnf[1][1],thnf[2][0],thnf[2][1],thnf[2][2]]
            out.write("  {0: <26}".format(' '.join(map(str, hnf))))
            sym_g = get_sym_group(params["lat_vecs"],params["basis_vecs"],thnf,3)
            agroup = []
            len_sym_g = len(sym_g.perm.site_perm)
            for i in range(len_sym_g):
                agroup.append([sym_g.perm.site_perm[i],sym_g.perm.arrow_perm[i]])
                
            # we need to loop over the concentrations and find the
            # number of arrangements possible for each cell size
            total = 0
            for iconc, conc in enumerate(c_list):
                if len(conc) > 0:
                    decorations = pb.arrow_concs(conc,a_concs)
                
                    # we need to know the concentrations of the
                    # species with and without arrows, we also need to
                    # know the number of arrows and their species so
                    # we can undo the previous step later
                    (n_arrows,arrow_types,concs_w_arrows) = pb.how_many_arrows(decorations)

                    # now find the number of unique arrangements using Polya.
                    if arrow_types != 0 or n_arrows !=0:
                        total_num = polya(concs_w_arrows,agroup,arrowings=arrow_types)
                    else:
                        total_num = polya(conc, agroup)

                    out.write("{0: <50d}".format(total_num))
                    total += total_num
                    conc_totals[iconc] += total_num
            out.write('{0: <10d}\n'.format(total))
        out.write("# " + ''.join(['-' for i in range(len(c_list)*10 + 10 + 30)]) + '\n')
        out.write("{0: <28}".format("  0 0 0 0 0 0"))
        for ctotal in conc_totals:
            out.write("{0: <50d}".format(ctotal))
        out.write("{0: <50d}\n".format(sum(conc_totals)))
        out.close()
def _polya_out(args):
    """Generates the 'polya.out' files for the cell sizes specified in 'lattice.in'
    (or other specified input file).

    Args:
        args (dict): The command line inputs.
    """
    from phenum.HNFs import get_HNFs
    from phenum.grouptheory import get_sym_group
    from phenum.symmetry import get_concs_for_size
    from phenum.io_utils import read_lattice
    import phenum.phonons as pb
    from phenum.polyaburnside import polya
    params = read_lattice(args["lattice"])

    for s in range(params["sizes"][0], params["sizes"][1] + 1):
        # get HNFs
        hnfs = get_HNFs(s, params["lat_vecs"], params["basis_vecs"], 3)
        out = open(args["outfile"] + "." + str(s), 'w+')
        # find the concentrations available for the desired cell sizes.
        c_list = get_concs_for_size(s, params["nspecies"],
                                    params["is_crestricted"],
                                    len(params["basis_vecs"]), params["concs"])

        # We need to write the concs in c_list to the output file.
        out.write('{0: <28}'.format("# HNF"))
        for conc in c_list:
            out.write("{0: <50}".format(':'.join(map(str, conc))))
        out.write('{0: <50}\n'.format("Total"))

        a_concs = pb.get_arrow_concs(params)
        conc_totals = [0 for i in range(len(c_list))]
        for thnf in hnfs:
            hnf = [
                thnf[0][0], thnf[1][0], thnf[1][1], thnf[2][0], thnf[2][1],
                thnf[2][2]
            ]
            out.write("  {0: <26}".format(' '.join(map(str, hnf))))
            sym_g = get_sym_group(params["lat_vecs"], params["basis_vecs"],
                                  thnf, 3)
            agroup = []
            len_sym_g = len(sym_g.perm.site_perm)
            for i in range(len_sym_g):
                agroup.append(
                    [sym_g.perm.site_perm[i], sym_g.perm.arrow_perm[i]])

            # we need to loop over the concentrations and find the
            # number of arrangements possible for each cell size
            total = 0
            for iconc, conc in enumerate(c_list):
                if len(conc) > 0:
                    decorations = pb.arrow_concs(conc, a_concs)

                    # we need to know the concentrations of the
                    # species with and without arrows, we also need to
                    # know the number of arrows and their species so
                    # we can undo the previous step later
                    (n_arrows, arrow_types,
                     concs_w_arrows) = pb.how_many_arrows(decorations)

                    # now find the number of unique arrangements using Polya.
                    if arrow_types != 0 or n_arrows != 0:
                        total_num = polya(concs_w_arrows,
                                          agroup,
                                          arrowings=arrow_types)
                    else:
                        total_num = polya(conc, agroup)

                    out.write("{0: <50d}".format(total_num))
                    total += total_num
                    conc_totals[iconc] += total_num
            out.write('{0: <10d}\n'.format(total))
        out.write("# " +
                  ''.join(['-'
                           for i in range(len(c_list) * 10 + 10 + 30)]) + '\n')
        out.write("{0: <28}".format("  0 0 0 0 0 0"))
        for ctotal in conc_totals:
            out.write("{0: <50d}".format(ctotal))
        out.write("{0: <50d}\n".format(sum(conc_totals)))
        out.close()