Changeset 5515
- Timestamp:
- Mar 16, 2023 5:56:09 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIstrMath.py ¶
r5513 r5515 364 364 365 365 dFFdS = {} 366 atFlg = [] 366 367 for iAt,Atype in enumerate(Tdata): 367 368 if 'Q' in Atype: 369 atFlg.append(1.0) 368 370 SHdat = SHCdict[iAt] 369 371 symAxis = np.array(SHdat['symAxis']) … … 387 389 FF[:,iAt] = 0. 388 390 ishl = 0 391 # dBSdR = np.zeros(HKL.shape[0]*HKL.shape[1]) 392 dSHdO = np.zeros(HKL.shape[0]*HKL.shape[1]) 393 dSHdOi = np.zeros(HKL.shape[0]*HKL.shape[1]) 394 dSHdOj = np.zeros(HKL.shape[0]*HKL.shape[1]) 395 dSHdOk = np.zeros(HKL.shape[0]*HKL.shape[1]) 389 396 while True: 390 397 shl = '%d'%ishl … … 407 414 R0M = sp.spherical_jn(0,QR*(R-0.01))/(4.*np.pi) 408 415 dBSdR = Nat*SFF*(R0P-R0M)/0.02 409 dSHdO = np.zeros(HKL.shape[0]*HKL.shape[1])410 dSHdOi = np.zeros(HKL.shape[0]*HKL.shape[1])411 dSHdOj = np.zeros(HKL.shape[0]*HKL.shape[1])412 dSHdOk = np.zeros(HKL.shape[0]*HKL.shape[1])413 416 FF[:,iAt] += Nat*SFF*R0 #Bessel function; L=0 term 414 417 for item in Shell: … … 438 441 dFFdS[name] = Nat*SFF*BS*SH 439 442 #fill derivatives here wrt iAt,ishl,item or l,m 443 ishl += 1 440 444 dFFdS[Rname] = dBSdR 441 dFFdS[Oname] = dSHdO 442 dFFdS[Oiname] = dSHdOi 443 dFFdS[Ojname] = dSHdOj 444 dFFdS[Okname] = dSHdOk 445 ishl += 1 445 dFFdS[Oname] = dSHdO 446 dFFdS[Oiname] = dSHdOi 447 dFFdS[Ojname] = dSHdOj 448 dFFdS[Okname] = dSHdOk 449 else: 450 atFlg.append(0.) 446 451 if ifDeriv: 447 return dFFdS 452 return dFFdS,atFlg 448 453 449 454 def GetSHC(pfx,parmDict): … … 1065 1070 return {} 1066 1071 mSize = len(Mdata) 1072 nOps = len(SGMT) 1067 1073 FF = np.zeros(len(Tdata)) 1068 1074 if 'NC' in calcControls[hfx+'histType'] or 'NB' in calcControls[hfx+'histType']: … … 1078 1084 dFdvDict = {} 1079 1085 dFdfr = np.zeros((nRef,mSize)) 1080 dFdff = np.zeros((nRef, mSize))1086 dFdff = np.zeros((nRef,nOps,mSize)) 1081 1087 dFdx = np.zeros((nRef,mSize,3)) 1082 1088 dFdui = np.zeros((nRef,mSize)) … … 1123 1129 Hij = np.reshape(np.array([G2lat.UijtoU6(uij) for uij in Hij]),(-1,len(SGT),6)) #Nref,Nops,6 1124 1130 if len(SHCdict): 1125 dffdsh = MakeSpHarmFF(Uniq,Bmat,SHCdict,Tdata,hType,FFtables,BLtables,FF,SQ,True)1131 dffdsh,atFlg = MakeSpHarmFF(Uniq,Bmat,SHCdict,Tdata,hType,FFtables,BLtables,FF,SQ,True) 1126 1132 if len(dffdSH): 1127 1133 for item in dffdSH: … … 1146 1152 #sum below is over Uniq 1147 1153 dfadfr = np.sum(fa/occ,axis=-2) #array(2,refBlk,nAtom) Fdata != 0 avoids /0. problem 1148 dfadff = np.sum(fa[0]*Tcorr/fot,axis=-2) #ignores resonant scattering? #TODO needs only for Q atoms! 1149 for i,aname in enumerate(Tdata): 1150 if 'Q' not in aname: 1151 dfadff[:,i] = 0.0 1154 # dfadff = np.sum(fa[0]*Tcorr*atFlg/fot,axis=-2) #ignores resonant scattering? #TODO needs only for Q atoms! 1155 dfadff = fa[0]*Tcorr*atFlg/fot #ignores resonant scattering? no sum on Uniq 1152 1156 dfadba = np.sum(-cosp*Tcorr,axis=-2) #array(refBlk,nAtom) 1153 1157 dfadx = np.sum(twopi*Uniq[nxs,:,nxs,:,:]*np.swapaxes(fax,-2,-1)[:,:,:,:,nxs],axis=-2) … … 1157 1161 if not SGData['SGInv']: 1158 1162 dfbdfr = np.sum(fb/occ,axis=-2) #Fdata != 0 avoids /0. problem 1159 dfbdff = np.sum(fb[0]*Tcorr/fot,axis=-2) #ignores resonant scattering? 1160 for i,aname in enumerate(Tdata): 1161 if 'Q' not in aname: 1162 dfbdff[:,i] = 0.0 1163 # dfbdff = np.sum(fb[0]*Tcorr*atFlg/fot,axis=-2) #ignores resonant scattering? 1164 dfbdff = fb[0]*Tcorr*atFlg/fot #ignores resonant scattering? no sum on Uniq 1163 1165 dfbdba = np.sum(-sinp*Tcorr,axis=-2) 1164 1166 dfadfl = np.sum(np.sum(-fotp*sinp,axis=-1),axis=-1) … … 1181 1183 if 'P' in calcControls[hfx+'histType']: #checked perfect for centro & noncentro 1182 1184 dFdfr[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs]*dfadfr+fbs[:,:,nxs]*dfbdfr,axis=0)*Mdata/len(SGMT) 1183 dFdff[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs]*dfadff+fbs[:,:,nxs]*dfbdff,axis=0)/len(SGMT) 1185 # dFdff[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs]*dfadff+fbs[:,:,nxs]*dfbdff,axis=0)/len(SGMT) 1186 dFdff[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs,nxs]*dfadff[nxs,:,:,:]+fbs[:,:,nxs,nxs]*dfbdff[nxs,:,:,:],axis=0) #not summed on Uniq yet 1184 1187 dFdx[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs,nxs]*dfadx+fbs[:,:,nxs,nxs]*dfbdx,axis=0) 1185 1188 dFdui[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs]*dfadui+fbs[:,:,nxs]*dfbdui,axis=0) … … 1187 1190 else: 1188 1191 dFdfr[iBeg:iFin] = (2.*SA[:,nxs]*(dfadfr[0]+dfadfr[1])+2.*SB[:,nxs]*(dfbdfr[0]+dfbdfr[1]))*Mdata/len(SGMT) 1189 dFdff[iBeg:iFin] = (2.*SA[:,nxs]*dfadff+2.*SB[:,nxs]*dfbdff)/len(SGMT) 1192 # dFdff[iBeg:iFin] = (2.*SA[:,nxs]*dfadff+2.*SB[:,nxs]*dfbdff)/len(SGMT) 1193 dFdff[iBeg:iFin] = (2.*SA[:,nxs,nxs]*dfadff+2.*SB[:,nxs,nxs]*dfbdff) #not summed on Uniq yet 1190 1194 dFdx[iBeg:iFin] = 2.*SA[:,nxs,nxs]*(dfadx[0]+dfadx[1])+2.*SB[:,nxs,nxs]*(dfbdx[0]+dfbdx[1]) 1191 1195 dFdui[iBeg:iFin] = 2.*SA[:,nxs]*(dfadui[0]+dfadui[1])+2.*SB[:,nxs]*(dfbdui[0]+dfbdui[1]) … … 1210 1214 dFdvDict[pfx+'AU23:'+str(i)] = dFdua.T[5][i] 1211 1215 for item in dffdSH: 1212 dFdvDict[pfx+'RBS'+item] = dFdff.T[i]*np.sum(np.reshape(dffdSH[item],(nRef,-1)),axis=-1) 1216 i = int(item.split(':')[1]) 1217 dFdvDict[pfx+'RBS'+item] = np.sum(dFdff[:,:,i]*np.reshape(dffdSH[item],(nRef,-1)),axis=-1) 1213 1218 dFdvDict[phfx+'Flack'] = 4.*dFdfl.T 1214 1219 dFdvDict[phfx+'BabA'] = dFdbab.T[0]
Note: See TracChangeset
for help on using the changeset viewer.