Exemplo n.º 1
0
def main():
    M = Molecule(argv[1])
    tempfnm = argv[3] if len(argv) >= 4 else None    
    if tempfnm != None:
        M.add_quantum(tempfnm)
    print M.Data.keys()
    M.write(argv[2])
Exemplo n.º 2
0
def main():
    M = Molecule(argv[1])
    tempfnm = argv[3] if len(argv) >= 4 else None
    if tempfnm != None:
        M.add_quantum(tempfnm)
    print M.Data.keys()
    M.write(argv[2])
Exemplo n.º 3
0
def do_quantum(wq_port):
    M = Molecule('shots.gro')
    M.add_quantum('../settings/qchem.in')
    # Special hack to add TIP3P waters.
    if os.path.exists('waters.gro'):
        print("Found waters.gro, loading as external waters and adding SPC charges.")
        Mext = Molecule('waters.gro')
        Q = col([-0.82 if (i%3==0) else 0.41 for i in range(Mext.na)])
        Qext = [np.hstack((xyz, Q)) for xyz in Mext.xyzs]
        M.qm_extchgs = Qext
    # End special hack.
    digits = len(str(len(M)-1))
    formstr = '\"%%0%ii\"' % digits

    def read_quantum():
        Result = None
        os.chdir('calcs')
        for i in range(M.ns):
            dnm = eval(formstr % i)
            print("\rNow in directory %i" % i, end=' ')
            if os.path.exists(dnm):
                os.chdir(dnm)
                if os.path.exists('qchem.out'):
                    Output = Molecule('qchem.out')
                    if os.path.exists('plot.esp'):
                        ESP = Molecule('plot.esp')
                        #print ESP.Data.keys()
                        Output.qm_espxyzs = list(ESP.qm_espxyzs)
                        Output.qm_espvals = list(ESP.qm_espvals)
                        #Output += Molecule('plot.esp')
                    if Result == None:
                        Result = Output
                    else:
                        Result += Output
                else:
                    raise Exception("The output file %s doesn't exist." % os.path.abspath('qchem.out'))
                os.chdir('..')
            else:
                raise Exception("The subdirectory %s doesn't exist." % os.path.abspath(dnm))
        os.chdir('..')
        return Result
    
    def run_quantum():
        ESP = create_esp_surfaces(M)
        work_queue.set_debug_flag('all')
        wq = work_queue.WorkQueue(wq_port, exclusive=False, shutdown=False)
        wq.specify_name('forcebalance')
        os.makedirs('calcs')
        os.chdir('calcs')
        for i in range(M.ns):
            dnm = eval(formstr % i)
            os.makedirs(dnm)
            os.chdir(dnm)
            M.edit_qcrems({'igdesp':len(ESP[i])})
            M.write("qchem.in", select=i)
            ESPBohr = np.array(ESP[i]) / bohr2ang
            np.savetxt('ESPGrid',ESPBohr)
            print("Queueing up job", dnm)
            queue_up(wq, command = 'qchem40 qchem.in qchem.out', 
                     input_files = ["qchem.in", "ESPGrid"],
                     output_files = ["qchem.out", "plot.esp", "efield.dat"], verbose=False)
            os.chdir('..')
        for i in range(M.ns):
            wq_wait(wq)
        os.chdir('..')
    if os.path.exists('calcs'):
        print("calcs directory exists.  Reading calculation results.")
        Result = read_quantum()
    else:
        print("calcs directory doesn't exist.  Setting up and running calculations.")
        run_quantum()
        print("Now reading calculation results.")
        Result = read_quantum()
    print("Writing results to qdata.txt.")
    Result.write('qdata.txt')
    return Result