Changeset 1480


Ignore:
Timestamp:
Aug 27, 2014 12:59:17 PM (7 years ago)
Author:
vondreele
Message:

reset mustrain now gives correct SHKL coefficients for a 1000 mustrain
generalized mustrain now scaled correctly by 0.018/pi

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r1478 r1480  
    400400            UseList[item]['Mustrain'][1][1] = 1000.0
    401401        elif name == 'generalized':
     402            muiso = 1000.
     403            cell = generalData['Cell'][1:7]
     404            vals = G2spc.Muiso2Shkl(muiso,SGData,cell)
    402405            nTerm = len(UseList[item]['Mustrain'][4])
    403406            for i in range(nTerm):
    404                 UseList[item]['Mustrain'][4][i] = 0.01
     407                UseList[item]['Mustrain'][4][i] = vals[i]
    405408        G2plt.PlotSizeStrainPO(G2frame,data)
    406409        wx.CallAfter(UpdateDData,G2frame,DData,data)
  • trunk/GSASIIplot.py

    r1475 r1480  
    24062406                        uvw = np.inner(A.T,xyz)
    24072407                        Strm = np.array(G2spc.MustrainCoeff(uvw,SGData))
    2408                         sum = np.sum(np.multiply(Shkl,Strm))
    2409                         sum = np.where(sum > 0.01,sum,0.01)
    2410                         sum = np.sqrt(sum)*math.pi/.18      #centidegrees to radians!
    2411                         return sum*xyz
     2408                        Sum = np.sum(np.multiply(Shkl,Strm))
     2409                        Sum = np.where(Sum > 0.01,Sum,0.01)
     2410                        Sum = np.sqrt(Sum)
     2411                        return Sum*xyz
    24122412                       
    24132413                    Shkl = np.array(coeff[4])
  • trunk/GSASIIspc.py

    r1471 r1480  
    1818import numpy.ma as ma
    1919import numpy.linalg as nl
     20import scipy.optimize as so
    2021import math
    2122import sys
     
    2526GSASIIpath.SetVersionNumber("$Revision$")
    2627import pyspg
     28
     29npsind = lambda x: np.sin(x*np.pi/180.)
     30npcosd = lambda x: np.cos(x*np.pi/180.)
    2731
    2832def SpcGroup(SGSymbol):
     
    731735   
    732736def Muiso2Shkl(muiso,SGData,cell):
    733     "this is to convert isotropic mustrain to generalized Shkls - doesn't work just now"
     737    "this is to convert isotropic mustrain to generalized Shkls"
    734738    import GSASIIlattice as G2lat
    735     from scipy.optimize import fmin
    736739    A = G2lat.cell2AB(cell)[0]
    737     def minMus(Shkl,H,muiso,SGData,A):
     740   
     741    def minMus(Shkl,muiso,H,SGData,A):
    738742        U = np.inner(A.T,H)
    739         S = np.array(MustrainCoeff(H.T,SGData))
    740         sum = np.sqrt(np.sum(np.multiply(S,Shkl)))
    741         return abs(muiso-sum*H)
     743        S = np.array(MustrainCoeff(U,SGData))
     744        Sum = np.sqrt(np.sum(np.multiply(S,Shkl[:,np.newaxis]),axis=0))
     745        rad = np.sqrt(np.sum((Sum[:,np.newaxis]*H)**2,axis=1))
     746        return (muiso-rad)**2
     747       
    742748    laue = SGData['SGLaue']
     749    PHI = np.linspace(0.,360.,60,True)
     750    PSI = np.linspace(0.,180.,60,True)
     751    X = np.outer(npsind(PHI),npsind(PSI))
     752    Y = np.outer(npcosd(PHI),npsind(PSI))
     753    Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI))
     754    HKL = np.dstack((X,Y,Z))
    743755    if laue in ['m3','m3m']:
    744         H = [[1,0,0],[1,1,0]]
    745         S0 = [0.01,0.01]
     756        S0 = [1000.,1000.]
    746757    elif laue in ['6/m','6/mmm','3m1']:
    747         H = [[1,0,0],[0,0,1],[1,0,1]]
    748         S0 = [0.01,0.01,0.01]
     758        S0 = [1000.,1000.,1000.]
    749759    elif laue in ['31m','3']:
    750         H = [[1,0,0],[0,0,1],[1,0,1],[1,1,1]]
    751         S0 = [0.01,0.01,0.01,0.01]
     760        S0 = [1000.,1000.,1000.,1000.]
    752761    elif laue in ['3R','3mR']:
    753         H = [[1,0,0],[1,1,0],[1,0,1],[1,1,1]]
    754         S0 = [0.01,0.01,0.01,0.01]
     762        S0 = [1000.,1000.,1000.,1000.]
    755763    elif laue in ['4/m','4/mmm']:
    756         H = [[1,0,0],[0,0,1],[1,1,0],[1,0,1]]
    757         S0 = [0.01,0.01,0.01,0.01]
     764        S0 = [1000.,1000.,1000.,1000.]
    758765    elif laue in ['mmm']:
    759         H = [[1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,0,1],[0,1,1]]
    760         S0 = [0.01,0.01,0.01,0.01,0.01,0.01]
     766        S0 = [1000.,1000.,1000.,1000.,1000.,1000.]
    761767    elif laue in ['2/m']:
    762         H = [[1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,0,1],[0,1,1]]
    763         if uniq == 'a':
    764             H.append([0,1,-1])
    765             H.append([0,-2,1])
    766         elif uniq == 'b':
    767             H.append([1,0,-1])
    768             H.append([-2,0,1])
    769         elif uniq == 'c':
    770             H.append([1,-1,0])
    771             H.append([-2,1,0])
    772         H.append([1,1,1])
    773         S0 = [9*[0.01,]]
     768        S0 = [1000.,1000.,1000.,0.,0.,0.,0.,0.,0.]
    774769    else:
    775         H = [[1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,0,1],[0,1,1],
    776             [-1,1,0],[1,0,-1],[0,-1,1],[1,-2,0],[-2,0,1],[0,1,-2],
    777             [1,-1,1],[-1, 1, 1],[1,-1,1]]
    778         S0 = [15*[0.01,]]
    779     H = np.array(H)
     770        S0 = [1000.,1000.,1000.,1000.,1000., 1000.,1000.,1000.,1000.,1000.,
     771            1000.,1000.,0.,0.,0.]
    780772    S0 = np.array(S0)
    781     return fmin(minMus,S0,(H,muiso,SGData,A))
     773    HKL = np.reshape(HKL,(-1,3))
     774    result = so.leastsq(minMus,S0,(np.ones(HKL.shape[0])*muiso,HKL,SGData,A))
     775    return result[0]
    782776       
    783777def SytSym(XYZ,SGData):
  • trunk/GSASIIstrMath.py

    r1479 r1480  
    11901190            for i,strm in enumerate(Strms):
    11911191                Sum += parmDict[phfx+'Mustrain:'+str(i)]*strm
    1192             Mgam = refl[4]**2*tand(refl[5]/2.)*np.sqrt(Sum)
     1192            Mgam = 0.018*refl[4]**2*tand(refl[5]/2.)*np.sqrt(Sum)/np.pi
    11931193    elif 'T' in calcControls[hfx+'histType']:
    11941194        #crystallite size
     
    12891289            sigDict[phfx+'Mustrain;a'] = 2*(Mgam/Sa+dsa)*Mgam*(1.-parmDict[phfx+'Mustrain;mx'])**2/ateln2       
    12901290        else:       #generalized - P.W. Stephens model
    1291             const = refl[4]**2*tanth
     1291            const = 0.018*refl[4]**2*tanth/np.pi
    12921292            Strms = G2spc.MustrainCoeff(refl[:3],SGData)
    12931293            Sum = 0
Note: See TracChangeset for help on using the changeset viewer.