def prepare(conc, size, temp): path = "." unitcell = UnitCell.from_file("log.txt") ecis = Ecis.from_dirc(".") matrix = Matrix(conc, unitcell, ecis, size) matrix.adjust_conc_fine(conc) mc = MonteCarlo(matrix, temp) return mc
def test_Matrix(self): """ Matrix """ # __init__ # TO ## 160309 path = os.path.join(self.PATH, "Matrix", "AlCu_TO") unitcell = UnitCell.from_file(os.path.join(path, "log.txt")) ecis = Ecis.from_dirc(path) conc = 0 matrix = Matrix(conc, unitcell, ecis, 2) # FCC (HCP0*A1B0*TO) matrix.matrix[:] = 1 assert np.allclose(matrix.get_energy(), -1.440741) # FCC (HCP0*A0B1*TO) matrix.matrix[:] = 0 assert np.allclose(matrix.get_energy(), -115.824971) # L10 (HCP3*A1B1) matrix.matrix[:] = 0 matrix.matrix[0, 0, 0, 0] = 1 matrix.matrix[1, 1, 1, 0] = 1 matrix.matrix[0, 1, 0, 0] = 1 matrix.matrix[1, 0, 1, 0] = 1 assert np.allclose(matrix.get_energy(), -211.482477833) # L12 (HCP27*A1B3) matrix.matrix[0, 0, 0, 0] = 0 matrix.matrix[1, 1, 1, 0] = 0 assert np.allclose(matrix.get_energy(), -173.72808675) # L12 (HCP28*A3B1) matrix.matrix[:] = 1 matrix.matrix[0, 1, 0, 0] = 0 matrix.matrix[1, 0, 1, 0] = 0 assert np.allclose(matrix.get_energy(), -172.812058) # BCCI 2N ## 160311 path = os.path.join(self.PATH, "Matrix", "FeH_BCCI_2N") unitcell = UnitCell.from_file(os.path.join(path, "log.txt")) conc = 0.5 ecis = Ecis.from_dirc(path) # BCCI (HCP0*A9B0*OP) matrix = Matrix(conc, unitcell, ecis, 1, order=[1, 1, 1, 1, 1, 1, 1, 1, 1]) assert np.allclose(matrix.get_energy(), -17.1659116) # FeH6 (HCP99999*A6B3*OP) matrix = Matrix(conc, unitcell, ecis, 2, order=[1, 1, 1, 1, 1, 1, 0, 0, 0]) assert np.allclose(matrix.get_energy(), 0) # FeH3 (HCP10*A3B6*OP) matrix = Matrix(conc, unitcell, ecis, 3, order=[0, 0, 0, 0, 0, 0, 1, 1, 1]) assert np.allclose(matrix.get_energy(), 0) # FeH5 (HCP99998*5B4*OP) matrix = Matrix(conc, unitcell, ecis, 4, order=[1, 0, 1, 0, 1, 0, 1, 0, 1]) assert np.allclose(matrix.get_energy(), -.572197E+01) # FeH6 (HCP99997*A6B3*OP) matrix = Matrix(conc, unitcell, ecis, 5, order=[1, 1, 1, 0, 0, 0, 1, 1, 1]) assert np.allclose(matrix.get_energy(), -.858296E+01) # # BCCI # ## 160309 path = os.path.join(self.PATH, "Matrix", "FeH_BCCI") unitcell = UnitCell.from_file(os.path.join(path, "log.txt")) conc = 0.5 ecis = Ecis.from_dirc(path) # BCCI (HCP0*A9B0*OP) matrix = Matrix(conc, unitcell, ecis, 1, order=[1, 1, 1, 1, 1, 1, 1, 1, 1]) assert np.allclose(matrix.get_energy(), 0.132641E+01) # FeH6 (HCP99999*A6B3*OP) matrix = Matrix(conc, unitcell, ecis, 2, order=[1, 1, 1, 1, 1, 1, 0, 0, 0]) assert np.allclose(matrix.get_energy(), -.243349E+02) # FeH3 (HCP10*A3B6*OP) matrix = Matrix(conc, unitcell, ecis, 3, order=[0, 0, 0, 0, 0, 0, 1, 1, 1]) assert np.allclose(matrix.get_energy(), -.848994E+02) # FeH5 (HCP99998*A5B4*OP) matrix = Matrix(conc, unitcell, ecis, 4, order=[1, 0, 1, 0, 1, 0, 1, 0, 1]) assert np.allclose(matrix.get_energy(), -.565030E+02) # FeH6 (HCP99997*A6B3*OP) matrix = Matrix(conc, unitcell, ecis, 5, order=[1, 1, 1, 0, 0, 0, 1, 1, 1]) assert np.allclose(matrix.get_energy(), -.100641E+03) # get_de matrix = Matrix(conc, unitcell, ecis, 5) # [0, 0, 0, 0] のみの de de = matrix.get_delta_energy([[[[True]]]]) # 全てのサイト de_matrix = matrix.get_delta_energy( matrix.matrix[:, :, :, :] != 0.5).reshape(5, 5, 5, 9) before = matrix.get_energy() matrix.matrix[0, 0, 0, 0] = 1 - matrix.matrix[0, 0, 0, 0] after = matrix.get_energy() assert np.allclose(de, (after - before)*(matrix.matrix.size)) assert np.allclose(de_matrix[0, 0, 0, 0], (after - before)*(matrix.matrix.size)) # adjust_conc_fine ## 160329 matrix = Matrix(conc, unitcell, ecis, 4) matrix.adjust_conc_fine(conc) assert matrix.conc == 0.5