def test__polynomial(): """ test pac99_io.reader.__ """ pac99_poly = pac99_io.reader.nasa_polynomial(OUT_STR) assert pac99_poly == read_text_file(['data'], 'pac99_poly.dat') name = 'mol' atom_dct = {'C': 2, 'H': 4, 'N': 2, 'O': 6} ckin_poly = pac99_io.pac2ckin_poly(name, atom_dct, pac99_poly) assert ckin_poly == read_text_file(['data'], 'ckin_poly.dat')
def test__convert(): """ test pac99_io._convert.pac2ckin_poly """ ckin_poly = pac2ckin_poly(name, atom_dict, comment_str, pac_poly_str): ref_ckin_poly = """ """ assert ckin_poly == ref_ckin_poly
def test__polynomial(): """ test pac99_io.reader.nasa_polynomial test pac99_io._convert.pac3ckin_poly """ # Read and Convert C2H4N2O6 out_str = pathtools.read_file(DAT_PATH, 'C2H4N2O6.c97') pac99_poly = pac99_io.reader.nasa_polynomial(out_str) assert pac99_poly == (pathtools.read_file(DAT_PATH, 'C2H4N2O6.paccpoly').rstrip()) name = 'C2H4N2O6' atom_dct = {'C': 2, 'H': 4, 'N': 2, 'O': 6} ckin_poly = pac99_io.pac2ckin_poly(name, atom_dct, pac99_poly) assert ckin_poly == pathtools.read_file(DAT_PATH, 'C2H4N2O6.ckinpoly') # Read and Convert CO out_str = pathtools.read_file(DAT_PATH, 'CO.c97') pac99_poly = pac99_io.reader.nasa_polynomial(out_str) assert pac99_poly == (pathtools.read_file(DAT_PATH, 'CO.paccpoly')).rstrip() name = 'CO' atom_dct = {'C': 1, 'O': 1} ckin_poly = pac99_io.pac2ckin_poly(name, atom_dct, pac99_poly) assert ckin_poly == pathtools.read_file(DAT_PATH, 'CO.ckinpoly') # Read and Convert H2 out_str = pathtools.read_file(DAT_PATH, 'H2.c97') pac99_poly = pac99_io.reader.nasa_polynomial(out_str) assert pac99_poly == (pathtools.read_file(DAT_PATH, 'H2.paccpoly')).rstrip() name = 'H2' atom_dct = {'H': 2} ckin_poly = pac99_io.pac2ckin_poly(name, atom_dct, pac99_poly) assert ckin_poly == pathtools.read_file(DAT_PATH, 'H2.ckinpoly')
def build_polynomial(spc_name, spc_dct, temps, pf_path, nasa_path, starting_path): """ Build a nasa polynomial """ print('Generating NASA polynomials at path: {}'.format(nasa_path)) # Generate forumula spc_dct_i = spc_dct[spc_name] formula = automol.inchi.formula_string(spc_dct_i['inchi']) formula_dct = automol.inchi.formula(spc_dct_i['inchi']) hform0 = spc_dct_i['Hfs'][0] # Go to NASA path if not os.path.exists(nasa_path): os.makedirs(nasa_path) pathtools.go_to(nasa_path) # Write and run ThermP to get the Hf298K and coefficients write_thermp_inp(formula, hform0, temps) pfrunner.run_thermp(pf_path, nasa_path) thermp_out_str = pathtools.read_file(nasa_path, 'thermp.out') hform298 = thermp_io.reader.hf298k(thermp_out_str) # Run PAC99 to get a NASA polynomial string in its format pfrunner.run_pac(formula, nasa_path) c97_file = pathtools.prepare_path(nasa_path, formula + '.c97') with open(c97_file, 'r') as file_obj: pac99_out_str = file_obj.read() # pac99_out_str = pathtools.read_file(o97_file) pac99_poly_str = pac99_io.reader.nasa_polynomial(pac99_out_str) # Obtain CHEMKIN string using PAC99 polynomial ckin_poly_str = pac99_io.pac2ckin_poly( spc_name, formula_dct, pac99_poly_str) # Write the full CHEMKIN strings header_str = '\n' nasa_str = writer.ckin.nasa_polynomial(hform0, hform298, ckin_poly_str) full_ckin_str = header_str + nasa_str print('\nCHEMKIN Polynomial:') print(full_ckin_str) # Go back to starting path pathtools.go_to(starting_path) return full_ckin_str