def mol_cluster(self): if self.mol_type == 0: mols0, count0 = cluster(0, self.lattice) self.mdense = count0 mols1, count1 = cluster(1, self.lattice) self.m1d = count1 mols2, count2 = cluster(2, self.lattice) self.m2d = count2 newlist = [] count3 = 0 # mol_list = range(self.num_mol) for i in range(len(mols0)): for j in range(len(mols0[i])): if mols0[i][j] not in newlist: newlist.append(mols0[i][j]) for i in range(len(mols1)): for j in range(len(mols1[i])): if mols1[i][j] not in newlist: newlist.append(mols1[i][j]) for i in range(len(mols2)): for j in range(len(mols2[i])): if mols2[i][j] not in newlist: newlist.append(mols2[i][j]) for i in range(self.num_mol): if i not in newlist: count3 = count3 + 1 self.mdis = count3 elif self.mol_type == 1: mols0, count0 = cluster(0, self.lattice) self.mdense= count0 mols1, count1 = cluster(1, self.lattice) self.m1d = count1 mols2, count2 = cluster(3, self.lattice) self.m2d = count2 newlist = [] count3 = 0 # mol_list = range(self.num_mol) for i in range(len(mols0)): for j in range(len(mols0[i])): if mols0[i][j] not in newlist: newlist.append(mols0[i][j]) for i in range(len(mols1)): for j in range(len(mols1[i])): if mols1[i][j] not in newlist: newlist.append(mols1[i][j]) for i in range(len(mols2)): for j in range(len(mols2[i])): if mols2[i][j] not in newlist: newlist.append(mols2[i][j]) for i in range(self.num_mol): if i not in newlist: count3 = count3 + 1 self.mdis = count3 self.mtotal = self.mdense + self.m1d + self.m2d + self.mdis self.mdense_p = self.mdense / self.mtotal self.m1d_p = self.m1d / self.mtotal self.m2d_p = self.m2d / self.mtotal self.mdis_p = self.mdis / self.mtotal
def clustering(self,mode): mols,count = cluster(mode,self.lattice) # mols: list, count: total number return mols,count