Changeset 3894
 Timestamp:
 Apr 13, 2019 8:10:41 AM (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIImath.py
r3893 r3894 3657 3657 :returns: density at xyz 3658 3658 ''' 3659 Blk = 8 #8 seems optimal 3660 nBlk = len(XYZ)//Blk #select Blk so this is an exact divide 3659 3661 rollMap = lambda rho,roll: np.roll(np.roll(np.roll(rho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2)[:2,:2,:2] 3660 3662 mapShape = np.array(rho.shape) 3661 3663 mapStep = 1./mapShape 3662 3664 X = XYZ%1. #get into unit cell 3663 I = np.array(np.rint(X*mapShape),dtype='int')3665 iBeg = 0 3664 3666 R = np.zeros(len(XYZ)) 3665 for i,x in enumerate(X): 3666 D = xI[i]*mapStep #position inside map cell 3667 Rho = rollMap(rho,I[i]) #shifts map so point is in corner 3668 RIJ = Rho[0,:2,:2]*(1.D[0]) 3669 RI = RIJ[0]*(1.D[1])+RIJ[1]*D[1] 3670 R[i] = RI[0]*(1.D[2])+RI[1]*D[2] 3667 #actually a bit faster! 3668 for iblk in range(nBlk): 3669 iFin = iBeg+Blk 3670 Xs = X[iBeg:iFin] 3671 I = np.array(np.rint(Xs*mapShape),dtype='int') 3672 Rhos = np.array([rollMap(rho,i) for i in I]) 3673 Ds = XsI*mapStep 3674 RIJs = Rhos[:,0,:2,:2]*(1.Ds[:,0][:,nxs,nxs]) 3675 RIs = RIJs[:,0]*(1.Ds[:,1][:,nxs])+RIJs[:,1]*Ds[:,1][:,nxs] 3676 R[iBeg:iFin] = RIs[:,0]*(1.Ds[:,2])+RIs[:,1]*Ds[:,2] 3677 iBeg += Blk 3678 #one at a time 3679 # for i,x in enumerate(X): 3680 # D = xI[i]*mapStep #position inside map cell 3681 # Rho = rollMap(rho,I[i]) #shifts map so point is in corner 3682 # RIJ = Rho[0,:2,:2]*(1.D[0]) 3683 # RI = RIJ[0]*(1.D[1])+RIJ[1]*D[1] 3684 # R[i] = RI[0]*(1.D[2])+RI[1]*D[2] 3671 3685 return R 3672 3686
Note: See TracChangeset
for help on using the changeset viewer.