コード例 #1
0
ファイル: gaussian.py プロジェクト: cathedralpkg/TorsiFlex
def read_gaussian_log(filename,target_level=None):
    '''
    xcc,gcc,Fcc and symbols --> returned without dummy atoms
    '''
    if not os.path.exists(filename): return
    # split lines into blocks (in case of Link1)
    blocks = split_gaulog_into_gaublocks(filename)
    # Get info of each block
    data = [get_data_from_gaublock(block) for block in blocks]
    # There is nothing to return
    if data == []: return [None]*12
    # Localize data with hessian matrix
    IDX = -1
    for idx,data_i in enumerate(data):
        Fcc =  data_i[7]
        if Fcc is not None:
           IDX = idx
           break
    # Return the best set of data (the last with the hessian or the last block)
    commands,comment,ch,mtp,symbols,xcc,gcc,Fcc,energies,E_oniom,num_imag,zmat = data[IDX]
    # Recalculating xcc from z-matrix (do not trust the orientation read from output)
    if zmat is not None:
       (lzmat,zmatvals,zmatatoms),symbols = convert_zmat(zmat)
       xcc = zmat2xcc(lzmat,zmatvals)
    # Correct symbols (just in case)
    symbols,atonums = symbols_and_atonums(symbols)
    # Remove dummies from xcc, gcc and Fcc!
    if xcc is not None: xcc = clean_dummies(symbols,xcc=xcc)[1]
    if gcc is not None: gcc = clean_dummies(symbols,gcc=gcc)[1]
    if Fcc is not None: Fcc = clean_dummies(symbols,Fcc=Fcc)[1]
    symbols = clean_dummies(symbols)

    # If user does not ask for level, send one of lowest energy
    if target_level is None:
       energies.sort()
       energy,level = energies[0]
    else:
       IDX = None
       exception = Exc.LevelNotFound()
       exception._var = target_level
       for idx,(energy,level) in enumerate(energies):
           if level.lower() == target_level.lower():
               IDX = idx
               break
       if IDX is None: raise exception
       energy, level = energies[IDX]
    # oniom?
    if E_oniom is not None:
       energy = E_oniom
       level  = "ONIOM"
    # Return data
    return commands,comment,ch,mtp,symbols,xcc,gcc,Fcc,energy,num_imag,zmat,level
コード例 #2
0
def read_gaussian_log(filename, target_level=None):
    if not os.path.exists(filename): return
    # split lines into blocks (in case of Link1)
    blocks = split_gaulog_into_gaublocks(filename)
    # Get info of each block
    data = [get_data_from_gaublock(block) for block in blocks]
    # There is nothing to return
    if data == []: return [None] * 12
    # Localize data with hessian matrix
    IDX = -1
    for idx, data_i in enumerate(data):
        Fcc = data_i[7]
        if Fcc is not None:
            IDX = idx
            break
    # Return the best set of data (the last with the hessian or the last block)
    commands, comment, ch, mtp, symbols, xcc, gcc, Fcc, energies, E_oniom, num_imag, zmat = data[
        IDX]
    # If user does not ask for level, send one of lowest energy
    if target_level is None:
        energies.sort()
        energy, level = energies[0]
    else:
        IDX = None
        exception = Exc.LevelNotFound()
        exception._var = target_level
        for idx, (energy, level) in enumerate(energies):
            if level.lower() == target_level.lower():
                IDX = idx
                break
        if IDX is None: raise exception
        energy, level = energies[IDX]
    # oniom?
    if E_oniom is not None:
        energy = E_oniom
        level = "ONIOM"
    # Return data
    return commands, comment, ch, mtp, symbols, xcc, gcc, Fcc, energy, num_imag, zmat, level