コード例 #1
0
    def _test_load_poscar(self):
        """POSCAR から cell を作成"""
        path = os.path.join(self.PATH, "i-s/poscar")
        # fcci = NaClXtal.from_pickle_ecis(os.path.join(path, "cluster.pickle"),
        #                                   arrange='random', size=10, conc=(0.01, 0.01))
        # fcci.make_poscar(os.path.join(path, "POSCAR"), 1, 1)
        fcci = NaClXtal.from_pickle_ecis(os.path.join(path, "cluster.pickle"),
                                         arrange='FCC_d', size=10)

        fcci.load_poscar(os.path.join(path, "POSCAR"), 1, 1)
        fcci.make_poscar(os.path.join(path, "POSCAR_rep"), 1, 1)

        fcci = NaClXtal.from_pickle_ecis(os.path.join(path, "cluster.pickle"),
                                         arrange='FCC_d', size=20)
        fcci.load_poscar(os.path.join(path, "POSCAR_4840"), 1, 1)
        fcci.make_poscar(os.path.join(path, "POSCAR_rep2"), 0, 1, True)
コード例 #2
0
    def _test_order_Cr(self):
        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int.pickle"),
            arrange='FCC_u', size=2)
        print('FCC Fe 57.3544')
        print(nacl.get_energy() + 171.363194)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int.pickle"),
            arrange='NaCl_uu', size=2)
        print('NaCl FeC 531.492')
        print(nacl.get_energy() + 171.363194)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int.pickle"),
            arrange='NaCl_du', size=2)
        print('NaCl CrC 115.585')
        print(nacl.get_energy() + 171.363194)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int.pickle"),
            arrange='FCC_d', size=2)
        print('FCC Cr 171.363')
        print(nacl.get_energy() + 171.363194)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int.pickle"),
            arrange='FCC_u', size=10)
        nacl.cell[0,0,0,0] = 0
        single_Cr = nacl.get_energy()
        nacl.cell[0,0,0,5] = 1
        pair_CrC = nacl.get_energy()
        nacl.cell[0,0,0,5] = 0
        nacl.cell[5,5,5,5] = 1
        solo_CrC = nacl.get_energy()
        de = pair_CrC - solo_CrC
        print(de * 10**3 * 4)
        print()
コード例 #3
0
    def _test_clus_ene(self):
        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int_Ti.pickle"),
            arrange='FCC_u', size=5)
        nacl.cell[0,0,0,0] = 0
        single_Ti = nacl.get_energy()
        nacl.cell[0,0,0,5] = 1
        pair_TiC = nacl.get_energy()
        nacl.cell[0,0,0,5] = 0
        nacl.cell[3,3,3,5] = 1
        solo_TiC = nacl.get_energy()
        de = pair_TiC - solo_TiC
        print(de * 5**3 * 4)

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int_Ti_onlyNN.pickle"),
            arrange='FCC_u', size=5)
        nacl.cell[1,0,0,0] = 0
        single_Ti = nacl.get_energy()
        nacl.cell[1,0,0,5] = 1
        pair_TiC = nacl.get_energy()
        nacl.make_poscar(os.path.join(self.PATH, 'POSCAR'))
        nacl.cell[1,0,0,5] = 0
        nacl.cell[3,3,3,5] = 1
        solo_TiC = nacl.get_energy()
        de = pair_TiC - solo_TiC
        print(de * 5**3 * 4)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "cluster_int_Ti.pickle"),
            arrange='FCC_u', size=5)
        all_Fe = nacl.get_energy()
        nacl.cell[0,0,0,0] = 0
        single_Ti = nacl.get_energy()
        nacl.cell[0,0,0,5] = 1
        pair_TiC = nacl.get_energy()
        nacl.cell[0,0,0,0] = 1
        single_C = nacl.get_energy()
        de = pair_TiC - single_Ti - single_C + all_Fe
        print(de * 5**3 * 8 / 2)
コード例 #4
0
    def _test_mc_micro_nacl(self):
        """
        i-s 系での mc 計算のてすと
        """
        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "i-s/fcci/Ti1C1/cluster.pickle"),
            arrange='random', conc=(0.001, 0.999), size=2)
        # print((-nacl.get_flip_de_int()/80))

        mc = MonteCarlo(nacl, T=1000)
        # mc.loop_flip_nacl_fix_conc(100)
        e = mc.loop_nacl_micro(10)
        lines = ""
        for i in range(len(e[0])):
            lines += str(i) + "\t" + str(e[0][i][2]) + "\t"
            for val in e[1][i][0]:
                lines += str(val) + "\t"
            for val in e[1][i][1]:
                lines += str(val) + "\t"
            lines += "\n"
        print(lines)
コード例 #5
0
    def _test_order_Ti_rev(self):
        """
        Fe-Ti-C の test
        """
        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "i-s/fcci/Ti1C1/cluster.pickle"),
            arrange='FCC_d', size=2)
        print('FCC Fe: 63.0657')
        print(nacl.get_energy() + 54.8679061)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "i-s/fcci/Ti1C1/cluster.pickle"),
            arrange='NaCl_du', size=2)
        print('NaCl FeC: 532.114')
        print(nacl.get_energy() + 54.8679061)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "i-s/fcci/Ti1C1/cluster.pickle"),
            arrange='NaCl_uu', size=2)
        print('NaCl TiC: -839.445')
        print(nacl.get_energy() + 54.8679061)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "i-s/fcci/Ti1C1/cluster.pickle"),
            arrange='FCC_u', size=2)
        print('FCC Ti: 54.8679')
        print(nacl.get_energy() + 54.8679061)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "i-s/fcci/Ti1C1/cluster.pickle"),
            arrange='order_01', size=2)
        print('FCC Ti: -243.445')
        print(nacl.get_energy() + 54.8679061)
        nacl.make_poscar(os.path.join(self.PATH, "i-s/fcci/Ti1C1/POSCAR_test"), 0, 1, True)
        print()

        nacl = NaClXtal.from_pickle_ecis(
            os.path.join(self.PATH, "i-s/fcci/Ti1C1/cluster.pickle"),
            arrange='order_00', size=2)
        print('FCC Ti: -175.298')
        print(nacl.get_energy() + 54.8679061)
        nacl.make_poscar(os.path.join(self.PATH, "i-s/fcci/Ti1C1/POSCAR_test"), 0, 1, True)
        print()
コード例 #6
0
    def _test_get_cluser_energy(self):
        """
        全てのクラスターを作成分解してエネルギーを出す
        """
        path = os.path.join(self.PATH, "i-s/fcci/Ti1C1/R6N4")
        # path = os.path.join(self.PATH, "i-s/fcci/Ti0C1/R4N4")
        # path = os.path.join(self.PATH, "i-s/fcci/Ti1C1/R4N4")
        clus = CEMParser.parse_logtxt_2sub(os.path.join(path, 'log.txt'))
        print(clus[0])
        clus_idxs = (
            np.array([[NaClSite.conv_site2idx(site) for site in cluster]
                for cluster in clus[0]]))
        fcci_xtal = NaClXtal.from_pickle_ecis(os.path.join(path, 'cluster.pickle'),
                                             size=5)
        # 全ての POSCAR を作成
        # for i in range(len(clus_idxs)):
        #     fcci_xtal.cell[:, :, :, :] = 0
        #     fcci_xtal.cell[tuple(np.array(clus_idxs[i]).T)] = 1
        #     fcci_xtal.make_poscar(os.path.join(path, 'POSCAR_{0}'.format(i)), 1, 1)

        # 全てのエネルギーを計算
        # fcci_xtal.sub_ecis[3] = 0
        # fcci_xtal.int_ecis[3] = 0
        # fcci_xtal.sub_ecis[4] = 0
        print(fcci_xtal.int_ecis)

        c_spin = 1
        a_spin = 1
        fcci_xtal.cell[:, :, :, :] = 0
        fcci_xtal.cell[:, :, :, 0:4] = 1 - c_spin
        ref_null = fcci_xtal.get_energy() * fcci_xtal.size ** 3 * 8
        print(ref_null )

        fcci_xtal.cell[:, :, :, :] = 0
        fcci_xtal.cell[tuple(np.array(clus_idxs[0]).T)] = 1
        fcci_xtal.cell[:, :, :, 0:4] = \
            (1 - fcci_xtal.cell[:, :, :, 0:4]) * (1 - c_spin) + \
            fcci_xtal.cell[:, :, :, 0:4] * c_spin
        ref_i = fcci_xtal.get_energy() * fcci_xtal.size ** 3 * 8 - ref_null

        fcci_xtal.cell[:, :, :, :] = 0
        fcci_xtal.cell[tuple(np.array(clus_idxs[1]).T)] = 1
        fcci_xtal.cell[:, :, :, 0:4] = \
            (1 - fcci_xtal.cell[:, :, :, 0:4]) * (1 - c_spin) + \
            fcci_xtal.cell[:, :, :, 0:4] * c_spin
        ref_s = fcci_xtal.get_energy() * fcci_xtal.size ** 3 * 8 - ref_null

        for i in range(len(clus_idxs)):
            fcci_xtal.cell[:, :, :, :] = 0
            fcci_xtal.cell[tuple(np.array(clus_idxs[i]).T)] = 1
            fcci_xtal.cell[:, :, :, 0:4] = \
                (1 - fcci_xtal.cell[:, :, :, 0:4]) * (1 - c_spin) + \
                fcci_xtal.cell[:, :, :, 0:4] * c_spin
            fcci_xtal.make_poscar(os.path.join(path, 'POSCAR_{0}'.format(i+1)), 1, 1)
            fcci_xtal.cell[:, :, :, :] = c_spin
            fcci_xtal.cell[:, :, :, 4:] = 1
            tot_e = fcci_xtal.get_energy() * fcci_xtal.size ** 3 * 8
            num_s = ((1 - fcci_xtal.get_conc()['subs']) * (1 - c_spin) +
                     fcci_xtal.get_conc()['subs'] * c_spin) * fcci_xtal.size ** 3 * 4
            num_i = fcci_xtal.get_conc()['inter'] * fcci_xtal.size ** 3 * 4
            num = (num_s + num_i)
            clus_e = (tot_e - num_s * ref_s - num_i * ref_i - ref_null) / num
            print(i+1, num_s, num_i, clus_e)
            # clus_e2 = (tot_e - )
        fcci_xtal.cell[:, :, :, :] = 1