How to use the pymars.sampling.sample 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 / drgep.py View on Github external
path : str, optional
        Optional path for writing files

    Returns
    -------
    ReducedModel
        Return reduced model and associated metadata
    
    """
    solution = ct.Solution(model_file, phase_name)
    assert species_targets, 'Need to specify at least one target species.'

    # first, sample thermochemical data and generate metrics for measuring error
    # (e.g, ignition delays). Also produce adjacency matrices for graphs, which
    # will be used to produce graphs for any threshold value.
    sampled_metrics, sampled_data = sample(
        model_file, ignition_conditions, phase_name=phase_name, num_threads=num_threads, path=path
        )
    
    matrices = []
    for state in sampled_data:
        matrices.append(create_drgep_matrix((state[0], state[1], state[2:]), solution))

    # For DRGEP, find the overall interaction coefficients for all species 
    # using the maximum over all the sampled states
    importance_coeffs = get_importance_coeffs(
        solution.species_names, species_targets, matrices
        )

    # begin reduction iterations
    logging.info('Beginning DRGEP reduction loop')
    logging.info(45 * '-')
github Niemeyer-Research-Group / pyMARS / pymars / pfa.py View on Github external
Optional path for writing files

    Returns
    -------
    ReducedModel
        Return reduced model and associated metadata

    """
    solution = ct.Solution(model_file)

    assert species_targets, 'Need to specify at least one target species.'

    # first, sample thermochemical data and generate metrics for measuring error
    # (e.g, ignition delays). Also produce adjacency matrices for graphs, which
    # will be used to produce graphs for any threshold value.
    sampled_metrics, sampled_data = sample(
        model_file, ignition_conditions, num_threads=num_threads, path=path
        )

    matrices = []
    for state in sampled_data:
        matrices.append(create_pfa_matrix((state[0], state[1], state[2:]), solution))

    # begin reduction iterations
    logging.info('Beginning PFA reduction loop')
    logging.info(45 * '-')
    logging.info('Threshold | Number of species | Max error (%)')

    # start with detailed (starting) model
    previous_model = ReducedModel(model=solution, filename=model_file, error=0.0)

    first = True
github Niemeyer-Research-Group / pyMARS / pymars / drg.py View on Github external
Optional path for writing files

    Returns
    -------
    ReducedModel
        Return reduced model and associated metadata

    """
    solution = ct.Solution(model_file)

    assert species_targets, 'Need to specify at least one target species.'

    # first, sample thermochemical data and generate metrics for measuring error
    # (e.g, ignition delays). Also produce adjacency matrices for graphs, which
    # will be used to produce graphs for any threshold value.
    sampled_metrics, sampled_data = sample(
        model_file, ignition_conditions, num_threads=num_threads, path=path
        )

    matrices = []
    for state in sampled_data:
        matrices.append(create_drg_matrix((state[0], state[1], state[2:]), solution))

    # begin reduction iterations
    logging.info('Beginning DRG reduction loop')
    logging.info(45 * '-')
    logging.info('Threshold | Number of species | Max error (%)')

    # start with detailed (starting) model
    previous_model = ReducedModel(model=solution, filename=model_file, error=0.0)

    first = True