Changeset 470


Ignore:
Timestamp:
Feb 3, 2012 3:56:08 PM (10 years ago)
Author:
vondreele
Message:

progress on texture stuff

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r469 r470  
    429429        self.oldFocus = None
    430430        self.GSASprojectfile = ''
    431         self.dirname = os.getcwd()
     431        self.dirname = ospath.expanduser('~')       #start in the users home directory by default; may be meaningless
    432432        self.undofile = ''
    433433        self.TreeItemDelete = False
  • trunk/GSASIImath.py

    r458 r470  
    152152        return np.sqrt(np.sum(np.inner(Amat,(TxT-Ox))**2))
    153153       
    154     inv = 1
    155     if Top < 0:
    156         inv = -1
     154    inv = Top/abs(Top)
    157155    cent = abs(Top)/100
    158156    op = abs(Top)%100-1
     
    195193    OxBN,OxB,TxBN,TxB,unitB,TopB = VB
    196194    invA = invB = 1
    197     if TopA < 0:
    198         invA = -1
    199     if TopB < 0:
    200         invB = -1
     195    invA = TopA/abs(TopA)
     196    invB = TopB/abs(TopB)
    201197    centA = abs(TopA)/100
    202198    centB = abs(TopB)/100
     
    240236        return calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat),0.0
    241237       
     238def GetTorsionSig(Atoms,Amat,SGData,covData={}):
     239    XYZ = []
     240    for atom in Atoms:   
     241        XYZ.append(np.array(atom[3:6]))
     242    XYZ = np.inner(Amat,XYZ).T
     243    V1 = XYZ[1]-XYZ[0]
     244    V2 = XYZ[2]-XYZ[1]
     245    V3 = XYZ[3]-XYZ[2]
     246    V1 /= np.sqrt(np.sum(V1**2))
     247    V2 /= np.sqrt(np.sum(V2**2))
     248    V3 /= np.sqrt(np.sum(V3**2))
     249    M = np.array([V1,V2,V3])
     250    D = nl.det(M)
     251    Ang = 1.0
     252    P12 = np.dot(V1,V2)
     253    P13 = np.dot(V1,V3)
     254    P23 = np.dot(V2,V3)
     255    Tors = acosd((P12*P23-P13)/(np.sqrt(1.-P12**2)*np.sqrt(1.-P23**2)))*D/abs(D)
     256   
     257    sig = 0.0
     258    if 'covMatrix' in covData:
     259        for atom in Atoms:
     260            xyz = atom[3:6]
     261            Op,Unit = atom[-1]
     262            inv = Op/abs(Op)
     263            M,T = SGData['SGOps'][abs(Op)%100-1]
     264            C = SGData['SGCen'][abs(Op)/100]
     265            #reverse inv*(np.inner(M,Tx)+T)+C
     266            XYZ = np.inner(nl.inv(M),((xyz-C)*inv-T))
     267            print Op,Unit,xyz,XYZ
     268        covMatrix = covData['covMatrix']
     269        varyList = covData['varyList']
     270   
     271    return Tors,sig
     272       
    242273   
    243274def ValEsd(value,esd=0,nTZ=False):                  #NOT complete - don't use
  • trunk/GSASIIphsGUI.py

    r468 r470  
    18331833        TorsionData = {}
    18341834        drawingData = data['Drawing']
    1835         atomData = drawingData['Atoms']
     1835        atomData = data['Atoms']
     1836        atomDData = drawingData['Atoms']
    18361837        colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())]
    18371838        cx = colLabels.index('x')
    18381839        cn = colLabels.index('Name')
    18391840        xyz = []
    1840         for i,atom in enumerate(atomData):
     1841        for i,atom in enumerate(atomDData):
    18411842            if i in indx:
    18421843                xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+4]) #also gets Sym Op
    1843         TorsionData['Atoms'] = xyz
     1844        TorsionData['Datoms'] = xyz
    18441845        generalData = data['General']
    18451846        TorsionData['Name'] = generalData['Name']
  • trunk/GSASIIstruct.py

    r460 r470  
    27062706            ' alpha = ','%.3f'%(Cell[3]),' beta = ','%.3f'%(Cell[4]),' gamma = ', \
    27072707            '%.3f'%(Cell[5]),' volume = ','%.3f'%(Cell[6])
    2708     for atom in TorsionData['Atoms']:
     2708    #find one end of 4 atom string - involved in longest distance
     2709    dist = {}
     2710    for i,X1 in enumerate(TorsionData['Datoms']):
     2711        for j,X2 in enumerate(TorsionData['Datoms'][:i]):
     2712            dist[np.sqrt(np.sum(np.inner(Amat,np.array(X2[3:6])-np.array(X1[3:6]))**2))] = [i,j]
     2713    sortdist = dist.keys()
     2714    sortdist.sort()
     2715    end = dist[sortdist[-1]][0]
     2716    #order atoms in distance from end - defines sequence of atoms for the torsion angle
     2717    dist = {}
     2718    X1 = TorsionData['Datoms'][end]
     2719    for i,X2 in enumerate(TorsionData['Datoms']):               
     2720        dist[np.sqrt(np.sum(np.inner(Amat,np.array(X2[3:6])-np.array(X1[3:6]))**2))] = i
     2721    sortdist = dist.keys()
     2722    sortdist.sort()
     2723    Datoms = []
     2724    for d in sortdist:
     2725        atom = TorsionData['Datoms'][dist[d]]
     2726        symop = atom[-1].split('+')
     2727        if len(symop) == 1:
     2728            symop.append('0,0,0')       
     2729        symop[0] = int(symop[0])
     2730        symop[1] = eval(symop[1])
     2731        atom[-1] = symop
    27092732        print atom
     2733        Datoms.append(atom)
     2734    Tors,sig = G2mth.GetTorsionSig(Datoms,Amat,SGData,covData={})
     2735    print ' Torsion: ',G2mth.ValEsd(Tors,sig)
     2736       
    27102737       
    27112738def BestPlane(PlaneData):
     
    27172744
    27182745    ShowBanner(PlaneData['Name'])
    2719 
    2720 #    Cell = PlaneData['Cell']   
    2721 #    Amat,Bmat = G2lat.cell2AB(Cell[:6])
    2722 #       
    2723 #    Atoms = PlaneData['Atoms']
    2724 #    sumXYZ = np.zeros(3)
    2725 #    XYZ = []
    2726 #    Natoms = len(Atoms)
    2727 #    for atom in Atoms:
    2728 #        xyz = np.array(atom[3:6])
    2729 #        XYZ.append(xyz)
    2730 #        sumXYZ += xyz
    2731 #    sumXYZ /= Natoms
    2732 #    XYZ = np.array(XYZ)-sumXYZ
    2733 #    XYZ = np.inner(Amat,XYZ).T
    2734 #    Zmat = np.zeros((3,3))
    2735 #    print ' Selected atoms: Cartesian coordinates centered at',sumXYZ
    2736 #    Evec,Emat = nl.eig(Zmat)
    2737 #    Evec = np.sqrt(Evec)/(Natoms-3)
    2738 #    Order = np.argsort(Evec)
    2739 #    print [Evec[Order[i]] for i in [2,1,0]]   
    2740 #    XYZ = np.inner(XYZ,Emat.T).T
    2741 #    XYZ = np.array([XYZ[Order[2]],XYZ[Order[1]],XYZ[Order[0]]]).T
    2742 #    print ' Atoms in Cartesian best plane coordinates:'
    2743 #    for i,xyz in enumerate(XYZ):
    2744 #        print Atoms[i][1],xyz
    27452746
    27462747    Cell = PlaneData['Cell']   
Note: See TracChangeset for help on using the changeset viewer.