# Changeset 1097

Ignore:
Timestamp:
Oct 10, 2013 10:35:50 AM (9 years ago)
Message:

mods to restraint GUI & LS output for restraints
correct torsion & Ramachandran penalties

Location:
trunk
Files:
4 edited

Unmodified
Added
Removed
• ## trunk/GSASIImath.py

 r1096 XYZ[j] -= x tor = getRestTorsion(XYZ,Amat) p,d1 = calcTorsionEnergy(tor,Coeff) p1,d1 = calcTorsionEnergy(tor,Coeff) XYZ[j] += 2*x tor = getRestTorsion(XYZ,Amat) p,d2 = calcTorsionEnergy(tor,Coeff) p2,d2 = calcTorsionEnergy(tor,Coeff) XYZ[j] -= x deriv[j][i] = (d2-d1)/(2*dx) deriv[j][i] = (p2-p1)/(2*dx) return deriv.flatten() XYZ[j] -= x phi,psi = getRestRama(XYZ,Amat) p,d1 = calcRamaEnergy(phi,psi,Coeff) p1,d1 = calcRamaEnergy(phi,psi,Coeff) XYZ[j] += 2*x phi,psi = getRestRama(XYZ,Amat) p,d2 = calcRamaEnergy(phi,psi,Coeff) p2,d2 = calcRamaEnergy(phi,psi,Coeff) XYZ[j] -= x deriv[j][i] = (d2-d1)/(2*dx) deriv[j][i] = (p2-p1)/(2*dx) return deriv.flatten()
• ## trunk/GSASIIphsGUI.py

 r1076 PhaseName = rd.Phase['General']['Name'] print 'Read phase '+str(PhaseName)+' from file '+str(G2frame.lastimport) print rd.Phase['Atoms'] atomData = data['Atoms'] for atom in rd.Phase['Atoms'][:5]: print atom for atom in atomData[:5]: print atom return
• ## trunk/GSASIIrestrGUI.py

 r1077 wtBox = wx.BoxSizer(wx.HORIZONTAL) wtBox.Add(wx.StaticText(wind,-1,'Restraint weight factor:'),0,wx.ALIGN_CENTER_VERTICAL) wtfactor = wx.TextCtrl(wind,-1,value='%.2f'%(restData['wtFactor']),style=wx.TE_PROCESS_ENTER) wtfactor = wx.TextCtrl(wind,-1,value='%.2f'%(restData['wtFactor']),style=wx.TE_PROCESS_ENTER,size=(50,20)) wtfactor.Bind(wx.EVT_TEXT_ENTER,OnWtFactor) wtfactor.Bind(wx.EVT_KILL_FOCUS,OnWtFactor) if 'Bonds' in restData or 'Angles' in restData: wtBox.Add(wx.StaticText(wind,-1,'Search range:'),0,wx.ALIGN_CENTER_VERTICAL) sRange = wx.TextCtrl(wind,-1,value='%.2f'%(restData['Range']),style=wx.TE_PROCESS_ENTER) sRange = wx.TextCtrl(wind,-1,value='%.2f'%(restData['Range']),style=wx.TE_PROCESS_ENTER,size=(50,20)) sRange.Bind(wx.EVT_TEXT_ENTER,OnRange) sRange.Bind(wx.EVT_KILL_FOCUS,OnRange) rowLabels = [] bad = [] chisq = 0. Types = [wg.GRID_VALUE_STRING,]+4*[wg.GRID_VALUE_FLOAT+':10,3',] if 'macro' in General['Type']: XYZ = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cx,3)) calc = G2mth.getRestDist(XYZ,Amat) chisq += bondRestData['wtFactor']*((obs-calc)/esd)**2 table.append([name[:-3],calc,obs,esd,(obs-calc)/esd]) rowLabels.append(str(i)) XYZ = G2mth.getSyXYZ(XYZ,ops,SGData) calc = G2mth.getRestDist(XYZ,Amat) chisq += bondRestData['wtFactor']*((obs-calc)/esd)**2 table.append([names[0]+'+('+ops[0]+') - '+names[1]+'+('+ops[1]+')',calc,obs,esd,(obs-calc)/esd]) rowLabels.append(str(i)) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD) mainSizer.Add(wx.StaticText(BondRestr,-1, 'Bond restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \ %(chisq,chisq/len(bondList))),0,wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(Bonds,0,) else: rowLabels = [] bad = [] chisq = 0. Types = [wg.GRID_VALUE_STRING,]+4*[wg.GRID_VALUE_FLOAT+':10,2',] if 'macro' in General['Type']: XYZ = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cx,3)) calc = G2mth.getRestAngle(XYZ,Amat) chisq += angleRestData['wtFactor']*((obs-calc)/esd)**2 table.append([name[:-3],calc,obs,esd,(obs-calc)/esd]) rowLabels.append(str(i)) XYZ = G2mth.getSyXYZ(XYZ,ops,SGData) calc = G2mth.getRestAngle(XYZ,Amat) chisq += angleRestData['wtFactor']*((obs-calc)/esd)**2 table.append([name,calc,obs,esd,(obs-calc)/esd]) rowLabels.append(str(i)) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD) mainSizer.Add(wx.StaticText(AngleRestr,-1, 'Angle restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \ %(chisq,chisq/len(angleList))),0,wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(Angles,0,) else: rowLabels = [] bad = [] chisq = 0. Types = [wg.GRID_VALUE_STRING,]+3*[wg.GRID_VALUE_FLOAT+':10,2',] if 'macro' in General['Type']: XYZ = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cx,3)) calc = G2mth.getRestPlane(XYZ,Amat) chisq += planeRestData['wtFactor']*((calc)/esd)**2 table.append([name[:-3],calc,obs,esd]) rowLabels.append(str(i)) XYZ = G2mth.getSyXYZ(XYZ,ops,SGData) calc = G2mth.getRestPlane(XYZ,Amat) chisq += planeRestData['wtFactor']*((calc)/esd)**2 name = '' for a,atom in enumerate(atoms): G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD) mainSizer.Add(wx.StaticText(PlaneRestr,-1, 'Plane restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \ %(chisq,chisq/len(planeList))),0,wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(Planes,0,) else: rowLabels = [] bad = [] chisq = 0. Types = [wg.GRID_VALUE_STRING,]+4*[wg.GRID_VALUE_FLOAT+':10,2',] if 'macro' in General['Type']: XYZ = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cx,3)) calc = G2mth.getRestChiral(XYZ,Amat) chisq += chiralRestData['wtFactor']*((obs-calc)/esd)**2 table.append([name,calc,obs,esd,(obs-calc)/esd]) rowLabels.append(str(i)) XYZ = G2mth.getSyXYZ(XYZ,ops,SGData) calc = G2mth.getRestChiral(XYZ,Amat) chisq += chiralRestData['wtFactor']*((obs-calc)/esd)**2 table.append([name,calc,obs,esd,(obs-calc)/esd]) rowLabels.append(str(i)) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD) mainSizer.Add(wx.StaticText(ChiralRestr,-1, 'Chiral volume restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \ %(chisq,chisq/len(volumeList))),0,wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(Volumes,0,) else: for row in rows: torsionList.remove(torsionList[row]) UpdateTorsionRestr(torsionRestData) wx.CallAfter(UpdateTorsionRestr,torsionRestData) def OnChangeEsd(event): torsionRestData['Torsions'][r][4] = parm dlg.Destroy() UpdateTorsionRestr(torsionRestData) wx.CallAfter(UpdateTorsionRestr,torsionRestData) TorsionRestr.DestroyChildren() coeffDict = torsionRestData['Coeff'] torsionList = torsionRestData['Torsions'] mainSizer.Add(wx.StaticText(TorsionRestr,-1,'Torsion restraints:'),0,wx.ALIGN_CENTER_VERTICAL) if len(torsionList): table = [] rowLabels = [] bad = [] chisq = 0. Types = 2*[wg.GRID_VALUE_STRING,]+4*[wg.GRID_VALUE_FLOAT+':10,2',] if 'macro' in General['Type']: tor = G2mth.getRestTorsion(XYZ,Amat) restr,calc = G2mth.calcTorsionEnergy(tor,coeffDict[cofName]) chisq += torsionRestData['wtFactor']*(restr/esd)**2 table.append([name,cofName,tor,calc,restr,esd]) rowLabels.append(str(i)) G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD) mainSizer.Add(wx.StaticText(TorsionRestr,-1, 'Torsion restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \ %(chisq,chisq/len(torsionList))),0,wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(Torsions,0,) rowLabels = [] bad = [] chisq = 0. Types = 2*[wg.GRID_VALUE_STRING,]+5*[wg.GRID_VALUE_FLOAT+':10,2',] if 'macro' in General['Type']: phi,psi = G2mth.getRestRama(XYZ,Amat) restr,calc = G2mth.calcRamaEnergy(phi,psi,coeffDict[cofName]) chisq += ramaRestData['wtFactor']*(restr/esd)**2 table.append([name,cofName,phi,psi,calc,restr,esd]) rowLabels.append(str(i)) G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD) mainSizer.Add(wx.StaticText(RamaRestr,-1, 'Ramachandran restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \ %(chisq,chisq/len(ramaList))),0,wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(Ramas,0,) else: rowLabels = [] bad = [] chisq = 0. Types = [wg.GRID_VALUE_STRING,]+5*[wg.GRID_VALUE_FLOAT+':10,2',] colLabels = ['Atoms','mul*frac','factor','calc','obs','esd'] mulfrac = mul*frac calcs = mul*frac*factors chisq += chiralRestData['wtFactor']*((obs-np.sum(calcs))/esd)**2 for iatm,[atom,mf,fr,clc] in enumerate(zip(atoms,mulfrac,factors,calcs)): table.append([atom,mf,fr,clc,'','']) G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE) G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL) mainSizer.Add(wx.StaticText(ChemCompRestr,-1, 'Chemical composition restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \ %(chisq,chisq/len(chemcompList))),0,wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(ChemComps,0,) else:
• ## trunk/GSASIIstrMath.py

 r1092 phi,psi = G2mth.getRestRama(XYZ,Amat) restr,calc = G2mth.calcRamaEnergy(phi,psi,coeffDict[cofName]) pVals.append(obs-calc) pVals.append(restr) pWt.append(wt/esd**2) pWsum[name] += wt*((obs-calc)/esd)**2 pWsum[name] += wt*(restr/esd)**2 elif name == 'ChemComp': for i,[indx,factors,obs,esd] in enumerate(itemRest[rest]): pSum = np.sum(pWt*pVals**2) for name in pWsum: print '  Penalty function for %s = %.3f'%(name,pWsum[name]) print '  Penalty function for %8s = %.3f'%(name,pWsum[name]) print 'Total penalty function: %.3f on %d terms'%(pSum,len(pVals)) Nobs += len(pVals)
Note: See TracChangeset for help on using the changeset viewer.