Changeset 1315


Ignore:
Timestamp:
May 1, 2014 3:20:21 PM (8 years ago)
Author:
vondreele
Message:

new controls parameter 'Contrast' & remove Substances from arguments list

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r1313 r1315  
    26842684            data['Particle']['Levels'].append({
    26852685                'Controls':{'FormFact':'Sphere','DistType':'LogNormal','Material':material,
    2686                     'FFargs':{},'SFargs':{},'NumPoints':50,'Cutoff':0.01,
     2686                    'FFargs':{},'SFargs':{},'NumPoints':50,'Cutoff':0.01,'Contrast':0.0,
    26872687                    'SlitSmear':[0.0,False],'StrFact':'Dilute'},    #last 2 not used - future?
    26882688                'LogNormal':{'Volume':[0.05,False],'Mean':[1000.,False],'StdDev':[0.5,False],'MinSize':[10.,False],},
     
    26962696                    'PkSig':[10,False],'PkGam':[10,False],},        #reasonable 31A peak
    26972697                })
    2698             G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
     2698            G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    26992699            RefreshPlots(True)
    27002700                   
     
    27892789                ILimits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Limits'))
    27902790                IInst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Instrument Parameters'))
    2791                 ISubstances = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Substances'))
    2792                 IfOK,result,varyList,sig,Rvals,covMatrix = G2sasd.ModelFit(IProfile,IProfDict,ILimits,ISubstances,ISample,IModel)
     2791#                ISubstances = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Substances'))
     2792                IfOK,result,varyList,sig,Rvals,covMatrix = G2sasd.ModelFit(IProfile,IProfDict,ILimits,ISample,IModel)
    27932793                if not IfOK:
    27942794                    G2frame.ErrorDialog('Failed sequential refinement for data '+name,
     
    27992799                    break
    28002800               
    2801                 G2sasd.ModelFxn(IProfile,IProfDict,ILimits,ISubstances,ISample,IModel)
     2801                G2sasd.ModelFxn(IProfile,IProfDict,ILimits,ISample,IModel)
    28022802                SeqResult[name] = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals,
    28032803                    'covMatrix':covMatrix,'title':name}
     
    28222822                    ' Do Substances and then Sample parameters')
    28232823                return
    2824             G2sasd.SizeDistribution(Profile,ProfDict,Limits,Substances,Sample,data)
     2824            G2sasd.SizeDistribution(Profile,ProfDict,Limits,Sample,data)
    28252825            G2plt.PlotSASDSizeDist(G2frame)
    28262826            RefreshPlots(True)
     
    28282828        elif data['Current'] == 'Particle fit':
    28292829            SaveState()
    2830             if not G2sasd.ModelFit(Profile,ProfDict,Limits,Substances,Sample,data)[0]:
     2830            if not G2sasd.ModelFit(Profile,ProfDict,Limits,Sample,data)[0]:
    28312831                G2frame.ErrorDialog('Failed refinement',
    28322832                    'You need to rethink your selection of parameters\n'+    \
    28332833                    ' Model restored to previous version')
    2834             G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
     2834            G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    28352835            RefreshPlots(True)
    28362836            wx.CallAfter(UpdateModelsGrid,G2frame,data)
     
    28422842        G2frame.dataFrame.SasdUndo.Enable(False)
    28432843        UpdateModelsGrid(G2frame,data)
    2844         G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
     2844        G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    28452845        RefreshPlots(True)
    28462846
     
    30313031                sldrObj.SetRange(slMult*valMinMax[0],slMult*valMinMax[1])
    30323032                sldrObj.SetValue(slMult*logv)
    3033             G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
     3033            G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    30343034            RefreshPlots()
    30353035           
     
    30443044                    item['SFargs'] = StructureFactors[Obj.GetValue()]
    30453045                wx.CallAfter(UpdateModelsGrid,G2frame,data)
    3046                 G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
     3046                G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    30473047                RefreshPlots()
    30483048               
     
    30523052            del data['Particle']['Levels'][item]
    30533053            wx.CallAfter(UpdateModelsGrid,G2frame,data)
    3054             G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
     3054            G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    30553055            RefreshPlots()
    30563056           
     
    30653065            item[key][0] = value
    30663066            pvObj.SetValue('%.3g'%(item[key][0]))
    3067             G2sasd.ModelFxn(Profile,ProfDict,Limits,Substances,Sample,data)
     3067            G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    30683068            RefreshPlots()
    30693069           
     
    30963096                sizeSizer.Add(matSel,0,WACV) #do neutron test here?
    30973097                rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
    3098                 contrast = (rho-rhoMat)**2
     3098                level['Controls']['Contrast'] = contrast = (rho-rhoMat)**2                 
    30993099                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Resonant X-ray contrast: '),0,WACV)
    31003100                sizeSizer.Add(wx.StaticText(G2frame.dataDisplay,label='  %.2f 10%scm%s'%(contrast,Pwr20,Pwrm4)),0,WACV)
  • trunk/GSASIIsasd.py

    r1313 r1315  
    10051005###############################################################################
    10061006
    1007 def SizeDistribution(Profile,ProfDict,Limits,Substances,Sample,data):
     1007def SizeDistribution(Profile,ProfDict,Limits,Sample,data):
    10081008    shapes = {'Spheroid':[SpheroidFF,SpheroidVol],'Cylinder':[CylinderDFF,CylinderDVol],
    10091009        'Cylinder AR':[CylinderARFF,CylinderARVol],'Unified sphere':[UniSphereFF,UniSphereVol],
     
    10531053################################################################################
    10541054
    1055 def ModelFit(Profile,ProfDict,Limits,Substances,Sample,Model):
     1055def ModelFit(Profile,ProfDict,Limits,Sample,Model):
    10561056    shapes = {'Spheroid':[SpheroidFF,SpheroidVol],'Cylinder':[CylinderDFF,CylinderDVol],
    10571057        'Cylinder AR':[CylinderARFF,CylinderARVol],'Unified sphere':[UniSphereFF,UniSphereVol],
     
    10811081        parmDict['Back'] = Back[0]
    10821082        partData = Model['Particle']
    1083         parmDict['Matrix density'] = Substances['Substances'][partData['Matrix']['Name']].get('XAnom density',0.0)
    10841083        for i,level in enumerate(partData['Levels']):
    10851084            cid = str(i)+':'
     
    10941093                parmDict[cid+'FFVolume'] = shapes[controls['FormFact']][1]
    10951094                parmDict[cid+'StrFact'] = sfxns[controls['StrFact']]
    1096                 parmDict[cid+'XAnom density'] = Substances['Substances'][controls['Material']].get('XAnom density',0.0)
     1095                parmDict[cid+'Contrast'] = controls['Contrast']
    10971096                for item in FFparmOrder:
    10981097                    if item in controls['FFargs']:
     
    11261125            Type = controls['DistType']
    11271126            if Type in ['LogNormal','Gaussian','LSW','Schulz-Zimm','Monodisperse']:
    1128                 print ' Component %d: Type: %s: Structure Factor: %s'%(i,Type,controls['StrFact'])               
     1127                print ' Component %d: Type: %s: Structure Factor: %s Contrast: %12.3f'  \
     1128                    %(i,Type,controls['StrFact'],controls['Contrast'])               
    11291129            else:
    11301130                print ' Component %d: Type: %s: '%(i,Type,)
     
    11521152    def getSASD(Q,levelTypes,parmDict):
    11531153        Ic = np.zeros_like(Q)
    1154         rhoMat = parmDict['Matrix density']
    11551154        for i,Type in enumerate(levelTypes):
    11561155            cid = str(i)+':'
     
    11711170                    if item in parmDict:
    11721171                        distDict[item.split(':')[1]] = parmDict[item]
    1173                 rho = parmDict[cid+'XAnom density']
    1174                 contrast = (rho-rhoMat)**2
     1172                contrast = parmDict[cid+'Contrast']
    11751173                rBins,dBins,dist = MakeDiamDist(Type,parmDict[cid+'NumPoints'],parmDict[cid+'Cutoff'],distDict)
    11761174                Gmat = G_matrix(Q,rBins,contrast,FFfxn,Volfxn,FFargs).T
     
    12001198                    if item in parmDict:
    12011199                        SFargs.append(parmDict[item])
    1202                 rho = parmDict[cid+'XAnom density']
    1203                 contrast = (rho-rhoMat)**2
     1200                contrast = parmDict[cid+'Contrast']
    12041201                R = parmDict[cid+'Radius']
    12051202                Gmat = G_matrix(Q,R,contrast,FFfxn,Volfxn,FFargs)             
     
    12521249        return False,0,0,0,0,0
    12531250   
    1254 def ModelFxn(Profile,ProfDict,Limits,Substances,Sample,sasdData):
     1251def ModelFxn(Profile,ProfDict,Limits,Sample,sasdData):
    12551252   
    12561253    shapes = {'Spheroid':[SpheroidFF,SpheroidVol],'Cylinder':[CylinderDFF,CylinderDVol],
     
    12641261#    pdb.set_trace()
    12651262    partData = sasdData['Particle']
    1266     rhoMat = Substances['Substances'][partData['Matrix']['Name']].get('XAnom density',0.0)
    12671263    matFrac = partData['Matrix']['VolFrac'] #[value,flag]       
    12681264    Scale = Sample['Scale']     #[value,flag]
     
    12941290                if item in controls['FFargs']:
    12951291                    FFargs.append(controls['FFargs'][item][0])
    1296             rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
    1297             contrast = (rho-rhoMat)**2
     1292            contrast = controls['Contrast']
    12981293            distDict = {}
    12991294            for item in parmDict:
     
    13361331                if item in controls['FFargs']:
    13371332                    FFargs.append(controls['FFargs'][item][0])
    1338             rho = Substances['Substances'][level['Controls']['Material']].get('XAnom density',0.0)
    1339             contrast = (rho-rhoMat)**2
     1333            contrast = controls['Contrast']
    13401334            Gmat = G_matrix(Q[Ibeg:Ifin],R,contrast,FFfxn,Volfxn,FFargs)             
    13411335            Ic[Ibeg:Ifin] += Gmat[0]*level[distFxn]['Volume'][0]*SFfxn(Q[Ibeg:Ifin],args=SFargs)
Note: See TracChangeset for help on using the changeset viewer.