Conditions

Data Processing Module

class uconnrcmpy.conditions.AltCondition(cti_file=None, plotting=True)

Class containing all of the alternate experiments at a condition

add_experiment(file_name=None)

Add an experiment to the Condition.

Parameters:file_name (str or None) – Filename of the file with the voltage trace of the experiment to be added.
add_nonreactive_case()

Add the nonreactive_case to the AltCondition if it hasn’t been set yet. If the nonreactive_case exists but the name of the nonreactive_file is different than the name of the existing case, the case is replaced. If neither of these is true, nothing is done.

add_reactive_case()

Add the reactive_case to the AltCondition if it hasn’t been set yet. If the reactive_case exists but the name of the reactive_file is different than the name of the existing case, the case is replaced. If neither of these is true, nothing is done.

class uconnrcmpy.conditions.Condition(cti_file=None, plotting=True)

Class containing all the experiments at a condition.

Parameters:
  • cti_file (str or pathlib.Path, optional) – The location of the CTI file to use for Cantera. If it is not specified, the default is ./species.cti, but if that file cannot be found, the user is prompted for a filename.
  • plotting (bool, optional) – Set to True to enable plotting when experiments are added
reactive_experiments

dict – Dictionary of instances of class Experiment containing reactive experiments. Indexed by the file name of the underlying voltage trace from the experiment.

nonreactive_experiments

dict – Dictionary of instances of class Experiment containing nonreactive experiments. Indexed by the file name of the underlying voltage trace from the experiment.

reactive_case

Experiment – Single instance of class Experiment that is the closest to the mean of all of the experiments.

nonreactive_case

Experiment – Single instance of class Experiment that best matches the reactive_case.

presout

numpy.ndarray – Pressure array that will be saved to the output file

volout

numpy.ndarray – Volume array that will be saved to the output file

nonreactive_sim

Simulation – Instance containing the nonreactive simulation

reactive_sim

Simulation – Instance containing the reactive simulation

plotting

bool – Set to True when plotting of experiments is enabled

all_runs_figure

matplotlib.figure.Figure – Figure showing all the runs at a condition

nonreactive_figure

matplotlib.figure.Figure – Figure showing a comparison of the nonreactive pressure trace with the reactive_case

pressure_comparison_figure

matplotlib.figure.Figure – Comparison figure of the reactive_case pressure and the pressure calculated by the volume trace routine

simulation_figure

matplotlib.figure.Figure – Comparison of the simulation with the reactive_case pressure

add_experiment(file_name=None, **kwargs)

Add an experiment to the Condition.

Parameters:file_name (pathlib.Path or str or None) – Filename of the file with the voltage trace of the experiment to be added.
add_nonreactive_case()

Add the nonreactive_case to the Condition if it hasn’t been set yet. If the nonreactive_case exists but the name of the nonreactive_file is different than the name of the existing case, the case is replaced. If neither of these is true, nothing is done.

add_reactive_case()

Add the reactive_case to the Condition if it hasn’t been set yet. If the reactive_case exists but the name of the reactive_file is different than the name of the existing case, the case is replaced. If neither of these is true, nothing is done.

change_EOC_time(experiment, time, is_reactive=True)

Change the EOC time manually for an experiment

Parameters:
  • experiment (Experiment or str or pathlib.Path) – The experiment to be modified, either as a filename or as the instance of an Experiment class.
  • time (float) – The value for the EOC time
  • is_reactive (boolean) – The experiment is reactive or not
change_filter_freq(experiment, value)

Change the cutoff frequency of the filter for an experiment

Parameters:
  • experiment (Experiment or str or pathlib.Path) – The experiment to be modified, either as a filename or as the instance of an Experiment class.
  • value (float) – The value for the cutoff frequency
compare_to_sim(run_reactive=False, run_nonreactive=True)

Compare the experiments to the simulations.

Run the simulations for this condition, and if plotting is on, generate the comparison plot.

Parameters:
  • run_reactive (bool, optional) – True to run the reactive comparison. False by default.
  • run_nonreactive (bool, optional) – True to run the nonreactive comparison. True by default.
create_volume_trace()

Create the volume trace based on the information in the loaded yaml file.

load_old_yaml()

Load the yaml file called volume-trace.yaml containing the information needed to construct the volume trace. All the following data are required unless otherwise noted. The format of the yaml file is:

variable: value
  • nonrfile: File name of the non-reactive pressure trace.
    Type: String
  • reacfile: File name of the reactive pressure trace.
    Type: String
  • comptime: Length of time of the compression stroke, in ms.
    Type: Float
  • nonrend: End time used for the produced volume trace, in ms.
    Type: Float
  • reacend: End time of the output reactive pressure trace, in ms.
    Type: Float
  • reacoffs: Offset in number of points from EOC for the
    reactive case. Optional, defaults to zero. Type: Integer
  • nonroffs: Offset in number of points from EOC for the
    non-reactive case. Optional, defaults to zero. Type: Integer
load_yaml()

Load the yaml file called volume-trace.yaml containing the information needed to construct the volume trace. This method reads the YAML file and sets the appropriate attributes of the Condition instance. All the following data are required unless otherwise noted. The format of the yaml file is:

variable: value
  • nonreactive_file: File name of the non-reactive pressure trace.
    Type: String
  • reactive_file: File name of the reactive pressure trace.
    Type: String
  • reactive_compression_time: Length of time of the compression stroke, in ms.
    Type: Float
  • nonreactive_end_time: End time used for the produced volume trace, in ms.
    Type: Float
  • reactive_end_time: End time of the output reactive pressure trace, in ms.
    Type: Float
  • reactive_offset_points: Offset in number of points from EOC for the
    reactive case. Optional, defaults to zero. Type: Integer
  • nonreactive_offset_points: Offset in number of points from EOC for the
    non-reactive case. Optional, defaults to zero. Type: Integer
nonreactive_end_time

float – The end time for the output of the nonreactive case to a file, relative to the end of compression in milliseconds

nonreactive_file

pathlib.Path – File name of the non-reactive case that best matches the pressure trace of the reactive_case. Can be set with a str or Path.

nonreactive_offset_points

int – The number of points to offset the end of compression, to better match the non-reactive and reactive pressure traces together

plot_nonreactive_figure(exp)

Plot the nonreactive pressure traces on a figure.

Plots the nonreactive pressure traces in comparison with the reactive pressure trace. Adds additional traces each time.

Parameters:exp (Experiment) – Experiment to plot
plot_reactive_figures(exp)

Plot the reactive pressure trace on figures.

Plots the reactive pressure trace on two figures. The first is a comparison of all of the processed reactive pressure traces. The second plot is a comparison of the pressure trace and the derivative for a single experiment.

Parameters:exp (Experiment) – Experiment to plot
reactive_compression_time

float – The compression time for the reactive case, in milliseconds

reactive_end_time

float – The end time for the output of the reactive case to a file, relative to the end of compression in milliseconds

reactive_file

pathlib.Path – File name of the case that is the closest to the mean of all the experiments. Can be set with a str or Path.

reactive_offset_points

int – The number of points to offset the end of compression, to better match the non-reactive and reactive pressure traces together

run_simulation(run_reactive=False, run_nonreactive=True, end_temp=2500.0, end_time=0.2)

Run the simulations for this condition.

Parameters:
  • run_reactive (bool, optional) – True to run the reactive case. False by default.
  • run_nonreactive (bool, optional) – True to run the nonreactive case. True by default.
  • end_temp (float, optional) – Temperature at which the simulation is ended
  • end_time (float, optional) – Time at which the simulation is ended.
write_output(volout, presout, Tin)

Write the output files from the volume and pressure traces. The traces are sampled every 5 points to reduce the amount of required computational time. This has negligible effect on the computed pressure trace. The volume trace is written in csv format to the file volume.csv and the experimental pressure trace is written to the file Tc__P0__T0_XXXK_pressure.txt, where XXX represents the initial temperature of the experiment. The user should fill the missing values into the file name after simulations are completed and the values are known.

write_yaml()

Write the volume-trace.yaml output file for storage of parameters. The YAML file format is detailed in load_yaml.

uconnrcmpy.conditions.process_alt_folder(cti_file, path=’.’, plot=False)

Process a folder of alternative experimental files.

Process a folder containing files with reactive experiments to calculate the ignition delays and copy a table with the results to the clipboard.

Parameters:
  • cti_file (str or pathlib.Path) – File containing the CTI for Cantera
  • path (str, optional) – Path to folder to be analyzed. Defaults to the current folder.
  • plot (bool, optional) – True to enable plotting. False by default.
uconnrcmpy.conditions.process_folder(cti_file, path=’.’, plot=False)

Process a folder of experimental files.

Process a folder containing files with reactive experiments to calculate the ignition delays and copy a table with the results to the clipboard.

Parameters:
  • cti_file (str or pathlib.Path) – File containing the CTI for Cantera
  • path (str, optional) – Path to folder to be analyzed. Defaults to the current folder.
  • plot (bool, optional) – True to enable plotting. False by default.