Changeset 1274 for trunk/GSASIIsasd.py


Ignore:
Timestamp:
Apr 11, 2014 10:17:01 AM (8 years ago)
Author:
vondreele
Message:

implement Bragg peaks in SASD - required new fortran routines
implement unified (Guinier + Porod) and Porod models in SASD
implement monodisperse models in SASD
correct bin width issue in lognormal, etc. fitting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIsasd.py

    r1273 r1274  
    3636import GSASIIIO as G2IO
    3737import GSASIImath as G2mth
    38 import pypowder as pyd
     38import GSASIIpwd as G2pwd
    3939
    4040# trig functions in degrees
     
    909909       
    910910################################################################################
    911 #### Unified fit
    912 ################################################################################
    913 
    914 def UnifiedFit(Profile,ProfDict,Limits,Substances,Sample,data):
    915     print 'do unified fit'
    916    
    917 def UnifiedFxn(Q,G,Rg,B,Rgcf,P,SQfxn,args=[]):
    918     termA = G*np.exp(-((Q*Rg)**2)/3.)
    919     termB = B*np.exp(-((Q*Rgcf)**2)/3.)
    920     termC = (scsp.erf(Q*Rg/np.sqrt(6))**3/Q)**P
    921     return SQfxn(Q,args)*termA+(termB*termC)
    922    
    923 
    924 
    925 ################################################################################
    926911#### Modelling
    927912################################################################################
     
    955940    for level in partData['Levels']:
    956941        controls = level['Controls']
    957         FFfxn = shapes[controls['FormFact']][0]
    958         Volfxn = shapes[controls['FormFact']][1]
    959         FFargs = []
    960         for item in ['Aspect ratio','Length','Thickness','Diameter',]:
    961             if item in controls['FFargs']:
    962                 FFargs.append(controls['FFargs'][item][0])
    963942        distFxn = controls['DistType']
    964         rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
    965         contrast = rho**2-rhoMat**2
    966         parmDict = level[controls['DistType']]
    967         rBins,dBins,dist = MakeDiamDist(controls['DistType'],controls['NumPoints'],controls['Cutoff'],parmDict)
    968         Gmat = 2.*G_matrix(Q[Ibeg:Ifin],rBins,contrast,FFfxn,Volfxn,FFargs).T*dBins
    969         dist *= level[distFxn]['Volume'][0]
    970         Ic[Ibeg:Ifin] += np.dot(Gmat,dist)
    971         Rbins.append(rBins)
    972         Dist.append(dist)
     943        if distFxn in ['LogNormal','Gaussian','LSW','Schulz-Zimm']:
     944            FFfxn = shapes[controls['FormFact']][0]
     945            Volfxn = shapes[controls['FormFact']][1]
     946            FFargs = []
     947            for item in ['Aspect ratio','Length','Thickness','Diameter',]:
     948                if item in controls['FFargs']:
     949                    FFargs.append(controls['FFargs'][item][0])
     950            rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
     951            contrast = rho**2-rhoMat**2
     952            parmDict = level[controls['DistType']]
     953            rBins,dBins,dist = MakeDiamDist(controls['DistType'],controls['NumPoints'],controls['Cutoff'],parmDict)
     954            Gmat = G_matrix(Q[Ibeg:Ifin],rBins,contrast,FFfxn,Volfxn,FFargs).T
     955            dist *= level[distFxn]['Volume'][0]
     956            Ic[Ibeg:Ifin] += np.dot(Gmat,dist)
     957            Rbins.append(rBins)
     958            Dist.append(dist/(4.*dBins))
     959        elif 'Unified' in distFxn:
     960            rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
     961            parmDict = level[controls['DistType']]
     962            Rg,G,B,P = parmDict['Rg'][0],parmDict['G'][0],parmDict['B'][0],parmDict['P'][0]
     963            Qstar = Q[Ibeg:Ifin]/(scsp.erf(Q[Ibeg:Ifin]*Rg/np.sqrt(6)))**3
     964            Guin = G*np.exp(-(Q[Ibeg:Ifin]*Rg)**2/3)
     965            Porod = (B/Qstar**P)
     966            Ic[Ibeg:Ifin] += Guin+Porod
     967            Rbins.append([])
     968            Dist.append([])
     969        elif 'Porod' in distFxn:
     970            rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
     971            parmDict = level[controls['DistType']]
     972            B,P,Rgco = parmDict['B'][0],parmDict['P'][0],parmDict['Cutoff'][0]
     973            Porod = (B/Q[Ibeg:Ifin]**P)*np.exp(-(Q[Ibeg:Ifin]*Rgco)**2/3)
     974            Ic[Ibeg:Ifin] += Porod
     975            Rbins.append([])
     976            Dist.append([])
     977        elif 'Mono' in distFxn:
     978            FFfxn = shapes[controls['FormFact']][0]
     979            Volfxn = shapes[controls['FormFact']][1]
     980            FFargs = []
     981            for item in ['Aspect ratio','Length','Thickness','Diameter',]:
     982                if item in controls['FFargs']:
     983                    FFargs.append(controls['FFargs'][item][0])
     984            rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
     985            contrast = rho**2-rhoMat**2
     986            R = level[controls['DistType']]['Radius'][0]
     987            Gmat = G_matrix(Q[Ibeg:Ifin],R,contrast,FFfxn,Volfxn,FFargs)             
     988            Ic[Ibeg:Ifin] += Gmat[0]*level[distFxn]['Volume'][0]
     989            Rbins.append([])
     990            Dist.append([])
     991        elif 'Bragg' in distFxn:
     992            parmDict = level[controls['DistType']]
     993            Ic[Ibeg:Ifin] += parmDict['PkInt'][0]*G2pwd.getPsVoigt(parmDict['PkPos'][0],
     994                parmDict['PkSig'][0],parmDict['PkGam'][0],Q[Ibeg:Ifin])
     995            Rbins.append([])
     996            Dist.append([])
     997           
    973998    sasdData['Size Calc'] = [Rbins,Dist]
    974999   
Note: See TracChangeset for help on using the changeset viewer.