示例#1
0
 def _load_old_reactions(self, path, species):
     """
     Load an old-style reaction library from `path`. This algorithm can
     handle both the pressure-independent and pressure-dependent reaction
     files. If the pressure-dependent file is read, the extra pressure-
     dependent kinetics information is ignored unless the kinetics database
     is a seed mechanism.
     """
     from rmgpy.chemkin import read_reactions_block
     f = open(path, 'r')
     reaction_list = read_reactions_block(f, species_dict=species)
     f.close()
     return reaction_list
示例#2
0
    def test_pdep_job(self):
        """
        A general test for a PDep job in Arkane
        """
        self.tst1 = Arkane()
        self.tst1.input_file = self.input_file
        self.tst1.output_directory = self.directory
        self.tst1.verbose = logging.WARN
        self.tst1.plot = False
        self.tst1.job_list = []
        self.tst1.job_list = self.tst1.load_input_file(self.tst1.input_file)
        self.tst1.execute()

        job = self.tst1.job_list[0]
        self.assertEquals(job.Tmin.value_si, 300.0)
        self.assertEquals(job.minimum_grain_count, 100)
        self.assertFalse(job.rmgmode)
        self.assertTrue(job.active_j_rotor)
        self.assertEquals(job.network.path_reactions[0].label, 'acetylperoxy <=> hydroperoxylvinoxy')
        self.assertAlmostEquals(job.network.path_reactions[0].transition_state.tunneling.E0_TS.value_si, -24267.2)
        self.assertAlmostEquals(job.network.path_reactions[0].transition_state.tunneling.frequency.value_si, -1679.04)
        self.assertEquals(len(job.network.net_reactions[0].reactants[0].conformer.modes), 6)
        # self.assertEquals(self.tst1.frequencyScaleFactor, 0.947)

        # test that a network pdf was generated
        files = [f for f in os.listdir(self.directory) if os.path.isfile(os.path.join(self.directory, f))]
        self.assertTrue(any(f == 'network.pdf' for f in files))

        # Test the generated network reaction
        dictionary = {'hydroperoxylvinoxy': Species().from_smiles('[CH2]C(=O)OO'),
                      'acetylperoxy': Species().from_smiles('CC(=O)O[O]')}
        with open(os.path.join(self.directory, 'chem.inp'), 'r') as chem:
            reaction_list = read_reactions_block(chem, dictionary)
        rxn = reaction_list[0]
        self.assertIsInstance(rxn.kinetics, Chebyshev)
        # Accept a delta of 0.2, which could result from numerical discrepancies
        # See RMG-Py #1682 on GitHub for discussion
        self.assertAlmostEquals(rxn.kinetics.get_rate_coefficient(1000.0, 1.0), 88.88253229631246, delta=0.2)

        files = [f for f in os.listdir(os.path.join(self.directory, 'sensitivity', ''))
                 if os.path.isfile(os.path.join(self.directory, 'sensitivity', f))]
        self.assertTrue(any('hydroperoxylvinoxy.pdf' in f for f in files))

        with open(os.path.join(self.directory, 'sensitivity', 'network1.txt'), 'r') as f:
            lines = f.readlines()
            for line in lines:
                if '1000.0' in line:
                    break
        sa_coeff = line.split()[-2]
        self.assertAlmostEquals(float(sa_coeff), -8.23e-6, delta=0.02e-6)