Changeset 2497


Ignore:
Timestamp:
Oct 19, 2016 4:03:22 PM (6 years ago)
Author:
vondreele
Message:

further work on mag derivatives all seem ok except Mx, My, & Mz

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r2492 r2497  
    800800            magSizer = wx.BoxSizer(wx.VERTICAL)
    801801            magSizer.Add(wx.StaticText(General,label=' Magnetic spin operator selection:'),0,WACV)
    802             magSizer.Add(wx.StaticText(General,label='  NB: UNDER CONSTRUCTION - LS NOT AVAILABLE'),0,WACV)
     802            magSizer.Add(wx.StaticText(General,label='  NB: UNDER CONSTRUCTION - LS NOT FINISHED'),0,WACV)
    803803            if not len(GenSym):
    804804                magSizer.Add(wx.StaticText(General,label=' No spin inversion allowed'),0,WACV)
  • trunk/GSASIIstrMath.py

    r2495 r2497  
    12401240    dFdfr = np.zeros((nRef,mSize))
    12411241    dFdx = np.zeros((nRef,mSize,3))
    1242     dFdmx = np.zeros((nRef,mSize,3))
     1242    dFdMx = np.zeros((nRef,mSize,3))
    12431243    dFdui = np.zeros((nRef,mSize))
    12441244    dFdua = np.zeros((nRef,mSize,6))
     
    12841284        HM = HM/np.sqrt(np.sum(HM**2,axis=0))               #Gdata = MAGS & HM = UVEC in magstrfc.for both OK
    12851285        eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0)
    1286         Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK
     1286        Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm = BPM in magstrfc.for OK
     1287        dqdm = (HM*HM-1)[:,:,nxs,nxs]/Mag[nxs,nxs,:,:]
    12871288        fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #ditto
    12881289        fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #ditto
    1289         fams = np.sum(np.sum(fam,axis=-1),axis=-1)                          #xyz,Nref
     1290        fams = np.sum(np.sum(fam,axis=-1),axis=-1)                          #Mxyz,Nref
    12901291        fbms = np.sum(np.sum(fbm,axis=-1),axis=-1)                          #ditto
    12911292        famx = Q*TMcorr[nxs,:,nxs,:]*Mag[nxs,nxs,:,:]*sinm[nxs,:,:,:]   #Mxyz,Nref,Nops,Natom
    12921293        fbmx = Q*TMcorr[nxs,:,nxs,:]*Mag[nxs,nxs,:,:]*cosm[nxs,:,:,:]
    12931294        #sum below is over Uniq
    1294         dfadfr = np.sum(fam/occ,axis=-2)        #array(mxyz,refBlk,nAtom) Fdata != 0 avoids /0. problem
    1295 #        GSASIIpath.IPyBreak()
    1296 #        dfadx = np.sum(twopi*Uniq.T[:,:,:,nxs]*famx,axis=2)
    1297 #        dfadmx = twopi*Uniq.T[:,:,:,nxs]*famx) #?
     1295        dfadfr = np.sum(fam/occ,axis=2)        #array(Mxyz,refBlk,nAtom) Fdata != 0 avoids /0. problem
     1296        dfadx = np.sum(twopi*Uniq[nxs,:,:,nxs,:]*famx[:,:,:,:,nxs],axis=2)
     1297        dfadmx = np.sum(TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*(Mag[nxs,nxs,:,:]*dqdm+Q),axis=2)
     1298        dfadmx = np.reshape(dfadmx,(iFin-iBeg,-1,3))
    12981299        dfadui = np.sum(-SQfactor[:,nxs,nxs]*fam,axis=2) #array(Ops,refBlk,nAtoms)
    12991300        dfadua = np.sum(-Hij[nxs,:,:,nxs,:]*fam[:,:,:,:,nxs],axis=2)
    1300         # array(2,refBlk,nAtom,3) & array(2,refBlk,nAtom,6)
    1301         if not SGData['SGInv']:
    1302             dfbdfr = np.sum(fbm/occ,axis=-2)        #array(mxyz,refBlk,nAtom) Fdata != 0 avoids /0. problem
    1303 #            dfbdx = np.sum(twopi*Uniq.T[:,:,:,nxs]*fbmx,axis=2)
    1304 #            dfbdmx = twopi*Uniq[:,nxs,:,:]*np.transpose(fbmx,(1,2,3,0))
    1305             dfbdui = np.sum(-SQfactor[:,nxs,nxs]*fbm,axis=2) #array(Ops,refBlk,nAtoms)
    1306             dfbdua = np.sum(-Hij[nxs,:,:,nxs,:]*fbm[:,:,:,:,nxs],axis=2)
    1307         else:
    1308             dfbdfr = np.zeros_like(dfadfr)
    1309 #            dfbdx = np.zeros_like(dfadx)
    1310 #            dfbdmx = np.zeros_like(dfadmx)
    1311             dfbdui = np.zeros_like(dfadui)
    1312             dfbdua = np.zeros_like(dfadua)
     1301        # array(3,refBlk,nAtom,3) & array(3,refBlk,nAtom,6)
     1302        dfbdfr = np.sum(fbm/occ,axis=2)        #array(mxyz,refBlk,nAtom) Fdata != 0 avoids /0. problem
     1303        dfbdx = np.sum(twopi*Uniq[nxs,:,:,nxs,:]*fbmx[:,:,:,:,nxs],axis=2)
     1304        dfbdmx = np.sum(TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*(Mag[nxs,nxs,:,:]*dqdm+Q),axis=2)
     1305        dfbdmx = np.reshape(dfbdmx,(iFin-iBeg,-1,3))
     1306        dfbdui = np.sum(-SQfactor[:,nxs,nxs]*fbm,axis=2) #array(Ops,refBlk,nAtoms)
     1307        dfbdua = np.sum(-Hij[nxs,:,:,nxs,:]*fbm[:,:,:,:,nxs],axis=2)
    13131308        dFdfr[iBeg:iFin] = np.sum(2.*(fams[:,:,nxs]*dfadfr+fbms[:,:,nxs]*dfbdfr)*Mdata/(2*Nops*Ncen),axis=0)
    1314 #        dFdx[iBeg:iFin] = 2.*(fams[:,:,nxs]*dfadx+fbms[:,:,nxs]*dfbdx)
    1315 #        dFdMx[iBeg:iFin] = np.sum(2.*(fams[:,nxs,nxs]*dfadmx+fbms[:,nxs,nxs]*dfbdmx),axis=0)
    1316         dFdui[iBeg:iFin] = np.sum(2.*(fams[:,:,nxs]*dfadui+fbms[:,:,nxs]*dfbdui),axis=0)
    1317         dFdua[iBeg:iFin] = np.sum(2.*(fams[:,:,nxs,nxs]*dfadua+fbms[:,:,nxs,nxs]*dfbdua),axis=0)
     1309        dFdx[iBeg:iFin] = np.sum(2.*(fams[:,:,nxs,nxs]*dfadx+fbms[:,:,nxs,nxs]*dfbdx),axis=0)
     1310        dFdMx[iBeg:iFin] = 2.*(fams.T[:,nxs,:]*dfadmx+fbms.T[:,nxs,:]*dfbdmx)
     1311        dFdui[iBeg:iFin] = 2.*np.sum(fams[:,:,nxs]*dfadui+fbms[:,:,nxs]*dfbdui,axis=0)
     1312        dFdua[iBeg:iFin] = 2.*np.sum(fams[:,:,nxs,nxs]*dfadua+fbms[:,:,nxs,nxs]*dfbdua,axis=0)
     1313        iBeg += blkSize
    13181314#        GSASIIpath.IPyBreak()
    1319         iBeg += blkSize
    13201315    print ' %d derivative time %.4f\r'%(nRef,time.time()-time0)
    13211316        #loop over atoms - each dict entry is list of derivatives for all the reflections
     
    13251320        dFdvDict[pfx+'dAy:'+str(i)] = dFdx.T[1][i]
    13261321        dFdvDict[pfx+'dAz:'+str(i)] = dFdx.T[2][i]
    1327         dFdvDict[pfx+'dAMx:'+str(i)] = dFdMx.T[0][i]
    1328         dFdvDict[pfx+'dAMy:'+str(i)] = dFdMx.T[1][i]
    1329         dFdvDict[pfx+'dAMz:'+str(i)] = dFdMx.T[2][i]
     1322        dFdvDict[pfx+'AMx:'+str(i)] = dFdMx.T[0][i]
     1323        dFdvDict[pfx+'AMy:'+str(i)] = dFdMx.T[1][i]
     1324        dFdvDict[pfx+'AMz:'+str(i)] = dFdMx.T[2][i]
    13301325        dFdvDict[pfx+'AUiso:'+str(i)] = dFdui.T[i]
    13311326        dFdvDict[pfx+'AU11:'+str(i)] = dFdua.T[0][i]
     
    38603855                        try:
    38613856                            aname = name.split(pfx)[1][:2]
    3862                             if aname not in ['Af','dA','AU','RB','Xs','Xc','Ys','Yc','Zs','Zc','Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param
     3857                            if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc',    \
     3858                                'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param
    38633859                        except IndexError:
    38643860                            continue
Note: See TracChangeset for help on using the changeset viewer.