def execute(input_model_files, **kwargs): try: wd = kwargs['wd'] except KeyError: wd = os.getcwd() transport = kwargs['transport'] output_chemkin_file = os.path.join(wd, 'chem.inp') output_species_dictionary = os.path.join(wd, 'species_dictionary.txt') output_transport_file = os.path.join(wd, 'tran.dat') if transport else None models = get_models_to_merge(input_model_files) final_model = combine_models(models) # Save the merged model to disk save_chemkin_file(output_chemkin_file, final_model.species, final_model.reactions) save_species_dictionary(output_species_dictionary, final_model.species) if transport: save_transport_file(output_transport_file, final_model.species) print('Merged Chemkin file saved to {0}'.format(output_chemkin_file)) print('Merged species dictionary saved to {0}'.format( output_species_dictionary)) if transport: print( 'Merged transport file saved to {0}'.format(output_transport_file))
def test_transport_data_read_and_write(self): """ Test that we can write to chemkin and recreate the same transport object """ Ar = Species(label="Ar", transport_data=TransportData( shapeIndex=0, epsilon=(1134.93, 'J/mol'), sigma=(3.33, 'angstrom'), dipoleMoment=(0, 'De'), polarizability=(0, 'angstrom^3'), rotrelaxcollnum=0.0, comment="""GRI-Mech""")) Ar_write = Species(label="Ar") folder = os.path.join(os.path.dirname(rmgpy.__file__), 'test_data') temp_transport_path = os.path.join(folder, 'tran_temp.dat') save_transport_file(temp_transport_path, [Ar]) species_dict = {'Ar': Ar_write} load_transport_file(temp_transport_path, species_dict) self.assertEqual(repr(Ar), repr(Ar_write)) os.remove(temp_transport_path)