Skip to content

knightshock.kinetics

A module for performing chemical kinetics simulations using cantera.

Warning

Modifying the state of underlying cantera objects in between function calls to the knightshock interface can lead to unexpected results.


Simulation(gas, T, P, X, *, reactor=ct.Reactor)

A class for initializing and running a zero-dimensional homogeneous reactor simulation.

Attributes:

  • gas

    Cantera Solution object.

  • reactor

    Cantera Reactor object.

  • reactor_net

    Cantera ReactorNet object.

  • states

    Cantera SolutionArray object.

Parameters:

  • gas (ct.Solution | str) –

    Cantera gas phase object or filepath to mechanism.

  • T (float) –

    Temperature [K].

  • P (float) –

    Pressure [Pa].

  • X (str | dict[str, float]) –

    Species mole fractions.

  • reactor (ct.Reactor | Type[ct.Reactor]) –

    Cantera reactor object or subclass (optional).

t: np.ndarray[float] property

Reactor elapsed time [s].

T: np.ndarray[float] property

Reactor temperature history [K].

P: np.ndarray[float] property

Reactor pressure history [Pa].

run(t=0.01)

Parameters:

  • t (float) –

    Simulation end time [s] (optional).

X(species)

Returns the mole fraction history for the given species.

Parameters:

  • species (str) –

    Name of species.

ignition_delay_time(species=None, *, method='inflection')

Calculates the ignition delay time from the reactor temperature history, or species mole fraction if given, using the specified method.

Note

Returns np.nan if calculated ignition delay time occurs at the end of the simulated time.

Parameters:

  • species (str) –

    Name of species (optional).

  • method (str) –

    Method used to calculate ignition delay time (optional).

    • 'inflection' point (max slope)

    • 'peak'

Returns:

  • float

    Ignition delay time [s].

get_top_species(n=None, *, exclude=None)

Returns the top n species by mole fraction in descending order. If n is not given, all non-excluded species are returned.

Parameters:

  • n (int) –

    Number of species (optional).

  • exclude (str | list[str]) –

    Species to exclude (optional).

Returns:

  • list[str]

    List of top species.