Changeset 3777


Ignore:
Timestamp:
Jan 9, 2019 10:51:24 AM (5 years ago)
Author:
vondreele
Message:

fix wx.SAVE --> wx.FD_SAVE bug
work on incommensurate magnetic structure factor calcs. close but no cigar yet

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3774 r3777  
    34903490                        dlg = wx.FileDialog(self, 'Choose sum image filename', pth,outname.split('IMG ')[1],
    34913491                            'G2img files (*.G2img)|*.G2img',
    3492                             wx.SAVE|wx.FD_OVERWRITE_PROMPT)
     3492                            wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
    34933493                        if dlg.ShowModal() == wx.ID_OK:
    34943494                            newimagefile = dlg.GetPath()
  • trunk/GSASIImath.py

    r3774 r3777  
    13461346        Umod = 1.0
    13471347    if nWaves[3]:
    1348         tauM = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau  #Mwaves x ngl
     1348        tauM = np.arange(1.,nWaves[3]+1-nx)[:,nxs]*glTau  #Mwaves x ngl
    13491349        MmodA = Am[:,:,:,nxs]*np.sin(twopi*tauM[nxs,:,nxs,:]) #atoms X waves X 3 X ngl
    13501350        MmodB = Bm[:,:,:,nxs]*np.cos(twopi*tauM[nxs,:,nxs,:]) #ditto
     
    13591359    H: array nRefBlk x ops X hklt
    13601360    HP: array nRefBlk x ops X hklt proj to hkl
     1361    nWaves: list number of waves for frac, pos, uij & mag
    13611362    Fmod: array 2 x atoms x waves    (sin,cos terms)
    13621363    Xmod: array atoms X 3 X ngl
     
    13661367    '''
    13671368   
    1368     if nWaves[2]:
     1369    if nWaves[2]:       #uij (adp) waves
    13691370        if len(HP.shape) > 2:
    13701371            HbH = np.exp(-np.sum(HP[:,:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.?
  • trunk/GSASIIstrMath.py

    r3774 r3777  
    14121412    '''
    14131413    phfx = pfx.split(':')[0]+hfx
     1414    g = nl.inv(G)
    14141415    ast = np.sqrt(np.diag(G))
     1416    ainv = np.sqrt(np.diag(g))
     1417    GS = G/np.outer(ast,ast)
     1418    Ginv = g/np.outer(ainv,ainv)
     1419    VGi = np.sqrt(nl.det(Ginv))
     1420    uAmat = G2lat.Gmat2AB(GS)[0]
    14151421    Mast = twopisq*np.multiply.outer(ast,ast)   
    14161422    SGInv = SGData['SGInv']
     
    14311437    if not Xdata.size:          #no atoms in phase!
    14321438        return
    1433 
    1434     if parmDict[pfx+'isMag']:       #TODO: fix the math
    1435         Mag = np.sqrt(np.sum(Gdata**2,axis=0))      #magnitude of moments for uniq atoms
    1436         Gdata = np.where(Mag>0.,Gdata/Mag,0.)       #normalze mag. moments
    1437         Gdata = np.inner(Gdata.T,SGMT).T            #apply sym. ops.
    1438         if SGData['SGInv'] and not SGData['SGFixed']:
    1439             Gdata = np.hstack((Gdata,-Gdata))       #inversion if any
    1440         Gdata = np.hstack([Gdata for icen in range(Ncen)])        #dup over cell centering
    1441         Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata   #flip vectors according to spin flip * det(opM)
    1442         Mag = np.tile(Mag[:,nxs],len(SGMT)*Ncen).T
    1443         if SGData['SGInv'] and not SGData['SGFixed']:
    1444             Mag = np.repeat(Mag,2,axis=0)                  #Mag same shape as Gdata
    1445 
    1446 
    14471439    waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict)
    14481440    ngl,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,MSSdata,Mast)
    14491441    modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']])
     1442
     1443    if parmDict[pfx+'isMag']:       #TODO: fix the math
     1444        GSdata = Gdata[:,nxs,:]+Mmod.T
     1445        GSdata = np.inner(GSdata.T,SGMT).T            #apply sym. ops.
     1446        if SGData['SGInv'] and not SGData['SGFixed']:
     1447            GSdata = np.hstack((GSdata,-GSdata))       #inversion if any
     1448        GSdata = np.hstack([GSdata for icen in range(Ncen)])        #dup over cell centering
     1449        GSdata = SGData['MagMom'][nxs,:,nxs,nxs]*GSdata   #flip vectors according to spin flip * det(opM)
     1450        SMag = np.sqrt(np.sum((np.inner(GSdata.T,Ginv)*GSdata.T),axis=-1)).T
     1451        Kdata = np.inner(GSdata.T,uAmat).T*VGi/SMag[nxs,:,:,:]     #Cartesian unit vectors = 0.9626 for hexagonal???
     1452
    14501453    FF = np.zeros(len(Tdata))
    14511454    if 'NC' in calcControls[hfx+'histType']:
     
    14561459    Uij = np.array(G2lat.U6toUij(Uijdata)).T
    14571460    bij = Mast*Uij
    1458     blkSize = 32       #no. of reflections in a block
     1461    blkSize = 48       #no. of reflections in a block
    14591462    nRef = refDict['RefList'].shape[0]
    14601463    SQ = 1./(2.*refDict['RefList'].T[5])**2
     
    15111514        Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/Uniq.shape[1]  #refBlk x ops x atoms
    15121515        GfpuA = G2mth.Modulation(Uniq,UniqP,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt) #2 x refBlk x sym X atoms
    1513         fams = np.zeros(32)
    1514         fbms = np.zeros(32)
     1516        fams = 0.
     1517        fbms = 0.
    15151518
    15161519        if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']:       #TODO: mag math here??
     
    15251528            sinm = np.sin(mphase)                               #ditto - match magstrfc.for
    15261529            cosm = np.cos(mphase)                               #ditto
     1530           
    15271531            HM = np.inner(Bmat,HP.T)                             #put into cartesian space
    15281532            HM = HM/np.sqrt(np.sum(HM**2,axis=0))               #Gdata = MAGS & HM = UVEC in magstrfc.for both OK
    1529             eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0)
    1530             Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK
    1531             fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #ditto
    1532             fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #ditto
    1533             fagm = fam*GfpuA[0]-fbm*GfpuA[1]   #real; 2 x refBlk x sym x atoms
    1534             fbgm = fbm*GfpuA[0]+fam*GfpuA[1]
    1535             fams = np.sum(np.sum(fagm,axis=-1),axis=-1)                          #xyz,Nref
    1536             fbms = np.sum(np.sum(fbgm,axis=-1),axis=-1)                          #ditto
    1537 
     1533            eDotK = np.sum(HM[:,:,nxs,nxs,nxs]*Kdata[:,nxs,:,:,:],axis=0)
     1534            Q = HM[:,:,nxs,nxs,nxs]*eDotK[nxs,:,:,:,:]-Kdata[:,nxs,:,:,:] #Mxyz,Nref,Nop,Ntau,Natm
     1535           
     1536            fam = Q*TMcorr[nxs,:,nxs,nxs,:]*cosm[nxs,:,:,nxs,:]*SMag[nxs,nxs,:,:,:]    #ditto
     1537            fbm = Q*TMcorr[nxs,:,nxs,nxs,:]*sinm[nxs,:,:,nxs,:]*SMag[nxs,nxs,:,:,:]    #ditto
     1538           
     1539            fams = np.sum(np.sum(fam,axis=2),axis=-1)                          #xyz,Nref,ntau
     1540            fbms = np.sum(np.sum(fbm,axis=2),axis=-1)                          #ditto
     1541           
     1542            fams = np.sum(np.sum(fams**2,axis=0)*glWt[nxs,:],axis=-1)
     1543            fbms = np.sum(np.sum(fbms**2,axis=0)*glWt[nxs,:],axis=-1)
    15381544
    15391545        if 'T' in calcControls[hfx+'histType']:
     
    15471553        fas = np.sum(np.sum(fag,axis=-1),axis=-1)   #2 x refBlk; sum sym & atoms
    15481554        fbs = np.sum(np.sum(fbg,axis=-1),axis=-1)
    1549         refl.T[10] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2+np.sum(fams,axis=0)**2+np.sum(fbms,axis=0)**2    #square of sums
     1555        refl.T[10] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2+fams+fbms    #square of sums
    15501556        refl.T[11] = atan2d(fbs[0],fas[0])  #ignore f' & f"
    15511557        if 'P' not in calcControls[hfx+'histType']:
     
    16761682        Tuij = np.where(HbH<1.,np.exp(HbH),1.0)
    16771683        Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/Uniq.shape[1]  #refBlk x ops x atoms
    1678 #        GSASIIpath.IPyBreak()
    16791684        if 'T' in calcControls[hfx+'histType']:
    16801685            fa = np.array([np.reshape(((FF+FP).T-Bab).T,cosp.shape)*cosp*Tcorr,-np.reshape(Flack*FPP,sinp.shape)*sinp*Tcorr])
     
    17581763    dFdGf = np.zeros((nRef,mSize,FSSdata.shape[1],2))
    17591764    dFdGx = np.zeros((nRef,mSize,XSSdata.shape[1],6))
    1760 #    dFdGz = np.zeros((nRef,mSize,5))
    17611765    dFdGu = np.zeros((nRef,mSize,USSdata.shape[1],12))
    17621766    Flack = 1.0
     
    19101914            dFdvDict[pfx+'U23cos:'+str(i)+':'+str(j)] = 2.*dFdGu.T[11][j][i]
    19111915           
    1912 #        GSASIIpath.IPyBreak()
    19131916    dFdvDict[phfx+'Flack'] = 4.*dFdfl.T
    19141917    dFdvDict[phfx+'BabA'] = dFdbab.T[0]
     
    19421945        if parm == '0':
    19431946            continue
    1944         if parm.split(':')[2] in ['Tmin','Tmax','Xmax','Ymax','Zmax','Fzero','Fwid',]:
     1947        if parm.split(':')[2] in ['Tmin','Tmax','Xmax','Ymax','Zmax','Fzero','Fwid',
     1948            'MXsin','MXcos','MYsin','MYcos','MZsin','MZcos','AMx','AMy','AMz',]:
    19451949            parmDict[parm] += dM
    19461950            prefList = SStructureFactor(trefDict,G,hfx,pfx,SGData,SSGData,calcControls,parmDict)
     
    33263330                    aname = name.split(pfx)[1][:2]
    33273331                    if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc',    \
    3328                         'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param
     3332                        'Tm','Xm','Ym','Zm','U1','U2','U3','MX','MY','MZ']: continue # skip anything not an atom or rigid body param
    33293333                except IndexError:
    33303334                    continue
     
    33363340                    aname = name.split(pfx)[1][:2]
    33373341                    if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc',    \
    3338                         'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param
     3342                        'Tm','Xm','Ym','Zm','U1','U2','U3','MX','MY','MZ']: continue # skip anything not an atom or rigid body param
    33393343                except IndexError:
    33403344                    continue
Note: See TracChangeset for help on using the changeset viewer.