コード例 #1
0
ファイル: run_autotst.py プロジェクト: rvkmr1989/ARC
def main(reaction_label=None, reaction_family=None):
    """
    Run AutoTST to generate a TS guess
    Currently only works for H Abstraction
    """
    if has_auto_tst:
        if reaction_label is None:
            # Parse the command-line arguments (requires the argparse module)
            args = parse_command_line_arguments()
            reaction_label = str(args.reaction_label)
            reaction_family = str(args.reaction_family)
        reaction_family = str('H_Abstraction') if reaction_family is None else reaction_family

        try:
            reaction = AutoTST_Reaction(label=reaction_label, reaction_family=reaction_family)
        except AssertionError as e:
            logger.error('Could not generate a TS guess using AutoTST for reaction {0}'.format(reaction_label))
            raise TSError('Could not generate AutoTST guess:\n{0}'.format(e))
        else:
            positions = reaction.ts.ase_ts.get_positions()
            numbers = reaction.ts.ase_ts.get_atomic_numbers()
            xyz_guess = xyz_to_str(xyz_dict=xyz_from_data(coords=positions, numbers=numbers))

            xyz_path = os.path.join(arc_path, 'arc', 'ts', 'auto_tst.xyz')

            with open(xyz_path, 'w') as f:
                f.write(xyz_guess)
コード例 #2
0
ファイル: run_autotst.py プロジェクト: xiaoruiDong/ARC
def main():
    """
    Run AutoTST to generate a TS guess
    Currently only works for H Abstraction
    """
    # Parse the command-line arguments (requires the argparse module)
    args = parse_command_line_arguments()
    reaction_label = str(args.reaction_label)
    reaction_family = str(args.reaction_family)

    try:
        reaction = AutoTST_Reaction(label=reaction_label,
                                    reaction_family=reaction_family)
    except AssertionError:
        logging.error(
            'Could not generate a TS guess using AutoTST for reaction {0}'.
            format(reaction_label))
        raise TSError('Could not generate AutoTST guess')
    else:
        positions = reaction.ts.ase_ts.get_positions()
        numbers = reaction.ts.ase_ts.get_atomic_numbers()
        xyz_guess = get_xyz_string(coord=positions, number=numbers)

        xyz_path = os.path.join(arc_path, 'arc', 'ts', 'auto_tst.xyz')

        with open(xyz_path, 'wb') as f:
            f.write(xyz_guess)
コード例 #3
0
from autotst.geometry import Bond, Angle, Torsion
from ase.io.gaussian import read_gaussian_out

# To perform TS search
from ase.calculators.gaussian import Gaussian
from autotst.calculators.gaussian import AutoTST_Gaussian
from autotst.calculators.vibrational_analysis import Vibrational_Analysis, percent_change
from autotst.calculators.cantherm import AutoTST_CanTherm

# For conformer analysis
from ase.calculators.lj import LennardJones
from autotst.conformer.utilities import create_initial_population, select_top_population
from autotst.conformer.ga import perform_ga
from autotst.conformer.simple_es import perform_simple_es

test_reaction = AutoTST_Reaction("[CH]=CC=C+[O]O_[CH]=C[C]=C+OO",
                                 "H_Abstraction")

scratch_dir = "./gaussian_example"

### Performing the partial optimizations
tst_calculators = AutoTST_Gaussian(test_reaction,
                                   scratch=scratch_dir,
                                   save_directory=".")

kinetics = tst_calculators.read_kinetics_file()

if kinetics:
    logging.info("We have previously loaded kinetics:")
    logging.info("{0!r}".format(kinetics['reaction']))

else:
コード例 #4
0
ファイル: graph_reader.py プロジェクト: skrsna/nmp_qc
def xyz_graph_reader_ts(graph_file):
    with open(graph_file, 'rb') as f:
        na = int(f.readline())
        properties = f.readline()
        g, l = init_graph_ts(properties)
        atom_properties = []
        # Atoms properties
        for i in range(na):
            a_properties = f.readline()
            a_properties = a_properties.replace('.*^', 'e')
            a_properties = a_properties.replace('*^', 'e')
            a_properties = a_properties.split()
            atom_properties.append(a_properties)
        # rxn_string
        rxn_label = graph_file.split('/')[-1].split('.')[0]
        autotst_ts = AutoTST_Reaction(rxn_label, "H_Abstraction")
        rdkit_ts = autotst_ts.ts.rdkit_ts
        fdef_name = os.path.join(RDConfig.RDDataDir, 'BaseFeatures.fdef')
        factory = ChemicalFeatures.BuildFeatureFactory(fdef_name)
        feats = factory.GetFeaturesForMol(rdkit_ts)
        for i in range(0, rdkit_ts.GetNumAtoms()):
            atom_i = rdkit_ts.GetAtomWithIdx(i)

            g.add_node(
                i,
                a_type=atom_i.GetSymbol(),
                a_num=atom_i.GetAtomicNum(),
                acceptor=0,
                donor=0,
                aromatic=atom_i.GetIsAromatic(),
                hybridization=atom_i.GetHybridization(),
                num_h=atom_i.GetTotalNumHs(),
                coord=np.array(atom_properties[i][1:4]).astype(np.float),
            )

        for i in range(0, len(feats)):
            if feats[i].GetFamily() == 'Donor':
                node_list = feats[i].GetAtomIds()
                for i in node_list:
                    g.node[i]['donor'] = 1
            elif feats[i].GetFamily() == 'Acceptor':
                node_list = feats[i].GetAtomIds()
                for i in node_list:
                    g.node[i]['acceptor'] = 1

        # Read Edges
        for i in range(0, rdkit_ts.GetNumAtoms()):
            for j in range(0, rdkit_ts.GetNumAtoms()):
                e_ij = rdkit_ts.GetBondBetweenAtoms(i, j)
                if e_ij is not None:
                    g.add_edge(i,
                               j,
                               b_type=e_ij.GetBondType(),
                               distance=np.linalg.norm(g.node[i]['coord'] -
                                                       g.node[j]['coord']))

                else:
                    # Unbonded
                    g.add_edge(i,
                               j,
                               b_type=None,
                               distance=np.linalg.norm(g.node[i]['coord'] -
                                                       g.node[j]['coord']))
    return g, l