Changeset 970


Ignore:
Timestamp:
Jun 27, 2013 10:55:13 AM (10 years ago)
Author:
vondreele
Message:

more fixups of MC/SA

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r965 r970  
    23182318        x0 = schedule.getstart_temp(best_state)
    23192319    else:
    2320 #        x0 = random.uniform(size=len(x0))*(upper-lower) + lower
     2320        x0 = random.uniform(size=len(x0))*(upper-lower) + lower
    23212321        best_state.x = None
    23222322        best_state.cost = numpy.Inf
     
    23322332    fqueue = [100, 300, 500, 700]
    23332333    iters = 0
    2334     while 1:
     2334    keepGoing = True
     2335    while keepGoing:
     2336        retval = 0
    23352337        for n in xrange(dwell):
    23362338            current_state.x = schedule.update_guess(last_state.x)
     
    23512353                best_state.x = last_state.x.copy()
    23522354                best_state.cost = last_state.cost
    2353                 break
     2355                retval = 5
    23542356        schedule.update_temp()
    23552357        iters += 1
     
    23612363        # 3) maxiter is set and we are past it
    23622364        # 4) maxaccept is set and we are past it
     2365        # 5) user canceled run via progress bar
    23632366
    23642367        fqueue.append(squeeze(last_state.cost))
    23652368        fqueue.pop(0)
    23662369        af = asarray(fqueue)*1.0
     2370        if retval == 5:
     2371            print ' User terminated run; incomplete MC/SA'
     2372            keepGoing = False
     2373            break
    23672374        if all(abs((af-af[0])/af[0]) < feps):
    23682375            retval = 0
     
    25882595#        phase = np.inner(Uniq,Xdata)     #hx+ky+lz
    25892596#        phase += Phi[:,np.newaxis]      #hx+ky+lz+phi
    2590 #        if len(Uniq) == 3: print 'python',phase
    25912597#        cosp = np.cos(twopi*phase)
    25922598#        fas = np.sum(FF*cosp)
    2593 #        print fas
    25942599#        if ifInv:
    25952600#            fbs = 0.
     
    25972602#            sinp = np.sin(twopi*phase)
    25982603#            fbs = np.sum(FF*sinp)
    2599 #        return (fas**2+fbs**2)*mul       
    2600        
     2604#        return (fas**2+fbs**2)*mul
     2605
    26012606    def mcsaCalc(values,refList,rcov,ifInv,RBdata,varyList,parmDict):
    26022607        ''' Compute structure factors for all h,k,l for phase
     
    26182623            t0 = time.time()
    26192624            refl[5] = mcsasfCalc(ifInv,Tdata,Mdata,Xdata,refl[3],refl[7],refl[8],refl[9])
    2620 #            refl[5] *= calcMDcorr(MDval,MDaxis,Uniq,Gmat) 
     2625#            refl[5] *= calcMDcorr(MDval,MDaxis,Uniq,Gmat)
    26212626            tsum += (time.time()-t0)
    26222627            sumFcsq += refl[5]
     
    27512756    x0 = [parmDict[val] for val in varyList]
    27522757    ifInv = SGData['SGInv']
    2753     results = anneal(mcsaCalc,x0,args=(refs,rcov,ifInv,RBdata,varyList,parmDict), 
     2758    results = anneal(mcsaCalc,x0,args=(refs,rcov,ifInv,RBdata,varyList,parmDict),
    27542759        schedule=MCSA['Algorithm'], full_output=True,
    27552760        T0=MCSA['Annealing'][0], Tf=MCSA['Annealing'][1],dwell=MCSA['Annealing'][2],
  • trunk/GSASIIphsGUI.py

    r966 r970  
    43884388                    Result,tsum = G2mth.mcsaSearch(data,RBdata,reflType,reflData,covData,pgbar)
    43894389                    MCSAdata['Results'].append(Result)
    4390                     print ' MC/SA run completed: %d residual: %.3f%%'%(i,100*Result[2])
     4390                    print ' MC/SA run completed: %d residual: %.3f%% SFcalc time: %.2fs'%(i,100*Result[2],tsum)
    43914391                    tsf += tsum
    43924392                print ' Structure factor time: %.2f'%(tsf)
Note: See TracChangeset for help on using the changeset viewer.