Example #1
0
def find_cfl_number(config, state):

    # setup result data
    results = ordered_bunch()
    results.CONFIG = copy.deepcopy(config)
    results.ANALYSES = ordered_dict()

    # run a bracketing algorithm
    sp.optimize.brent(
        func=run_su2,
        args=(config, state, results),
        brack=tuple(SEARCH_BRACKET),
        tol=0.001,
        maxiter=MAX_ANALYSES -
        3,  #analyses are used in the first bracket pass and aren't counted by this algorithm
    )

    ## run a search method
    #sp.optimize.fminbound(
    #func    = run_su2,
    #x1      = SEARCH_BRACKET[0],
    #x2      = SEARCH_BRACKET[2],
    #args    = ( config, state, results ),
    #xtol    = 0.001,
    #maxfun  = MAX_ANALYSES,
    #disp    = 0,
    #)

    # get final result
    cfl = np.array([r.CFL_NUMBER for r in results.ANALYSES.values()])
    its = np.array([r.ITERATIONS for r in results.ANALYSES.values()])
    ind = np.lexsort((-cfl, its))

    # done!
    print 'Final Result'
    print '  CFL        = %.4f' % cfl[ind[0]]
    print '  Iterations = %i' % its[ind[0]]

    # save the data
    SU2.io.save_data('experiment_results.pkl', results)

    return
Example #2
0
def find_cfl_number(config,state):

    # setup result data
    results = ordered_bunch()
    results.CONFIG = copy.deepcopy(config)
    results.ANALYSES = ordered_dict()
        
    # run a bracketing algorithm
    sp.optimize.brent(
        func    = run_su2,
        args    = ( config, state, results ),
        brack   = tuple(SEARCH_BRACKET),
        tol     = 0.001,
        maxiter = MAX_ANALYSES-3, #analyses are used in the first bracket pass and aren't counted by this algorithm
    )
    
    ## run a search method
    #sp.optimize.fminbound(
        #func    = run_su2,
        #x1      = SEARCH_BRACKET[0],
        #x2      = SEARCH_BRACKET[2],
        #args    = ( config, state, results ),
        #xtol    = 0.001,
        #maxfun  = MAX_ANALYSES,
        #disp    = 0,
    #)
    
    
    # get final result
    cfl = np.array([ r.CFL_NUMBER for r in results.ANALYSES.values() ])
    its = np.array([ r.ITERATIONS for r in results.ANALYSES.values() ])
    ind = np.lexsort((-cfl,its))
    
    # done!
    print 'Final Result'
    print '  CFL        = %.4f' % cfl[ind[0]]
    print '  Iterations = %i'   % its[ind[0]]
    
    # save the data
    SU2.io.save_data('experiment_results.pkl',results)    
    
    return