Changeset 5520
- Timestamp:
- Mar 23, 2023 1:03:34 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIconstrGUI.py ¶
r5502 r5520 3027 3027 3028 3028 rbid = ran.randint(0,sys.maxsize) 3029 radius = 1.03030 3029 atType = 'C' 3031 3030 rbType = 'Q' … … 3035 3034 name = G2obj.MakeUniqueLabel(name,namelist) 3036 3035 atColor = G2elem.GetAtomInfo(atType)['Color'] 3037 data['Spin'][rbid] = {'RBname':name,'Natoms':Natoms,' radius':[radius,False],'atType':atType,'rbType':rbType,3038 'useCount':0,'nSH':0,'SHC':[{},],' Matrix':np.eye(3),'rbPos':np.zeros(3),'atColor':atColor}3036 data['Spin'][rbid] = {'RBname':name,'Natoms':Natoms,'atType':atType,'rbType':rbType, 3037 'useCount':0,'nSH':0,'SHC':[{},],'Radius':[1.0,False],'Matrix':np.eye(3),'rbPos':np.zeros(3),'atColor':atColor} 3039 3038 data['RBIds']['Spin'].append(rbid) 3040 3039 UpdateSpinRB() … … 3404 3403 Obj.ChangeValue(El) 3405 3404 3406 def OnRefSel(event):3407 ObjId = event.GetId()3408 data['Spin'][Indx[ObjId]]['radius'][1] = not data['Spin'][Indx[ObjId]]['radius'][1]3409 3410 3405 def OnSymSel(event): 3411 3406 ObjId = event.GetId() … … 3434 3429 Indx = {} 3435 3430 SpinRBSizer.Add(wx.StaticText(SpinRBDisplay,label=' Spinning rigid body shells/nonspherical atoms (radius=0):'),0,WACV) 3436 bodSizer = wx.FlexGridSizer(0, 7,5,5)3437 for item in ['Name','Type','RB sym','Atom','Number' ,'radius','refine']:3431 bodSizer = wx.FlexGridSizer(0,5,5,5) 3432 for item in ['Name','Type','RB sym','Atom','Number']: 3438 3433 bodSizer.Add(wx.StaticText(SpinRBDisplay,label=item)) 3439 3434 for ibod,spinID in enumerate(data['Spin']): … … 3453 3448 bodSizer.Add(atSel,0) 3454 3449 bodSizer.Add(G2G.ValidatedTxtCtrl(SpinRBDisplay,data['Spin'][spinID],'Natoms')) 3455 bodSizer.Add(G2G.ValidatedTxtCtrl(SpinRBDisplay,data['Spin'][spinID]['radius'],0))3456 refSel = wx.CheckBox(SpinRBDisplay)3457 refSel.SetValue(data['Spin'][spinID]['radius'][1])3458 Indx[refSel.GetId()] = spinID3459 refSel.Bind(wx.EVT_CHECKBOX,OnRefSel)3460 bodSizer.Add(refSel,0)3461 3450 3462 3451 SpinRBSizer.Add(bodSizer) -
TabularUnified trunk/GSASIIlattice.py ¶
r5513 r5520 2706 2706 def SHarmcal(SytSym,SHFln,psi,gam): 2707 2707 '''Perform a surface spherical harmonics computation. 2708 Presently only used for plotting 2708 2709 Note that the the number of gam values must either be 1 or must match psi 2709 2710 -
TabularUnified trunk/GSASIIobj.py ¶
r5443 r5520 2041 2041 'RBSO([aijk])' : 'Spinning rigid body orientation parameter \\1', 2042 2042 'RBSP([xyz])' : 'Spinning rigid body \\1 position parameter', 2043 'RBSShRadius' : 'Spinning rigid body radius', 2043 2044 'RBSShC([1-20,1-20])' : 'Spinning rigid body sph. harmonics term', 2044 2045 'constr([0-9]*)' : 'Generated degree of freedom from constraint', -
TabularUnified trunk/GSASIIphsGUI.py ¶
r5517 r5520 11581 11581 RBObj['RBId'].append(rbIds[selection]) 11582 11582 RBObj['SHC'].append({}) 11583 for name in ['atColor','atType','Natoms','nSH',' radius','RBname','RBsym']:11583 for name in ['atColor','atType','Natoms','nSH','RBname','RBsym','Radius']: 11584 11584 RBObj[name].append(rbData[name]) 11585 11585 RBObj['hide'].append(False) … … 11612 11612 iSh,name = Indx[Obj.GetId()] 11613 11613 RBObj['SHC'][iSh][name][2] = not RBObj['SHC'][iSh][name][2] 11614 11615 def OnRadRef(event): 11616 Obj = event.GetEventObject() 11617 iSh = Indx[Obj.GetId()] 11618 RBObj['Radius'][iSh][1] = not RBObj['Radius'][iSh][1] 11614 11619 11615 11620 def NewSHC(invalid,value,tc): 11616 11621 G2plt.PlotStructure(G2frame,data) 11617 11622 11618 11623 def OnDelShell(event): 11619 11624 Obj = event.GetEventObject() … … 11622 11627 RBData['Spin'][rbId]['useCount'] -= 1 11623 11628 RBData['Spin'][rbId]['useCount'] = max(0,RBData['Spin'][rbId]['useCount']) 11624 for name in ['atColor','atType','Natoms','nSH',' radius','RBId','RBname','RBsym','SHC']:11629 for name in ['atColor','atType','Natoms','nSH','RBId','RBname','RBsym','SHC']: 11625 11630 del RBObj[name][iSh] 11626 11631 G2plt.PlotStructure(G2frame,data) … … 11630 11635 shSizer = wx.BoxSizer(wx.VERTICAL) 11631 11636 for iSh,nSh in enumerate(RBObj['nSH']): 11637 #patch 11638 if 'Radius' not in RBObj: 11639 RBObj['Radius'] = [[1.0,False] for i in range(len(RBObj['nSH']))] 11640 #end patch 11632 11641 rbId = RBObj['RBId'][iSh] 11633 11642 RBObj['atType'][iSh] = RBData['Spin'][rbId]['atType'] … … 11654 11663 shoSizer.Add(shOrder,0,WACV) 11655 11664 if RBObj['nSH'][iSh]>0: 11656 shoSizer.Add(wx.StaticText(RigidBodies,label=" 'c' for cubic harmonic term"),0,WACV) 11665 shoSizer.Add(wx.StaticText(RigidBodies,label=" 'c' for cubic harmonic term. "),0,WACV) 11666 shoSizer.Add(wx.StaticText(RigidBodies,label=' Radius: '),0,WACV) 11667 shoSizer.Add(G2G.ValidatedTxtCtrl(RigidBodies,RBObj['Radius'][iSh],0,nDig=(8,5),xmin=0.0,xmax=5.0, 11668 typeHint=float,size=(70,-1),OnLeave=NewSHC),0,WACV) 11669 radref = wx.CheckBox(RigidBodies,label=' refine? ') 11670 radref.SetValue(RBObj['Radius'][iSh][1]) 11671 radref.Bind(wx.EVT_CHECKBOX,OnRadRef) 11672 Indx[radref.GetId()] = iSh 11673 shoSizer.Add(radref,0,WACV) 11657 11674 shSizer.Add(shoSizer) 11658 11675 if not RBObj['nSH'][iSh]: … … 12287 12304 data['RBModels'][rbType] = [] 12288 12305 if rbType == 'Spin': #convert items to lists of shells 12289 for name in ['atColor','atType','Natoms','nSH',' radius','RBId','RBname','RBsym']:12306 for name in ['atColor','atType','Natoms','nSH','Radius','RBId','RBname','RBsym']: 12290 12307 item = rbObj[name] 12291 12308 rbObj[name] = [item,] … … 12942 12959 if rbType == 'Spin': 12943 12960 data['testRBObj']['rbAtTypes'] = [RBData[rbType][rbId]['rbType'],] 12944 data['testRBObj']['AtInfo'] = {RBData[rbType][rbId]['rbType']:[RBData[rbType][rbId][' radius'],(128, 128, 255)],}12961 data['testRBObj']['AtInfo'] = {RBData[rbType][rbId]['rbType']:[RBData[rbType][rbId]['Radius'],(128, 128, 255)],} 12945 12962 data['testRBObj']['rbType'] = rbType 12946 12963 data['testRBObj']['rbData'] = RBData … … 12975 12992 'Orient':[[0.,0.,0.,1.],' '],'Ids':[],'RBId':rbId,'Torsions':[], 12976 12993 'numChain':'','RBname':RBData[rbType][rbId]['RBname']} 12994 # if rbType == 'Spin': 12995 # data['testRBObj']['rbObj']['Radius'] = [1.0,False] 12977 12996 data['testRBObj']['torAtms'] = [] 12978 12997 for item in RBData[rbType][rbId].get('rbSeq',[]): -
TabularUnified trunk/GSASIIplot.py ¶
r5516 r5520 10349 10349 if SpnData is not None: 10350 10350 SytSym = G2spc.SytSym(atom[cx:cx+3],SGData)[0] 10351 radius = SpnData[' radius']10351 radius = SpnData['Radius'] 10352 10352 atColor = SpnData['atColor'] 10353 10353 symAxis = np.array(SpnData.get('symAxis',[0,0,1])) -
TabularUnified trunk/GSASIIstrIO.py ¶
r5513 r5520 1059 1059 pFile.write('Spinning RB name: %s atom type: %s, no.atoms: %d, No. times used: %d\n'% 1060 1060 (RBModel['RBname'],RBModel['atType'],RBModel['Natoms'],RBModel['useCount'])) 1061 for i in WriteSpnRBModel(RBModel):1062 pFile.write(i)1063 1061 1064 1062 def PrintResRBModel(RBModel): … … 1083 1081 for irb,item in enumerate(rbIds['Spin']): 1084 1082 if rigidbodyDict['Spin'][item]['useCount']: 1085 RBradius = rigidbodyDict['Spin'][item]['radius']1086 pid = '::RBS;0:'+str(irb)1087 rbDict[pid] = RBradius[0]1088 if RBradius[1]:1089 rbVary.append(pid)1090 1083 if Print: 1091 1084 pFile.write('\nSpinning rigid body model:\n') … … 1132 1125 pFile.write(sigstr+'\n') 1133 1126 1134 def PrintRBSpnandSig(SpinRB,SpinSig):1135 pFile.write('\n Spinning radius for %s:\n'%SpinRB['RBname'])1136 namstr = ' names :'1137 valstr = ' values:'1138 sigstr = ' esds :'1139 for i,[val,sig] in enumerate(zip(SpinRB['radius'],SpinSig)):1140 namstr += '%12s'%('Spin '+str(i))1141 valstr += '%12.4f'%(val)1142 if sig:1143 sigstr += '%12.4f'%(sig)1144 else:1145 sigstr += 12*' '1146 pFile.write(namstr+'\n')1147 pFile.write(valstr+'\n')1148 pFile.write(sigstr+'\n')1149 1150 1127 RBIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[],'Spin':[]}) #these are lists of rbIds 1151 if not RBIds['Vector'] and not RBIds['Spin']:1128 if not RBIds['Vector']: 1152 1129 return 1153 1130 for irb,item in enumerate(RBIds['Vector']): … … 1160 1137 VectSig.append(sigDict[name]) 1161 1138 PrintRBVectandSig(rigidbodyDict['Vector'][item],VectSig) 1162 for irb,item in enumerate(RBIds['Spin']):1163 if rigidbodyDict['Spin'][item]['useCount']:1164 SpinSig = []1165 name = '::RBS;'+str(0)+':'+str(irb)1166 if name in sigDict:1167 SpinSig.append(sigDict[name])1168 1169 1170 PrintRBSpnandSig(rigidbodyDict['Spin'][item],SpinSig)1171 1139 1172 1140 ################################################################################ … … 1343 1311 iFin = min(iBeg+6,nCoeff) 1344 1312 for block in range(nBlock): 1345 ptlbls = ' names :' 1346 ptstr = ' values:' 1347 ptref = ' refine:' 1313 if not block: 1314 ptlbls = ' names :%12s'%'Radius' 1315 ptstr = ' values:%12.4f'%RB['Radius'][ish][0] 1316 ptref = ' refine:%12s'%RB['Radius'][ish][1] 1317 else: 1318 ptlbls = ' names :' 1319 ptstr = ' values:' 1320 ptref = ' refine:' 1348 1321 for item in SHkeys[iBeg:iFin]: 1349 1322 ptlbls += '%12s'%(item) … … 1592 1565 continue 1593 1566 rbid = str(rbids.index(RB['RBId'][ish])) 1567 name = '%sRBSSh;%d;Radius:%s:%s'%(pfx,ish,iAt,rbid) 1568 phaseDict[name] = RB['Radius'][ish][0] 1569 if RB['Radius'][ish][1]: 1570 phaseVary += [name,] 1594 1571 pfxRB = '%sRBSSh;%d;'%(pfx,ish) 1595 1572 for i,shcof in enumerate(Shcof): … … 2569 2546 jrb = SRBIds.index(RBObj['RBId'][ish]) #spin rb no. 2570 2547 rbsx = ':%d:%d'%(iAt,jrb) 2571 pFile.write(' Spin rigid body parameters:\n') 2572 PrintRBObjPOAndSig('RBS',rbsx) 2548 pFile.write(' Spin rigid body parameters for at. no. %d; shell %d:\n'%(iAt,ish)) 2549 if not ish: 2550 PrintRBObjPOAndSig('RBS',rbsx[1:]) #skip leading ':' 2573 2551 PrintRBObjSHCAndSig('RBSSh;%d;'%ish,RBObj['SHC'][ish],rbsx) 2574 2552 atomsSig = {} … … 4202 4180 if name in sigDict: 4203 4181 sigstr += '%12.4f'%(sigDict[name]) 4182 else: 4183 sigstr += 12*' ' 4204 4184 out.append(namstr+'\n') 4205 4185 out.append(valstr+'\n') … … 4212 4192 ''' 4213 4193 out = [] 4214 namstr = ' names :' 4215 valstr = ' values:' 4194 name = pfx+rbfx+'Radius'+rbsx 4195 namstr = ' names :%12s'%'Radius' 4196 valstr = ' values:%12.4f'%parmDict[name] 4216 4197 sigstr = ' esds :' 4198 if name in sigDict: 4199 sigstr += '%12.4f'%sigDict[name] 4200 [name] 4201 else: 4202 sigstr += 12*' ' 4217 4203 out.append(' Sp.harm.:\n') 4218 4204 for item in SHC: … … 4222 4208 if name in sigDict: 4223 4209 sigstr += '%12.4f'%(sigDict[name]) 4210 else: 4211 sigstr += 12*' ' 4224 4212 out.append(namstr+'\n') 4225 4213 out.append(valstr+'\n') 4226 4214 out.append(sigstr+'\n') 4227 return out4228 4229 def WriteSpnRBModel(RBModel,sigDict={},irb=None):4230 '''Write description of a spinning rigid body. Code here to make usable from G2export_CIF4231 '''4232 out = ' Radius: %10.3f refine? %s\n'%(RBModel['radius'][0],RBModel['radius'][1])4233 4215 return out 4234 4216 -
TabularUnified trunk/GSASIIstrMain.py ¶
r5498 r5520 423 423 G2stIO.SetISOmodes(parmDict,sigDict,Phases,printFile) 424 424 G2stIO.SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms,calcControls, 425 425 pFile=printFile,covMatrix=covMatrix,varyList=varyList) 426 426 G2stIO.SetHistogramData(parmDict,sigDict,Histograms,calcControls,pFile=printFile) 427 427 # check for variables outside their allowed range, reset and freeze them -
TabularUnified trunk/GSASIIstrMath.py ¶
r5518 r5520 76 76 name = '::RBV;'+str(j)+':'+str(i) 77 77 VRBData[rbId]['VectMag'][j] = parmDict[name] 78 if RBIds['Spin']:79 SRBData = RBData['Spin']80 for i,rbId in enumerate(SRBIds):81 if SRBData[rbId]['useCount']:82 name = '::RBS;0:'+str(i)83 SRBData[rbId]['radius'][0] = parmDict[name]84 78 85 79 for phase in Phases: … … 171 165 jrb = SRBIds.index(RBObj['RBId'][0]) 172 166 name = pfx+'RBSOa:%d:%d'%(iAt,jrb) 173 RBObj['Orient'][0][0] = parmDict[name] 167 for i,po in enumerate(['RBSOa:','RBSOi:','RBSOj:','RBSOk:']): 168 name = pfx+'%s%d:%d'%(po,iAt,jrb) 169 RBObj['Orient'][0][i] = parmDict[name] 174 170 for ish in range(len(RBObj['RBId'])): 175 171 jrb = SRBIds.index(RBObj['RBId'][ish]) … … 205 201 RBModels = Phase['RBModels'] 206 202 207 for irb,RBObj in enumerate(RBModels.get('Spin',[])):208 name = '::RBS;0:%d'%irb209 if name in dFdvDict:210 dFdvDict[name] += dFdvDict[pfx+'RBS;0:%d'%irb]211 else:212 dFdvDict[name] = dFdvDict[pfx+'RBS;0:%d'%irb]203 # for irb,RBObj in enumerate(RBModels.get('Spin',[])): 204 # name = '::RBS;0:%d'%irb 205 # if name in dFdvDict: 206 # dFdvDict[name] += dFdvDict[pfx+'RBS;0:%d'%irb] 207 # else: 208 # dFdvDict[name] = dFdvDict[pfx+'RBS;0:%d'%irb] 213 209 214 210 for irb,RBObj in enumerate(RBModels.get('Vector',[])): … … 399 395 break 400 396 Shell = SHdat[shl] 401 R = Shell['R ']397 R = Shell['Radius'] 402 398 Atm = Shell['AtType'] 403 399 Nat = Shell['Natoms'] … … 409 405 dat = G2el.getBLvalues(BLtables) 410 406 SFF = dat[Atm] 411 Rname = ' ;0:%s'%Irb407 Rname = 'Sh;%s;Radius:%d:%s'%(shl,iAt,Irb) 412 408 R0 = sp.spherical_jn(0,QR*R)/(4.*np.pi) 413 409 R0P = sp.spherical_jn(0,QR*(R+0.01))/(4.*np.pi) … … 440 436 name = 'Sh;%s;%s:%d:%s'%(shl,item,iAt,Irb) 441 437 dFFdS[name] = Nat*SFF*BS*SH 442 #fill derivatives here wrt iAt,ishl,item or l,m438 dFFdS[Rname] = dBSdR 443 439 ishl += 1 444 dFFdS[Rname] = dBSdR445 440 dFFdS[Oname] = dSHdO 446 441 dFFdS[Oiname] = dSHdOi … … 468 463 shno = bits[1] 469 464 if shno not in SHCdict[atid]: 470 SHCdict[atid][shno] = { 'R':parmDict['::RBS;0:%s'%shno]}465 SHCdict[atid][shno] = {} 471 466 if 'AtType' in bits[0] or 'Natoms' in bits[0] or 'ShR' in bits[0]: 472 467 SHCdict[atid][shno][bits[0]] = parmDict[parm] … … 1067 1062 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1068 1063 GetAtomFXU(pfx,calcControls,parmDict) 1069 atFlg = np.zeros(len(Tdata)) 1064 atFlg = np.zeros(len(Tdata)) #non zero for Q type atoms - see below 1070 1065 if not Xdata.size: #no atoms in phase! 1071 1066 return {}
Note: See TracChangeset
for help on using the changeset viewer.