Simulations¶
Simulations Module
-
class
uconnrcmpy.simulations.
Simulation
(initial_temperature, initial_pressure, volume, is_reactive, end_temp=2500.0, end_time=0.2, chem_file=’species.cti’, cti_source=None)¶ Contains a single simulation of the experiment.
Parameters: - initial_temperature (
float
) – The initial temperature of the simulation - initial_pressure (
float
) – The initial pressure of the simulation - volume (
numpy.ndarray
orNone
) – The volume trace to be used for the simulation. Must be supplied, but if the input value isNone
, the volume trace will be read from the filevolume.csv
. The first column should be the time, the second column should be the volume. - is_reactive (
bool
) – If the simulation should be reactive or non-reactive. IfFalse
sets the Cantera reaction rate multiplier to 0.0 via theset_multiplier
function. - end_temp (
float
, optional) – Reactor temperature at which the simulation will be ended - end_time (
float
, optional) – Time at which the simulation will be ended - chem_file (
str
, optional) – String filename of the chemistry file to use
-
time
¶ numpy.ndarray
– Array of simulated time values
-
temperature
¶ numpy.ndarray
– Array of simulated temperature values
-
pressure
¶ numpy.ndarray
– Array of simulated pressure values
-
input_volume
¶ numpy.ndarray
– Array of input volume values
-
simulated_volume
¶ numpy.ndarray
– Array of simulated volume values
-
calculate_derivative
(dep_var, indep_var)¶ Calculate the derivative.
Parameters: - dep_var (
numpy.ndarray
) – Dependent variable (e.g., the pressure) - indep_var (
numpy.ndarray
) – Independent variable (e.g., the time)
Returns: 1-D array containing the derivative
Return type: Notes
The derivative is calculated by computing the first-order Lagrange polynomial fit to the point under consideration and its nearest neighbors. The Lagrange polynomial is used because of the unequal spacing of the simulated data. The formula, from Chapra and Canale is:
\[ \begin{align}\begin{aligned}\left(\frac{dy}{dt}\right)_i = y_{i-1}\frac{(x_{i} - x_{i+1})}{(x_{i-1} - x_{i})(x_{i-1} - x_{i+1})} +\\y_{i}\frac{(2x_{i} - x_{i-1} - x_{i+1})}{(x_{i} - x_{i-1})(x_{i} - x_{i+1})} +\\y_{i+1}\frac{(x_{i} - x_{i-1})}{(x_{i+1} - x_{i-1})(x_{i+1} - x_{i})}\end{aligned}\end{align} \]- dep_var (
- initial_temperature (
-
class
uconnrcmpy.simulations.
VolumeProfile
(time, volume)¶ Set the velocity of the piston by using a user specified volume profile. The initialization and calling of this class are handled by the
cantera.Func1
interface of Cantera.The velocity is calculated by assuming a unit area and using the forward difference, calculated by
numpy.diff
. This function is only called once when the class is initialized at the beginning of a problem so it is efficient.Parameters: - time (
numpy.ndarray
) – Array or list of time values - volume (
numpy.ndarray
) – Array or list of volume values
-
time
¶ numpy.ndarray
– Array of time values
-
volume
¶ numpy.ndarray
– Array of volume values
-
velocity
¶ numpy.ndarray
– Array of velocity values
- time (