def setUp(cls): """A method that is run before each unit test in this class""" arkane = Arkane() job_list = arkane.load_input_file( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'methoxy.py')) pdepjob = job_list[-1] cls.kineticsjob = job_list[0] pdepjob.active_j_rotor = True network = pdepjob.network cls.Nisom = len(network.isomers) cls.Nreac = len(network.reactants) cls.Nprod = len(network.products) cls.Npath = len(network.path_reactions) cls.PathReaction2 = network.path_reactions[2] cls.TminValue = pdepjob.Tmin.value cls.Tmaxvalue = pdepjob.Tmax.value cls.TmaxUnits = pdepjob.Tmax.units cls.TlistValue = pdepjob.Tlist.value cls.PminValue = pdepjob.Pmin.value cls.Pcount = pdepjob.Pcount cls.Tcount = pdepjob.Tcount cls.GenTlist = pdepjob.generate_T_list() cls.PlistValue = pdepjob.Plist.value cls.maximum_grain_size_value = pdepjob.maximum_grain_size.value cls.method = pdepjob.method cls.rmgmode = pdepjob.rmgmode
def setUp(self): arkane = Arkane() jobList = arkane.loadInputFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'methoxy.py')) pdepjob = jobList[-1] self.kineticsjob = jobList[0] pdepjob.activeJRotor = True network = pdepjob.network self.Nisom = len(network.isomers) self.Nreac = len(network.reactants) self.Nprod = len(network.products) self.Npath = len(network.pathReactions) self.PathReaction2 = network.pathReactions[2] self.TminValue = pdepjob.Tmin.value self.Tmaxvalue = pdepjob.Tmax.value self.TmaxUnits = pdepjob.Tmax.units self.TlistValue = pdepjob.Tlist.value self.PminValue = pdepjob.Pmin.value self.Pcount = pdepjob.Pcount self.Tcount = pdepjob.Tcount self.GenTlist = pdepjob.generateTemperatureList() self.PlistValue = pdepjob.Plist.value self.maximumGrainSizeValue = pdepjob.maximumGrainSize.value self.method = pdepjob.method self.rmgmode = pdepjob.rmgmode
def test_arkane_two_parameter_arrhenius_fit(self): test_path = os.path.join(self.test_base_path, 'two_parameter_arrhenius_fit') file_to_remove = [ 'output.py', 'chem.inp', 'supporting_information.csv' ] for file in file_to_remove: if os.path.exists(os.path.join(test_path, file)): os.remove(os.path.join(test_path, file)) arkane = Arkane(input_file=os.path.join(test_path, 'input.py'), output_directory=test_path) arkane.plot = False arkane.save_rmg_libraries = False arkane.execute() with open(os.path.join(test_path, 'output.py'), 'r') as f: output = f.readlines() reverse_output = output[::-1] for i, line in enumerate(reverse_output): if 'kinetics fitted using' in line: msg_output = line.rstrip() n_output = reverse_output[i - 5].split('=')[1].strip().replace( ',', '') break msg_expected = '# kinetics fitted using the two-parameter Arrhenius equation k = A * exp(-Ea/RT)' self.assertEqual(msg_output, msg_expected) n_expected = '0' self.assertEqual(n_output, n_expected)
def setUpClass(cls): arkane = Arkane() cls.jobList = arkane.loadInputFile(os.path.join(os.path.dirname(os.path.abspath(__file__)),'data','methoxy_explore.py')) for job in cls.jobList: if not isinstance(job,ExplorerJob): job.execute(outputFile=None, plot=None) else: thermoLibrary,kineticsLibrary,speciesList = arkane.getLibraries() job.execute(outputFile=None, plot=None, speciesList=speciesList, thermoLibrary=thermoLibrary, kineticsLibrary=kineticsLibrary) cls.thermoLibrary = thermoLibrary cls.kineticsLibrary = kineticsLibrary cls.explorerjob = cls.jobList[-1] cls.pdepjob = cls.jobList[-2]
def setUpClass(cls): """A method that is run before each unit test in this class""" arkane = Arkane() cls.job_list = arkane.load_input_file( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'methoxy_explore.py')) for job in cls.job_list: if not isinstance(job, ExplorerJob): job.execute(output_file=None, plot=None) else: thermo_library, kinetics_library, species_list = arkane.get_libraries() job.execute(output_file=None, plot=None, thermo_library=thermo_library, kinetics_library=kinetics_library) cls.thermo_library = thermo_library cls.kinetics_library = kinetics_library cls.explorer_job = cls.job_list[-1] cls.pdep_job = cls.job_list[-2]
def setUpClass(cls): """ A method that is run ONCE before all unit tests in this class. """ cls.arkane = Arkane() path = os.path.join(os.path.dirname(os.path.dirname(rmgpy.__file__)), 'examples', 'arkane', 'species') cls.dump_path = os.path.join(path, 'C2H6') cls.dump_input_path = os.path.join(cls.dump_path, 'input.py') cls.dump_output_file = os.path.join(cls.dump_path, 'output.py') cls.dump_yaml_file = os.path.join(cls.dump_path, 'species', 'C2H6.yml') cls.load_path = os.path.join(path, 'C2H6_from_yaml') cls.load_input_path = os.path.join(cls.load_path, 'input.py') cls.load_output_file = os.path.join(cls.load_path, 'output.py') if os.path.exists(cls.dump_yaml_file): logging.debug('removing existing yaml file {0} before running tests'.format(cls.dump_yaml_file)) os.remove(cls.dump_yaml_file)
def test_arkane_examples(self): for example_type in self.example_types: example_type_path = os.path.join(self.base_path, example_type) for example in os.listdir(example_type_path): path = os.path.join(example_type_path, example) arkane = Arkane(inputFile=os.path.join(path, 'input.py'), outputDirectory=path) arkane.plot = True arkane.execute() with open(os.path.join(path, 'arkane.log'), 'r') as f: log = f.readlines() for line in log[::-1]: if 'execution terminated' in line: break else: self.failed.append([example_type, example]) error_message = 'Arkane example(s) failed: ' for example_type, example_name in self.failed: error_message += '{1} in {0}; '.format(example_name, example_type) self.assertFalse(self.failed, error_message)
def test_arkane_examples(self): for example_type in self.example_types: example_type_path = os.path.join(self.base_path, example_type) for example in sorted(os.listdir(example_type_path)): path = os.path.join(example_type_path, example) arkane = Arkane(input_file=os.path.join(path, 'input.py'), output_directory=path) arkane.plot = example_type != 'bac' # Don't plot BAC examples because they require a lot of memory logging.info("running {}".format(example)) arkane.execute() with open(os.path.join(path, 'arkane.log'), 'r') as f: log = f.readlines() for line in log[::-1]: if 'execution terminated' in line: break else: self.failed.append([example_type, example]) error_message = 'Arkane example(s) failed: ' for example_type, example_name in self.failed: error_message += '{1} in {0}; '.format(example_name, example_type) self.assertFalse(self.failed, error_message)
def setUp(cls): """A method that is run before each unit test in this class""" arkane = Arkane() cls.job_list = arkane.load_input_file( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'Benzyl', 'input.py'))
def setUp(self): arkane = Arkane() self.job_list = arkane.loadInputFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'Benzyl', 'input.py'))