def check_corr(self): """This test should check that for every pair in the bilayer: symmetry operators of the stabilizer of a bilayer generate the same symmetry equivalent pairs as obtained by coset decom position of the stabilizer of the bilayer with respect to the sta bilizer of a pair(method Pair.indOfEqvPairs)""" symops = self.bilayer.stab frags_0 = self.bilayer.layers[0].fragments #fragments of the first layer frags_1 = self.bilayer.layers[1].fragments #fragments of the second layer cosets_0 = [getattr(fragment, "coset") for fragment in frags_0] cosets_1 = [getattr(fragment, "coset") for fragment in frags_1] alerts = [] checks = [] for i,fr0 in enumerate(frags_0): for j,fr1 in enumerate(frags_1): print "-----------Testing pair (%d,%d)-----------------------"\ % (i,j) #calculated indices for the symmetry equivalent pairs pairs_calc = Pair((i,j),self.bilayer).indOfEqvPairs #observed indices for the symmetry equivalent pairs pairs_obs = [] for symop in symops: cs0 = map(core.modulo_n, core.lcoset((fr0.coset,symop))) cs1 = map(core.modulo_n, core.lcoset((fr1.coset,symop))) indices = core.eqv_frag_ind(cs0,cs1,cosets_0, cosets_1) pairs_obs.append(indices) print "Number of eqv. pairs calc.,obs.: %d, %d" \ % (len(pairs_calc),len(pairs_obs)) set_calc = set(pairs_calc) set_obs = set(pairs_obs) print "Number of unique eqv. pairs calc.,obs.: %d, %d" \ % (len(set_calc),len(set_obs)) test_value = all((set_obs <= set_calc, set_obs >= set_calc)) checks.append(test_value) if not test_value: alerts.append((i,j)) print "Calculated and observed pairs are the same:", test_value sys.stdout.flush() print "\nALL THE PAIRS PASSED THE TEST:", all(checks) print "Problematic pairs (if any):\n" print alerts
def indOfEqvPairs(self): """Uses self.cosets to find indices of fragmens in bilayer that form pairs symmetry equivalent to the self. Indices are a a list of tuples: [(),...(j,i),...()], j-index of the fragment in self.bilayer.layers[1] and i-...in self.bilayer.layers[0]. Theory beyound: Coset representatives g of decomposition self.bilayer.stab:self.stab, stored in self.cosets produce pair symmetry equivalent to self. We designate self=X_iX_j. (1) X_i = g_i*S_0*X_0 (2) X_j = g_j*S_0*X_0 Acting on (1) and (2) with g we get: g*X_i = g*g_i*S_0*X_0 g*X_j = g*g_j*S_0*X_0 So we only have to find indices of cosets g*g_i*S_0 and g*g_j*S_0 in coset attributes of self.bilayer.layers[0/1]""" if self._indEqvPairs: return self._indEqvPairs #generating cosets of the equivalent pairs with respect to the #basic fragment stabilizer. indices = [] for cset in self.cosets: gg_iS_0 = [core.modulo_n(cset[0]*symop, 1)\ for symop in self.__init_fragments[0].coset] gg_jS_0 = [core.modulo_n(cset[0]*symop, 1)\ for symop in self.__init_fragments[1].coset] #finding the indices of the cosets among the cosets of layer0 # and layer1 cosLay0Fragms = [fragment.coset\ for fragment in self.bilayer.layers[0].fragments] cosLay1Fragms = [fragment.coset\ for fragment in self.bilayer.layers[1].fragments] #finding indices of the corresponding cosets ind01_tuple = core.eqv_frag_ind(gg_iS_0, gg_jS_0,\ cosLay0Fragms, cosLay1Fragms) indices.append(ind01_tuple) self._indEqvPairs = indices return self._indEqvPairs