Changeset 1274


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

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r1268 r1274  
    238238                keys = ['type','wavelength','calibrant','distance','center',
    239239                    'tilt','rotation','azmthOff','fullIntegrate','LRazimuth',
    240                     'IOtth','outAzimuths','invert_x','invert_y']
     240                    'IOtth','outAzimuths','invert_x','invert_y','DetDepth']
    241241                for key in keys:
    242242                    if key in ['rotation']:
     
    249249       
    250250    def OnLoadControls(event):
    251         cntlList = ['wavelength','distance','tilt','invert_x','invert_y',
    252             'fullIntegrate','outAzimuths','LRazimuth','IOtth','azmthOff']
     251        cntlList = ['wavelength','distance','tilt','invert_x','invert_y','type',
     252            'fullIntegrate','outAzimuths','LRazimuth','IOtth','azmthOff','DetDepth']
    253253        dlg = wx.FileDialog(G2frame, 'Choose image controls file', '.', '',
    254254            'image control files (*.imctrl)|*.imctrl',wx.OPEN|wx.CHANGE_DIR)
  • trunk/GSASIIplot.py

    r1273 r1274  
    14611461        Rbins,Dist = data['Size Calc']
    14621462        for i in range(len(Rbins)):
    1463             Plot.plot(2.*Rbins[i],Dist[i])       #plot diameters
     1463            if len(Rbins[i]):
     1464                Plot.plot(2.*Rbins[i],Dist[i])       #plot diameters
    14641465    Page.canvas.draw()
    14651466
  • trunk/GSASIIpwd.py

    r1248 r1274  
    712712    sumDf = np.sum(Df)
    713713    return Df,dFdp,dFds,dFdg,dFdsh
     714
     715def getPsVoigt(pos,sig,gam,xdata):
     716    'needs a doc string'
     717   
     718    Df = pyd.pypsvoigt(len(xdata),xdata-pos,sig,gam)
     719    Df /= np.sum(Df)
     720    return Df
     721
     722def getdPsVoigt(pos,sig,gam,xdata):
     723    'needs a doc string'
     724   
     725    Df,dFdp,dFds,dFdg = pyd.pydpsvoigt(len(xdata),xdata-pos,sig,gam)
     726    sumDf = np.sum(Df)
     727    return Df,dFdp,dFds,dFdg
    714728
    715729def getEpsVoigt(pos,alp,bet,sig,gam,xdata):
  • trunk/GSASIIpwdGUI.py

    r1273 r1274  
    120120        'Shape':['Spheroid',1.0],'MaxEnt':{'Niter':100,'Precision':0.01,'Sky':-3},
    121121        'IPG':{'Niter':100,'Approach':0.8,'Power':-1},'Reg':{},},           
    122         'Unified':{'Levels':[],},           
    123122        'Particle':{'Matrix':{'Name':'vacuum','VolFrac':[0.0,False]},'Levels':[],},
    124123        'Current':'Size dist.',
     
    26712670    def OnAddModel(event):
    26722671        if data['Current'] == 'Particle fit':
    2673             data['Particle']['Levels'].append({'Model':'Size Distr.',
    2674                 'Controls':{'FormFact':'Sphere','DistType':'LogNormal','Material':'vacuum',
     2672            material = 'vacuum'
     2673            if len(data['Particle']['Levels']):
     2674                material = data['Particle']['Levels'][-1]['Controls']['Material']
     2675            data['Particle']['Levels'].append({
     2676                'Controls':{'FormFact':'Sphere','DistType':'LogNormal','Material':material,
    26752677                    'FFargs':{},'NumPoints':50,'Cutoff':0.01,'AutoDist':True,'logR':True,
    2676                     'RgCutoff':0,'k-Factor':1,'StrFact':'Dilute','Blink':False},
     2678                    'StrFact':'Dilute'},
    26772679                'LogNormal':{'Volume':[0.05,False],'MinSize':[10.,False],'Mean':[1000.,False],'StdDev':[0.5,False]},
    26782680                'Gaussian':{'Volume':[0.05,False],'Mean':[1000.,False],'StdDev':[300.,False],},
    26792681                'LSW':{'Volume':[0.05,False],'Mean':[1000.0,False],},
    26802682                'Schulz-Zimm':{'Volume':[0.05,False],'Mean':[1000.,False],'StdDev':[300.,False],},
    2681                 'Unified':{'G':[100,False],'Rg':[100,False],'B':[1,False],'P':[4,False],},
    2682                 'Bragg':[{'PkType':'psVoigt','PkInt':[100,False],'PkPos':[0.1,False],
    2683                     'PkSig':[0.01,False],'PkGam':[0.01,False],'PkSkew':[1.,False],},],
     2683                'Unified':{'G':[100,False],'Rg':[100,False],'B':[1.e-4,False],'P':[4,False],},
     2684                'Porod':{'B':[1.e-4,False],'P':[4,False],'Cutoff':[100,False]},
     2685                'Monodisperse':{'Volume':[0.05,False],'Radius':[100,False],},   #OK for spheres
     2686                'Bragg':{'PkInt':[100,False],'PkPos':[0.2,False],
     2687                    'PkSig':[10,False],'PkGam':[10,False],},        #reeasonable 31A peak
    26842688                })
    26852689            G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
    26862690            G2plt.PlotPatterns(G2frame,plotType='SASD',newPlot=True)
    26872691                   
    2688         elif data['Current'] == 'Unified fit':
    2689             data['Unified']['Levels'].append({'Type':'Guinier','GuinScale':[100,False],'RadGyr':[100,False],
    2690                 'PorodScale':[0.01,False],'PorodPwr':[4.,False],})
    26912692        wx.CallAfter(UpdateModelsGrid,G2frame,data)
    26922693       
     
    27022703            G2plt.PlotPatterns(G2frame,plotType='SASD',newPlot=True)
    27032704            G2plt.PlotSASDSizeDist(G2frame)
    2704            
    2705         elif data['Current'] == 'Unified fit':
    2706             G2sasd.UnifiedFit(Profile,ProfDict,Limits,Substances,Sample,data)
    2707             G2plt.PlotPatterns(G2frame,plotType='SASD',newPlot=True)
    27082705           
    27092706        elif data['Current'] == 'Particle fit':
     
    28532850    def PartSizer():
    28542851       
    2855         ffChoices = {'Sphere':{},'Spheroid':{'Aspect ratio':[1.0,False]},
     2852        FormFactors = {'Sphere':{},'Spheroid':{'Aspect ratio':[1.0,False]},
    28562853            'Cylinder':{'Length':[100.,False]},'Cylinder diam':{'Diameter':[100.,False]},
    28572854            'Cylinder AR':{'Aspect ratio':[1.0,False]},'Unified sphere':{},
     
    28602857            'Unified tube':{'Length':[100.,False],'Thickness':[10.,False]},}
    28612858               
     2859        ffDistChoices =  ['Sphere','Spheroid','Cylinder','Cylinder diam',
     2860            'Cylinder AR','Unified sphere','Unified rod','Unified rod AR',
     2861            'Unified disk','Unified tube',]
     2862               
     2863        ffMonoChoices = ['Sphere','Spheroid','Cylinder','Cylinder AR',
     2864            ]
     2865                 
    28622866        def RefreshPlots():
    28632867            PlotText = G2frame.G2plotNB.nb.GetPageText(G2frame.G2plotNB.nb.GetSelection())
     
    28882892            item[key] = Obj.GetValue()
    28892893            if 'Refine' not in Obj.GetLabel():
    2890                 if 'FormFact' in key:
    2891                     item['FFargs'] = ffChoices[Obj.GetValue()]
     2894                if 'FormFact' in key :
     2895                    item['FFargs'] = FormFactors[Obj.GetValue()]
     2896                wx.CallAfter(UpdateModelsGrid,G2frame,data)
    28922897                G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
    28932898                RefreshPlots()
    2894                 wx.CallAfter(UpdateModelsGrid,G2frame,data)
    2895            
     2899               
    28962900        def OnDelLevel(event):
    28972901            Obj = event.GetEventObject()
     
    29052909            Obj = event.GetEventObject()
    29062910            item,key,pvObj = Indx[Obj.GetId()]
    2907             item[key] = 10.**float(Obj.GetValue()/1000.)
     2911            slide = Obj.GetValue()
     2912            value = 10.**float(slide/1000.)
     2913            item[key] = value
    29082914            pvObj.SetValue('%.3g'%(item[key]))
    29092915            G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
    29102916            RefreshPlots()
    29112917           
     2918        def OnCenterSlider(event):
     2919            Obj = event.GetEventObject()
     2920            Obj.SetValue(False)
     2921            sldrObj,value = Indx[Obj.GetId()]
     2922            sldrObj.SetRange(1000*(value-1),1000*(value+1))
     2923            sldrObj.SetValue(1000*value)
     2924           
    29122925        def SizeSizer():
    29132926            sizeSizer = wx.FlexGridSizer(0,4,5,5)
    2914             sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Material: '),0,WACV)
    2915             matSel = wx.ComboBox(G2frame.dataDisplay,value=level['Controls']['Material'],
    2916                 choices=Substances['Substances'].keys(),style=wx.CB_READONLY|wx.CB_DROPDOWN)
    2917             Indx[matSel.GetId()] = [level['Controls'],'Material']
    2918             matSel.Bind(wx.EVT_COMBOBOX,OnSelect)       
    2919             sizeSizer.Add(matSel,0,WACV) #do neutron test here?
    2920             rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
    2921             contrast = rho**2-rhoMat**2
    2922             sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Resonant X-ray contrast: '),0,WACV)
    2923             sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label='  %.2f 10%scm%s'%(contrast,Pwr20,Pwrm4)),0,WACV)
    2924             sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Form Factor: '),0,WACV)
    2925             ffChoice = wx.ComboBox(G2frame.dataDisplay,value=level['Controls']['FormFact'],choices=ffChoices.keys(),
    2926                 style=wx.CB_READONLY|wx.CB_DROPDOWN)
    2927             Indx[ffChoice.GetId()] = [level['Controls'],'FormFact']
    2928             ffChoice.Bind(wx.EVT_COMBOBOX,OnSelect)
    2929             sizeSizer.Add(ffChoice,0,WACV)
    29302927            sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Distribution: '),0,WACV)
    2931             Distchoice = ['LogNormal','Gaussian','LSW','Schulz-Zimm']
     2928            Distchoice = ['LogNormal','Gaussian','LSW','Schulz-Zimm','Bragg','Unified','Porod','Monodisperse',]
    29322929            distChoice = wx.ComboBox(G2frame.dataDisplay,value=level['Controls']['DistType'],choices=Distchoice,
    29332930                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     
    29352932            distChoice.Bind(wx.EVT_COMBOBOX,OnSelect)
    29362933            sizeSizer.Add(distChoice,0,WACV)
    2937             sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Num. radii: '),0,WACV)
    2938             radii = ['25','50','75','100','200']
    2939             nRadii = wx.ComboBox(G2frame.dataDisplay,value=str(level['Controls']['NumPoints']),choices=radii,
    2940                 style=wx.CB_READONLY|wx.CB_DROPDOWN)
    2941             Indx[nRadii.GetId()] = [level['Controls'],'NumPoints']
    2942             nRadii.Bind(wx.EVT_COMBOBOX,OnSelect)
    2943             sizeSizer.Add(nRadii,0,WACV)
    2944             sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' R dist. cutoff: '),0,WACV)
    2945             rCutoff = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,level['Controls'],'Cutoff',
    2946                 min=0.001,max=0.1,typeHint=float)
    2947             sizeSizer.Add(rCutoff,0,WACV)
     2934            if level['Controls']['DistType'] not in ['Bragg','Unified','Porod',]:
     2935                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Form Factor: '),0,WACV)
     2936                if 'Mono' not in level['Controls']['DistType']:
     2937                    ffChoice = wx.ComboBox(G2frame.dataDisplay,value=level['Controls']['FormFact'],choices=ffDistChoices,
     2938                        style=wx.CB_READONLY|wx.CB_DROPDOWN)
     2939                else:
     2940                    ffChoice = wx.ComboBox(G2frame.dataDisplay,value=level['Controls']['FormFact'],choices=ffMonoChoices,
     2941                        style=wx.CB_READONLY|wx.CB_DROPDOWN)
     2942                Indx[ffChoice.GetId()] = [level['Controls'],'FormFact']
     2943                ffChoice.Bind(wx.EVT_COMBOBOX,OnSelect)
     2944                sizeSizer.Add(ffChoice,0,WACV)
     2945                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Material: '),0,WACV)
     2946                matSel = wx.ComboBox(G2frame.dataDisplay,value=level['Controls']['Material'],
     2947                    choices=Substances['Substances'].keys(),style=wx.CB_READONLY|wx.CB_DROPDOWN)
     2948                Indx[matSel.GetId()] = [level['Controls'],'Material']
     2949                matSel.Bind(wx.EVT_COMBOBOX,OnSelect)       
     2950                sizeSizer.Add(matSel,0,WACV) #do neutron test here?
     2951                rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
     2952                contrast = rho**2-rhoMat**2
     2953                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Resonant X-ray contrast: '),0,WACV)
     2954                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label='  %.2f 10%scm%s'%(contrast,Pwr20,Pwrm4)),0,WACV)
     2955                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Num. radii: '),0,WACV)
     2956                radii = ['25','50','75','100','200']
     2957                nRadii = wx.ComboBox(G2frame.dataDisplay,value=str(level['Controls']['NumPoints']),choices=radii,
     2958                    style=wx.CB_READONLY|wx.CB_DROPDOWN)
     2959                Indx[nRadii.GetId()] = [level['Controls'],'NumPoints']
     2960                nRadii.Bind(wx.EVT_COMBOBOX,OnSelect)
     2961                sizeSizer.Add(nRadii,0,WACV)
     2962                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' R dist. cutoff: '),0,WACV)
     2963                rCutoff = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,level['Controls'],'Cutoff',
     2964                    min=0.001,max=0.1,typeHint=float)
     2965                sizeSizer.Add(rCutoff,0,WACV)
     2966#            elif level['Controls']['DistType']  in ['Unified','Porod',]:
    29482967            return sizeSizer
    29492968           
     
    29722991            G2gd.HorizontalLine(partSizer,G2frame.dataDisplay)
    29732992            topLevel = wx.BoxSizer(wx.HORIZONTAL)
    2974             topLevel.Add(wx.StaticText(G2frame.dataDisplay,label=' Model level %d: '%(ilev)),0,WACV)
    2975             modelChoice = ['Size Distr.','Unified','Bragg peak']
    2976             model = wx.ComboBox(G2frame.dataDisplay,value=level['Model'],choices=modelChoice,
    2977                 style=wx.CB_READONLY|wx.CB_DROPDOWN)
    2978             Indx[model.GetId()] = [level,'Model']
    2979             model.Bind(wx.EVT_COMBOBOX,OnSelect)
    2980             topLevel.Add(model,0,WACV)
     2993            topLevel.Add(wx.StaticText(G2frame.dataDisplay,label=' Model component %d: '%(ilev)),0,WACV)
    29812994            delBtn = wx.Button(G2frame.dataDisplay,label=' Delete?')
    29822995            Indx[delBtn.GetId()] = ilev
     
    29842997            topLevel.Add(delBtn,0,WACV)
    29852998            partSizer.Add(topLevel,0)
    2986             if 'Size' in level['Model']:
    2987                 partSizer.Add(SizeSizer())
     2999            partSizer.Add(SizeSizer())
    29883000           
    29893001            lvlSizer = wx.BoxSizer(wx.HORIZONTAL)
    2990             parmSizer = wx.FlexGridSizer(1,3,5,5)
     3002            parmSizer = wx.FlexGridSizer(1,4,5,5)
    29913003            parmSizer.AddGrowableCol(2,1)
    29923004            parmSizer.SetFlexibleDirection(wx.HORIZONTAL)
     
    30023014                parmValue.Bind(wx.EVT_TEXT_ENTER,OnValue)       
    30033015                parmValue.Bind(wx.EVT_KILL_FOCUS,OnValue)
    3004 #                parmValue = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,Parms[parm],0,
    3005 #                    typeHint=float,OnLeave=AfterChange)
    30063016                parmSizer.Add(parmValue,0,WACV)
    30073017                value = np.log10(Parms[parm][0])
    3008                 valMinMax = [value-2,value+2]
     3018                valMinMax = [value-1,value+1]
    30093019                parmSldr = wx.Slider(G2frame.dataDisplay,minValue=1000.*valMinMax[0],
    30103020                    maxValue=1000.*valMinMax[1],value=1000.*value)
     
    30143024                parmSldr.Bind(wx.EVT_SLIDER,OnParmSlider)
    30153025                parmSizer.Add(parmSldr,1,wx.EXPAND)
     3026                center = wx.CheckBox(G2frame.dataDisplay,label='Center? ')
     3027                Indx[center.GetId()] = [parmSldr,value]
     3028                center.Bind(wx.EVT_CHECKBOX,OnCenterSlider)
     3029                parmSizer.Add(center,0,WACV)
    30163030            for parm in list(FFargs):
    30173031                parmVar = wx.CheckBox(G2frame.dataDisplay,label='Refine? FF '+parm)
     
    30243038                parmValue.Bind(wx.EVT_TEXT_ENTER,OnValue)       
    30253039                parmValue.Bind(wx.EVT_KILL_FOCUS,OnValue)
    3026 #                parmValue = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,FFargs[parm],0,
    3027 #                    typeHint=float,OnLeave=AfterChange)
    30283040                parmSizer.Add(parmValue,0,WACV)
    30293041                value = np.log10(FFargs[parm][0])
    3030                 valMinMax = [value-2,value+2]
     3042                valMinMax = [value-1,value+1]
    30313043                parmSldr = wx.Slider(G2frame.dataDisplay,minValue=1000.*valMinMax[0],
    30323044                    maxValue=1000.*valMinMax[1],value=1000.*value)
     
    30363048                parmSldr.Bind(wx.EVT_SLIDER,OnParmSlider)
    30373049                parmSizer.Add(parmSldr,1,wx.EXPAND)
     3050                center = wx.CheckBox(G2frame.dataDisplay,label='Center? ')
     3051                Indx[center.GetId()] = [parmSldr,value]
     3052                center.Bind(wx.EVT_CHECKBOX,OnCenterSlider)
     3053                parmSizer.Add(center,0,WACV)
    30383054            lvlSizer.Add(parmSizer,1,wx.EXPAND)
    30393055            partSizer.Add(lvlSizer,1,wx.EXPAND)
    30403056        return partSizer
    3041        
    3042     def UnifSizer():
    3043         print data['Unified']
    3044         unifSizer = wx.BoxSizer(wx.VERTICAL)
    3045         unifSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Unified fit parameters: '),0,WACV)
    3046         return unifSizer
    30473057       
    30483058    def OnEsdScale(event):
     
    30763086    mainSizer = wx.BoxSizer(wx.VERTICAL)
    30773087    topSizer = wx.BoxSizer(wx.HORIZONTAL)
    3078     models = ['Size dist.','Unified fit','Particle fit']
     3088    models = ['Size dist.','Particle fit']
    30793089    topSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Modeling by: '),0,WACV)
    30803090    fitSel = wx.ComboBox(G2frame.dataDisplay,value=data['Current'],choices=models,
     
    30973107    elif 'Particle' in data['Current']:
    30983108        mainSizer.Add(PartSizer(),1,wx.ALIGN_LEFT|wx.EXPAND)
    3099     elif 'Unified' in data['Current']:
    3100         mainSizer.Add(UnifSizer())
    31013109    G2gd.HorizontalLine(mainSizer,G2frame.dataDisplay)   
    31023110    backSizer = wx.BoxSizer(wx.HORIZONTAL)
  • 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   
  • trunk/fsource/powsubs/psvoigt.for

    r712 r1274  
    8686      SUBROUTINE PSVOIGT2(DX,SIG,GAM,FUNC,DFDX,DFDS,DFDG)
    8787
    88 !PURPOSE: Compute function & derivatives pseudovoigt
     88!PURPOSE: Compute function & derivatives pseudovoigt - unfinished;
     89!   no derivatives
    8990!pseudo Voigt W.I.F. David, J. Appl. Cryst. 19, 63-64 (1986)
    9091
     
    160161      TG = STOFW*EXP(EX)/(SQ2PI*FWHM)
    161162      FUNC = ETAL*TL+ETAG*TG
     163       
     164! Unfinished - no derivatives
    162165
    163166      RETURN
  • trunk/fsource/pypowder.for

    r1051 r1274  
    5555        CALL PSVFCJ(DTT(I)*100.,TTHETA*100.,SIG,GAM,SPH,
    5656     1    PRFUNC(I),DPRDT(I),SIGPART(I),GAMPART(I),SLPART(I))
     57        DPRDT(I) = DPRDT(I)*100.
     58      END DO
     59      RETURN
     60      END
     61
     62      SUBROUTINE PYPSVOIGT(NPTS,DTT,SIG,GAM,PRFUNC)
     63C DTT in degrees
     64C RETURNS FUNCTION ONLY
     65Cf2py intent(in) NPTS
     66Cf2py intent(in) DTT
     67cf2py depend(NPTS) DTT
     68Cf2py intent(in) SIG
     69Cf2py intent(in) GAM
     70Cf2py intent(out) PRFUNC
     71Cf2py depend(NPTS) PRFUNC
     72
     73      REAL*4 DTT(0:NPTS-1),PRFUNC(0:NPTS-1)
     74      REAL*4 SIG,GAM
     75      INTEGER*4 NPTS,I
     76      DO I=0,NPTS-1
     77        CALL PSVOIGT(DTT(I)*100.,SIG,GAM,
     78     1    PRFUNC(I),DPRDT,SIGPART,GAMPART)
     79      END DO
     80      RETURN
     81      END
     82
     83      SUBROUTINE PYDPSVOIGT(NPTS,DTT,SIG,GAM,PRFUNC,
     84     1  DPRDT,SIGPART,GAMPART)
     85C DTT in degrees
     86C RETURNS FUNCTION & DERIVATIVES
     87Cf2py intent(in) NPTS
     88Cf2py intent(in) DTT
     89cf2py depend(NPTS) DTT
     90Cf2py intent(in) SIG
     91Cf2py intent(in) GAM
     92Cf2py intent(out) PRFUNC
     93Cf2py depend(NPTS) PRFUNC
     94Cf2py intent(out) DPRDT
     95Cf2py depend(NPTS) DPRDT
     96Cf2py intent(out) SIGPART
     97Cf2py depend(NPTS) SIGPART
     98Cf2py intent(out) GAMPART
     99Cf2py depend(NPTS) GAMPART
     100
     101      INTEGER*4 NPTS
     102      REAL*4 SIG,GAM
     103      REAL*4 DTT(0:NPTS-1),DPRDT(0:NPTS-1),SIGPART(0:NPTS-1),
     104     1  GAMPART(0:NPTS-1),PRFUNC(0:NPTS-1)
     105      DO I=0,NPTS-1
     106        CALL PSVOIGT(DTT(I)*100.,SIG,GAM,
     107     1    PRFUNC(I),DPRDT(I),SIGPART(I),GAMPART(I))
    57108        DPRDT(I) = DPRDT(I)*100.
    58109      END DO
Note: See TracChangeset for help on using the changeset viewer.