Changeset 1136


Ignore:
Timestamp:
Nov 6, 2013 1:03:50 PM (8 years ago)
Author:
vondreele
Message:

block StructureFactor2 calcs - less memory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMath.py

    r1134 r1136  
    636636    Uij = np.array(G2lat.U6toUij(Uijdata))
    637637    bij = Mast*Uij.T
     638    blkSize = 100       #no. of reflections in a block
     639    nRef = refDict['RefList'].shape[0]
    638640    if not len(refDict['FF']):                #no form factors - 1st time thru StructureFactor
    639641        if 'N' in calcControls[hfx+'histType']:
     
    645647            refDict['FF']['El'] = dat.keys()
    646648            refDict['FF']['FF'] = np.ones((len(refDict['RefList']),len(dat)))
    647         refDict['ifNew'] = True           
     649            for iref,ref in enumerate(refDict['RefList']):
     650                SQ = 1./(2.*ref[4])**2
     651                dat = G2el.getFFvalues(FFtables,SQ)
     652                refDict['FF']['FF'][iref] *= dat.values()
    648653#reflection processing begins here - big arrays!
    649     try:
    650         refl = refDict['RefList']
     654    iBeg = 0           
     655    while iBeg < nRef:
     656        iFin = min(iBeg+blkSize,nRef)
     657        refl = refDict['RefList'][iBeg:iFin]
    651658        H = refl.T[:3]
    652659        SQ = 1./(2.*refl.T[4])**2
    653660        SQfactor = 4.0*SQ*twopisq
    654661        Bab = np.repeat(parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor),len(SGT))
    655         if refDict['ifNew']:                #no form factors - 1st time thru StructureFactor
    656             for iref in range(len(refl)):
    657                 if 'X' in calcControls[hfx+'histType']:
    658                     dat = G2el.getFFvalues(FFtables,SQ[iref])
    659                     refDict['FF']['FF'][iref] *= dat.values()
    660             refDict['ifNew'] = False
    661662        Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])
    662         FF = np.repeat(refDict['FF']['FF'].T[Tindx].T,len(SGT),axis=0)
     663        FF = np.repeat(refDict['FF']['FF'][iBeg:iFin].T[Tindx].T,len(SGT),axis=0)
    663664        Uniq = np.reshape(np.inner(H.T,SGMT),(-1,3))
    664665        Phi = np.inner(H.T,SGT).flatten()
     
    681682        fasq = fas**2
    682683        fbsq = fbs**2        #imaginary
    683     except MemoryError:
    684         print '**** ERROR - insufficient memory for this size problem; try 64-bit version of GSAS-II****'
    685         return
    686     refl.T[9] = np.sum(fasq,axis=0)+np.sum(fbsq,axis=0)
    687     refl.T[10] = atan2d(fbs[0],fas[0])
     684        refl.T[9] = np.sum(fasq,axis=0)+np.sum(fbsq,axis=0)
     685        refl.T[10] = atan2d(fbs[0],fas[0])
     686        iBeg += blkSize
    688687   
    689688def StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
     
    18931892                depDerivDict[j] = np.zeros(shape=(len(refDict['RefList'])))
    18941893            wdf = np.zeros(len(refDict['RefList']))
     1894            time0 = time.time()
    18951895            if calcControls['F**2']:
    18961896                for iref,ref in enumerate(refDict['RefList']):
     
    19511951            # now process derivatives in constraints
    19521952            G2mv.Dict2Deriv(varylist,depDerivDict,dMdvh)
     1953            print 'matrix build time: %.3f'%(time.time()-time0)
    19531954
    19541955            if dlg:
Note: See TracChangeset for help on using the changeset viewer.