How to use the pymars.soln2ck.write function in pymars

To help you get started, we’ve selected a few pymars examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Niemeyer-Research-Group / pyMARS / pymars / tools.py View on Github external
>>> convert('gri30.cti')
    [gri30.inp, gri30_thermo.dat, gri30_transport.dat]

    """
    # check whether Chemkin or Cantera model
    basename = os.path.splitext(os.path.basename(model_file))[0]
    extension = os.path.splitext(os.path.basename(model_file))[1]

    # Chemkin files can have multiple extensions, so easier to check if Cantera
    if extension == '.cti':
        # Convert from Cantera to Chemkin format.
        logging.info('Converter detected Cantera input model: ' + model_file)
        logging.info('Converting to Chemkin format.')

        solution = ct.Solution(model_file)
        converted_files = soln2ck.write(solution, basename + '.inp', path=path)
        return converted_files
    else:
        # Convert from Chemkin to Cantera format.
        logging.info('Converter detected Chemkin input model: ' + model_file)
        logging.info('Converting to Cantera format.')

        converted_file = os.path.join(path, basename + '.cti')

        # calls ck2cti based on given files
        args = [f'--input={model_file}']
        if thermo_file:
            args.append(f'--thermo={thermo_file}')
        if transport_file:
            args.append(f'--transport={transport_file}')
        args.append(f'--output={converted_file}')