def findNextVec(S, parentlatt, which): ''' Applies all symmetry operations, and chooses a new primitive vector that is most orthogonal to the other(s)''' eps = 1.0e-6 found = False newvec = array([0., 0., 0.]) rotvecs = zeros((3, parentlatt.nops), dtype=np_float) dotvecs = zeros((parentlatt.nops), dtype=np_float) dotvecs0 = zeros((parentlatt.nops), dtype=np_float) for iop in range(parentlatt.nops): rotvecs[:, iop] = transpose( dot(parentlatt.symops[:, :, iop], S[:, which - 1])) # all 1-d arrays are horizontal dotvecs[iop] = cosvecs(rotvecs[:, iop], S[:, which - 1]) if norm(abs(dotvecs) - 1) > eps: # We have at least one independent vector if which == 1: #Take the one that is most perpendicular to the earlier one found = True op2 = argmin(abs(dotvecs)) newvec = rotvecs[:, op2] elif which == 2: # Third vector needs to be independent of first S vector, too. Use the first vector that is ind. of both for iop in range(parentlatt.nops): if isindependent(rotvecs[:, iop], S[:, 0]) and isindependent( rotvecs[:, iop], S[:, 1]): found = True newvec = rotvecs[:, iop] break return [found, newvec]
def eigenvecfind(S, parentlatt): '''Find eigenvectors of symmetry operations (in cartesian basis). A single eigenvector of eigenvalue 1 signifies a rotation operator. This returns a cartesian vector that corresponds to a rotation axis that is not in the plane of the first two vectors of S''' # print 'S after array convert'; print S eps = 1.0e-6 for iop in range(parentlatt.nops): #loop for printing only evals, evecs = eig(parentlatt.symops[:, :, iop]) for iop in range(parentlatt.nops): evals, evecs = eig(parentlatt.symops[:, :, iop]) nOne = 0 for i, eval in enumerate(evals): if abs(eval - 1) < eps: nOne += 1 indexOne = i if nOne == 1: axis = evecs[indexOne] unitaxis = axis / norm(axis) #unit vector if abs(cosvecs(cross(S[:, 0], S[:, 1]), axis)) > eps: #print'found independent third vector' return unitaxis
def eigenvecfind(S,parentlatt): '''Find eigenvectors of symmetry operations (in cartesian basis). A single eigenvector of eigenvalue 1 signifies a rotation operator. This returns a cartesian vector that corresponds to a rotation axis that is not in the plane of the first two vectors of S''' # print 'S after array convert'; print S eps = 1.0e-6 for iop in range(parentlatt.nops): #loop for printing only evals,evecs = eig(parentlatt.symops[:,:,iop]) for iop in range(parentlatt.nops): evals,evecs = eig(parentlatt.symops[:,:,iop]) nOne = 0 for i, eval in enumerate(evals): if abs(eval - 1) < eps: nOne += 1 indexOne = i if nOne == 1: axis = evecs[indexOne] unitaxis = axis/norm(axis) #unit vector if abs(cosvecs(cross(S[:,0],S[:,1]),axis))>eps: #print'found independent third vector' return unitaxis
def eigenvecfind(S,parentlatt): '''Find eigenvectors of symmetry operations (in cartesian basis). A single eigenvector of eigenvalue 1 signifies a rotation operator. This returns a cartesian vector that corresponds to a rotation axis that is not in the plane of the first two vectors of S''' # print 'S after array convert'; print S eps = 1.0e-6 for iop in range(parentlatt.nops): #loop for printing only evals,evecs = eig(parentlatt.symops[:,:,iop]) # print; print iop; # print 'symop R'; print parentlatt.symops[:,:,iop] # print 'symop m'; print dot(dot(inv(parentlatt.vecs[:,:]),parentlatt.symops[:,:,iop]),parentlatt.vecs[:,:]) # print 'det(m)', det( dot(dot(inv(parentlatt.vecs[:,:]),parentlatt.symops[:,:,iop]),parentlatt.vecs[:,:]) ) # print 'eigenvalues',evals # print 'eigenvectors'; print evecs #loop for printing only for iop in range(parentlatt.nops): evals,evecs = eig(parentlatt.symops[:,:,iop]) nOne = 0 for i, eval in enumerate(evals): if abs(eval - 1) < eps: nOne += 1 indexOne = i # print 'indexOne',indexOne if nOne == 1: # print; print iop;print 'eigenvalues',evals # print 'eigenvectors'; print evecs axis = evecs[indexOne] unitaxis = axis/norm(axis) #unit vector #print "S";print S #print 'axis', axis #test to see if it's independent of the first two axes #print 'cos angle between (cross(S[:,0],S[:,1]) and axis)', cosvecs(cross(S[:,0],S[:,1]),axis) # print 'cross(S[:,0],S[:,1]),axis', cross(S[:,0],S[:,1]),axis if abs(cosvecs(cross(S[:,0],S[:,1]),axis))>eps: #print'found independent third vector' return unitaxis
def eigenvecfind(S, parentlatt): '''Find eigenvectors of symmetry operations (in cartesian basis). A single eigenvector of eigenvalue 1 signifies a rotation operator. This returns a cartesian vector that corresponds to a rotation axis that is not in the plane of the first two vectors of S''' # print 'S after array convert'; print S eps = 1.0e-6 for iop in range(parentlatt.nops): #loop for printing only evals, evecs = eig(parentlatt.symops[:, :, iop]) # print; print iop; # print 'symop R'; print parentlatt.symops[:,:,iop] # print 'symop m'; print dot(dot(inv(parentlatt.vecs[:,:]),parentlatt.symops[:,:,iop]),parentlatt.vecs[:,:]) # print 'det(m)', det( dot(dot(inv(parentlatt.vecs[:,:]),parentlatt.symops[:,:,iop]),parentlatt.vecs[:,:]) ) # print 'eigenvalues',evals # print 'eigenvectors'; print evecs #loop for printing only for iop in range(parentlatt.nops): evals, evecs = eig(parentlatt.symops[:, :, iop]) nOne = 0 for i, eval in enumerate(evals): if abs(eval - 1) < eps: nOne += 1 indexOne = i # print 'indexOne',indexOne if nOne == 1: # print; print iop;print 'eigenvalues',evals # print 'eigenvectors'; print evecs axis = evecs[indexOne] unitaxis = axis / norm(axis) #unit vector #print "S";print S #print 'axis', axis #test to see if it's independent of the first two axes #print 'cos angle between (cross(S[:,0],S[:,1]) and axis)', cosvecs(cross(S[:,0],S[:,1]),axis) # print 'cross(S[:,0],S[:,1]),axis', cross(S[:,0],S[:,1]),axis if abs(cosvecs(cross(S[:, 0], S[:, 1]), axis)) > eps: #print'found independent third vector' return unitaxis
def findNextVec(S,parentlatt,which): ''' Applies all symmetry operations, and chooses a new primitive vector that is most orthogonal to the other(s)''' eps = 1.0e-6 found = False newvec = array([0.,0.,0.]) rotvecs = zeros((3,parentlatt.nops),dtype=np_float) dotvecs = zeros((parentlatt.nops),dtype=np_float) dotvecs0 = zeros((parentlatt.nops),dtype=np_float) for iop in range(parentlatt.nops): rotvecs[:,iop] = transpose(dot(parentlatt.symops[:,:,iop],S[:,which-1])) # all 1-d arrays are horizontal dotvecs[iop] = cosvecs(rotvecs[:,iop],S[:,which-1]) if norm(abs(dotvecs)-1)>eps:# We have at least one independent vector if which == 1: #Take the one that is most perpendicular to the earlier one found = True op2 = argmin(abs(dotvecs)) newvec = rotvecs[:,op2] elif which == 2: # Third vector needs to be independent of first S vector, too. Use the first vector that is ind. of both for iop in range(parentlatt.nops): if isindependent(rotvecs[:,iop],S[:,0]) and isindependent(rotvecs[:,iop],S[:,1]): found = True newvec = rotvecs[:,iop] break return [found, newvec]
def matchDirection(vec,list): '''if vec parallel or antiparallel to any vector in the list, don't include it''' for vec2 in list: if areEqual(abs(cosvecs(vec,vec2)),1.0): return True return False
def matchDirection(vec, list): '''if vec parallel or antiparallel to any vector in the list, don't include it''' for vec2 in list: if areEqual(abs(cosvecs(vec, vec2)), 1.0): return True return False