occupymakert.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:ababe 作者: unkcpz 项目源码 文件源码
def run(self):
        # Create directory contain POSCARs
        import random
        import string

        rd_suffix = ''.join(random.choices(string.ascii_uppercase
                                           + string.digits, k=5))
        working_path = os.getcwd()
        out_dir = os.path.join(working_path,
                                   'STRUCTURES_{0:}_{1:}'.format(self.comment,
                                                              rd_suffix))
        if not os.path.exists(out_dir):
            os.makedirs(out_dir)
        else:
            shutil.rmtree(out_dir)
            os.makedirs(out_dir)

        ogg = OccupyGenerator(self.cell)

        if self.tr is not None:
            tr = (Specie(self.tr[0]), self.tr[1])
            applied_restriction = MinDistanceRestriction(tr)


        for n1 in range(1, self.n - 1):
            for n2 in range(1, self.n - n1):
                g = ogg.gen_nodup_trinary_alloy(Specie(self.s1), n1,
                                                Specie(self.s2), n2)

                for n_count, c in enumerate(g):
                    if self.tr is not None:
                        condition = c.is_primitive() and applied_restriction.is_satisfied(c)
                    else:
                         condition = c.is_primitive()

                    if condition:
                        if self.refined:
                            c = c.get_refined_pcell()
                        out = GeneralIO(c)

                        f_suffix = ''.join(random.choices(string.ascii_uppercase
                                                          + string.digits, k=4))
                        ofname = "STRUCTURE_{:}_{:}.{:}".format(c.comment, f_suffix, self.outmode)
                        lastpath = os.path.join(out_dir, ofname)
                        out.write_file(lastpath)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号