pymars/pymars.py
def main(model_file, error_limit, 
         ignition_conditions, psr_conditions=[], flame_conditions=[],
         method=None, target_species=[], safe_species=[], phase_name='',
         run_sensitivity_analysis=False, upper_threshold=None, sensitivity_type='greedy',
         path='', num_threads=1
         ):
    """Driver function for reducing a chemical kinetic model.

    Parameters
    ----------
    model_file : str
        Cantera-format model to be reduced (e.g., 'mech.cti').
    error_limit : float
        Maximum error percentage for the reduced model.
    ignition_conditions : list of InputIgnition
        List of autoignition initial conditions.
    psr_conditions : list of InputPSR, optional
        List of PSR simulation conditions.
    flame_conditions : list of InputLaminarFlame, optional
        List of laminar flame simulation conditions.
    method : {'DRG', 'DRGEP', 'PFA'}, optional
        Skeletal reduction method to use.
    target_species: list of str, optional
        List of target species for graph-based reduction.
    safe_species : list of str, optional
        List of non-target species to always retain.
    phase_name : str, optional
        Optional name for phase to load from CTI file (e.g., 'gas'). 
    run_sensitivity_analysis : bool, optional
        Flag to run sensitivity analysis after completing another method.
    upper_threshold : float, optional
        Upper threshold (epsilon^*) used to determine species for sensitivity analysis 
        in combination with DRG or DRGEP method
    sensitivity_type : {'initial', 'greedy'}, optional
        Type of sensitivity analysis
    path : str
        Path to directory for writing files
    num_threads : int, optional
        Number of CPU threads to use for performing simulations in parallel.
        Optional; default = 1, in which the multiprocessing module is not used.
        If 0, then use the available number of cores minus one. Otherwise,
        use the specified number of threads.

    """

    if method in ['DRG', 'DRGEP', 'PFA']:
        assert target_species, (
            'Need to specify at least one target species for graph-based reduction methods'
            )
    
    if not method and not run_sensitivity_analysis:
        raise ValueError(
            'Either a graph-based method or sensitivity analysis (or both) must be specified.'
            )
    
    if method == 'DRG':
        reduced_model = run_drg(
            model_file, ignition_conditions, psr_conditions, flame_conditions,
            error_limit, target_species, safe_species, phase_name=phase_name,
            threshold_upper=upper_threshold, num_threads=num_threads, path=path
            )    
    elif method == 'DRGEP':
        reduced_model = run_drgep(
            model_file, ignition_conditions, psr_conditions, flame_conditions, 
            error_limit, target_species, safe_species, phase_name=phase_name,
            threshold_upper=upper_threshold, num_threads=num_threads, path=path
            )
    elif method == 'PFA':
        reduced_model = run_pfa(
            model_file, ignition_conditions, psr_conditions, flame_conditions,
            error_limit, target_species, safe_species, phase_name=phase_name,
            num_threads=num_threads, path=path
            )
    
    error = 0.0
    limbo_species = []
    if method in ['DRG', 'DRGEP', 'PFA']:
        model_file = reduced_model.filename
        error = reduced_model.error
        limbo_species = reduced_model.limbo_species

    if run_sensitivity_analysis:
        if not sensitivity_type:
            sensitivity_type = 'greedy'

        reduced_model = run_sa(
            model_file, error, ignition_conditions, psr_conditions, flame_conditions, 
            error_limit, target_species + safe_species, phase_name=phase_name,
            algorithm_type=sensitivity_type, species_limbo=limbo_species, 
            num_threads=num_threads, path=path
            )
   
    return reduced_model
Driver function for reducing a chemical kinetic model.

    Parameters
    ----------
    model_file : str
        Cantera-format model to be reduced (e.g., 'mech.cti').
    error_limit : float
        Maximum error percentage for the reduced model.
    ignition_conditions : list of InputIgnition
        List of autoignition initial conditions.
    psr_conditions : list of InputPSR, optional
        List of PSR simulation conditions.
    flame_conditions : list of InputLaminarFlame, optional
        List of laminar flame simulation conditions.
    method : {'DRG', 'DRGEP', 'PFA'}, optional
        Skeletal reduction method to use.
    target_species: list of str, optional
        List of target species for graph-based reduction.
    safe_species : list of str, optional
        List of non-target species to always retain.
    phase_name : str, optional
        Optional name for phase to load from CTI file (e.g., 'gas'). 
    run_sensitivity_analysis : bool, optional
        Flag to run sensitivity analysis after completing another method.
    upper_threshold : float, optional
        Upper threshold (epsilon^*) used to determine species for sensitivity analysis 
        in combination with DRG or DRGEP method
    sensitivity_type : {'initial', 'greedy'}, optional
        Type of sensitivity analysis
    path : str
        Path to directory for writing files
    num_threads : int, optional
        Number of CPU threads to use for performing simulations in parallel.
        Optional; default = 1, in which the multiprocessing module is not used.
        If 0, then use the available number of cores minus one. Otherwise,
        use the specified number of threads.

    
Driver function for reducing a chemical kinetic model.
Parameters

model_file : str
Cantera-format model to be reduced .
error_limit : float
Maximum error percentage for the reduced model.
ignition_conditions : list of InputIgnition
List of autoignition initial conditions.
psr_conditions : list of InputPSR, optional
List of PSR simulation conditions.
flame_conditions : list of InputLaminarFlame, optional
List of laminar flame simulation conditions.
Driver function for reducing a chemical kinetic model . Parameters model_file : str Cantera - format model to be reduced . error_limit : float Maximum error percentage for the reduced model . ignition_conditions : list of InputIgnition List of autoignition initial conditions . psr_conditions : list of InputPSR optional List of PSR simulation conditions . flame_conditions : list of InputLaminarFlame optional List of laminar flame simulation conditions .
def main(model_file, error_limit, 
         ignition_conditions, psr_conditions=[], flame_conditions=[],
         method=None, target_species=[], safe_species=[], phase_name='',
         run_sensitivity_analysis=False, upper_threshold=None, sensitivity_type='greedy',
         path='', num_threads=1
         ):
    if method in ['DRG', 'DRGEP', 'PFA']:
        assert target_species, (
            'Need to specify at least one target species for graph-based reduction methods'
            )
    if not method and not run_sensitivity_analysis:
        raise ValueError(
            'Either a graph-based method or sensitivity analysis (or both) must be specified.'
            )
    if method == 'DRG':
        reduced_model = run_drg(
            model_file, ignition_conditions, psr_conditions, flame_conditions,
            error_limit, target_species, safe_species, phase_name=phase_name,
            threshold_upper=upper_threshold, num_threads=num_threads, path=path
            )    
    elif method == 'DRGEP':
        reduced_model = run_drgep(
            model_file, ignition_conditions, psr_conditions, flame_conditions, 
            error_limit, target_species, safe_species, phase_name=phase_name,
            threshold_upper=upper_threshold, num_threads=num_threads, path=path
            )
    elif method == 'PFA':
        reduced_model = run_pfa(
            model_file, ignition_conditions, psr_conditions, flame_conditions,
            error_limit, target_species, safe_species, phase_name=phase_name,
            num_threads=num_threads, path=path
            )
    error = 0.0
    limbo_species = []
    if method in ['DRG', 'DRGEP', 'PFA']:
        model_file = reduced_model.filename
        error = reduced_model.error
        limbo_species = reduced_model.limbo_species
    if run_sensitivity_analysis:
        if not sensitivity_type:
            sensitivity_type = 'greedy'
        reduced_model = run_sa(
            model_file, error, ignition_conditions, psr_conditions, flame_conditions, 
            error_limit, target_species + safe_species, phase_name=phase_name,
            algorithm_type=sensitivity_type, species_limbo=limbo_species, 
            num_threads=num_threads, path=path
            )
    return reduced_model
def main ( model_file , error_limit , ignition_conditions , psr_conditions = [ ] , flame_conditions = [ ] , method = None , target_species = [ ] , safe_species = [ ] , phase_name = '' , run_sensitivity_analysis = False , upper_threshold = None , sensitivity_type = 'greedy' , path = '' , num_threads = 1 ) : if method in [ 'DRG' , 'DRGEP' , 'PFA' ] : assert target_species , ( 'Need to specify at least one target species for graph-based reduction methods' ) if not method and not run_sensitivity_analysis : raise ValueError ( 'Either a graph-based method or sensitivity analysis (or both) must be specified.' ) if method == 'DRG' : reduced_model = run_drg ( model_file , ignition_conditions , psr_conditions , flame_conditions , error_limit , target_species , safe_species , phase_name = phase_name , threshold_upper = upper_threshold , num_threads = num_threads , path = path ) elif method == 'DRGEP' : reduced_model = run_drgep ( model_file , ignition_conditions , psr_conditions , flame_conditions , error_limit , target_species , safe_species , phase_name = phase_name , threshold_upper = upper_threshold , num_threads = num_threads , path = path ) elif method == 'PFA' : reduced_model = run_pfa ( model_file , ignition_conditions , psr_conditions , flame_conditions , error_limit , target_species , safe_species , phase_name = phase_name , num_threads = num_threads , path = path ) error = 0.0 limbo_species = [ ] if method in [ 'DRG' , 'DRGEP' , 'PFA' ] : model_file = reduced_model . filename error = reduced_model . error limbo_species = reduced_model . limbo_species if run_sensitivity_analysis : if not sensitivity_type : sensitivity_type = 'greedy' reduced_model = run_sa ( model_file , error , ignition_conditions , psr_conditions , flame_conditions , error_limit , target_species + safe_species , phase_name = phase_name , algorithm_type = sensitivity_type , species_limbo = limbo_species , num_threads = num_threads , path = path ) return reduced_model
Driver function for reducing a chemical kinetic model.
Driver function for reducing a chemical kinetic model .
"""Driver function for reducing a chemical kinetic model.

    Parameters
    ----------
    model_file : str
        Cantera-format model to be reduced (e.g., 'mech.cti').
    error_limit : float
        Maximum error percentage for the reduced model.
    ignition_conditions : list of InputIgnition
        List of autoignition initial conditions.
    psr_conditions : list of InputPSR, optional
        List of PSR simulation conditions.
    flame_conditions : list of InputLaminarFlame, optional
        List of laminar flame simulation conditions.
    method : {'DRG', 'DRGEP', 'PFA'}, optional
        Skeletal reduction method to use.
    target_species: list of str, optional
        List of target species for graph-based reduction.
    safe_species : list of str, optional
        List of non-target species to always retain.
    phase_name : str, optional
        Optional name for phase to load from CTI file (e.g., 'gas'). 
    run_sensitivity_analysis : bool, optional
        Flag to run sensitivity analysis after completing another method.
    upper_threshold : float, optional
        Upper threshold (epsilon^*) used to determine species for sensitivity analysis 
        in combination with DRG or DRGEP method
    sensitivity_type : {'initial', 'greedy'}, optional
        Type of sensitivity analysis
    path : str
        Path to directory for writing files
    num_threads : int, optional
        Number of CPU threads to use for performing simulations in parallel.
        Optional; default = 1, in which the multiprocessing module is not used.
        If 0, then use the available number of cores minus one. Otherwise,
        use the specified number of threads.

    """
model_file
error_limit
ignition_conditions
psr_conditions
flame_conditions
method
target_species
safe_species
phase_name
run_sensitivity_analysis
upper_threshold
sensitivity_type
path
num_threads