Changeset 3079
 Timestamp:
 Sep 18, 2017 8:52:24 AM (4 years ago)
 Location:
 trunk
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIconstrGUI.py
r3065 r3079 1514 1514 else: 1515 1515 rbXYZ = np.array(rbXYZ)np.array(rbXYZ[0]) 1516 Xxyz = rbXYZ[1] 1517 X = Xxyz/np.sqrt(np.sum(Xxyz**2)) 1518 Yxyz = rbXYZ[2] 1519 Y = Yxyz/np.sqrt(np.sum(Yxyz**2)) 1520 Mat = G2mth.getRBTransMat(X,Y) 1521 rbXYZ = np.inner(Mat,rbXYZ).T 1516 1522 data['Residue'][rbId] = {'RBname':'UNKRB','rbXYZ':rbXYZ,'rbTypes':rbTypes, 1517 1523 'atNames':atNames,'rbRef':[0,1,2,False],'rbSeq':[],'SelSeq':[0,0],'useCount':0} … … 1850 1856 rbData['rbTypes'] = newTypes 1851 1857 rbData['rbXYZ'] = newXYZ 1858 G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults) 1852 1859 wx.CallAfter(UpdateResidueRB) 1853 1860 … … 1917 1924 1918 1925 def OnRefSel(event): 1926 1919 1927 Obj = event.GetEventObject() 1920 1928 iref,res,jref = Indx[Obj.GetId()] … … 1927 1935 for i,ref in enumerate(RefObjs[jref]): 1928 1936 ref.SetItems([atNames[j] for j in refChoice[rbId][i]]) 1929 ref.SetValue(atNames[rbData['rbRef'][i]]) 1937 ref.SetValue(atNames[rbData['rbRef'][i]]) 1938 rbXYZ = rbData['rbXYZ'] 1930 1939 if not iref: #origin change 1931 rbXYZ = rbData['rbXYZ']1932 1940 rbXYZ = rbXYZ[ind] 1933 res.ClearSelection() 1934 resTable = res.GetTable() 1935 for r in range(res.GetNumberRows()): 1936 row = resTable.GetRowValues(r) 1937 row[2:4] = rbXYZ[r] 1938 resTable.SetRowValues(r,row) 1939 res.ForceRefresh() 1940 G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults) 1941 #TODO  transform all atom XYZ by axis choices 1942 Xxyz = rbXYZ[rbData['rbRef'][1]] 1943 X = Xxyz/np.sqrt(np.sum(Xxyz**2)) 1944 Yxyz = rbXYZ[rbData['rbRef'][2]] 1945 Y = Yxyz/np.sqrt(np.sum(Yxyz**2)) 1946 Mat = G2mth.getRBTransMat(X,Y) 1947 rbXYZ = np.inner(Mat,rbXYZ).T 1948 rbData['rbXYZ'] = rbXYZ 1949 res.ClearSelection() 1950 resTable = res.GetTable() 1951 for r in range(res.GetNumberRows()): 1952 row = resTable.GetRowValues(r) 1953 row[2:4] = rbXYZ[r] 1954 resTable.SetRowValues(r,row) 1955 res.ForceRefresh() 1956 G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults) 1941 1957 1942 1958 Types = 2*[wg.GRID_VALUE_STRING,]+3*[wg.GRID_VALUE_FLOAT+':10,5',] 
trunk/GSASIImath.py
r3048 r3079 825 825 return np.array(XYZ) 826 826 827 def getRBTransMat(X,Y): 828 '''Get transformation for Cartesian axes given 2 vectors 829 X will be parallel to new Xaxis; X cross Y will be new Zaxis & 830 (X cross Y) cross Y will be new Yaxis 831 Useful for rigid body axes definintion 832 833 :param array X: normalized vector 834 :param array Y: normalized vector 835 836 :returns: array M: transformation matrix 837 use as XYZ' = np.inner(M,XYZ) where XYZ are Cartesian 838 839 ''' 840 Mat2 = np.cross(X,Y) #UxV>Z 841 Mat2 /= np.sqrt(np.sum(Mat2**2)) 842 Mat3 = np.cross(Mat2,X) #(UxV)xU>Y 843 Mat3 /= np.sqrt(np.sum(Mat3**2)) 844 return np.array([X,Mat3,Mat2]) 845 827 846 def RotateRBXYZ(Bmat,Cart,oriQ): 828 847 '''rotate & transform cartesian coordinates to crystallographic ones 
trunk/GSASIIphsGUI.py
r3058 r3079 7524 7524 rbsizer.Add(rbsizer2) 7525 7525 if model['Type'] == 'Residue': 7526 atNames = RBData['Residue'][model['RBId']]['atNames'] 7527 rbsizer.Add(wx.StaticText(G2frame.MCSA,1,'Torsions:'),0,WACV) 7528 rbsizer3 = wx.FlexGridSizer(0,8,5,5) 7529 for it,tor in enumerate(model['Tor'][0]): 7530 iBeg,iFin = RBData['Residue'][model['RBId']]['rbSeq'][it][:2] 7531 name = atNames[iBeg]+''+atNames[iFin] 7532 torRef = wx.CheckBox(G2frame.MCSA,1,label=' %s: '%(name)) 7533 torRef.SetValue(model['Tor'][1][it]) 7534 torRef.Bind(wx.EVT_CHECKBOX,OnPosRef) 7535 Indx[torRef.GetId()] = [model,'Tor',it] 7536 rbsizer3.Add(torRef,0,WACV) 7537 torVal = G2G.ValidatedTxtCtrl(G2frame.MCSA,model['Tor'][0],it,nDig=(10,4),OnLeave=OnPosVal) 7538 rbsizer3.Add(torVal,0,WACV) 7539 rbsizer3.Add(wx.StaticText(G2frame.MCSA,1,' Range: '),0,WACV) 7540 rmin,rmax = model['Tor'][2][it] 7541 torRange = wx.TextCtrl(G2frame.MCSA,1,'%.3f %.3f'%(rmin,rmax),style=wx.TE_PROCESS_ENTER) 7542 Indx[torRange.GetId()] = [model,'Tor',it] 7543 torRange.Bind(wx.EVT_TEXT_ENTER,OnPosRange) 7544 torRange.Bind(wx.EVT_KILL_FOCUS,OnPosRange) 7545 rbsizer3.Add(torRange,0,WACV) 7546 rbsizer.Add(rbsizer3) 7547 7526 try: 7527 atNames = RBData['Residue'][model['RBId']]['atNames'] 7528 rbsizer.Add(wx.StaticText(G2frame.MCSA,1,'Torsions:'),0,WACV) 7529 rbsizer3 = wx.FlexGridSizer(0,8,5,5) 7530 for it,tor in enumerate(model['Tor'][0]): 7531 iBeg,iFin = RBData['Residue'][model['RBId']]['rbSeq'][it][:2] 7532 name = atNames[iBeg]+''+atNames[iFin] 7533 torRef = wx.CheckBox(G2frame.MCSA,1,label=' %s: '%(name)) 7534 torRef.SetValue(model['Tor'][1][it]) 7535 torRef.Bind(wx.EVT_CHECKBOX,OnPosRef) 7536 Indx[torRef.GetId()] = [model,'Tor',it] 7537 rbsizer3.Add(torRef,0,WACV) 7538 torVal = G2G.ValidatedTxtCtrl(G2frame.MCSA,model['Tor'][0],it,nDig=(10,4),OnLeave=OnPosVal) 7539 rbsizer3.Add(torVal,0,WACV) 7540 rbsizer3.Add(wx.StaticText(G2frame.MCSA,1,' Range: '),0,WACV) 7541 rmin,rmax = model['Tor'][2][it] 7542 torRange = wx.TextCtrl(G2frame.MCSA,1,'%.3f %.3f'%(rmin,rmax),style=wx.TE_PROCESS_ENTER) 7543 Indx[torRange.GetId()] = [model,'Tor',it] 7544 torRange.Bind(wx.EVT_TEXT_ENTER,OnPosRange) 7545 torRange.Bind(wx.EVT_KILL_FOCUS,OnPosRange) 7546 rbsizer3.Add(torRange,0,WACV) 7547 rbsizer.Add(rbsizer3) 7548 except KeyError: #Missing RB  clear all away! 7549 data['MCSA'] = {'Models':[{'Type':'MD','Coef':[1.0,False,[.8,1.2],],'axis':[0,0,1]}],'Results':[],'AtInfo':{}} 7550 wx.CallAfter(UpdateMCSA) 7548 7551 return rbsizer 7549 7552 … … 7796 7799 return 7797 7800 time1 = time.time() 7798 if process == 'single': 7801 nprocs = GSASIIpath.GetConfigValue('Multiprocessing_cores',0) 7802 if process == 'single' or not nprocs: 7799 7803 pgbar = wx.ProgressDialog('MC/SA','Residual Rcf =',101.0, 7800 7804 style = wx.PD_ELAPSED_TIMEwx.PD_AUTO_HIDEwx.PD_CAN_ABORT) … … 7809 7813 tsf = 0. 7810 7814 nCyc = mcsaControls['Cycles'] 7811 if process == 'single' :7815 if process == 'single' or not nprocs: 7812 7816 for i in range(nCyc): 7813 7817 pgbar.SetTitle('MC/SA run '+str(i+1)+' of '+str(nCyc)) … … 7821 7825 Title='Reflection covariance matrix',zrange=[1.,1.],color='RdYlGn') 7822 7826 else: 7823 nprocs = GSASIIpath.GetConfigValue('Multiprocessing_cores')7824 7827 Results,sftime,numsf = G2mth.MPmcsaSearch(nCyc,data,RBdata,reflType,reflData,covData,nprocs) 7825 7828 MCSAdata['Results'] += Results #+= to any saved ones 7826 7829 print ' Total SF time: %.2fs MC/SA run time: %.2fs Nsfcalc: %d'%(sftime,time.time()time1,numsf) 7827 7830 finally: 7828 if process == 'single' :7831 if process == 'single' or not nprocs: 7829 7832 pgbar.Destroy() 7830 7833 MCSAdata['Results'] = G2mth.sortArray(MCSAdata['Results'],2,reverse=False)
Note: See TracChangeset
for help on using the changeset viewer.