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
orNone
) – Filename of the file with the voltage trace of the experiment to be added.
-
add_nonreactive_case
()¶ Add the
nonreactive_case
to theAltCondition
if it hasn’t been set yet. If thenonreactive_case
exists but the name of thenonreactive_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 theAltCondition
if it hasn’t been set yet. If thereactive_case
exists but the name of thereactive_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
orpathlib.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 classExperiment
containing reactive experiments. Indexed by the file name of the underlying voltage trace from the experiment.
-
nonreactive_experiments
¶ dict
– Dictionary of instances of classExperiment
containing nonreactive experiments. Indexed by the file name of the underlying voltage trace from the experiment.
-
reactive_case
¶ Experiment
– Single instance of classExperiment
that is the closest to the mean of all of the experiments.
-
nonreactive_case
¶ Experiment
– Single instance of classExperiment
that best matches thereactive_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
-
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
orstr
orNone
) – Filename of the file with the voltage trace of the experiment to be added.
-
add_nonreactive_case
()¶ Add the
nonreactive_case
to theCondition
if it hasn’t been set yet. If thenonreactive_case
exists but the name of thenonreactive_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 theCondition
if it hasn’t been set yet. If thereactive_case
exists but the name of thereactive_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
orstr
orpathlib.Path
) – The experiment to be modified, either as a filename or as the instance of anExperiment
class. - time (
float
) – The value for the EOC time - is_reactive (
boolean
) – The experiment is reactive or not
- experiment (
-
change_filter_freq
(experiment, value)¶ Change the cutoff frequency of the filter for an experiment
Parameters: - experiment (
Experiment
orstr
orpathlib.Path
) – The experiment to be modified, either as a filename or as the instance of anExperiment
class. - value (
float
) – The value for the cutoff frequency
- experiment (
-
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:
-
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 theCondition
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 thereactive_case
. Can be set with astr
orPath
.
-
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_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 astr
orPath
.
-
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.
- run_reactive (
-
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 filevolume.csv
and the experimental pressure trace is written to the fileTc__P0__T0_XXXK_pressure.txt
, whereXXX
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.
- cti_file (
-
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
orpathlib.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.
- cti_file (
-
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
orpathlib.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.
- cti_file (