示例#1
0
 def test_firefly(self):
     """
     Tests (pychemia.searcher.firefly) with LJ Clusters           :
     """
     if not has_connection():
         return
     pcm_log.debug('FireFly')
     popu = LJCluster('test',
                      composition='Xe13',
                      refine=True,
                      direct_evaluation=True)
     popu.pcdb.clean()
     searcher = FireFly(popu, generation_size=8, stabilization_limit=3)
     searcher.run()
     popu.pcdb.clean()
     searcher = FireFly(popu, {
         'delta': 0.1,
         'gamma': 0.1,
         'beta0': 0.8,
         'alpha0': 0,
         'multi_move': True
     },
                        generation_size=8,
                        stabilization_limit=3)
     searcher.run()
     popu.pcdb.clean()
示例#2
0
 def test_swarm(self):
     """
     Test (pychemia.searcher.swarm) with LJ Clusters             :
     """
     if not has_connection():
         return
     pcm_log.debug('ParticleSwarm')
     popu = LJCluster('test', composition='Xe13', refine=False, direct_evaluation=True)
     popu.pcdb.clean()
     searcher = ParticleSwarm(popu, generation_size=8, stabilization_limit=3)
     searcher.run()
     popu.pcdb.clean()
示例#3
0
def notest_searcher():
    """
    Test (pychemia.searcher) with LJ Clusters                   :
    """
    if not has_connection():
        return

    p1 = multiprocessing.Process(target=lj_searcher)
    p2 = multiprocessing.Process(target=evaluator)

    p1.start()
    time.sleep(10)
    p2.start()
示例#4
0
def notest_searcher():
    """
    Testing HarmonySearch               :
    """
    if not has_connection():
        return

    p1 = multiprocessing.Process(target=searcher)
    p2 = multiprocessing.Process(target=evaluator)

    p1.start()
    time.sleep(10)
    p2.start()
示例#5
0
def test_queue():
    """
    Tests (pychemia.db.PyChemiaQueue)                            :
    """
    if not has_connection():
        return

    print("Testing PyChemiaQueue")

    source = 'pychemia/test/data/vasp_01'
    destination = tempfile.mkdtemp()
    print('Destination: %s' % destination)

    st = pychemia.code.vasp.read_poscar(source + os.sep + 'POSCAR')
    print('Structure: \n%s' % st)

    vi = pychemia.code.vasp.read_incar(source + os.sep + 'INCAR')
    print('VASP Input: \n%s' % vi)

    pq = pychemia.db.PyChemiaQueue()

    files = [source + os.sep + 'KPOINTS']
    entry_id = pq.new_entry(structure=st,
                            variables=vi,
                            code='vasp',
                            files=files)

    nfiles = pq.db.fs.files.count()
    print('Number of files: ', nfiles)

    pychemia.code.vasp.write_from_queue(pq, entry_id, destination)

    for i in os.listdir(source):
        assert hashfile(source + os.sep + i) == hashfile(destination + os.sep +
                                                         i)

    print('Files in source and destination are identical')

    print(
        'Adding the same entry again and testing that the number of files is unchanged'
    )
    entry_id = pq.new_entry(structure=st,
                            variables=vi,
                            code='vasp',
                            files=files)

    assert nfiles == pq.db.fs.files.count()
    print('The number of files remains the same ', nfiles)

    shutil.rmtree(destination)
示例#6
0
 def test_harmony(self):
     """
     Tests (pychemia.searcher.harmony) with LJ Clusters           :
     """
     if not has_connection():
         return
     pcm_log.debug('HarmonySearch')
     popu = LJCluster('test',
                      composition='Xe13',
                      refine=False,
                      direct_evaluation=True)
     popu.pcdb.clean()
     searcher = HarmonySearch(popu,
                              generation_size=8,
                              stabilization_limit=3)
     searcher.run()
     popu.pcdb.clean()
def test_queue():
    """
    Tests (pychemia.db.PyChemiaQueue)                            :
    """
    if not has_connection():
        return

    print("Testing PyChemiaQueue")

    source = 'tests/data/vasp_01'
    destination = tempfile.mkdtemp()
    print('Destination: %s' % destination)

    st = pychemia.code.vasp.read_poscar(source + os.sep + 'POSCAR')
    print('Structure: \n%s' % st)

    vi = pychemia.code.vasp.read_incar(source + os.sep + 'INCAR')
    print('VASP Input: \n%s' % vi)

    pq = pychemia.db.PyChemiaQueue()

    files = [source + os.sep + 'KPOINTS']
    entry_id = pq.new_entry(structure=st, variables=vi, code='vasp', files=files)

    nfiles = pq.db.fs.files.count()
    print('Number of files: ', nfiles)

    pychemia.code.vasp.write_from_queue(pq, entry_id, destination)

    for i in os.listdir(source):
        assert hashfile(source + os.sep + i) == hashfile(destination + os.sep + i)

    print('Files in source and destination are identical')

    print('Adding the same entry again and testing that the number of files is unchanged')
    entry_id = pq.new_entry(structure=st, variables=vi, code='vasp', files=files)

    assert nfiles == pq.db.fs.files.count()
    print('The number of files remains the same ', nfiles)

    shutil.rmtree(destination)