Ejemplo n.º 1
0
def generator(dbfile='godb.db'):
    ''' This function will be called to generate the initial batch
    of random structures, which will then be partially relaxed
    using the reference method (usually DFT). Here, we simply
    use the random structure generator which will also be
    used in the genetic algorithm searches. We wish to have
    twenty of such random structures (N=20):
    '''
    prepare_ga(dbfile=dbfile, N=10)
    return
Ejemplo n.º 2
0
def run(args):
    rundir, maxiter = args

    if not os.path.exists(rundir):
        os.mkdir(rundir)
    os.chdir(rundir)

    sys.stdout = open('out.txt', 'a')
    sys.stderr = open('err.txt', 'w')

    try:
        if not os.path.exists('godb.db'):
            prepare_ga(splits={(2, 2): 1, (2, ): 2, (1, ): 1}, N=N)
        run_ga(maxiter, kptdensity=kptdensity)
    except:
        traceback.print_exc()
        sys.stderr.flush()
        raise

    os.chdir('..')
    return
Ejemplo n.º 3
0
def run(args):
    ''' This method specifies how to conduct a global optimization
    search, accepting a (run_directory, maximum_iterations)
    tuple as required by TANGO.
    '''
    rundir, maxiter = args

    # Create the run directory if it doesn't already exist:
    if not os.path.exists(rundir):
        os.mkdir(rundir)
    os.chdir(rundir)

    # Redirect the standard output and error to local files:
    sys.stdout = open('out.txt', 'a')
    sys.stderr = open('err.txt', 'w')

    try:
        # Create a database with N initial random structures
        # (N is here a global variable set in the __main__
        # function):
        if not os.path.exists('godb.db'):
            prepare_ga(N=N)
            #prepare_ga(splits={(2, 2): 1, (2,): 2, (1,): 1}, N=N)
        # Run the genetic algorithm (kptdensity is another
        # global variable set in the __main__ function):
        run_ga(maxiter, kptdensity=kptdensity)
    except:
        # When using the multiprocessing module
        # we need to explicitly print the error
        # traceback:
        traceback.print_exc()
        sys.stderr.flush()
        raise

    os.chdir('..')
    return
Ejemplo n.º 4
0
def generator(dbfile='godb.db'):
    prepare_ga(dbfile=dbfile, splits={(2, 2): 1, (2, ): 2, (1, ): 1}, N=20)
    return