Changeset 2776 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Apr 11, 2017 10:39:15 AM (5 years ago)
Author:
vondreele
Message:

add a number of materials to Substances.py
implement multilayer reflectometry models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r2774 r2776  
    19461946                values.append(data[parm][0])
    19471947                bounds.append(Bounds[parm])
    1948         parmDict['nLayers'] = len(data['Layers'])
     1948        parmDict['Layer Seq'] = np.array(['0',]+data['Layer Seq'].split()+[str(len(data['Layers'])-1),],dtype=int)
     1949        parmDict['nLayers'] = len(parmDict['Layer Seq'])
    19491950        for ilay,layer in enumerate(data['Layers']):
    19501951            name = layer['Name']
     
    20092010        Nlayers = parmDict['nLayers']
    20102011        Res = parmDict['Res']
    2011         Gaus = np.zeros((9,len(Q)))
    20122012        depth = np.zeros(Nlayers)
    20132013        rho = np.zeros(Nlayers)
    20142014        irho = np.zeros(Nlayers)
    20152015        sigma = np.zeros(Nlayers)
    2016         for ilay in range(Nlayers):
    2017             cid = str(ilay)+';'
     2016        for ilay,lay in enumerate(parmDict['Layer Seq']):
     2017            cid = str(lay)+';'
    20182018            depth[ilay] = parmDict[cid+'Thick']
    20192019            sigma[ilay] = parmDict[cid+'Rough']
     
    20292029        Ic += (A**2+B**2)*Scale     
    20302030        return Ic
     2031       
     2032        def Smear(f,w,z,dq):
     2033            y = f(w,z)
     2034            s = dq/ateln2
     2035            y += 0.1354*(f(w,z+2*s)+f(w,z-2*s))
     2036            y += 0.24935*(f(w,z-1.666667*s)+f(w,z+1.666667*s))
     2037            y += 0.4111*(f(w,z-1.333333*s)+f(w,z+1.333333*s))
     2038            y += 0.60653*(f(w,z-s) +f(w,z+s))
     2039            y += 0.80074*(f(w,z-0.6666667*s)+f(w,z+0.6666667*s))
     2040            y += 0.94596*(f(w,z-0.3333333*s)+f(w,z+0.3333333*s))
     2041            y *= 0.137023
     2042            return y
    20312043       
    20322044    def estimateT0(takestep):
     
    21432155   
    21442156    sq2 = np.sqrt(2.)
    2145     Nlayers = len(data['Layers'])
     2157    laySeq = ['0',]+data['Layer Seq'].split()+[str(len(data['Layers'])-1),]
     2158    Nlayers = len(laySeq)
     2159    laySeq = np.array(laySeq,dtype=int)
    21462160    interfaces = np.zeros(Nlayers)
    21472161    rho = np.zeros(Nlayers)
    2148     irho = np.zeros(Nlayers)
    21492162    sigma = np.zeros(Nlayers)
     2163    name = data['Layers'][0]['Name']
    21502164    thick = 0.
    2151     for ilayer,layer in enumerate(data['Layers']):
     2165    for ilay,lay in enumerate(laySeq):
     2166        layer = data['Layers'][lay]
    21522167        name = layer['Name']
    2153         if 'Thick' in layer:    #skips first & last layers
     2168        if 'Thick' in layer:
    21542169            thick += layer['Thick'][0]
    2155             interfaces[ilayer] = layer['Thick'][0]+interfaces[ilayer-1]
    2156         if 'Rough' in layer:    #skips first layer
    2157             sigma[ilayer] = max(0.001,layer['Rough'][0])
    2158         rho[ilayer] = Substances[name]['Scatt density']*layer['DenMul'][0]
     2170            interfaces[ilay] = layer['Thick'][0]+interfaces[ilay-1]
     2171        if 'Rough' in layer:
     2172            sigma[ilay] = max(0.001,layer['Rough'][0])
     2173        if name != 'vacuum':
     2174            rho[ilay] = Substances[name]['Scatt density']*layer['DenMul'][0]
    21592175        if 'Mag SLD' in layer:
    2160             rho[ilayer] += layer['Mag SLD'][0]
    2161         irho[ilayer] = Substances[name].get('XImag density',0.)*layer['DenMul'][0]
     2176            rho[ilay] += layer['Mag SLD'][0]
     2177    name = data['Layers'][-1]['Name']
    21622178    x = np.linspace(-0.15*thick,1.15*thick,1000,endpoint=True)
    21632179    xr = np.flipud(x)
     
    21822198    Ic[:] = 0
    21832199    Scale = data['Scale'][0]
    2184     Nlayers = len(data['Layers'])
     2200    laySeq = ['0',]+data['Layer Seq'].split()+[str(len(data['Layers'])-1),]
     2201    Nlayers = len(laySeq)
    21852202    depth = np.zeros(Nlayers)
    21862203    rho = np.zeros(Nlayers)
    21872204    irho = np.zeros(Nlayers)
    21882205    sigma = np.zeros(Nlayers)
    2189     for ilayer,layer in enumerate(data['Layers']):
     2206    for ilay,lay in enumerate(np.array(laySeq,dtype=int)):
     2207        layer = data['Layers'][lay]
    21902208        name = layer['Name']
    21912209        if 'Thick' in layer:    #skips first & last layers
    2192             depth[ilayer] = layer['Thick'][0]
     2210            depth[ilay] = layer['Thick'][0]
    21932211        if 'Rough' in layer:    #skips first layer
    2194             sigma[ilayer] = layer['Rough'][0]
     2212            sigma[ilay] = layer['Rough'][0]
    21952213        if 'unit scatter' == name:
    2196             rho[ilayer] = layer['DenMul'][0]
    2197             irho[ilayer] = layer['iDenMul'][0]
     2214            rho[ilay] = layer['DenMul'][0]
     2215            irho[ilay] = layer['iDenMul'][0]
    21982216        else:
    2199             rho[ilayer] = Substances[name]['Scatt density']*layer['DenMul'][0]
    2200             irho[ilayer] = Substances[name].get('XImag density',0.)*layer['DenMul'][0]
     2217            rho[ilay] = Substances[name]['Scatt density']*layer['DenMul'][0]
     2218            irho[ilay] = Substances[name].get('XImag density',0.)*layer['DenMul'][0]
    22012219        if 'Mag SLD' in layer:
    2202             rho[ilayer] += layer['Mag SLD'][0]
     2220            rho[ilay] += layer['Mag SLD'][0]
    22032221    A,B = abeles(0.5*Q[iBeg:iFin],depth,rho,irho,sigma[1:])     #Q --> k, offset roughness for abeles
    22042222    Ic[iBeg:iFin] = (A**2+B**2)*Scale+Ib[iBeg:iFin]
Note: See TracChangeset for help on using the changeset viewer.