Changeset 936


Ignore:
Timestamp:
May 30, 2013 9:05:36 AM (9 years ago)
Author:
vondreele
Message:

more MC/SA stuff
further drawing optimization

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r934 r936  
    6767[ wxID_ATOMSEDITADD, wxID_ATOMSEDITINSERT, wxID_ATOMSEDITDELETE, wxID_ATOMSREFINE,
    6868    wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT,
    69     wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,wxID_RBAPPEND,
     69    wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,
    7070    wxID_ASSIGNATMS2RB
    71 ] = [wx.NewId() for item in range(13)]
     71] = [wx.NewId() for item in range(12)]
    7272
    7373[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
     
    8080] = [wx.NewId() for item in range(4)]
    8181
    82 [ wxID_ADDMCSAATOM,wxID_ADDMCSARB,wxID_CLEARMCSARB,
    83 ] = [wx.NewId() for item in range(3)]
     82[ wxID_ADDMCSAATOM,wxID_ADDMCSARB,wxID_CLEARMCSARB,wxID_MOVEMCSA,
     83] = [wx.NewId() for item in range(4)]
    8484
    8585[ wxID_CLEARTEXTURE,wxID_REFINETEXTURE,
     
    16811681        self.AtomEdit.Append(id=wxID_ATOMSVIEWADD, kind=wx.ITEM_NORMAL,text='Append view point',
    16821682            help='Appended as an H atom')
    1683         self.AtomEdit.Append(id=wxID_RBAPPEND, kind=wx.ITEM_NORMAL,text='Append rigid body',
    1684             help='Append atoms for rigid body')
    16851683        self.AtomEdit.Append(id=wxID_ATOMSEDITINSERT, kind=wx.ITEM_NORMAL,text='Insert atom',
    16861684            help='Select atom row to insert before; inserted as an H atom')
     
    17841782            help='Add rigid body to MC/SA model' )
    17851783        self.MCSAEdit.Append(id=wxID_CLEARMCSARB, kind=wx.ITEM_NORMAL,text='Clear rigid bodies',
    1786             help='Clear all rigid bodies from MC/SA model' )
     1784            help='Clear all atoms & rigid bodies from MC/SA model' )
     1785        self.MCSAEdit.Append(id=wxID_MOVEMCSA, kind=wx.ITEM_NORMAL,text='Move MC/SA solution',
     1786            help='Move MC/SA solution to atom list' )
    17871787        self.PostfillDataMenu()
    17881788           
  • trunk/GSASIImath.py

    r934 r936  
    283283    return XYZ,Cart
    284284
    285 def UpdateMCSAxyz(Bmat,mcsaModels,RBData):
     285def UpdateMCSAxyz(Bmat,MCSA):
    286286    xyz = []
    287287    atTypes = []
    288288    iatm = 0
    289     for model in mcsaModels[1:]:        #skip the MD model
     289    for model in MCSA['Models'][1:]:        #skip the MD model
    290290        if model['Type'] == 'Atom':
    291291            xyz.append(model['Pos'][0])
     
    293293            iatm += 1
    294294        else:
    295             rideList = []
    296             RBRes = RBData[model['Type']][model['RBId']]
     295            RBRes = MCSA['rbData'][model['Type']][model['RBId']]
    297296            Pos = np.array(model['Pos'][0])
    298297            Qori = np.array(model['Ori'][0])
     
    309308                    for ride in seq[3]:
    310309                        Cart[ride] = prodQVQ(QuatA,Cart[ride]-Cart[seq[1]])+Cart[seq[1]]
    311                     rideList += seq[3]
    312             centList = set(range(len(Cart)))-set(rideList)
    313             if model['MolCent']:
    314                 cent = np.zeros(3)
    315                 for i in centList:
    316                     cent += Cart[i]
    317                 Cart -= cent/len(centList)
     310            if model['MolCent'][1]:
     311                Cart -= model['MolCent'][0]
    318312            for i,x in enumerate(Cart):
    319313                xyz.append(np.inner(Bmat,prodQVQ(Qori,x))+Pos)
     
    322316                iatm += 1
    323317    return np.array(xyz),atTypes
     318   
     319def SetMolCent(model,RBData):
     320    rideList = []
     321    RBRes = RBData[model['Type']][model['RBId']]
     322    if model['Type'] == 'Vector':
     323        vecs = RBRes['rbVect']
     324        mags = RBRes['VectMag']
     325        Cart = np.zeros_like(vecs[0])
     326        for vec,mag in zip(vecs,mags):
     327            Cart += vec*mag
     328    elif model['Type'] == 'Residue':
     329        Cart = np.array(RBRes['rbXYZ'])
     330        for seq in RBRes['rbSeq']:
     331            rideList += seq[3]
     332    centList = set(range(len(Cart)))-set(rideList)
     333    cent = np.zeros(3)
     334    for i in centList:
     335        cent += Cart[i]
     336    model['MolCent'][0] = cent/len(centList)   
    324337   
    325338def UpdateRBUIJ(Bmat,Cart,RBObj):
  • trunk/GSASIIphsGUI.py

    r934 r936  
    12071207        FillAtomsGrid(Atoms)
    12081208        event.StopPropagation()
     1209        G2plt.PlotStructure(G2frame,data)
    12091210       
    12101211    def OnAtomViewAdd(event):
     
    12171218        FillAtomsGrid(Atoms)
    12181219        event.StopPropagation()
     1220        G2plt.PlotStructure(G2frame,data)
    12191221               
    12201222    def AtomAdd(x,y,z,El='H',Name='UNK'):
     
    12341236        if 'Atoms' in data['Drawing']:           
    12351237            DrawAtomAdd(data['Drawing'],atomData[-1])
    1236             G2plt.PlotStructure(G2frame,data)
    12371238
    12381239    def OnAtomInsert(event):
     
    12401241        FillAtomsGrid(Atoms)
    12411242        event.StopPropagation()
     1243        G2plt.PlotStructure(G2frame,data)
    12421244       
    12431245    def OnAtomViewInsert(event):
     
    12481250            FillAtomsGrid(Atoms)
    12491251        event.StopPropagation()
    1250        
    1251     def OnRBAppend(event):          #unfinished!
    1252         rbData = G2frame.PatternTree.GetItemPyData(   
    1253             G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies'))
    1254         general = data['General']
    1255         atomData = data['Atoms']
    1256         Amat,Bmat = G2lat.cell2AB(general['Cell'][1:7])
    1257         rbNames = {}
    1258         for rbVec in rbData['Vector']:
    1259             if rbVec != 'AtInfo':
    1260                 rbNames[rbData['Vector'][rbVec]['RBname']] = ['Vector',rbVec]
    1261         for rbRes in rbData['Residue']:
    1262             if rbRes != 'AtInfo':
    1263                 rbNames[rbData['Residue'][rbRes]['RBname']] = ['Residue',rbRes]
    1264         if not rbNames:
    1265             print '**** ERROR - no rigid bodies defined ****'
    1266             return
    1267         dlg = wx.SingleChoiceDialog(G2frame.dataFrame,'Select','Rigid body',rbNames.keys())
    1268         if dlg.ShowModal() == wx.ID_OK:
    1269             sel = dlg.GetSelection()
    1270             rbname = rbNames.keys()[sel]
    1271             rbType,rbId = rbNames[rbname]
    1272             RB = rbData[rbType][rbId]
    12731252       
    12741253    def OnAtomMove(event):
     
    40314010                Obj = event.GetEventObject()
    40324011                model = Indx[Obj.GetId()]
    4033                 model['MolCent'] = Obj.GetValue()
     4012                model['MolCent'][1] = Obj.GetValue()
     4013                if model['MolCent'][1]:
     4014                    G2mth.SetMolCent(model,RBData)               
    40344015                G2plt.PlotStructure(G2frame,data)
    40354016           
     
    40494030                rbsizer1.Add(posVal,0,wx.ALIGN_CENTER_VERTICAL)
    40504031            molcent = wx.CheckBox(MCSA,-1,label=' Use mol. center? ')
    4051             molcent.SetValue(model['MolCent'])
     4032            molcent.SetValue(model['MolCent'][1])
    40524033            molcent.Bind(wx.EVT_CHECKBOX,OnMolCent)
    40534034            Indx[molcent.GetId()] = model
     
    43184299            RB = rbData[rbType][rbId]
    43194300        body = {'name':RB['RBname']+'('+str(len(data['MCSA']['Models']))+')','RBId':rbId,'Type':rbType,
    4320             'Pos':[[0.,0.,0.],[False,False,False],[[0.,1.],[0.,1.],[0.,1.]]],'Ovar':'','MolCent':False,
     4301            'Pos':[[0.,0.,0.],[False,False,False],[[0.,1.],[0.,1.],[0.,1.]]],'Ovar':'','MolCent':[[0.,0.,0.],False],
    43214302            'Ori':[[1.,0.,0.,0.],[False,False,False,False],[[-180.,180.],[-1.,1.],[-1.,1.],[-1.,1.]]]}
    43224303        if rbType == 'Residue':
     
    43354316        data['MCSA'] = {'Models':[{'Type':'MD','Coef':[1.0,False,[0.,3.],],'axis':[0,0,1]}],'Results':[],'AtInfo':{}}
    43364317        G2plt.PlotStructure(G2frame,data)
    4337         UpdateMCSA()           
    4338                        
     4318        UpdateMCSA()
     4319       
     4320    def OnMCSAmove(event):
     4321        general = data['General']
     4322        Amat,Bmat = G2lat.cell2AB(general['Cell'][1:7])
     4323        xyz,aTypes = G2mth.UpdateMCSAxyz(Bmat,data['MCSA'])
     4324        for iat,atype in enumerate(aTypes):
     4325            x,y,z = xyz[iat]
     4326            AtomAdd(x,y,z,atype,Name=atype+'(%d)'%(iat+1))           
     4327        G2plt.PlotStructure(G2frame,data)
     4328                   
    43394329################################################################################
    43404330##### Pawley routines
     
    45614551                mag,x,y,z,d = mapPeaks[ind]
    45624552                AtomAdd(x,y,z,'H',Name='M '+'%d'%(int(100*mag/peakMax)))
     4553            G2plt.PlotStructure(G2frame,data)
    45634554   
    45644555    def OnPeaksClear(event):
     
    48264817            G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomAdd, id=G2gd.wxID_ATOMSEDITADD)
    48274818            G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomViewAdd, id=G2gd.wxID_ATOMSVIEWADD)
    4828             G2frame.dataFrame.Bind(wx.EVT_MENU, OnRBAppend, id=G2gd.wxID_RBAPPEND)
    48294819            G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomInsert, id=G2gd.wxID_ATOMSEDITINSERT)
    48304820            G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomViewInsert, id=G2gd.wxID_ATOMVIEWINSERT)
     
    49154905            G2frame.dataFrame.Bind(wx.EVT_MENU, OnMCSAaddRB, id=G2gd.wxID_ADDMCSARB)
    49164906            G2frame.dataFrame.Bind(wx.EVT_MENU, OnMCSAclear, id=G2gd.wxID_CLEARMCSARB)
     4907            G2frame.dataFrame.Bind(wx.EVT_MENU, OnMCSAmove, id=G2gd.wxID_MOVEMCSA)
    49174908            UpdateMCSA()                       
    49184909            wx.CallAfter(G2plt.PlotStructure,G2frame,data)
  • trunk/GSASIIplot.py

    r935 r936  
    26192619    rbObj = testRBObj.get('rbObj',{})
    26202620    MCSA = data.get('MCSA',{})
    2621     mcsaModels = []
    2622     if len(MCSA):
    2623         mcsaModels = MCSA['Models']
     2621    mcsaModels = MCSA.get('Models',[])
    26242622    drawAtoms = drawingData.get('Atoms',[])
    26252623    mapData = {}
     
    34753473                RenderLabel(x,y,z,name,0.2,Or)
    34763474        if len(mcsaModels) > 1 and pageName == 'MC/SA':             #skip the default MD entry
    3477             XYZ,atTypes = G2mth.UpdateMCSAxyz(Bmat,mcsaModels,MCSA.get('rbData',{}))
     3475            XYZ,atTypes = G2mth.UpdateMCSAxyz(Bmat,MCSA)
    34783476            rbBonds = FindPeaksBonds(XYZ)
    34793477            for ind,[x,y,z] in enumerate(XYZ):
Note: See TracChangeset for help on using the changeset viewer.