Example #1
0
def create_engine(enginename, inputfile=None, work_queue_port=None, native_opt=False, extra_constraints=None):
    """
    Function to create a QM Engine object with work_queue and geomeTRIC setup.
    This is intentionally left outside of DihedralScanner class, because multiple DihedralScanner could share the same engine
    """
    engine_dict = {'psi4': EnginePsi4, 'qchem': EngineQChem, 'terachem':EngineTerachem, 'openmm': EngineOpenMM, "gaussian": EngineGaussian}
    # initialize a work_queue
    if work_queue_port is not None:
        from torsiondrive.wq_tools import WorkQueue
        work_queue = WorkQueue(work_queue_port)
    else:
        work_queue = None
    # Check the engine, if OpenMM we can not use a native_opt
    if enginename == 'openmm':
        assert native_opt is False, "OpenMM engine does not support native optimizer"
    if enginename == "gaussian":
        if shutil.which("g16") is not None:
            gaussian_exe = "g16"
        elif shutil.which("g09") is not None:
            gaussian_exe = "g09"
        else:
            raise RuntimeError("Neither of g16 or g09 is found, please check your environment.")
        engine = EngineGaussian(input_file=inputfile, work_queue=work_queue, native_opt=native_opt, extra_constraints=extra_constraints, exe=gaussian_exe)
    else:
        engine = engine_dict[enginename](inputfile, work_queue, native_opt=native_opt, extra_constraints=extra_constraints)
    return engine
Example #2
0
def create_engine(enginename,
                  inputfile=None,
                  work_queue_port=None,
                  native_opt=False,
                  extra_constraints=None):
    """
    Function to create a QM Engine object with work_queue and geomeTRIC setup.
    This is intentionally left outside of DihedralScanner class, because multiple DihedralScanner could share the same engine
    """
    engine_dict = {
        'psi4': EnginePsi4,
        'qchem': EngineQChem,
        'terachem': EngineTerachem,
        'openmm': EngineOpenMM
    }
    # initialize a work_queue
    if work_queue_port is not None:
        from torsiondrive.wq_tools import WorkQueue
        work_queue = WorkQueue(work_queue_port)
    else:
        work_queue = None
    # Check the engine, if OpenMM we can not use a native_opt
    if enginename == 'openmm':
        assert native_opt is False, "OpenMM engine does not support native optimizer"
    engine = engine_dict[enginename](inputfile,
                                     work_queue,
                                     native_opt=native_opt,
                                     extra_constraints=extra_constraints)
    return engine
Example #3
0
def test_work_queue():
    from torsiondrive.wq_tools import WorkQueue
    wq = WorkQueue(56789)
    wq.submit('echo test > test.txt', [], ['test.txt'])
    assert wq.get_queue_status() == (0,0,0,1)
    # submit a worker
    p = subprocess.Popen("$HOME/opt/cctools/bin/work_queue_worker localhost 56789 -t 1", shell=True, stderr=subprocess.DEVNULL)
    for _ in range(10):
        path = wq.check_finished_task_path()
        if path is not None:
            assert path == os.getcwd()
            break
    wq.print_queue_status()
    p.terminate()
    assert os.path.isfile('test.txt')
    assert open('test.txt').read().strip() == 'test'
    os.unlink('test.txt')