def _test_exch_de_bcci(self): path = os.path.join(self.PATH, "i-s/bcci/CrC") pickle = os.path.join(path, 'cluster.pickle') print("A3C -.678871E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='A3C').get_energy() - 9614.98293) bcci = SubLattXtal.from_pickle_ecis( 30, pickle, BcciOctaSite, arrange='random', conc=(0.1,0.1)) bcci.cell[0,0,0,7] = 1 # print(bcci.get_energy()) print(bcci.get_energy()) with Benchmarker(width=20, loop=10) as bench: @bench("get_energy") def _(bm): #pylint: disable=W0613,C0111 bcci.get_exchange_de(np.array([0,0,0,0]), np.array([0,0,0,0])) @bench("get_energy2") def __(bm): #pylint: disable=W0613,C0111 bcci.get_exchange_de2(np.array([0,0,0,0]), np.array([0,0,0,0])) return for i in range(10): s_or_i = np.random.choice([0, 1], 1)[0] print(['sub', 'int'][s_or_i]) s0 = [bcci.cell[:, :, :, 0:2] == 0, bcci.cell[:, :, :, 2:] == 0][s_or_i] select_s0 = np.random.choice(range((s0).sum()), 1, replace=False) site_s0 = ((np.array(np.where(s0)))[:, select_s0[0]] + np.array([0,0,0,s_or_i*2])) s1 = [bcci.cell[:, :, :, 0:2] == 1, bcci.cell[:, :, :, 2:] == 1][s_or_i] select_s1 = np.random.choice(range((s1).sum()), 1, replace=False) site_s1 = ((np.array(np.where(s1)))[:, select_s1[0]] + np.array([0,0,0,s_or_i*2])) de = bcci.get_exchange_de2(site_s0, site_s1) e0 = bcci.get_energy() bcci.cell[tuple(site_s0.T)] = 1 bcci.cell[tuple(site_s1.T)] = 0 e1 = bcci.get_energy() print((de - (e1-e0)*bcci.size**3*8) ** 2 < 1e-16)
def _test_mc_bcci(self): path = os.path.join(self.PATH, "i-s/bcci/TiC_spin_r_R6N4") path = os.path.join(self.PATH, "i-s/bcci/TiC_R6N4_330str") CEMParser02.from_dirc_bcci(path, BcciOctaSite) CrC = SubLattXtal.from_pickle_ecis( 5, os.path.join(path, 'cluster.pickle'), BcciOctaSite, arrange='random', conc=(0.1, 0.1)) # CrC = SubLattXtal(2, out, BcciOctaSite, arrange='A3C', conc=(0.1, 0.1)) CrC.make_poscar(os.path.join(self.PATH, "i-s/bcci/TiC_R6N4_330str/POSCAR_init"), 1, 1) mc = MonteCarlo(CrC, T=1000) e = mc.loop_bcci_micro_single(1) CrC.make_poscar(os.path.join(self.PATH, "i-s/bcci/TiC_R6N4_330str/POSCAR"), 1, 1) print(e)
def _test_bcci3(self): path = os.path.join(self.PATH, "i-s/bcci/TiC_spin_r_R6N4") path = os.path.join(self.PATH, "i-s/bcci/TiC_R6N4_330str") clus = CEMParser.parse_logtxt_bcci(os.path.join(path, 'log.txt')) # print(clus[2]) # CEMParser.symm_cubic_bcci(clus[0], BcciOctaSite) clusters = [] for c in clus: clusters.append(CEMParser.symm_cubic_bcci(c, BcciOctaSite)) ecis = CEMParser.parse_ecitxt(os.path.join(path, 'eci.txt')) out = {} for label in ['C', 'A1', 'A2', 'A3']: tmp_clus = [] tmp_ecis = [] for i in sorted(ecis.keys()): if clusters[i][label]: tmp_clus.append( np.array([[BcciOctaSite.conv_site2idex(site) for site in cluster] for cluster in clusters[i][label]])) tmp_ecis.append(ecis[i]) out.update({label:[tmp_clus, tmp_ecis]}) # print(out['C']) print(SubLattXtal(1, out, BcciOctaSite, arrange='A3C').get_energy() - 7962.21404) print(SubLattXtal(1, out, BcciOctaSite, arrange='A2C').get_energy() - 7962.21404) print(SubLattXtal(1, out, BcciOctaSite, arrange='A1C').get_energy() - 7962.21404) print(SubLattXtal(1, out, BcciOctaSite, arrange='BCC_u').get_energy() - 7962.21404) print(SubLattXtal(1, out, BcciOctaSite, arrange='A3D').get_energy() - 7962.21404) print(SubLattXtal(1, out, BcciOctaSite, arrange='A2D').get_energy() - 7962.21404) print(SubLattXtal(1, out, BcciOctaSite, arrange='A1D').get_energy() - 7962.21404) print(SubLattXtal(1, out, BcciOctaSite, arrange='BCC_d').get_energy() - 7962.21404) print(SubLattXtal(4, out, BcciOctaSite, arrange='ACD').get_energy() - 7962.21404) CrC = SubLattXtal(4, out, BcciOctaSite, arrange='BCC_u') CrC.cell[0,0,0,2] = 1 CrC.cell[0,0,0,0] = 0 crc1 = CrC.get_energy() CrC.cell[0,0,0,2] = 0 CrC.cell[2,2,2,7] = 1 crc2 = CrC.get_energy() print((crc1 - crc2)*4**3*8)
def _test_bcci(self): path = os.path.join(self.PATH, "i-s/bcci/CrC") # clus = CEMParser.parse_logtxt_bcci(os.path.join(path, 'log.txt')) # # print(clus[2]) # # CEMParser.symm_cubic_bcci(clus[0], BcciOctaSite) # clusters = [] # for c in clus: # clusters.append(CEMParser.symm_cubic_bcci(c, BcciOctaSite)) # ecis = CEMParser.parse_ecitxt(os.path.join(path, 'eci.txt')) # out = {} # for label in ['C', 'A1', 'A2', 'A3']: # tmp_clus = [] # tmp_ecis = [] # for i in sorted(ecis.keys()): # if clusters[i][label]: # tmp_clus.append( # np.array([[BcciOctaSite.conv_site2idx(site) # for site in cluster] # for cluster in clusters[i][label]])) # tmp_ecis.append(ecis[i]) # out.update({label:[tmp_clus, tmp_ecis]}) # print(out['C']) # CEMParser02.from_dirc_bcci(path, BcciOctaSite) # CrC = SubLattXtal.from_pickle_ecis( # 5, os.path.join(path, 'cluster.pickle'), # BcciOctaSite, arrange='random', conc=(0.1, 0.1)) pickle = os.path.join(path, 'cluster.pickle') print("A3C -.678871E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='A3C').get_energy() - 9614.98293) print("A2C -.685326E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='A2C').get_energy() - 9614.98293) print("A1C -.734503E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='A1C').get_energy() - 9614.98293) print("BCC_C -.829233E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='BCC_u').get_energy() - 9614.98293) print("A3D -.705443E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='A3D').get_energy() - 9614.98293) print("A2D -.723986E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='A2D').get_energy() - 9614.98293) print("A1D -.832914E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='A1D').get_energy() - 9614.98293) print("BCC_D -.961498E+04") print(SubLattXtal.from_pickle_ecis( 1, pickle, BcciOctaSite, arrange='BCC_d').get_energy() - 9614.98293) # print("ACD") # print(SubLattXtal.from_pickle_ecis( # 4, pickle, BcciOctaSite, arrange='ACD').get_energy() - 9614.98293) CrC = SubLattXtal.from_pickle_ecis( 4, pickle, BcciOctaSite, arrange='BCC_u') CrC.cell[0,0,0,2] = 1 CrC.cell[0,0,0,0] = 0 crc1 = CrC.get_energy() CrC.cell[0,0,0,2] = 0 CrC.cell[2,2,2,2] = 1 crc2 = CrC.get_energy() print((crc1 - crc2)*4**3*8)