Changeset 879


Ignore:
Timestamp:
Apr 2, 2013 1:08:48 PM (9 years ago)
Author:
vondreele
Message:

complete rb input to refinement

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r878 r879  
    12811281            sub = self.PatternTree.AppendItem(parent=self.root,text='Rigid bodies')
    12821282            self.PatternTree.SetItemPyData(sub,{'Vector':{'AtInfo':{}},
    1283                 'Residue':{'AtInfo':{}},'Z-matrix':{'AtInfo':{}}})
     1283                'Residue':{'AtInfo':{}},'RBIds':{'Vector':[],'Residue':[]}})
    12841284               
    12851285    class CopyDialog(wx.Dialog):
     
    21642164        parmDict = {}
    21652165        Histograms,Phases = self.GetUsedHistogramsAndPhasesfromTree()
    2166         Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases,RestraintDict=None,Print=False)       
     2166        rigidbodyDict = self.PatternTree.GetItemPyData(   
     2167            G2gd.GetPatternTreeItemId(self,self.root,'Rigid bodies'))
     2168        rbVary,rbDict,rbIds = G2str.GetRigidBodyModels(rigidbodyDict,Print=False)
     2169        Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False)       
    21672170        hapVary,hapDict,controlDict = G2str.GetHistogramPhaseData(Phases,Histograms,Print=False)
    21682171        histVary,histDict,controlDict = G2str.GetHistogramData(Histograms,Print=False)
    2169         varyList = phaseVary+hapVary+histVary
     2172        varyList = rbVary+phaseVary+hapVary+histVary
     2173        parmDict.update(rbDict)
    21702174        parmDict.update(phaseDict)
    21712175        parmDict.update(hapDict)
  • trunk/GSASIIconstrGUI.py

    r860 r879  
    9999        data.update({'Hist':[],'HAP':[],'Phase':[]})       #empty dict - fill it
    100100    Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
     101    rigidbodyDict = G2frame.PatternTree.GetItemPyData(   
     102        G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies'))
     103    rbVary,rbDict,rbIds = G2str.GetRigidBodyModels(rigidbodyDict,Print=False)
    101104    AtomDict = dict([Phases[phase]['pId'],Phases[phase]['Atoms']] for phase in Phases)
    102     Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases,Print=False)
     105    Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases,rbIds=rbIds,Print=False)
    103106    phaseList = []
    104107    for item in phaseDict:
     
    188191        if page[1] == 'phs':
    189192            atchoice = [item+' for '+phaseAtNames[item] for item in varList]
    190             atchoice += [FrstVarb+' for all']
    191             atchoice += [FrstVarb+' for all '+atype for atype in TypeList]
     193            if 'RB' not in FrstVarb:
     194                atchoice += [FrstVarb+' for all']
     195                atchoice += [FrstVarb+' for all '+atype for atype in TypeList]
    192196            dlg = wx.MultiChoiceDialog(G2frame,'Select more variables:'+legend,
    193197                'Constrain '+FrstVarb+' and...',atchoice)
     
    624628    Displays the rigid bodies in the data window
    625629    '''
    626     if not data:
    627         data.update({'Vector':{'AtInfo':{}},'Residue':{'AtInfo':{}}})       #empty dict - fill it
     630    if not data.get('RBId') or not data:
     631        data.update({'Vector':{'AtInfo':{}},'Residue':{'AtInfo':{}},
     632            'RBIds':{'Vector':[],'Residue':[]}})       #empty dict - fill it
     633               
    628634           
    629635    global resList
     
    726732            data['Vector'][rbId] = {'RBname':'UNKRB','VectMag':vecMag,'rbXYZ':np.zeros((nAtoms,3)),
    727733                'rbRef':[0,1,2,False],'VectRef':vecRef,'rbTypes':rbTypes,'rbVect':vecVal,'useCount':0}
     734            data['RBIds']['Vector'].append(rbId)
    728735        dlg.Destroy()
    729736        UpdateVectorRB()
     
    770777                    'atNames':atNames,'rbRef':[nOrig-1,mRef-1,nRef-1,True],'rbSeq':rbSeq,
    771778                    'SelSeq':[0,0],'useCount':0}
     779                data['RBIds']['Residue'].append(rbId)
    772780                print 'Rigid body '+rbName+' added'
    773781            macStr = macro.readline()
     
    830838        data['Residue'][rbId] = {'RBname':'UNKRB','rbXYZ':rbXYZ,'rbTypes':rbTypes,
    831839            'atNames':atNames,'rbRef':[0,1,2,False],'rbSeq':[],'SelSeq':[0,0],'useCount':0}
     840        data['RBIds']['Residue'].append(rbId)
    832841        print 'Rigid body UNKRB added'
    833842        text.close()
     
    913922            rbData['rbSeq'].append([Orig,Piv,0.0,Riding])           
    914923        dlg.Destroy()
    915         UpdateResidueRB()
    916        
     924        UpdateResidueRB()       
    917925
    918926    def UpdateVectorRB(Scroll=0):
    919927        AtInfo = data['Vector']['AtInfo']
    920928        refChoice = {}
    921         SetStatusLine(' You may use e.g. "sind(60)", "cos(60)", "c60" or "s60" for a vector entry')
     929        SetStatusLine(' You may use e.g. "c60" or "s60" for a vector entry')
    922930        def rbNameSizer(rbId,rbData):
    923931
     
    931939                rbId = Indx[Obj.GetId()]
    932940                del data['Vector'][rbId]
     941                data['RBIds']['Vector'].remove(rbId)
    933942                wx.CallAfter(UpdateVectorRB)
    934943               
     
    11001109        VectorRBDisplay = wx.Panel(VectorRB)
    11011110        VectorRBSizer = wx.BoxSizer(wx.VERTICAL)
    1102         for rbId in data['Vector']:
     1111        for rbId in data['RBIds']['Vector']:
    11031112            if rbId != 'AtInfo':
    11041113                rbData = data['Vector'][rbId]
     
    11401149                rbId = Indx[Obj.GetId()]
    11411150                del data['Residue'][rbId]
     1151                data['RBIds']['Residue'].remove(rbId)
    11421152                wx.CallAfter(UpdateResidueRB)
    11431153               
     
    13671377        ResidueRBDisplay = wx.Panel(ResidueRB)
    13681378        ResidueRBSizer = wx.BoxSizer(wx.VERTICAL)
    1369         rbKeys = data['Residue'].keys()
    1370         rbKeys.remove('AtInfo')
    1371         rbNames = [data['Residue'][k]['RBname'] for k in rbKeys]
    1372         rbIds = dict(zip(rbNames,rbKeys))
    1373         rbNames.sort()
    1374         for name in rbNames:
    1375             rbId = rbIds[name]
     1379        for rbId in data['RBIds']['Residue']:
    13761380            rbData = data['Residue'][rbId]
    13771381            FillRefChoice(rbId,rbData)
  • trunk/GSASIIphsGUI.py

    r876 r879  
    16651665        RBData['Residue'][rbId] = {'RBname':rbName,'rbXYZ':rbXYZ,'rbTypes':rbType,
    16661666            'atNames':atNames,'rbRef':[0,1,2,False],'rbSeq':[],'SelSeq':[0,0],'useCount':0}
     1667        RBData['RBIds']['Residue'].append(rbId)
    16671668        G2frame.dataFrame.SetStatusText('New rigid body UNKRB added to set of Residue rigid bodies')
    16681669
     
    37803781    def OnRBRemoveAll(event):
    37813782        data['RBModels']['Residue'] = []
    3782         data['RBModels']['Vector'] = []   
     3783        data['RBModels']['Vector'] = []
    37833784        RBData = G2frame.PatternTree.GetItemPyData(   
    37843785            G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies'))
  • trunk/GSASIIstruct.py

    r874 r879  
    130130    if not Histograms:
    131131        return 'Error: no diffraction data',''
    132     Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,RestraintDict=None,Print=False)
     132    rigidbodyDict = GetRigidBodies(GPXfile)
     133    rbVary,rbDict,rbIds = GetRigidBodyModels(rigidbodyDict,Print=False)
     134    Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False)
    133135    hapVary,hapDict,controlDict = GetHistogramPhaseData(Phases,Histograms,Print=False)
    134136    histVary,histDict,controlDict = GetHistogramData(Histograms,Print=False)
     
    528530       
    529531################################################################################
     532##### Rigid Body Models
     533################################################################################
     534       
     535def GetRigidBodyModels(rigidbodyDict,Print=True,pFile=None):
     536   
     537    def PrintResRBModel(RBModel):
     538        atNames = RBModel['atNames']
     539        rbRef = RBModel['rbRef']
     540        rbSeq = RBModel['rbSeq']
     541        print >>pFile,'Residue RB name: ',RBModel['RBname'],' no.atoms: ',len(RBModel['rbTypes']), \
     542            'No. times used: ',RBModel['useCount']
     543        print >>pFile,'    At name       x          y          z'
     544        for name,xyz in zip(atNames,RBModel['rbXYZ']):
     545            print >>pFile,'  %8s %10.4f %10.4f %10.4f'%(name,xyz[0],xyz[1],xyz[2])
     546        print >>pFile,'Orientation defined by:',atNames[rbRef[0]],' -> ',atNames[rbRef[1]], \
     547            ' & ',atNames[rbRef[0]],' -> ',atNames[rbRef[2]]
     548        if rbSeq:
     549            for i,rbseq in enumerate(rbSeq):
     550                print >>pFile,'Torsion sequence ',i,' Bond: '+atNames[rbseq[0]],' - ', \
     551                    atNames[rbseq[1]],' riding: ',[atNames[i] for i in rbseq[3]]
     552       
     553    def PrintVecRBModel(RBModel):
     554        rbRef = RBModel['rbRef']
     555        atTypes = RBModel['rbTypes']
     556        print >>pFile,'Vector RB name: ',RBModel['RBname'],' no.atoms: ',len(RBModel['rbTypes']), \
     557            'No. times used: ',RBModel['useCount']
     558        for i in range(len(RBModel['VectMag'])):
     559            print >>pFile,'Vector no.: ',i,' Magnitude: ', \
     560                '%8.4f'%(RBModel['VectMag'][i]),' Refine? ',RBModel['VectRef'][i]
     561            print >>pFile,'  No. Type     vx         vy         vz'
     562            for j,[name,xyz] in enumerate(zip(atTypes,RBModel['rbVect'][i])):
     563                print >>pFile,'  %d   %2s %10.4f %10.4f %10.4f'%(j,name,xyz[0],xyz[1],xyz[2])
     564        print >>pFile,'  No. Type      x          y          z'
     565        for i,[name,xyz] in enumerate(zip(atTypes,RBModel['rbXYZ'])):
     566            print >>pFile,'  %d   %2s %10.4f %10.4f %10.4f'%(i,name,xyz[0],xyz[1],xyz[2])
     567        print >>pFile,'Orientation defined by: atom ',rbRef[0],' -> atom ',rbRef[1], \
     568            ' & atom ',rbRef[0],' -> atom ',rbRef[2]
     569    rbVary = []
     570    rbDict = {}
     571    rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})
     572    if len(rigidbodyDict['Vector']):
     573        for irb,item in enumerate(rigidbodyDict['RBIds']['Vector']):
     574            if rigidbodyDict['Vector'][item]['useCount']:
     575                RBmags = rigidbodyDict['Vector'][item]['VectMag']
     576                RBrefs = rigidbodyDict['Vector'][item]['VectRef']
     577                for i,[mag,ref] in enumerate(zip(RBmags,RBrefs)):
     578                    pid = '::RBV;'+str(irb)+':'+str(i)
     579                    rbDict[pid] = mag
     580                    if ref:
     581                        rbVary.append(pid)
     582                if Print:
     583                    print >>pFile,'\nVector rigid body model:'
     584                    PrintVecRBModel(rigidbodyDict['Vector'][item])
     585    if len(rigidbodyDict['Residue']):
     586        for item in rigidbodyDict['RBIds']['Residue']:
     587            if rigidbodyDict['Residue'][item]['useCount']:
     588                if Print:
     589                    print >>pFile,'\nResidue rigid body model:'
     590                    PrintResRBModel(rigidbodyDict['Residue'][item])
     591    return rbVary,rbDict,rbIds
     592       
     593################################################################################
    530594##### Phase data
    531595################################################################################       
    532596                   
    533 def GetPhaseData(PhaseData,RestraintDict={},Print=True,pFile=None):
     597def GetPhaseData(PhaseData,RestraintDict={},rbIds={},Print=True,pFile=None):
    534598           
    535599    def PrintFFtable(FFtable):
     
    561625            print >>pFile,line
    562626           
    563     #def PrintRBObjects()
     627    def PrintRBObjects(resRBData,vecRBData):
     628       
     629        def PrintRBThermals():
     630            tlstr = ['11','22','33','12','13','23']
     631            sstr = ['12','13','21','23','31','32','AA','BB']
     632            TLS = RB['ThermalMotion'][1]
     633            TLSvar = RB['ThermalMotion'][2]
     634            if 'T' in RB['ThermalMotion'][0]:
     635                print >>pFile,'TLS data'
     636                text = ''
     637                for i in range(6):
     638                    text += 'T'+tlstr[i]+' %8.4f %s '%(TLS[i],str(TLSvar[i])[0])
     639                print >>pFile,text
     640                if 'L' in RB['ThermalMotion'][0]:
     641                    text = ''
     642                    for i in range(6,12):
     643                        text += 'L'+tlstr[i-6]+' %8.2f %s '%(TLS[i],str(TLSvar[i])[0])
     644                    print >>pFile,text
     645                if 'S' in RB['ThermalMotion'][0]:
     646                    text = ''
     647                    for i in range(12,20):
     648                        text += 'S'+sstr[i-12]+' %8.3f %s '%(TLS[i],str(TLSvar[i])[0])
     649                    print >>pFile,text
     650            if 'U' in RB['ThermalMotion'][0]:
     651                print >>pFile,'Uiso data'
     652                text = 'Uiso'+' %10.3f %s'%(TLS[0],str(TLSvar[0])[0])           
     653           
     654        if len(resRBData):
     655            for RB in resRBData:
     656                Oxyz = RB['Orig'][0]
     657                Qrijk = RB['Orient'][0]
     658                Angle = 2.0*acosd(Qrijk[0])
     659                print >>pFile,'\nRBObject ',RB['RBname'],' at ',      \
     660                    '%10.4f %10.4f %10.4f'%(Oxyz[0],Oxyz[1],Oxyz[2]),' Refine?',RB['Orig'][1]
     661                print >>pFile,'Orientation angle,vector:',      \
     662                    '%10.3f %10.4f %10.4f %10.4f'%(Angle,Qrijk[1],Qrijk[2],Qrijk[3]),' Refine? ',RB['Orient'][1]
     663                Torsions = RB['Torsions']
     664                if len(Torsions):
     665                    text = 'Torsions: '
     666                    for torsion in Torsions:
     667                        text += '%10.4f Refine? %s'%(torsion[0],torsion[1])
     668                    print >>pFile,text
     669                PrintRBThermals()
     670        if len(vecRBData):
     671            for RB in vecRBData:
     672                Oxyz = RB['Orig'][0]
     673                Qrijk = RB['Orient'][0]
     674                Angle = 2.0*acosd(Qrijk[0])
     675                print >>pFile,'\nRBObject ',RB['RBname'],' at ',      \
     676                    '%10.4f %10.4f %10.4f'%(Oxyz[0],Oxyz[1],Oxyz[2]),' Refine?',RB['Orig'][1]           
     677                print >>pFile,'Orientation angle,vector:',      \
     678                    '%10.3f %10.4f %10.4f %10.4f'%(Angle,Qrijk[1],Qrijk[2],Qrijk[3]),' Refine? ',RB['Orient'][1]
     679                PrintRBThermals()
    564680               
    565681    def PrintAtoms(General,Atoms):
     
    621737        print >>pFile,ptstr
    622738       
    623     if Print:print  >>pFile,' Phases:'
     739    def MakeRBParms():
     740        rbid = str(rbids.index(RB['RBId']))
     741        pfxRB = pfx+'RBP'
     742        pstr = ['x','y','z']
     743        ostr = ['a','i','j','k']
     744        for i in range(3):
     745            name = pfxRB+pstr[i]+':'+str(iRB)+':'+rbid
     746            phaseDict[name] = RB['Orig'][0][i]
     747            if RB['Orig'][1]:
     748                phaseVary += [name,]
     749        pfxRB = pfx+'RBO'
     750        for i in range(4):
     751            name = pfxRB+ostr[i]+':'+str(iRB)+':'+rbid
     752            phaseDict[name] = RB['Orient'][0][i]
     753            if RB['Orient'][1] == 'V' and i:
     754                phaseVary += [name,]
     755            elif RB['Orient'][1] == 'A' and not i:
     756                phaseVary += [name,]
     757           
     758    def MakeRBThermals():
     759        rbid = str(rbids.index(RB['RBId']))
     760        tlstr = ['11','22','33','12','13','23']
     761        sstr = ['12','13','21','23','31','32','AA','BB']
     762        if 'T' in RB['ThermalMotion'][0]:
     763            pfxRB = pfx+'RBT'
     764            for i in range(6):
     765                name = pfxRB+tlstr[i]+':'+str(iRB)+':'+rbid
     766                phaseDict[name] = RB['ThermalMotion'][1][i]
     767                if RB['ThermalMotion'][2][i]:
     768                    phaseVary += [name,]
     769        if 'L' in RB['ThermalMotion'][0]:
     770            pfxRB = pfx+'RBL'
     771            for i in range(6):
     772                name = pfxRB+tlstr[i]+':'+str(iRB)+':'+rbid
     773                phaseDict[name] = RB['ThermalMotion'][1][i+6]
     774                if RB['ThermalMotion'][2][i+6]:
     775                    phaseVary += [name,]
     776        if 'S' in RB['ThermalMotion'][0]:
     777            pfxRB = pfx+'RBS'
     778            for i in range(5):
     779                name = pfxRB+sstr[i]+':'+str(iRB)+':'+rbid
     780                phaseDict[name] = RB['ThermalMotion'][1][i+12]
     781                if RB['ThermalMotion'][2][i+12]:
     782                    phaseVary += [name,]
     783        if 'U' in RB['ThermalMotion'][0]:
     784            name = pfx+'RBU:'+str(iRB)+':'+rbid
     785            phaseDict[name] = RB['ThermalMotion'][1][0]
     786            if RB['ThermalMotion'][2][0]:
     787                phaseVary += [name,]
     788               
     789    def MakeRBTorsions():
     790        rbid = str(rbids.index(RB['RBId']))
     791        pfxRB = pfx+'RBTr;'
     792        for i,torsion in enumerate(RB['Torsions']):
     793            name = pfxRB+str(i)+':'+str(iRB)+':'+rbid
     794            phaseDict[name] = torsion[0]
     795            if torsion[1]:
     796                phaseVary += [name,]
     797                   
     798    if Print:
     799        print  >>pFile,'\n Phases:'
    624800    phaseVary = []
    625801    phaseDict = {}
     
    644820        Atoms = PhaseData[name]['Atoms']
    645821        AtLookup = G2mth.FillAtomLookUp(Atoms)
    646         try:
    647             PawleyRef = PhaseData[name]['Pawley ref']
    648         except KeyError:
    649             PawleyRef = []
     822        PawleyRef = PhaseData[name].get('Pawley ref',[])
    650823        SGData = General['SGData']
    651824        SGtext = G2spc.SGPrint(SGData)
     
    656829        if cell[0]:
    657830            phaseVary += cellVary(pfx,SGData)
    658         #rigid body model input here
     831        resRBData = PhaseData[name]['RBModels'].get('Residue',[])
     832        if resRBData:
     833            rbids = rbIds['Residue']
     834            for iRB,RB in enumerate(resRBData):
     835                MakeRBParms()
     836                MakeRBThermals()
     837                MakeRBTorsions()
     838       
     839        vecRBData = PhaseData[name]['RBModels'].get('Vector',[])
     840        if vecRBData:
     841            rbids = rbIds['Vector']
     842            for iRB,RB in enumerate(vecRBData):
     843                MakeRBParms()
     844                MakeRBThermals()
     845                   
    659846        Natoms[pfx] = 0
    660847        if Atoms and not General.get('doPawley'):
     
    727914                print >>pFile,''
    728915                for line in SGtext: print >>pFile,line
    729                 #PrintRBObjects(whatever is needed here)
     916                PrintRBObjects(resRBData,vecRBData)
    730917                PrintAtoms(General,Atoms)
    731918                print >>pFile,'\n Unit cell: a =','%.5f'%(cell[1]),' b =','%.5f'%(cell[2]),' c =','%.5f'%(cell[3]), \
     
    20842271
    20852272def penaltyFxn(HistoPhases,parmDict,varyList):
    2086     Histograms,Phases,restraintDict = HistoPhases
     2273    Histograms,Phases,restraintDict,rigidbodyDict = HistoPhases
    20872274    pNames = []
    20882275    pVals = []
     
    21802367   
    21812368def penaltyDeriv(pNames,pVal,HistoPhases,parmDict,varyList):
    2182     Histograms,Phases,restraintDict = HistoPhases
     2369    Histograms,Phases,restraintDict,rigidbodyDict = HistoPhases
    21832370    pDerv = np.zeros((len(varyList),len(pVal)))
    21842371    for phase in Phases:
     
    30843271        GA,GB = G2lat.Gmat2AB(G)    #Orthogonalization matricies
    30853272        Vst = np.sqrt(nl.det(G))    #V*
     3273#apply RB parms to atom parms in parmDict?
    30863274        if not Phase['General'].get('doPawley'):
    30873275            refList = StructureFactor(refList,G,hfx,pfx,SGData,calcControls,parmDict)
     
    33683556    parmdict.update(zip(varylist,values))
    33693557    G2mv.Dict2Map(parmdict,varylist)
    3370     Histograms,Phases,restraintDict = HistoPhases
     3558    Histograms,Phases,restraintDict,rigidbodyDict = HistoPhases
    33713559    nvar = len(varylist)
    33723560    dMdv = np.empty(0)
     
    34443632    parmdict.update(zip(varylist,values))
    34453633    G2mv.Dict2Map(parmdict,varylist)
    3446     Histograms,Phases,restraintDict = HistoPhases
     3634    Histograms,Phases,restraintDict,rigidbodyDict = HistoPhases
    34473635    nvar = len(varylist)
    34483636    Hess = np.empty(0)
     
    35423730    Values2Dict(parmdict, varylist, values)
    35433731    G2mv.Dict2Map(parmdict,varylist)
    3544     Histograms,Phases,restraintDict = HistoPhases
     3732    Histograms,Phases,restraintDict,rigidbodyDict = HistoPhases
    35453733    M = np.empty(0)
    35463734    SumwYo = 0
     
    35893777            A = [parmdict[pfx+'A%d'%(i)] for i in range(6)]
    35903778            G,g = G2lat.A2Gmat(A)       #recip & real metric tensors
     3779#apply RB models to atom parms in parmDict?
    35913780            refList = Histogram['Data']
    35923781            refList = StructureFactor(refList,G,hfx,pfx,SGData,calcControls,parmdict)
     
    36713860    constrDict,fixedList = GetConstraints(GPXfile)
    36723861    restraintDict = GetRestraints(GPXfile)
    3673     rigidbodyDict = GetRigidBodies(GPXfile)
    36743862    Histograms,Phases = GetUsedHistogramsAndPhases(GPXfile)
    36753863    if not Phases:
     
    36813869        print ' *** Refine aborted ***'
    36823870        raise Exception       
    3683     Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,restraintDict,pFile=printFile)
     3871    rigidbodyDict = GetRigidBodies(GPXfile)
     3872    rbVary,rbDict,rbIds = GetRigidBodyModels(rigidbodyDict,pFile=printFile)
     3873    Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,restraintDict,rbIds,pFile=printFile)
    36843874    calcControls['atomIndx'] = atomIndx
    36853875    calcControls['Natoms'] = Natoms
    36863876    calcControls['FFtables'] = FFtables
    36873877    calcControls['BLtables'] = BLtables
     3878    calcControls['rbIDs'] = rbIds
    36883879    hapVary,hapDict,controlDict = GetHistogramPhaseData(Phases,Histograms,pFile=printFile)
    36893880    calcControls.update(controlDict)
    36903881    histVary,histDict,controlDict = GetHistogramData(Histograms,pFile=printFile)
    36913882    calcControls.update(controlDict)
    3692     varyList = phaseVary+hapVary+histVary
     3883    varyList = rbVary+phaseVary+hapVary+histVary
     3884    parmDict.update(rbDict)
    36933885    parmDict.update(phaseDict)
    36943886    parmDict.update(hapDict)
     
    37263918            result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True,
    37273919                ftol=Ftol,col_deriv=True,factor=Factor,
    3728                 args=([Histograms,Phases,restraintDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     3920                args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
    37293921            ncyc = int(result[2]['nfev']/2)
    37303922        elif 'Hessian' in Controls['deriv type']:
    37313923            result = G2mth.HessianLSQ(errRefine,values,Hess=HessRefine,ftol=Ftol,maxcyc=maxCyc,
    3732                 args=([Histograms,Phases,restraintDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     3924                args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
    37333925            ncyc = result[2]['num cyc']+1
    37343926            Rvals['lamMax'] = result[2]['lamMax']
    37353927        else:           #'numeric'
    37363928            result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor,
    3737                 args=([Histograms,Phases,restraintDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     3929                args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
    37383930            ncyc = int(result[2]['nfev']/len(varyList))
    37393931#        table = dict(zip(varyList,zip(values,result[0],(result[0]-values))))
     
    38394031        print ' *** Refine aborted ***'
    38404032        raise Exception
    3841     Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,restraintDict,False,printFile)
     4033    rigidbodyDict = GetRigidBodies(GPXfile)
     4034    rbVary,rbDict,rbIds = GetRigidBodyModels(rigidbodyDict,pFile=printFile)
     4035    Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,restraintDict,rbIds,False,printFile)
    38424036    for item in phaseVary:
    38434037        if '::A0' in item:
     
    38624056        calcControls['FFtables'] = FFtables
    38634057        calcControls['BLtables'] = BLtables
     4058        calcControls['rbIDs'] = rbIds
    38644059        varyList = []
    38654060        parmDict = {}
     
    38694064        histVary,histDict,controlDict = GetHistogramData(Histo,False)
    38704065        calcControls.update(controlDict)
    3871         varyList = phaseVary+hapVary+histVary
     4066        varyList = rbVary+phaseVary+hapVary+histVary
    38724067        if not ihst:
    38734068            saveVaryList = varyList[:]
     
    39224117                result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True,
    39234118                    ftol=Ftol,col_deriv=True,factor=Factor,
    3924                     args=([Histo,Phases,restraintDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     4119                    args=([Histo,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
    39254120                ncyc = int(result[2]['nfev']/2)
    39264121            elif 'Hessian' in Controls['deriv type']:
    39274122                result = G2mth.HessianLSQ(errRefine,values,Hess=HessRefine,ftol=Ftol,maxcyc=maxCyc,
    3928                     args=([Histo,Phases,restraintDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     4123                    args=([Histo,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
    39294124                ncyc = result[2]['num cyc']+1                           
    39304125            else:           #'numeric'
    39314126                result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor,
    3932                     args=([Histo,Phases,restraintDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     4127                    args=([Histo,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
    39334128                ncyc = int(result[2]['nfev']/len(varyList))
    39344129
Note: See TracChangeset for help on using the changeset viewer.