pyjac : analytical jacobian generator for chemical kinetics · orgone state university, corvallis,...

43
* *

Upload: hatram

Post on 26-Jul-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

pyJac: analytical Jacobian generator for chemical kinetics

Kyle E. Niemeyera,∗, Nicholas J. Curtisb, Chih-Jen Sungb

aSchool of Mechanical, Industrial, and Manufacturing Engineering

Oregon State University, Corvallis, OR 97331, USAbDepartment of Mechanical Engineering

University of Connecticut, Storrs, CT, 06269, USA

Abstract

Accurate simulations of combustion phenomena require the use of detailed chemical kinet-ics in order to capture limit phenomena such as ignition and extinction as well as predictpollutant formation. However, the chemical kinetic models for hydrocarbon fuels of prac-tical interest typically have large numbers of species and reactions and exhibit high levelsof mathematical sti�ness in the governing di�erential equations, particularly for larger fuelmolecules. In order to integrate the sti� equations governing chemical kinetics, generallyreactive-�ow simulations rely on implicit algorithms that require frequent Jacobian matrixevaluations. Some in situ and a posteriori computational diagnostics methods also requireaccurate Jacobian matrices, including computational singular perturbation and chemical ex-plosive mode analysis. Typically, �nite di�erences numerically approximate these, but forlarger chemical kinetic models this poses signi�cant computational demands since the num-ber of chemical source term evaluations scales with the square of species count. Furthermore,existing analytical Jacobian tools do not optimize evaluations or support emerging SIMDprocessors such as GPUs. Here we introduce pyJac, a Python-based open-source programthat generates analytical Jacobian matrices for use in chemical kinetics modeling and anal-ysis. In addition to producing the necessary customized source code for evaluating reactionrates (including all modern reaction rate formulations), the chemical source terms, and theJacobian matrix, pyJac uses an optimized evaluation order to minimize computational andmemory operations. As a demonstration, we �rst establish the correctness of the Jacobianmatrices for kinetic models of hydrogen, methane, ethylene, and isopentanol oxidation (num-ber of species ranging 13�360) by showing agreement within 0.001% of matrices obtainedvia automatic di�erentiation. We then demonstrate the performance achievable on CPUsand GPUs using pyJac via matrix evaluation timing comparisons; the routines producedby pyJac outperformed �rst-order �nite di�erences by 3�7.5 times and the existing analyt-ical Jacobian software TChem by 1.1�2.2 times on a single-threaded basis. It is noted thatTChem is not thread-safe, while pyJac is easily parallelized, and hence can greatly outper-form TChem on multicore CPUs. The Jacobian matrix generator we describe here will beuseful for reducing the cost of integrating chemical source terms with implicit algorithms inparticular and algorithms that require an accurate Jacobian matrix in general. Furthermore,the open-source release of the program and Python-based implementation will enable wide

∗Corresponding authorEmail address: [email protected] (Kyle E. Niemeyer)

Preprint submitted to Computer Physics Communications June 30, 2017

Page 2: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

adoption.

Keywords: Chemical kinetics, Jacobian, SIMD, GPU

PROGRAM SUMMARYManuscript Title: pyJac: analytical Jacobian generator for chemical kinetics

Authors: Kyle E. Niemeyer, Nicholas J. Curtis, Chih-Jen Sung

Program Title: pyJacJournal Reference:Catalogue identi�er:Licensing provisions: MIT License

Programming language: PythonComputer: Windows, Ubuntu, and Mac OS computers

Operating system: Any (Linux, Mac OS X, Windows)

RAM: Problem dependent; typically less than 1 GB

Number of processors used: oneClassi�cation: 16.12, 4.3External routines/libraries: required: NumPy; optional: Cython, Cantera, PyYAML, AdeptNature of problem: Automatic generation of source code to evaluate Jacobian matrices for chemical

kinetic models

Solution method: Chemical kinetic model interpreted from input �le(s), and partial derivatives and

necessary supporting functions are written to �le based on a theoretical derivation.

Additional comments: This paper describes pyJac v1.0.2, available at http://dx.doi.org/10.

5281/zenodo.251144. Current version and support available at https://github.com/SLACKHA/

pyjac/

Running time: Problem dependent; from seconds to tens of minutes depending on the model size.

Keywords: Chemical kinetics, Jacobian, SIMD, GPU

1. Introduction

As the need for detailed and accurate chemical kinetic models1 in predictive reactive-�owsimulations has become recognized in recent years, such models describing the oxidationof hydrocarbon fuels simultaneously grew orders of magnitude in size and complexity. Forexample, a recently developed detailed kinetic model for 2-methylalkanes, relevant for jet anddiesel fuel surrogates, consists of over 7000 species and 30000 reactions [1]; similarly largesurrogate models exist for gasoline [2, 3] and biodiesel [4]. Since in general the computationalcost of solving the associated generally sti� systems of equations scales quadratically withthe number of species at best�and at worst, cubically�models of such a large size posechallenges even for lower-dimensional analyses, and cannot practically be used directly inmultidimensional reactive-�ow simulations.

In an e�ort to reduce the computational demands of using large, detailed kinetic models, anumber of techniques have been developed to reduce their size and complexity while retaining

1Note that the term �reaction mechanism� is also used commonly in the literature; we adopted ourpreferred terminology �chemical kinetic model� here.

2

Page 3: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

predictiveness, as reviewed by Lu and Law [5] as well as Turányi and Tomlin [6]. Major classesof such approaches include skeletal reduction methods that remove unimportant species andreactions [7�10], lumping of species that share similar properties [11�13], and time-scalereduction methods that reduce chemical sti�ness [14�17]. E�ective reduction strategies eithercombine multiple methods a priori [18�20] or apply them dynamically during a simulationto achieve greater local savings [21�26]. Techniques such as interpolation/tabulation ofexpensive terms [27] can also reduce computational costs.

In addition to the aforementioned cost reduction methods that modify the chemicalkinetic models, improvements to the integration algorithms that actually solve the governingdi�erential equations can also o�er signi�cant gains in computational performance. Due tothe chemical sti�ness exhibited by most kinetic models, solvers typically rely on robust,high-order implicit integration algorithms based on backward di�erentiation formulae [28�31]. In order to solve the nonlinear algebraic equations that arise in these methods, theJacobian matrix must be evaluated and factorized, operations that result in the quadraticand cubic costs mentioned previously. However, by using an analytical formulation forthe Jacobian matrix rather than a typical �nite di�erence approximation, the cost of thenumerous evaluations can drop from growing with the square of the number of species to alinear dependence [5].

In parallel with the potential improvements in sti� implicit integrators used for chem-ical kinetics, algorithms tailored for high-performance hardware accelerators o�er anotherroute to reducing computational costs. In the past, central processing unit (CPU) clockspeeds increased regularly�i.e., Moore's Law�but power consumption and heat dissipa-tion issues disrupted this trend recently, slowing the pace of increases in CPU clock rates.While multicore parallelism continues to raise CPU performance, single-instruction multi-ple data (SIMD) processors, e.g., graphics processing units (GPUs), recently emerged as alow-cost, low-power consumption, and massively parallel high-performance computing alter-native. GPUs�originally developed for graphics/video processing and display purposes�consist of hundreds to thousands of cores, compared to the tens of cores found on a typicalCPU. Recognizing that the SIMD parallelism model �ts well with the operator-split chem-istry integration that forms the basis of many reactive-�ow codes [32], a number of studiesin recent years [33�38] explored the use of SIMD processors to accelerate the integrationof chemical kinetics in reactive-�ow codes. Niemeyer and Sung [39] reviewed such e�ortsin greater detail. While explicit methods o�er signi�cant improvements in performance fornonsti� and moderately sti� chemical kinetics [38], experiences thus far suggest that sti�chemistry continues to require the use of implicit or similar algorithms. This provides sig-ni�cant motivation to provide the capability of evaluating analytical Jacobian matrices onGPUs as well as CPUs.

Thus, motivated by the potential cost reductions o�ered by analytical Jacobian matrixformulations, over the past �ve years a number of research groups developed analytical Ja-cobian generators for chemical kinetics, although as will be discussed the software packageintroduced here o�ers a number of improvements. The TChem toolkit developed by Saftaet al. [40] was one of the �rst software packages developed for calculating the analyticalJacobian matrix, but provides this functionality through an interface rather than generatingcustomized source code for each model. Yousse� [41] recognized the importance of usingan analytical Jacobian over a numerical approximation to reduce both computational cost

3

Page 4: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

and numerical error when performing eigendecomposition of the matrix. Bisetti [42] re-leased a utility for producing analytical Jacobian matrix source code based on isothermaland isobaric conditions, with the state vector comprised of species concentrations ratherthan mass fractions; while incompatible with many existing reactive-�ow formulations, thisformulation resulted in a signi�cant increase of Jacobian matrix sparsity�such a strategyshould be investigated further. Perini et al. [43] developed an analytical Jacobian matrixformulation for constant-volume combustion, and when used in a multidimensional reactive-�ow simulation�combined with tabulation of temperature-dependent properties�reporteda performance improvement of around 80% over �nite-di�erence-based approximations. Re-cently, Dijkmans et al. [44] used a GPU-based analytical Jacobian combined with tabulationof temperature-dependent functions based on polynomial interpolations to accelerate theintegration of chemical kinetics equations, similar to the earlier approach of Shi et al. [34].Unlike the current work, the approach of Dijkmans et al. [44] used the GPU to calculatethe elements of a single Jacobian matrix in parallel, rather than a large number of matricescorresponding to di�erent states.

To our knowledge, currently no open-source analytical chemical Jacobian tool exists thatis capable of generating code speci�cally optimized for SIMD processors. To this end, pyJacis capable of generating subroutines for reaction rates, species production rates, derivativesource terms, and analytical chemical Jacobian matrices both for CPU operation via C/C++ and GPU operation via CUDA [45], a widely used programming language for NVIDIAGPUs. Furthermore, pyJac supports newer pressure-dependent reaction formulations (i.e.,based on logarithmic or Chebyshev polynomial interpolation).

The rest of the paper is structured as follows. First, in Section 2 we introduce thegoverning equations for chemical kinetics and then provide the analytical Jacobian matrixformulation in Section 3. Next, Section 4 describes the techniques used to optimize evaluationof the analytical Jacobian on both CPUs and GPUs. Then, in Section 5 we demonstrate thecorrectness and computational performance of the generated analytical Jacobian matricesfor benchmark chemical kinetic models, and discuss the implications of these results. Finally,we summarize our work in Section 6 and outline future research directions.

2. Theory

This section describes the theoretical background of the analytical Jacobian generator,�rst in terms of the governing equations and then the components of the Jacobian matrixitself. The literature contains more detailed explanations of the governing equations devel-opment [46�48], but we include the necessary details here for completeness.

2.1. Governing equations

The initial value problem to be solved, whether in the context of a single homogeneousreacting system (e.g., autoignition, perfectly stirred reactor) or the chemistry portion of anoperator-split multidimensional reactive-�ow simulation [32], is described using an ordinarydi�erential equation for the thermochemical composition vector

Φ ={T, Y1, Y2, . . . , YNsp−1

}ᵀ, (1)

4

Page 5: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

where T is the temperature, Yi are the species mass fractions, and Nsp is the number ofspecies. The mass fraction of the �nal species, YNsp

, is determined through conservation ofmass:

YNsp= 1−

Nsp−1∑k=1

Yk , (2)

where the most abundant species (e.g., N2 in air-fed combustion) can be assigned to thisrole. In multidimensional simulations where the equations for chemical kinetics are coupledto conservation of energy (or enthalpy), temperature can be determined algebraically in astraightforward manner [32]. Completely de�ning the thermodynamic state also requires ei-ther pressure (p) or density (ρ), related to temperature and the mixture composition throughthe ideal equation of state

p = ρRWT = RT

Nsp∑k=1

[Xk] , (3)

where R is the universal gas constant, W is the average molecular weight of the mixture,and [Xk] is the molar concentration of the kth species. In the current implementation ofpyJac, we assume a constant-pressure system2; thus, we use Eq. (3) to determine densityrather than including it in the di�erential system given by Eq. (1). The average molecularweight is de�ned by

W =1∑Nsp

k=1 Yk/Wk

=ρRTp

(4)

and the molar concentrations by

[Xk] = ρYkWk

, (5)

where Wk is the molecular weight of the kth species.The system of ODEs governing the time change in thermochemical composition corre-

sponding to Eq. (1) is then f = ∂Φ/∂t:

f =∂Φ

∂t=

{∂T

∂t,∂Y1∂t

,∂Y2∂t

, . . . ,∂YNsp−1

∂t

}ᵀ

, (6)

where

∂T

∂t=−1

ρcp

Nsp∑k=1

hkWkωk , (7)

∂Yk∂t

=Wk

ρωk k = 1, . . . , Nsp − 1 , (8)

where cp is the mass-averaged constant-pressure speci�c heat, hk is the enthalpy of the kthspecies in mass units, and ωk is the kth species overall production rate.

2In the context of multidimensional reactive �ows, the constant-pressure assumption signi�es that pressureremains constant during the reaction substep of an operator-split scheme (and is thus an input variable tothe kinetics problem), not that the pressure is �xed throughout the entire simulation. This assumption iscommonly used in low-speed combustion simulations.

5

Page 6: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

2.2. Thermodynamic properties

The standard-state thermodynamic properties (in molar units) for a gaseous species k isde�ned using the standard seven-coe�cient polynomial of Gordon and McBride [49]:

C◦p,kR

= a0,k + T (a1,k + T (a2,k + T (a3,k + a4,kT ))) (9)

H◦kR

= T(a0,k + T

(a1,k2

+ T(a2,k

3+ T

(a3,k4

+a4,k5T))))

+ a5,k (10)

S◦kR

= a0,k lnT + T(a1,k + T

(a2,k2

+ T(a3,k

3+a4,k4T)))

+ a6,k (11)

where Cp,k is the constant-pressure speci�c heat in molar units, Hk is the enthalpy in molarunits, Sk is the entropy in molar units, and the ◦ indicates a standard-state property at oneatmosphere (equivalent to the property at any pressure for calorically perfect gases).

The mass-based speci�c heat and enthalpy are then de�ned as

cp,k =Cp,kWk

and hk =Hk

Wk

, (12)

and the mixture-averaged speci�c heat is

cp =

Nsp∑k=1

Ykcp,k . (13)

2.3. Reaction rate expressions

Next, we de�ne the species rates of production and related kinetic terms as

ωk =Nreac∑i=1

νkiqi , (14)

where Nreac is the number of reactions, νki is the overall stoichiometric coe�cient for speciesk in reaction i, and qi is the rate-of-progress for reaction i. These are de�ned by

νki = ν ′′ki − ν ′ki and (15)

qi = ciRi , (16)

where ν ′′ki and ν′ki are the product and reactant stoichiometric coe�cients (respectively) of

species k in reaction i. The base rate-of-progress for the ith reversible reaction Ri is givenby

Ri = Rf,i −Rr,i , (17)

Rf,i = kf,i

Nsp∏j=1

[Xj]ν′ji , and (18)

Rr,i = kr,i

Nsp∏j=1

[Xj]ν′′ji , (19)

6

Page 7: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

where kf,i and kr,i are the forward and reverse reaction rate coe�cients for the ith reaction,respectively, and the third-body/pressure modi�cation ci is given by

ci =

1 for elementary reactions,

[X]i for third-body enhanced reactions,

Pr,i1 + Pr,i

Fi for unimolecular/recombination fallo� reactions, and

1

1 + Pr,iFi for chemically-activated bimolecular reactions,

(20)

where for the ith reaction [X]i is the third-body concentration, Pr,i is the reduced pressure,and Fi is the fallo� blending factor. These terms are de�ned in the following sections.

The forward reaction rate coe�cient kf,i is given by the three-parameter Arrhenius ex-pression:

kf,i = AiTβi exp

(−Ta,iT

), (21)

where Ai is the pre-exponential factor, βi is the temperature exponent, and Ta,i is the acti-vation temperature given by Ta,i = Ea,i/R.

As given by Lu and Law [5], depending on the value of the Arrhenius parameters, kf,ican be calculated in di�erent ways to minimize the computational cost:

kf,i =

Ai if β = 0 and Ta,i = 0 ,

exp (logAi + βi log T ) if βi 6= 0 and Ta,i = 0 ,

exp (logAi + βi log T − Ta,i/T ) if βi 6= 0 and Ta,i 6= 0 ,

exp (logAi − Ta,i/T ) if βi = 0 and Ta,i 6= 0 , and

Ai

βi∏T if Ta,i = 0 and βi ∈ Z ,

(22)

where Z is the set of integers.

2.3.1. Reverse rate coe�cient

By de�nition, irreversible reactions have a zero reverse rate coe�cient kr,i, while reversiblereactions have nonzero kr,i. For reversible reactions, the reverse rate coe�cient is determinedin one of two ways: (1) via explicit reverse Arrhenius parameters as with the forward ratecoe�cient�thus following the same expression as Eq. (21)�or (2) via the ratio of the forwardrate coe�cient and the equilibrium constant,

kr,i =kf,iKc,i

, (23)

Kc,i = Kp,i

(patmRT

)∑Nspk=1 νki

, and (24)

Kp,i = exp

(∆S◦iR− ∆H◦iRT

)= exp

(Nsp∑k=1

νki

(S◦kR− H◦kRT

)), (25)

7

Page 8: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

where patm is the pressure of one standard atmosphere in the appropriate units.By combining the expressions for Kc,i and Kp,i, we obtain

Kc,i =(patmR

)∑Nspk=1 νki

exp

(Nsp∑k=1

νkiBk

), (26)

where, expanding the polynomial expressions for S◦k and H◦k from Eqs. (11) and (10), respec-

tively,

Bk = a6,k − a0,k + (a0,k − 1) lnT

+ T(a1,k

2+ T

(a2,k6

+ T(a3,k

12+a4,k20

T)))

− a5,kT

. (27)

2.3.2. Third-body e�ects

For a reaction enhanced (or diminished) by the presence of a third body, the reactionrate is modi�ed by the third-body concentration [X]i given by

[X]i =

Nsp∑j=1

αij[Xj] , (28)

where αij is the third-body e�ciency of species j in the ith reaction. If all species in themixture contribute equally as third bodies (the default) then αij = 1 for all species. In thiscase,

[X]i = [M ] =

Nsp∑j=1

[Xj] =p

RT=

ρ

W. (29)

In addition, a single species may act as the third body, in which case

[X]i = [Xm] , (30)

where the mth species is the third body.

2.3.3. Fallo� reactions

Unlike elementary and third-body reactions, fallo� reactions exhibit a pressure depen-dence described as a blending of rates at low- and high-pressure limits; thus, the rate coe�-cients depend on a mixture of low-pressure- (k0,i) and high-pressure-limit (k∞,i) coe�cients,each with corresponding Arrhenius parameters and expressed using Eq. (21). The ratio ofthe coe�cients k0,i and k∞,i, combined with the third-body concentration (based on eitherthe mixture as a whole including any e�ciencies αi,j, or a speci�c species), de�ne a reducedpressure Pr,i given by

Pr,i =

k0,ik∞,i

[X]i for the mixture as the third body, or

k0,ik∞,i

[Xm] for a speci�c species m as third body.

(31)

8

Page 9: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

The fallo� blending factor Fi used in Eq. (20) is determined based on one of threerepresentations: the Lindemann [50], Troe [51], and SRI [52] fallo� approaches

Fi =

1 for Lindemann,

F(1+(ATroe/BTroe)

2)−1

cent for Troe, or

dT e(a · exp

(− bT

)+ exp

(−Tc

))Xfor SRI.

(32)

The variables for the Troe representation are given by

Fcent = (1− a) exp

(− T

T ∗∗∗

)+ a · exp

(− T

T ∗

)+ exp

(−T

∗∗

T

), (33)

ATroe = log10 Pr,i − 0.67 log10 Fcent − 0.4 , and (34)

BTroe = 0.806− 1.1762 log10 Fcent − 0.14 log10 Pr,i , (35)

where a, T ∗∗∗, T ∗, and T ∗∗ are speci�ed parameters. The �nal parameter T ∗∗ is optional,and, if it is not used, the �nal term of Fcent is omitted. The exponent used in the SRIrepresentation is given by

X =(1 + (log10 Pr,i)

2)−1 (36)

where a, b, and c are required parameters. The parameters d and e are optional; if notspeci�ed, d = 1 and e = 0.

2.3.4. Pressure-dependent reactions

In addition to the fallo� approach given previously, two additional formulations can beused to describe the pressure dependence of reactions that do not follow the modi�cationfactor ci approach. The �rst involves logarithmic interpolation between Arrhenius rates attwo pressures [53, 54], each evaluated using Eq. (21):

k1(T ) = A1Tβ1 exp

(−Ta,1

T

)at p1 and (37)

k2(T ) = A2Tβ2 exp

(−Ta,2

T

)at p2 , (38)

where the Arrhenius coe�cients are given for each pressure p1 and p2. Then, the reactionrate coe�cient at a particular pressure p between p1 and p2 can be determined throughlogarithmic interpolation:

log kf (T, p) = log k1(T ) + (log k2(T )− log k1(T ))log p− log p1log p2 − log p1

. (39)

In addition, the pressure dependence of a reaction can be expressed through a bivariateChebyshev polynomial �t [53�57]:

log10 kf (T, p) =

NT∑i=1

Np∑j=1

ηijφi(T )φj (p) , (40)

9

Page 10: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

where ηij is the coe�cient corresponding to the grid points i and j, NT and Np are thenumbers of grid points for temperature and pressure, respectively, and φn is the Chebyshevpolynomial of the �rst kind of degree n− 1 typically expressed as

φn(x) = Tn−1(x) = cos ((n− 1) arccos(x)) for |x| ≤ 1 . (41)

The reduced temperature T and pressure p are given by

T ≡ 2T−1 − T−1min − T−1max

T−1max − T−1min

and (42)

p ≡ 2 log10 p− log10 pmin − log10 pmax

log10 pmax − log10 pmin

, (43)

where Tmin ≤ T ≤ Tmax and pmin ≤ p ≤ pmax describe the ranges of validity for temperatureand pressure.

3. Jacobian matrix formulation

Next, we detail the construction of the Jacobian matrix, and provide a simple method forevaluating it e�ciently by calculating elements in the appropriate order. More sophisticatedapproaches for reducing the cost of evaluating the matrix will be proposed in Section 4.

3.1. Elements of the Jacobian matrix

Let J denote the Jacobian matrix corresponding to the vector of ODEs given by Eq. (6).J is �lled by the partial derivatives ∂f/∂Φ, such that

Ji,j =∂fi∂Φj

. (44)

The �rst line of J is �lled with partial derivatives of the energy equation, or

J1,j =∂T

∂Φj

j = 1, . . . , Nsp − 1 . (45)

The components of J1,j are:

J1,1 =∂f1∂T

=−1

cp

Nsp∑k=1

[(∂hk∂T− hk

∂cp∂T

)Wkωkρ

+hkcp

∂T

(Wkωkρ

)], (46)

J1,j+1 =∂f1∂Yj

=−1

cp

Nsp∑k=1

[(∂hk∂Yj− hk

∂cp∂Yj

)Wkωkρ

+hkcp

∂Yj

(Wkωkρ

)], (47)

for j = 1, . . . , Nsp − 1.The remaining lines of J are �lled with the partial derivatives of the species equations,

with the components

Jk+1,1 =∂fk+1

∂T=Wk

ρ

(∂ωk∂T− ωk

ρ

∂ρ

∂T

)and (48)

10

Page 11: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Jk+1,j+1 =∂fk+1

∂Yj=Wk

ρ

(∂ωk∂Yj− ωk

ρ

∂ρ

∂Yj

), (49)

for k = 1, . . . , Nsp − 1 and j = 1, . . . , Nsp − 1.The partial derivatives of ρ, cp, hk, and ωk with respect to temperature and mass fraction

need to be evaluated. The partial derivatives of density are

∂ρ

∂T=

∂T

(pW

RT

)= − ρ

Tand (50)

∂ρ

∂Yj=

∂Yj

(pW

RT

)= −ρW

(1

Wj

− 1

WNsp

). (51)

The partial derivative of species speci�c enthalpy with respect to temperature is simplyconstant-pressure speci�c heat, and the partial derivative with respect to species mass frac-tion is zero:

∂hk∂T

= cp,k (52)

∂hk∂Yj

= 0 . (53)

The derivatives of speci�c heat are expressed by

∂cp∂T

=

Nsp∑k=1

Yk∂cp,k∂T

, (54)

∂cp,k∂T

=RWk

(a1,k + T (2a2,k + T (3a3,k + 4a4,kT ))) , and (55)

∂cp∂Yj

=∂

∂Yj

Nsp∑k=1

Ykcp,k = cp,j − cp,Nsp. (56)

Next, the derivatives of species rate-of-production ωk are given by

∂ωk∂T

=Nreac∑i=1

νki∂qi∂T

=Nreac∑i=1

νki

(∂ci∂T

Ri + ci∂Ri

∂T

)and (57)

∂ωk∂Yj

=Nreac∑i=1

νki∂qi∂Yj

=Nreac∑i=1

νki

(∂ci∂Yj

Ri + ci∂Ri

∂Yj

). (58)

The partial derivatives of Ri vary depending on whether the reaction is reversible. Forirreversible reactions,

∂Rf,i

∂T=∂kf,i∂T

1

kf,iRf,i + kf,i

∂T

(Nsp∏j=1

[Xj]ν′ji

)and (59)

∂Rf,i

∂Yj= kf,i

∂Yj

(Nsp∏k=1

[Xk]ν′ki

). (60)

11

Page 12: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

The partial derivatives of species concentration are

∂[Xi]

∂T=

YiWi

∂ρ

∂T= − [Xi]

T(61)

∂[Xi]

∂Yj=

YiWi

∂ρ

∂Yj+

ρ

Wi

∂Yi∂Yj

= −[Xi]W

(1

Wj

− 1

WNsp

)+(δij − δiNsp

) ρ

Wi

, (62)

where i = 1, . . . , Nsp, j = 1, . . . , Nsp−1, and δij is the Kronecker delta. The partial derivativesof the molar concentration product terms are then

∂T

(Nsp∏j=1

[Xj]ν′ji

)= − 1

T

(Nsp∏j=1

[Xj]ν′ji

)Nsp∑j=1

ν ′ji and (63)

∂Yj

(Nsp∏k=1

[Xk]ν′ki

)=

Nsp∑k=1

ν ′ki

(−[Xk]

ν′kiW

(1

Wj

− 1

WNsp

)

+(δkj − δkNsp

) ρ

Wk

[Xk]ν′ki−1

)Nsp∏l=1l 6=k

[Xl]ν′li , (64)

and the partial derivative of forward reaction rate coe�cient is

∂kf,i∂T

=kf,iT

(βi +

Ta,iT

). (65)

Inserting these into Eqs. (59) and (60) gives

∂Rf,i

∂T=Rf,i

T

(βi +

Ta,iT−

Nsp∑j=1

ν ′ji

)and (66)

∂Rf,i

∂Yj=

Nsp∑k=1

ν ′ki

(−Rf,iW

(1

Wj

− 1

WNsp

)

+(δkj − δkNsp

)kf,i

ρ

Wk

[Xk]ν′ki−1

Nsp∏l=1l 6=k

[Xl]ν′li

). (67)

For reversible reactions with explicit reverse Arrhenius coe�cients,

∂Ri

∂T=∂kf,i∂T

Nsp∏j=1

[Xj]ν′ji + kf,i

∂T

(Nsp∏j=1

[Xj]ν′ji

)

− ∂kr,i∂T

Nsp∏j=1

[Xj]ν′′ji − kr,i

∂T

(Nsp∏j=1

[Xj]ν′′ji

)(68)

=Rf,i

T

(βf,i +

Taf,iT−

Nsp∑j=1

ν ′ji

)− Rr,i

T

(βr,i +

Tar,iT−

Nsp∑j=1

ν ′′ji

). (69)

12

Page 13: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Similarly, 1[Xj ]

(ν ′jiRf,i − ν ′′jiRr,i

)should be avoided since [Xj] could be zero.

The partial derivative of the reverse reaction rate coe�cient, when evaluated using theforward rate coe�cient and equilibrium constant using Eq. (23), is more complicated:

∂kr,i∂T

=∂

∂T

(kf,iKc,i

)=

∂kf,i∂T

Kc,i − ∂Kc,i

∂Tkf,i

K2c,i

(70)

=kf,iKc,i

1

T

(βi +

Ta,iT

)− 1

Kc,i

∂Kc,i

∂T

kf,iKc,i

(71)

∂Kc,i

∂T= Kc,i

Nsp∑k=1

νki∂Bk

∂T(72)

∴∂kr,i∂T

= kr,i

(1

T

(βi +

Ta,iT

)−

Nsp∑k=1

νki∂Bk

∂T

), (73)

where∂Bk

∂T=

1

T

(a0,k − 1 +

a5,kT

)+a1,k2

+ T

(a2,k3

+ T(a3,k

4+a4,k5T))

. (74)

Now, the partial derivative of Ri with respect to temperature is

∂Ri

∂T=Rf,i

T

(βi +

Ta,iT−

Nsp∑j=1

ν ′ji

)

−Rr,i

(1

T

(βi +

Ta,iT−

Nsp∑j=1

ν ′′ji

)−

Nsp∑j=1

νji∂Bj

∂T

). (75)

For all reversible reactions,

∂Ri

∂Yj=

Nsp∑k=1

(ν ′ki

(−Rf,iW

( 1

Wj

− 1

WNsp

)+(δkj − δkNsp

)kf,i

ρ

Wk

[Xk]ν′ki−1

Nsp∏l=1l 6=k

[Xl]ν′li

)

− ν ′′ki(−Rr,iW

( 1

Wj

− 1

WNsp

)+(δkj − δkNsp

)kr,i

ρ

Wk

[Xk]ν′′ki−1

Nsp∏l=1l 6=k

[Xl]ν′′li

)). (76)

The partial derivatives of ci depend on the type of reaction. For elementary reactions,

∂ci∂T

= 0 and (77)

∂ci∂Yj

= 0 . (78)

13

Page 14: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

For third-body-enhanced reactions,

∂ci∂T

= −ciT

, and (79)

∂ci∂Yj

= −Wci

( 1

Wj

− 1

WNsp

)+ ρ(αijWj

−αiNsp

WNsp

). (80)

Note that in the case that all species contribute equally (i.e., αij = 1 for all species j), thelatter partial derivative simpli�es to

∂ci∂Yj

=∂

∂Yj

( p

RT

)= 0 , (81)

because ∂p∂Yj

= 0 (shown in Appendix B).

In the case of unimolecular/recombination fall-o� reactions,

∂ci∂T

= ci

(1

Pr,i(1 + Pr,i)

∂Pr,i∂T

+1

Fi

∂Fi∂T

)(82)

∂ci∂Yj

= ci

(1

Pr,i(1 + Pr,i)

∂Pr,i∂Yj

+1

Fi

∂Fi∂Yj

). (83)

The partial derivatives for Pr,i are

∂Pr,i∂T

=Pr,iT

(β0,i − β∞,i +

Ta0,i − Ta∞,iT

− 1

)(84)

∂Pr,i∂Yj

=

−Pr,iW

( 1

Wj

− 1

WNsp

)+k0,ik∞,i

ρ(αijWj

−αiNsp

WNsp

), or

−Pr,iW( 1

Wj

− 1

WNsp

)+k0,ik∞,i

ρ

Wm

(δmj − δmNsp

), if [X]i = [Xm] .

(85)

Similarly, for chemically-activated bimolecular reactions

∂ci∂T

= ci

(−1

1 + Pr,i

∂Pr,i∂T

+1

Fi

∂Fi∂T

)(86)

∂ci∂Yj

= ci

(−1

1 + Pr,i

∂Pr,i∂Yj

+1

Fi

∂Fi∂Yj

)(87)

The partial derivatives of Fi depend on the representation of pressure dependence. ForLindemann reactions,

∂Fi∂T

= 0 and (88)

∂Fi∂Yj

= 0 . (89)

For reactions using the Troe fallo� formulation,

∂Fi∂T

=∂Fi∂Fcent

∂Fcent

∂T+

∂Fi∂Pr,i

∂Pr,i∂T

and (90)

∂Fi∂Yj

=∂Fi∂Pr,i

∂Pr,i∂Yj

, (91)

14

Page 15: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

where

∂Fi∂Fcent

= Fi

(1

Fcent (1 + (ATroe/BTroe)2)

− lnFcent

2ATroe

B3Troe

∂ATroe

∂FcentBTroe − ATroe

∂BTroe

∂Fcent

(1 + (ATroe/BTroe)2)2

), (92)

∂Fcent

∂T= −1− a

T ∗∗∗exp

(−TT ∗∗∗

)− a

T ∗exp

(−TT ∗

)+T ∗∗

T 2exp

(−T ∗∗

T

), (93)

∂Fi∂Pr,i

= −Fi lnFcent

2ATroe

B3Troe

∂ATroe

∂Pr,iBTroe − ATroe

∂BTroe

∂Pr,i

(1 + (ATroe/BTroe)2)2 , (94)

∂Pr,i

∂Tis given by Eq. (84),

∂Pr,i

∂Yjis given by Eq. (85), and

∂ATroe

∂Fcent

=−0.67

Fcent log 10

∂BTroe

∂Fcent

=−1.1762

Fcent log 10(95)

∂ATroe

∂Pr,i=

1

Pr,i log 10

∂BTroe

∂Pr,i=−0.14

Pr,i log 10. (96)

Finally, for fallo� reactions described with the SRI formulation,

∂Fi∂T

= Fi

(e

T+X

abT 2 exp

(−bT

)− 1

cexp

(−Tc

)a · exp

(−bT

)+ exp

(−Tc

)+

∂X

∂Pr,i

∂Pr,i∂T

log

(a · exp

(−bT

)+ exp

(−Tc

)))(97)

∂Fi∂Yj

= Fi∂X

∂Yjlog

(a · exp

(−bT

)+ exp

(−Tc

))(98)

where

∂X

∂Pr,i= −X22 log10 Pr,i

Pr,i log 10, (99)

∂X

∂Yj=

∂X

∂Pr,i

∂Pr,i∂Yj

, (100)

∂Pr,i

∂Tis given by Eq. (84), and

∂Pr,i

∂Yjis given by Eq. (85). Note that for both fallo� and

chemically activated bimolecular reactions, regardless of fallo� parameterization, if all speciescontribute equally to the third-body concentration [X]i then the partial derivative of ci withrespect to species mass fraction Yj is zero, since

∂p∂Yj

= 0.

The contributions of the logarithmic and Chebyshev pressure-dependent descriptions tothe Jacobian matrix entries require separate descriptions since they do not follow the fallo�formulation (e.g., fallo� factor Fi). Instead, alternative partial derivatives of the reaction

rate coe�cient with respect to temperature (∂kf,i∂T

) must be provided in place of Eq. (65)when calculating the partial derivatives of Ri using Eqs. (59), (68), or (70). In both cases

the partial derivatives with respect to species mass fractions (∂kf,i∂Yj

) are zero, because the

15

Page 16: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

partial derivative of pressure with respect to species mass fraction is zero. In addition, sincethis treatment assumes a constant-pressure system, the partial derivative of pressure withrespect to temperature is also zero.

For the logarithmic pressure-dependent Arrhenius rate, the partial derivative with respectto temperature is

∂kf,i∂T

=

[∂(log k1)

∂T+

(∂(log k2)

∂T− ∂(log k1)

∂T

)log p− log p1log p2 − log p1

+ (log k2 − log k1)∂(log p)∂T

log p2 − log p1

]· kf,i , (101)

where k1 and k2 are given by Eqs. (37) and (38), respectively. Note that terms such as k1,k2, p1, and p2 are associated with the ith reaction alone; we omit the subscript for clarity,and continue this practice with other reaction-speci�c terms in the following discussion. Thenecessary components can be determined as

∂(log k1)

∂T=

1

T

(β1 +

Ta,1T

), (102)

∂(log k2)

∂T=

1

T

(β2 +

Ta,2T

), and (103)

∂(log p)

∂T=

1

p

∂p

∂T= 0 . (104)

The �nal simpli�ed expression can next be constructed, appropriate for use when pressurefalls between p1 and p2:

∂kf,i∂T

=kf,iT

[β1 +

Ta,1T

+

(β2 − β1 +

Ta,2 − Ta,1T

)log p− log p1log p2 − log p1

]. (105)

Finally, the partial derivatives of the rate coe�cient for the ith reaction with a Chebyshevrate expression can be evaluated; again, we omit the subscript i for clarity:

∂kf∂T

= log(10) · kfNT∑i=1

Np∑j=1

ηij∂

∂T

(Ti−1(T ) Tj−1 (p)

),

where

∂T

(Ti−1(T ) Tj−1 (p)

)= (i− 1)Ui−2(T ) Tj−1(p)

∂T

∂T

+ (j − 1)Ti−1(T )Uj−2(p)∂p

∂T, (106)

∂T

∂T=

−2T−2

T−1max − T−1min

, (107)

∂p

∂T=

2p log(10)

∂p∂T

log10 pmax − log10 pmin

= 0 , (108)

16

Page 17: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

and Un is the Chebyshev polynomial of the second kind of degree n, expressed as

Un(x) =sin ((n+ 1) arccosx)

sin(arccosx). (109)

Thus, the partial derivative of the forward rate coe�cient can be expressed as

∂kf∂T

=kfT

log(10)

NT∑i=1

Np∑j=1

ηij

((i− 1)Ui−2(T ) Tj−1(p)

−2T−1

T−1max − T−1min

). (110)

The partial derivative of the reverse rate coe�cient kr,i with respect to temperature canbe found using Eq. (70) for both pressure-dependent reaction classes. The partial derivativeof kr,i with respect to species mass fractions is zero, for the same reason as the forward ratecoe�cient.

3.2. Evaluation of Jacobian matrix

The Jacobian matrix can be e�ciently �lled by arranging the evaluation of elements inan appropriate order. First, evaluate the Jacobian entries for partial derivatives of speciesequations (Jk+1,1 and Jk+1,j+1 for k, j = 1, . . . , Nsp − 1):

Jk+1,1 =Wk

ρ

Nreac∑i=1

νki

[∂ci∂T

(Rf,i −Rr,i) + ci

(∂Ri

∂T+Rf,i −Rr,i

T

)], (111)

where all terms were expressed previously; note that ci = 1 and ∂ci∂T

= 0 for pressure-dependent reactions expressed via logarithmic interpolations or Chebyshev polynomials. Theremaining columns are given by

Jk+1,j+1 =Wk

ρ

ωkW (1

Wj

− 1

WNsp

)+

Nreac∑i=1

νki

∂ci∂Yj

(Rf,i −Rr,i)

+ ci

Nsp∑l=1

(ν ′li

(−Rf,iW

( 1

Wj

− 1

WNsp

)+(δlj − δlNsp

)kf,i

ρ

Wl

[Xl]ν′li−1

Nsp∏n=1n6=l

[Xn]ν′ni

)

− ν ′′li(−Rr,iW

( 1

Wj

− 1

WNsp

)

+(δlj − δlNsp

)kr,i

ρ

Wl

[Xl]ν′′li−1

Nsp∏n=1n 6=l

[Xn]ν′′ni

)) . (112)

Next, the Jacobian entries for partial derivatives of the energy equation (J1,1 and J1,j+1

for j = 1, . . . , Nsp − 1) are given by

J1,1 =−1

cp

{Nsp−1∑k=1

[(cp,k −

hkcp

∂cp∂T

)Wkωkρ

+ hkJk+1,1

]

17

Page 18: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

+

(cp,Nsp

−hNsp

cp

∂cp∂T

)WNsp

ωNsp

ρ+ hNsp

JNsp+1,1

}(113)

J1,j+1 =−1

cp

(−cp,j − cp,Nsp

ρcp

Nsp∑k=1

hkWkωk

+

Nsp−1∑k=1

hkJk+1,j+1 + hNspJNsp+1,j+1

), (114)

where ∂cp∂T

is given by Eq. (54); JNsp+1,1 and JNsp+1,j+1 are placeholder variables for the lastspecies Nsp calculated in a similar manner as Eqs. (111) and (112).

3.3. Jacobian matrix sparsity

While some discuss the sparsity of analytically evaluated Jacobian matrices for chemicalkinetics [5, 43], for the governing equations of constant-pressure kinetics using mass fractionsthe Jacobian is actually dense. This results from the partial derivative of density with respectto species mass fraction, ∂ρ/∂Yj, that appears in Eq. (49). As a consequence, the partialderivatives of all species rate-of-change Yk with respect to the jth species' mass fraction Yj,or Jk+1,j+1, are potentially nonzero. However, if the constant-volume assumption insteadholds true, then ∂ρ/∂Yj = 0 and Jacobian matrices exhibit the sparsity shown by Perini etal. [43]. In that case, o�-diagonal elements of the Jacobian matrix only arise due to directspecies interactions and fallo�/pressure-dependent reactions. Unfortunately, simulations oflow-speed combustion systems typically rely on the constant-pressure assumption [46].

Alternatively, the governing equations can be formulated in terms of species molar con-centrations rather than mass fractions [5, 42]. This eliminates the presence of ρ in thecross-species Jacobian matrix elements and thus signi�cantly increases matrix sparsity forconstant-pressure combustion. We plan to explore this approach for future versions of pyJac.

4. Optimization of Jacobian evaluation

Algorithm (1) presents pseudocode for a simple implementation of the outlined Jaco-bian evaluation approach based on the equations in Section 3.2. Although attractive as astraightforward implementation, it neglects potential reuse of computed products and thusunnecessarily recomputes terms. Furthermore, this formulation produces source code withsubstantial numbers of lines even for small kinetic models such as GRI-Mech 3.0 [58] (e.g.,∼100,000 lines).

Without a strategy to enable the reuse of temporary computed products, even reasonablymodern compilers (e.g., gcc 4.4.7) struggle to compile the resulting code, resulting in longcompilation times, slow execution, and even occasional crashes of the compiler itself. Thissection lays out a restructuring of Algorithm (1), presented in Algorithm (2), that greatlyaccelerates Jacobian evaluation via reuse of temporary products to reduce computationaloverhead. As a side-bene�t of this technique, compilation times are greatly reduced andcompiler crashes can be avoided.

18

Page 19: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Algorithm 1 A pseudo-code for simple/naive generation of the chemical Jacobian.

for i in 1, . . . , Nsp − 1 dofor k in 1, . . . , Nreac do

if νi,k 6= 0 then

Generate code for reaction k's contribution to ∂Yi∂T

for j in 1, . . . , Nsp − 1 dofor k in 1, . . . , Nreac do

if νj,k 6= 0 then

Generate code for reaction k's contribution to ∂Yk∂Yj

for i in 1, . . . , Nsp − 1 do

Generate code for ∂T∂Yi

Generate code for ∂T∂T

Algorithm 2 A restructured pseudo-code to enable e�cient chemical Jacobian evaluation.

for k in 1, . . . , Nreac do

De�ne reusable products for temperature derivativesfor i in 1, . . . , Nsp − 1 do

if νi,k 6= 0 then

Generate code for reaction k's contribution to ∂Yi∂T

De�ne reusable products for species derivativesfor j in 1, . . . , Nsp − 1 do

for i in 1, . . . , Nsp − 1 doif νi,k 6= 0 then

Generate code for ∂Yi∂Yj

for i in 1, . . . , Nsp − 1 do

Generate code for ∂T∂Yi

Generate code for ∂T∂T

19

Page 20: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

4.1. Accelerating evaluation via reuse of temporary products

First, examining Eqs. (111) and (112), we see that large portions of the Jacobian entriesare constant for a single reaction. For instance, if we de�ne a temporary variable for the ithreaction

Θ∂T,i =1

ρ

[∂ci∂T

(Rf,i −Rr,i) + ci

(∂Ri

∂T+Rf,i −Rr,i

T

)], (115)

then Eq. (111) can be rewritten as

Jk+1,1 = Wk

Nreac∑i=1

νkiΘ∂T,i . (116)

Next, instead of summing over all reactions for a single species, we transform Algorithm (1)to compute the temporary product for a single reaction i and add to all relevant species:

Jk+1,1 += νkiWkΘ∂T,i k = 1, . . . , Nsp − 1 . (117)

and�as introduced in Sec. (3.2)�the placeholder variable JNsp+1,1 may be updated analo-gously to Eq. (117). In doing so, the temporary product Θ∂T,i must only be evaluated oncefor each reaction, rather than once for every species in each reaction with a non-zero netproduction or consumption rate.

Similarly, for Eq. (112) we can de�ne similar temporary products, although more caremust be taken to ensure the correctness for all of the di�erent reaction types. For all reactionsi, the following temporary product can be de�ned:

Θ∂Y,i,ind = −Wciρ

(Rf,i

Nsp∑l=1

ν ′li −Rr,i

Nsp∑l=1

ν ′′li

). (118)

The Jacobian entries Jk+1,j+1 for a pressure-independent reaction i can then be updatedwith

Jk+1,j+1 += νkiWk

Wj

[Θ∂Y,i,ind

(1− Wj

WNsp

)+ ci

((kf,iS

′j − kr,iS ′′j

)− Wj

WNsp

(kf,iS

′Nsp− kr,iS ′′Nsp

))]k, j = 1, . . . , Nsp − 1 , (119)

where S ′l and S′′l are de�ned (for l = {j,Nsp}) as

S ′l = ν ′li[Xl]ν′li−1

Nsp∏n=1n6=l

[Xn]ν′ni and (120)

S ′′l = ν ′′li[Xl]ν′′li−1

Nsp∏n=1n 6=l

[Xn]ν′′ni . (121)

20

Page 21: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

and the placeholder variable JNsp+1,j+1 may be updated as in Eq. (119). Note that eitherone or both of ν ′ji and ν

′′ji can be zero, while ν ′Nspi

and ν ′′Nspiare typically both zero if the last

species is an inert abundant gas, e.g., N2 for air-fed combustion. This means that the addedS ′l and S

′′l terms are often zero, and may be omitted in such cases.

For third-body enhanced or fallo� reactions, the ∂ci∂Yj

term in Eq. (112) is inherently

dependent on the jth species; however, certain simpli�cations can still be made. First, forany third-body enhanced or fallo� reaction where all third-body e�ciencies αi,j are unity,the derivative ∂ci

∂Yjis identically zero as seen in Eq. (81), and the updating scheme de�ned in

Eq. (119) can be used. Otherwise, the appropriate update schemes described below must beemployed.

For third-body-enhanced reactions, we de�ne

Θ∂Y,i,3rd = Θ∂Y,i,ind +−Wciρ

Ri

= −Wciρ

(Rf,i

(1 +

Nsp∑l=1

ν ′li

)−Rr,i

(1 +

Nsp∑l=1

ν ′′li

)). (122)

The Jacobian entries Jk+1,j+1 for a third-body reaction without fallo� dependence can thenbe updated with

Jk+1,j+1 += νkiWk

Wj

[Θ∂Y,i,3rd

(1− Wj

WNsp

)+

(αij − αiNsp

Wj

WNsp

)Ri

+ ci

((kf,iS

′j − kr,iS ′′j

)− Wj

WNsp

(kf,iS

′Nsp− kr,iS ′′Nsp

))](123)

for k, j = 1, . . . , Nsp − 1, and the placeholder variable JNsp+1,j+1 may be updated usingEq. (123).

For reactions with fallo� dependence, we de�ne a temporary term corresponding to thePr polynomial in Eqs. (83) and (87):

ΘPr,i=

0 if Lindemann fallo� or chemically activated reaction,

1.0

1.0 + Prif Troe/SRI fallo� reaction, or

−Pr1.0 + Pr

if Troe/SRI chemically activated reaction.

(124)

21

Page 22: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Following this, we de�ne a temporary term for the fallo� function derivative ∂Fi

∂Yj:

ΘFi=

0 if Lindemann,

lnFcent

2ATroe

B3Troe

0.14ATroe +BTroe

log 10(1 + (ATroe/BTroe)2)2if Troe, or

X22 log10 Pr,ilog 10

log

(a · exp

−bT

+ exp−Tc

)if SRI.

(125)

Using the above components, we then de�ne the temporary products for fallo� reactions:

Θ∂Y,i,fallo� = Θ∂Y,i,ind + ci(ΘPr,i

+ ΘFi

)(−Wρ

)Ri

=−Wciρ

(Rf,i

(Nsp∑l

ν ′li

)−Rr,i

(Nsp∑l

ν ′′li

)+Ri

(ΘPr,i

+ ΘFi

)). (126)

The Jacobian entries Jk+1,j+1 for a fallo� dependent reaction i can then be updated as

Jk+1,j+1 += νkiWk

Wj

[Θ∂Y,i,fallo�

(1− Wj

WNsp

)+

k0k∞Fi

1 + Pri

(ΘPr,i

+ ΘFi

)(δM

(αij − αiNsp

Wj

WNsp

)+ (1− δM)

(δmj − δmNsp

Wj

WNsp

))Ri

+ ci

((kf,iS

′j − kr,iS ′′j

)− Wj

WNsp

(kf,iS

′Nsp− kr,iS ′′Nsp

))](127)

for k, j = 1, . . . , Nsp − 1, where δM is de�ned as:

δM =

{1 if the mixture acts as third body, or

0 if species m acts as third body.(128)

The placeholder variable JNsp+1,j+1 may be updated as in Eq. (127)

Finally, all Jacobian entries Jk+1,j+1 and placeholder term JNsp+1,j+1 must be �nishedwith the addition of the species rate term:

Jk+1,j+1 +=Wk

Wj

ωkW

ρ

(1− Wj

WNsp

)(129)

JNsp+1,1 +=WNsp

Wj

ωNspW

ρ

(1− Wj

WNsp

)(130)

As with the update scheme used in Eq. (117), the strategy presented in Eqs. (119),(123), and (127) reduces the computational overhead of Jacobian evaluation. The bulkof the computation is performed once per reaction, and only minor sub-products must becomputed for each species-species pair for a given reaction.

22

Page 23: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Model Nsp Nreac Lind. Troe SRI P-log Cheb. Ref.

H2/CO 13 27 × [65]GRI-Mech. 3.0 53 325 × × [58]USC-Mech II 111 784 × × [66]iC5H11OH 360 2172 × × × × × [67]

Table 1: Summary of chemical kinetic models used as benchmark test cases. All modelscontain third-body reactions with enhanced third bodies. The �Lind.�, �Troe�, �SRI�, �P-log�,and �Cheb.� columns indicate the presence of Lindemann, Troe, and SRI fallo�; logarithmicpressure interpolation; and Chebyshev pressure-dependent reactions, respectively. Two re-actions with photons were removed from the Sarathy et al. [67] model since neither Canteranor pyJac supports such reactions.

5. Results and discussion

The Python [59] package pyJac implements the methodology for producing analyticalJacobian matrices described in the previous sections, which we released openly online [60]under the MIT license. pyJac requires the Python module NumPy [61]. The modules usedto test the correctness and performance of pyJac are included in this release, and addition-ally require Cython [62], Cantera [54], PyYAML [63], and Adept [64]; however, these are notrequired for Jacobian/rate subroutine generation. In addition, interpreting Cantera-formatmodels [54] requires installing the Cantera module for any purpose, while pyJac includesnative support for interpreting Chemkin-format models [53].

In order to demonstrate the correctness and computational performance of the generatedanalytical Jacobian matrices, we chose four chemical kinetic models as test cases, selectedto represent a wide spectrum of sizes, classes of fuel species, and types of reaction rate pres-sure dependence formulations (e.g., Lindemann/Troe/SRI fallo� formulations, Chebyshev,pressure-log). Table 1 summarizes the chemical kinetics models used as benchmarks in thiswork, including the H2/CO model of Burke et al. [65], GRI-Mech 3.0 [58], USC-Mech versionII [66], and the isopentanol model of Sarathy et al. [67].

For both the correctness and performance tests, stochastic partially stirred reactor (PaSR)simulations generated thermochemical composition data covering a wide range of tempera-tures and species mass fractions. Appendix C contains a detailed description of the PaSRmethodology and implementation; in addition, the pyJac package contains the PaSR codeused in the present study. We performed nine premixed PaSR simulations for each fuel, withthe parameters given in Table 2. Each simulation ran for �ve (isopentanol) or ten (hydrogen,methane, and ethylene) residence times (τres) to ensure reaching statistical steady state.

5.1. Validation

In order to test the correctness of the Jacobian matrices produced by pyJac, we initiallycompared the resulting analytical matrices against numerical approximations based on �nitedi�erences. However, while these commonly provide numerical approximations to Jacobianmatrices, potential scaling issues due to large disparities in species mass fractions and as-sociated net production rates can cause challenges in selecting appropriate di�erencing step

23

Page 24: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Parameter H2 CH4 C2H4 iC5H11OH

φ 1Tin 400, 600, and 800Kp 1, 10, and 25 atmNpart 100τres 10ms 5ms 100 µs 100 µsτmix 1ms 1ms 10µs 10 µsτpair 1ms 1ms 10µs 10 µsNres 10 10 10 5

Table 2: PaSR parameters used for hydrogen/air, methane/air, ethylene/air, and isopen-tanol/air premixed combustion cases, where φ indicates equivalence ratio, Tin is the temper-ature of the in�owing particles, p is the pressure, Npart is the number of particles, τres is theresidence time, τmix is the mixing time, τpair is the pairing time, and Nres is the number ofresidence times simulated.

sizes [68]. For example, we encountered large errors in some partial derivatives under certainconditions when initially attempting to evaluate derivatives using sixth-order central di�er-ences with increments calculated similarly to the implicit CVODE integrator [31]. Adjustingthe relative and absolute tolerances reduced some of these errors, but we could not �nd con-sistent, e�ective values for all the states considered�in particular, states near equilibriumrequired unreasonably small tolerances (e.g., 1× 10=20), but these same tolerances causedlarger errors at other states. Note that the discussion of our experiences are not intendedto imply issues with the numerical Jacobian approach used in CVODE or other implicit in-tegrators; such solvers only require approximations to the Jacobian matrix. However, basedon our experiences, we recommend taking care when attempting to obtain highly accurateJacobian matrices, as in the current e�ort and for analysis techniques such as computationalsingular perturbation [15, 69�71] and chemical explosive mode analysis [72�74] that rely oneigendecomposition of the Jacobian matrix.

As a result of the aforementioned di�culties with �nite di�erences, we obtained ac-curate Jacobian matrices via automatic di�erentiation through expression templates usingthe Adept software library [64, 75]. In our experience, numerical Jacobians obtained us-ing multiple-term Richardson extrapolants [76�78] are of similar accuracy but have a muchhigher computational cost due to the large number of function evaluations required. We didnot explore other options for obtaining highly accurate numerical Jacobian approximationsusing, e.g., complex-step derivatives [79�81]. For all test cases, the correctness of the speciesand reaction rate subroutines were established through comparison with Cantera [54].

In reporting the discrepancy between the analytical and automatically di�erentiated Ja-cobian matrices, denoted by J and J respectively, we used the Frobenius norm of the relativeerrors of matrix elements

Erel =

∥∥∥∥∥J − JJ∥∥∥∥∥F

, (131)

to quantify error. This di�ers somewhat from the error metric suggested by Anderson et

24

Page 25: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Model Sample size Mean (%) Maximum (%)

H2/CO 900,900 3.170× 10=8 9.828× 10=4

GRI-Mech 3.0 450,900 2.946× 10=8 1.240× 10=4

USC-Mech II 91,800 9.046× 10=9 2.356× 10=4

iC5H11OH 450,900 8.686× 10=10 1.680× 10=5

Table 3: Summary of Jacobian matrix correctness study results. Error statistics are basedon the norm of the relative error percentages Erel for each sample. The sample size for eachcase depends on the number of particles and relevant timescales used.

al. [82] for use quantifying the error of matrices in LAPACK: the relative error Frobeniusnorm

Enorm =

∥∥∥J − J ∥∥∥F∥∥∥J ∥∥∥

F

. (132)

Enorm indicates overall error in the matrix but can be dominated by large elements, so webelieve the error measure Erel given by Eq. (131) to be more useful in identifying discrepanciesin both larger and smaller matrix elements.

Table 3 presents the correctness testing results for each benchmark case. For certainconditions, we observed large relative errors in small nonzero elements (e.g., magnitudes of∼10=22) likely due to roundo� errors; thus, error statistics comprised only matrix elementsJij where |Jij| ≥ ‖J ‖F/1020. For all benchmark cases, the analytical Jacobian matricesmatch closely with those obtained via automatic di�erentiation, with the largest discrepancybelow 1× 10=3%.

We also initially made comparisons with the TChem package [40, 83] for validation pur-poses, using the H2/CO model. However, while many quantities calculated via TChem agreedclosely with those from both Cantera and pyJac, we observed discrepancies in the TChem

species net production rates that correlated with signi�cant errors in the derivative sourceterm and Jacobian matrix. These discrepancies occurred mainly for low species productionrates, where the (larger) rates for other species agreed closely, and in general for near-equilibrium states. Furthermore, during our testing it became apparent that TChem v0.2is not thread-safe when parallelized with OpenMP. We discuss this issue further in Ap-pendix D. As a result, we do not present detailed Jacobian matrix comparisons betweenTChem and pyJac here.

5.2. Performance analysis

The performance of pyJac-generated subroutines for CPU and GPU execution was testedby evaluating Jacobian matrices for the four kinetic models using the previously discussedPaSR thermochemical composition data. In both cases, the performance of pyJac wascompared with that of a �nite-di�erence-based Jacobian; in addition, the CPU routineswere compared with TChem [83] for the H2/CO, GRI-Mech 3.0, and USC-Mech II models.The CPU Jacobian subroutines were compiled using gcc 4.8.5 [84], and run on four ten-core Intel Xeon E5-4640 v2 processors with 20MB of L3 cache memory, installed on an Ace

25

Page 26: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Model RTChem/RpyJac RFD/RpyJac

H2/CO 2.16 4.40GRI-Mech 3.0 1.49 6.98USC-Mech II 1.07 7.51iC5H11OH − 2.96

Table 4: Ratio between CPU-based Jacobian matrix evaluation times of TChem and �nitedi�erence (FD), and pyJac. R indicates the mean evaluation time.

Powerworks PW8027R-TRF+ with a Supermicro X9QR7-TF+/X9QRi-F+ baseboard. Aspreviously mentioned, our tests found that TChem v0.2 is not thread-safe (c.f., Appendix D).Therefore, all CPU performance comparisons between pyJac, TChem, and the �nite-di�erencemethod were carried in a single-threaded manner. Reported mean evaluation times werecomputed from the wall-clock run times of ten individual calculations. The GPU Jacobiansubroutines were compiled using nvcc 7.5.17 [85] and tested on a single NVIDIA Tesla C2075GPU. The mean GPU evaluation times were again computed from ten individual runs. Forthe CPU and GPU �nite-di�erence-based Jacobian calculations, we used a simple �rst-orderforward di�erence adapted from CVODE [31] to give a realistic comparison with a commonlyused �nite-di�erence technique.

Figure 1 shows the performance of the CPU-based pyJac Jacobian matrix evaluationsfor the four kinetic models, compared with the performance of �nite di�erence calculationsand the TChem package [40]. (TChem does not support pressure-log or Chebyshev pressure-dependent reaction expressions, so we could not evaluate its performance with the isopentanolmodel.) Table 4 summarizes the performance ratio between Jacobian matrices calculatedusing pyJac and �nite di�erence/TChem; pyJac-based routines perform approximately 1.1�2.2× faster than TChem on a single-threaded basis, depending on the size of the model.However, we again note that TChem's lack of thread-safety implies that calculation of Jaco-bians for many di�erent thermo-chemical states on a multicore CPU may be much fasterusing pyJac as the calculations may be accelerated easily using OpenMP. pyJac also per-forms 3�7.5× faster than the �rst-order �nite di�erence technique.

Figure 1 also shows best-�t lines based on least-squares regressions for the availabledata (the corresponding R2 values were 0.89, 0.57, and 0.99 for the �nite di�erence, pyJacand TChem results, respectively). These �ts suggest that pyJac and the �nite di�erencemethod scale superlinearly�nearly quadratically�with number of reactions, while TChem

scales nearly linearly with the number of reactions. This is expected for the �nite di�er-ence approach, but warrants explanation for the analytical Jacobian methods. Lu and Lawargued [5] that the cost of analytical Jacobian evaluation should scale linearly with thenumber of reactions in a model. However, this argument is predicated on the assumptionof a sparse Jacobian resulting from a molar-concentration-based system; namely, that onlychanges in species concentrations that participate in a reaction a�ect the resulting reactionrate. As discussed in Section 3.3, the constant-pressure/mass-fraction-based system used inpyJac�along with the majority of reactive-�ow modeling descriptions�results in a denseJacobian and thus execution times that exhibit a higher-order dependence on the number ofspecies/reactions. The current performance, while faster than either a typical �nite di�erence

26

Page 27: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

0 250 500 750 1000 1250 1500 1750 2000Number of Reactions

10 2

10 1

100

101

102

Mea

n ev

alua

tion

time

/ con

ditio

n (m

s) 9.7×10 5N1.8R

1.6×10 5N1.8R

2.8×10 4N1.3R

Finite DifferencepyJacTChem

Figure 1: CPU-based Jacobian matrix evaluation times using �nite di�erences, pyJac, andTChem for the four kinetic models. No performance data were available for the isopentanolmodel using TChem due to the presence of unsupported reaction types. The symbols indicateperformance data, while the solid lines represent least-squares best �ts based on the numberof reactions NR in the models. Error bars are present, but too small to detect. Data, plottingscripts, and the �gure �le are available under CC-BY [86].

27

Page 28: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

approach or TChem, motivates developing a sparse-concentration-based constant-pressure Ja-cobian system in future versions of pyJac.

Figure 2 demonstrates the performance of the GPU Jacobian matrix implementations.Figure 2a shows the mean runtime of the GPU Jacobian matrix evaluations against the num-ber of conditions�i.e., the number of thermochemical composition states, with one Jacobianmatrix evaluated per state. As the number of conditions increases, the GPU becomes fullyutilized and the growth rate of the evaluation time begins increasing linearly (here displayedon a log-log plot). This thread saturation point occurs at nearly the same number of con-ditions for each model. We adopted a �per-thread� GPU parallelization model in this work,where a single GPU thread evaluates a single Jacobian matrix, rather than a �per-block�model where GPU threads in a block cooperate to evaluate a Jacobian. The per-threadapproach simpli�es generation of highly optimized code for SIMD processors and provides ahigher theoretical bound on the number of Jacobian matrices that can be evaluated in paral-lel. However, the choice of GPU parallelization merits further investigation because memorybandwidth limits the current per-thread implementation due to small cache sizes availableon GPU streaming multiprocessors. A per-block implementation might utilize this smallcache more e�ectively, but it is unclear if this would increase overall performance. Figure 2bshows the longest pyJac and forward �nite-di�erence evaluation times�normalized by thenumber of conditions�for each kinetic model plotted against the number of reactions in themodel. As with the CPU matrix evaluations shown in Fig. 1, we observed a superlinear(but subquadratic) scaling of the performance with number of reactions. The least-squaresbest-�t lines for the pyJac and �nite-di�erence results�with R2 values of 0.98 and 0.82,respectively�exhibit similar polynomial orders to the CPU-based Jacobian evaluation, sug-gesting dependence on the methods rather than hardware.

Table 5 shows the ratios of average evaluation times between �nite di�erence and pyJac

on the GPU for the longest runtimes (i.e., the full number of conditions for each model).Interestingly, pyJac performs noticeably better than the �nite-di�erence technique withthe isopentanol model (∼3×) than the three smaller models (1�2×). This likely occursdue to the small cache size of the GPU; in this case, the larger model size (360 speciescompared to, e.g., 111 species for USC-Mech II) makes it di�cult to store a majority ofspecies concentrations in the cache, forcing more loads from global memory. Thus, usingan analytical Jacobian formulation increases performance for larger models by a factor of1.6�2.0 over �nite di�erence methods. A sparse Jacobian formulation would similarly greatlybene�t GPU evaluation due to the greatly reduced memory tra�c requirements (i.e., reducednumber of global reads and writes).

Lastly, Fig. 3 shows the scaling of performance with the number of CPU cores, rangingfrom 1 to 32, and the number of conditions �xed at the value given for each model inTable 3. Figure 3a shows the mean evaluation time, which exhibits a power-law dependenceon the number of cores. The functional relationship between evaluation time and numberof cores is similar for each model, with an intercept increasing with model size. Figure 3bshows the strong scaling e�ciency with number of cores. Interestingly, the strong scalinge�ciency drops most signi�cantly for the smallest and largest models (H2/CO and iC5H11OH,respectively) with increasing number of processors. We hypothesize that the reasons for thesharp drop in scaling e�ciency of these two models actually di�er. The cost of evaluationH2/CO is low enough, particularly at increasing numbers of CPU cores, that the relative

28

Page 29: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

100 101 102 103 104 105 106

Number of conditions

100

101

102

103

104

105

Mea

n ev

alua

tion

time

(ms)

H2/CO

GRI-Mech 3.0

USC-Mech II

iC5H11OH

(a) Mean GPU runtime versus the number of conditions evaluated.

0 250 500 750 1000 1250 1500 1750 2000Number of Reactions

10 3

10 2

10 1

100

Mea

n ev

alua

tion

time

/ con

ditio

n (m

s) 1.2×10 6N1.8R

1.1×10 6N1.8R

Finite DifferencepyJac (GPU)

(b) Comparison of normalized GPU pyJac and �nite di�erence Jacobian matrixevaluation times versus the number of reactions in the model. Symbols indicateperformance data, while solid lines represent least-squares best �ts based on thenumber of reactions NR in the models.

Figure 2: Performance of the GPU-based pyJac. Note the logarithmic scales of the ordinateaxes. Error bars are present, but too small to detect. Data, plotting scripts, and �gure �lesare available under CC-BY [86].

29

Page 30: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

0 5 10 15 20 25 30 35Number of CPU cores

10 3

10 2

10 1

100

101M

ean

eval

uatio

n tim

e pe

r con

ditio

n (m

s)

H2/CO

GRI-Mech 3.0

USC-Mech II

iC5H11OH

(a) Mean CPU runtime versus the number of CPU cores. Error bars are present,but too small to detect. Note the logarithmic scales of the ordinate axis.

0 5 10 15 20 25 30 35Number of CPU cores

0.70

0.75

0.80

0.85

0.90

0.95

1.00

Para

llel s

calin

g ef

ficie

ncy

H2/COGRI-Mech 3.0USC-Mech IIiC5H11OH

(b) Strong scaling e�ciency versus number of CPU cores.

Figure 3: Parallel performance scaling of the CPU-based pyJac, with the number of CPUcores varying and the number of states �xed at the value associated with each model givenin Table 3. Data, plotting scripts, and �gure �les are available under CC-BY [86].

30

Page 31: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

Model RFD/RpyJac

H2/CO 1.72GRI-Mech 3.0 1.37USC-Mech II 1.56iC5H11OH 2.73

Table 5: Ratio between �nite di�erence (FD) and pyJac Jacobian matrix evaluation timeson the GPU. R indicates the mean evaluation time.

overhead for launching OpenMP threads is larger and thus the e�ciency drops. Conversely,the much larger size of the iC5H11OH model requires frequent accesses of larger amounts ofmemory, and thus possibly also more frequent cache misses.

The results presented above raise a number of issues that warrant further study. Thesuperlinear scaling of pyJac matrix evaluation time with number of reactions in the ki-netic models results from the density of the Jacobian matrix, and suggests the potentialbene�ts of a sparse molar-concentration-based Jacobian formulation. However, while pyJacoutperforms TChem in all cases, the performance ratio between them reduces with increasingnumber of reactions, suggesting that the performance bene�t of a hard-coded subroutine maydecrease with increasing model size. Although it appears from these results that the perfor-mance of a hard-coded Jacobian subroutine can surpass that of an interface-based Jacobianevaluation, the hard-coded method has additional di�culties due to the size and numberof �les created. For example, the CPU Jacobian evaluation subroutine for USC-Mech IIcomprises over 360,000 total lines spread across 22 �les (not including the supporting �lesfor, e.g., species and reaction rate evaluations)�attempting to incorporate the entire matrixevaluation in a single �le crashed an older version of the gcc compiler (4.4.7). This notonly causes longer source code compilation times (on the order of ten minutes to an hourwhen using 24 parallel compiler instances), but could cause compiler crashes and inexpli-cable behavior, particularly for the less mature nvcc compiler. While we expect a sparseJacobian formulation would signi�cantly alleviate these issues, future work should directlycompare the performance of comparable hard-coded and interface-based Jacobian evaluationapproaches.

6. Conclusions

This work developed the theory behind an analytical Jacobian matrix evaluation ap-proach for constant-pressure chemical kinetics, including new derivations of partial deriva-tives with respect to modern pressure-dependent reaction formulations. In addition, wedetailed strategies for e�cient evaluation of the Jacobian matrix, including reordering ma-trix element evaluations in order to enable the reuse of temporary products. We implementedthe presented methodology in the open-source software package pyJac [60], which generatescustom source code �les for evaluating chemical kinetics Jacobian matrices on both CPU andGPU systems. We established the correctness of the resulting Jacobian matrices throughcomparison with matrices obtained by automatic di�erentiation. The results agree within0.001% for kinetic models describing the oxidation of hydrogen, methane, ethylene, and

31

Page 32: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

isopentanol, with 13 to 360 species (and 27 to 2172 reactions). Finally, we investigated theperformance of the CPU and GPU matrix evaluation subroutines by evaluating the matrixcalculation time for the same kinetic models. The pyJac CPU-based Jacobian evaluationperforms 3�7.5 times faster than a forward-�nite-di�erence approach, while a more modestimprovement speedup of 1.1�2.2× was found compared to the existing TChem software on asingle-threaded basis. We note again that TChem is not thread-safe when parallelized withOpenMP, while pyJac is easily parallelized with the same approach; for multicore CPUspyJac is expected to greatly outperform TChem.

Planned development work for pyJac includes adding support for the constant-volumeassumption, and the capability to generate Fortran and Matlab source codes. Further studywill be performed into the bene�ts of the current custom source-code, compiled Jacobianevaluation subroutine approach versus a loop/branch-based approach, in order to determinehow to obtain the best performance scaling with kinetic model size. Finally, we will investi-gate the performance bene�ts of converting from a di�erential system based on species massfractions to molar concentrations, which o�ers a marked improvement in matrix sparsity.

Acknowledgments

This material is based upon work supported by the National Science Foundation undergrants ACI-1535065 and ACI-1534688. In addition, we thank James Sutherland and MikeHansen of the University of Utah for helpful discussions on appropriate formulation of statevectors.

Appendix A. Supplementary material

The results for this paper were obtained using pyJac v1.0.2 [60]. The most recent versionof pyJac can be found at its GitHub repository https://github.com/SLACKHA/pyJac. Inaddition, the repository contains detailed documentation and an issue-tracking system. All�gures, and the data and plotting scripts necessary to reproduce them, are available openlyunder the CC-BY license [86].

Appendix B. Proof of partial derivative of pressure

∂p

∂Yj=

∂Yj

(RT

Nsp∑k=1

[Xk]

)= RT

Nsp∑k=1

∂[Xk]

∂Yj

= RTNsp∑k=1

[−[Xk]W

(1

Wj

− 1

WNsp

)+(δkj − δkNsp

) ρ

Wk

]

= −RTW(

1

Wj

− 1

WNsp

) Nsp∑k=1

[Xk] +RTρNsp∑k=1

δkj − δkNsp

Wk

= −pW(

1

Wj

− 1

WNsp

)+ ρRT

(1

Wj

− 1

WNsp

)

32

Page 33: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

= (−pW + pW )

(1

Wj

− 1

WNsp

)∴∂p

∂Yj= 0 . (B.1)

Note that this holds without any assumption of constant pressure or volume.

Appendix C. Partially stirred reactor implementation

Here, we describe our partially stirred reactor (PaSR) implementation for completeness,based on prior descriptions [27, 87�91]. The reactor model consists of an even number Npart

of particles, each with a time-varying composition φ(t). Unlike the composition vector givenpreviously (Eq. (1)), here we use mixture enthalpy and species mass fractions to describethe state of a particle:

φ ={h, Y1, Y2, . . . , YNsp

}ᵀ. (C.1)

At discrete time steps of size ∆t, events including in�ow, out�ow, and pairing cause certainparticles to change composition; between these time steps, mixing and reaction fractionalsteps separated by step size ∆tsub evolve the composition of all particles.

In�ow and out�ow events at the discrete time steps comprise the in�ow stream compo-sitions replacing the compositions of Npart∆t/τres randomly selected particles, where τres isthe residence time. For premixed combustion cases, the in�ow streams consist of a freshfuel/air mixture stream at a speci�ed temperature and equivalence ratio, and a pilot streamconsisting of the adiabatic equilibrium products of the fresh mixture stream, with the mass�ow rates of these two streams in a ratio of 0.95 : 0.05. Non-premixed cases consist of threein�ow streams: air, fuel, and a pilot consisting of the adiabatic equilibrium products of a sto-ichiometric fuel/air mixture at the same unburned temperature as the �rst two streams; themass �ow rates of these streams occur in a ratio of 0.85 : 0.05 : 0.1. Following in�ow/out�ow(for both premixed and non-premixed cases), 1

2Npart∆t/τpair pairs of particles (not including

the in�owing particles) are randomly selected for pairing and then randomly shu�ed withthe in�owing particles to exchange partners, where τpair is the pairing timescale.

Although multiple mixing models exist [90], the current mixing fractional step consistsof a pair of particles φp and φq exchanging compositional information and evolving by

dφp

dt= −φ

p − φq

τmix

and (C.2)

dφq

dt= −φ

q − φp

τmix

, (C.3)

where τmix is a characteristic mixing timescale. The analytical solution to this system ofequations determines the particle compositions φp and φq after a mixture fractional step:

φp = φp0 − α , (C.4)

φq = φq0 + α , and (C.5)

α =φp0 − φ

q0

2

[1− exp

(−2∆tsubτmix

)], (C.6)

33

Page 34: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

0.00 0.01 0.02 0.03 0.04 0.05

Time (s)

1900

2000

2100

2200

2300

2400

Mean t

em

pera

ture

(K

)

Figure C.1: Mean temperature of premixed PaSR combustion for stoichiometric methane/airwith an unburned temperature of 600K and at 1 atm, τres = 5 ms, τmix = τpair = 1 ms, andusing 100 particles. Data, plotting scripts, and the �gure �le are available under CC-BY [86].

where φp0 and φq0 are the particle compositions at the beginning of the mixture fractionalstep and ∆tsub is the mixing sub-time-step size. The reaction fractional step consists of theenthalpy evolving by

dh

dt=−1

ρ

Nsp∑k=1

hkWkωk (C.7)

and the species mass fractions evolving according to Eq. (8). However, in practice ourimplementation handles the reaction fractional step by advancing in time a Cantera [54]ReactorNet that contains a IdealGasConstPressureReactor object, rather than integrat-ing the above equations directly.

The time integration scheme implemented in our approach determines the discrete timestep between in�ow/out�ow and pairing events ∆t and the sub-time step size ∆tsub sepa-rating mixing/reaction fractional steps, both held constant in the current implementation,via

∆t = 0.1 min (τres, τpair) and (C.8)

∆tsub = 0.04 τmix , (C.9)

adopted from Pope [27].Figures C.1 and C.2 demonstrate sample results from premixed PaSR combustion of

methane/air, using GRI-Mech 3.0 [58]; Fig. C.1 shows the mean temperature evolution overtime, while Fig. C.2 shows the temperature distribution among all particles. Although a large

34

Page 35: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

600 800 1000 1200 1400 1600 1800 2000 2200 24000.00

0.01

0.02

0.03

0.04

0.05

Tim

e (

s)

600 800 1000 1200 1400 1600 1800 2000 2200 2400

Temperature (K)

0.000

0.005

0.010

0.015

0.020

PD

F

Figure C.2: Scatterplot of temperature over time (top) and probability density function(PDF) of temperature (bottom) of premixed PaSR combustion for stoichiometric methane/air with an unburned temperature of 600K and at 1 atm, τres = 5 ms, τmix = τpair = 1 ms, andusing 100 particles. Data, plotting scripts, and the �gure �le are available under CC-BY [86].

35

Page 36: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

number of particles reside near the equilibrium temperature of 2367K, the wide distributionin particle states is evident.

Appendix D. Discussion of TChem's thread-safety

During testing, it became evident that TChem v0.2 [83] is not thread-safe for parallelizationvia OpenMP. In other words, when using OpenMP to parallelize the evaluation of multipleJacobian matrices, the results di�er from those obtained by evaluating the same matrices inserial.

To investigate this observed phenomenon further, we created a straightforward test usingthe H2/CO model of Burke et al. [65] and a subset of the PaSR data discussed elsewhere inthis paper. In short, the testing program �rst used TChem to evaluate the Jacobian matricesin serial (i.e., in a single-threaded manner) for 100,100 states sampled from the PaSR datadescribed in Table 2. Next, this process was repeated, but with OpenMP parallelization ofthe outer loop enabled. To determine whether TChem is thread-safe, the computed Jacobianmatrices from these two approaches were compared.

We found signi�cant error between the Jacobian matrices computed in serial and withmultiple threads for all cases, demonstrating that the current version of TChem is not thread-safe. This self-contained test is available openly [92].

References

[1] S. M. Sarathy, C. K. Westbrook, M. Mehl, W. J. Pitz, C. Togbe, P. Dagaut, H. Wang,M. A. Oehlschlaeger, U. Niemann, K. Seshadri, P. S. Veloo, C. Ji, F. N. Egol-fopoulos, T. Lu, Comprehensive chemical kinetic modeling of the oxidation of 2-methylalkanes from C7 to C20, Combust. Flame 158 (12) (2011) 2338�2357. doi:

10.1016/j.combustflame.2011.05.007.

[2] M. Mehl, W. J. Pitz, C. K. Westbrook, H. J. Curran, Kinetic modeling of gasolinesurrogate components and mixtures under engine conditions, Proc. Combust. Inst. 33 (1)(2011) 193�200. doi:10.1016/j.proci.2010.05.027.

[3] M. Mehl, J.-Y. Chen, W. J. Pitz, S. M. Sarathy, C. K. Westbrook, An approachfor formulating surrogates for gasoline with application toward a reduced surrogatemechanism for CFD engine modeling, Energy Fuels 25 (11) (2011) 5215�5223. doi:

10.1021/ef201099y.

[4] O. Herbinet, W. J. Pitz, C. K. Westbrook, Detailed chemical kinetic mechanism for theoxidation of biodiesel fuels blend surrogate, Combust. Flame 157 (5) (2010) 893�908.doi:10.1016/j.combustflame.2009.10.013.

[5] T. Lu, C. K. Law, Toward accommodating realistic fuel chemistry in large-scale compu-tations, Prog. Energy Comb. Sci. 35 (2) (2009) 192�215. doi:10.1016/j.pecs.2008.10.002.

[6] T. Turányi, A. S. Tomlin, Analysis of Kinetic Reaction Mechanisms, Springer-Verlag,Berlin Heidelberg, 2014. doi:10.1007/978-3-662-44562-4.

36

Page 37: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

[7] T. Lu, C. K. Law, Linear time reduction of large kinetic mechanisms with directedrelation graph: n-heptane and iso-octane, Combust. Flame 144 (1-2) (2006) 24�36.doi:10.1016/j.combustflame.2005.02.015.

[8] P. Pepiot-Desjardins, H. Pitsch, An e�cient error-propagation-based reduction methodfor large chemical kinetic mechanisms, Combust. Flame 154 (1�2) (2008) 67�81. doi:

10.1016/j.combustflame.2007.10.020.

[9] V. Hiremath, Z. Ren, S. B. Pope, A greedy algorithm for species selection in dimensionreduction of combustion chemistry, Combust. Theor. Model. 14 (5) (2010) 619�652.doi:10.1080/13647830.2010.499964.

[10] K. E. Niemeyer, C. J. Sung, M. P. Raju, Skeletal mechanism generation for surrogatefuels using directed relation graph with error propagation and sensitivity analysis, Com-bust. Flame 157 (9) (2010) 1760�1770. doi:10.1016/j.combustflame.2009.12.022.

[11] T. Lu, C. K. Law, Di�usion coe�cient reduction through species bundling, Combust.Flame 148 (3) (2007) 117�126. doi:10.1016/j.combustflame.2006.10.004.

[12] S. S. Ahmed, F. Mauÿ, G. Moréac, T. Zeuch, A comprehensive and compact n-heptaneoxidation model derived using chemical lumping, Phys. Chem. Chem. Phys. 9 (9) (2007)1107�1126. doi:10.1039/b614712g.

[13] P. Pepiot-Desjardins, H. Pitsch, An automatic chemical lumping method for the re-duction of large chemical kinetic mechanisms, Combust. Theor. Model. 12 (6) (2008)1089�1108. doi:10.1080/13647830802245177.

[14] U. Maas, S. B. Pope, Simplifying chemical kinetics: intrinsic low-dimensional manifoldsin composition space, Combust. Flame 88 (3-4) (1992) 239�264. doi:10.1016/0010-

2180(92)90034-M.

[15] S.-H. Lam, D. A. Goussis, The CSP method for simplying kinetics, Int. J. Chem. Kinet.26 (4) (1994) 461�486. doi:10.1002/kin.550260408.

[16] T. Lu, Y. Ju, C. K. Law, Complex CSP for chemistry reduction and analysis, Combust.Flame 126 (1�2) (2001) 1445�1455. doi:10.1016/S0010-2180(01)00252-8.

[17] X. Gou, W. Sun, Z. Chen, Y. Ju, A dynamic multi-timescale method for combustionmodeling with detailed and reduced chemical kinetic mechanisms, Combust. Flame157 (6) (2010) 1111�1121. doi:10.1016/j.combustflame.2010.02.020.

[18] T. Lu, C. K. Law, Strategies for mechanism reduction for large hydrocarbons: n-heptane, Combust. Flame 154 (1�2) (2008) 153�163. doi:10.1016/j.combustflame.

2007.11.013.

[19] K. E. Niemeyer, C. J. Sung, Mechanism reduction for multicomponent surrogates: Acase study using toluene reference fuels, Combust. Flame 161 (11) (2014) 2752�2764.doi:10.1016/j.combustflame.2014.05.001.

37

Page 38: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

[20] K. E. Niemeyer, C. J. Sung, Reduced chemistry for a gasoline surrogate valid at engine-relevant conditions, Energy Fuels 29 (2) (2015) 1172�1185. doi:10.1021/ef5022126.

[21] I. Banerjee, M. Ierapetritou, An adaptive reduction scheme to model reactive �ow,Combust. Flame 144 (3) (2006) 619�633. doi:10.1016/j.combustflame.2005.10.001.

[22] L. Liang, J. Stevens, J. T. Farrell, A dynamic adaptive chemistry scheme for reactive�ow computations, Proc. Combust. Inst. 32 (1) (2009) 527�534. doi:10.1016/j.proci.2008.05.073.

[23] Y. Shi, L. Liang, H.-W. Ge, R. D. Reitz, Acceleration of the chemistry solver for model-ing DI engine combustion using dynamic adaptive chemistry (DAC) schemes, Combust.Theor. Model. 14 (1) (2010) 69�89. doi:10.1080/13647830903548834.

[24] X. Gou, Z. Chen, W. Sun, Y. Ju, A dynamic adaptive chemistry scheme with errorcontrol for combustion modeling with a large detailed mechanism, Combust. Flame160 (2) (2013) 225�231. doi:10.1080/13647830.2012.733825.

[25] H. Yang, Z. Ren, T. Lu, G. M. Goldin, Dynamic adaptive chemistry for turbulent �amesimulations, Combust. Theor. Model. 17 (1) (2013) 167�183. doi:10.1080/13647830.2012.733825.

[26] N. J. Curtis, K. E. Niemeyer, C. J. Sung, An automated target species selection methodfor dynamic adaptive chemistry simulations, Combust. Flame 162 (2015) 1358�1374.doi:10.1016/j.combustflame.2014.11.004.

[27] S. B. Pope, Computationally e�cient implementation of combustion chemistry using insitu adaptive tabulation, Combust. Theor. Model. 1 (1) (1997) 41�63. doi:10.1080/

713665229.

[28] C. F. Curtiss, J. O. Hirschfelder, Integration of sti� equations, PNAS 38 (3) (1952)235�243.

[29] G. D. Byrne, A. C. Hindmarsh, Sti� ODE solvers: a review of current and comingattractions, J. Comput. Phys. 70 (1) (1987) 1�62. doi:10.1016/0021-9991(87)90001-5.

[30] P. N. Brown, G. D. Byrne, A. C. Hindmarsh, VODE: a variable-coe�cient ODE solver,SIAM J. Sci. Stat. Comput. 10 (5) (1989) 1038�1051. doi:10.1137/0910062.

[31] A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, D. E. Shumaker, C. S.Woodward, SUNDIALS: Suite of nonlinear and di�erential/algebraic equation solvers,ACM T. Math. Software 31 (3) (2005) 363�396. doi:10.1145/1089014.1089020.

[32] E. S. Oran, J. P. Boris, Numerical Simulation of Reactive Flow, 2nd Edition, CambridgeUniversity Press, Cambridge, 2001.

38

Page 39: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

[33] K. Spa�ord, J. Meredith, J. Vetter, J. Chen, R. Grout, R. Sankaran, AcceleratingS3D: A GPGPU case study, in: Euro-Par 2009 Parallel Processing Workshops, LNCS6043, Springer-Verlag, Berlin, Heidelberg, 2010, pp. 122�131. doi:10.1007/978-3-

642-14122-5_16.

[34] Y. Shi, W. H. G. Jr, H.-W. Wong, O. O. Oluwole, Redesigning combustion modelingalgorithms for the graphics processing unit (GPU): Chemical kinetic rate evaluationand ordinary di�erential equation integration, Combust. Flame 158 (5) (2011) 836�847.doi:10.1016/j.combustflame.2011.01.024.

[35] K. E. Niemeyer, C. J. Sung, C. G. Fotache, J. C. Lee, Turbulence-chemistry closuremethod using graphics processing units: a preliminary test, in: 7th Fall TechnicalMeeting of the Eastern States Section of the Combustion Institute, 2011. doi:10.

6084/m9.figshare.3384964.v1.

[36] Y. Shi, W. H. Green, H.-W. Wong, O. O. Oluwole, Accelerating multi-dimensional com-bustion simulations using GPU and hybrid explicit/implicit ODE integration, Combust.Flame 159 (7) (2012) 2388�2397. doi:10.1016/j.combustflame.2012.02.016.

[37] C. P. Stone, R. L. Davis, Techniques for solving sti� chemical kinetics on graphicalprocessing units, J. Propul. Power 29 (4) (2013) 764�773. doi:10.2514/1.B34874.

[38] K. E. Niemeyer, C. J. Sung, Accelerating moderately sti� chemical kinetics in reactive-�ow simulations using GPUs, J. Comput. Phys. 256 (2014) 854�871. doi:10.1016/j.jcp.2013.09.025.

[39] K. E. Niemeyer, C. J. Sung, Recent progress and challenges in exploiting graphicsprocessors in computational �uid dynamics, J. Supercomput. 67 (2) (2014) 528�564.doi:10.1007/s11227-013-1015-7.

[40] C. Safta, H. N. Najm, O. M. Knio, TChem - a software toolkit for the analysis of complexkinetic models, Tech. Rep. SAND2011-3282, Sandia National Laboratories (May 2011).

[41] M. R. Yousse�, Development of analytic tools for computational �ame diagnostics,Master's thesis, University of Connecticut, http://digitalcommons.uconn.edu/gs_theses/145/ (Aug. 2011).

[42] F. Bisetti, Integration of large chemical kinetic mechanisms via exponential methodswith Krylov approximations to Jacobian matrix functions, Combust. Theor. Model.16 (3) (2012) 387�418. doi:10.1080/13647830.2011.631032.

[43] F. Perini, E. Galligani, R. D. Reitz, An analytical Jacobian approach to sparse re-action kinetics for computationally e�cient combustion modeling with large reactionmechanisms, Energy Fuels 26 (8) (2012) 4804�4822. doi:10.1021/ef300747n.

[44] T. Dijkmans, C. M. Schietekat, K. M. Van Geem, G. B. Marin, GPU based simulation ofreactive mixtures with detailed chemistry in combination with tabulation and an analyt-ical Jacobian, Comput. Chem. Eng. 71 (2014) 521�531. doi:10.1016/j.compchemeng.2014.09.016.

39

Page 40: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

[45] J. Nickolls, I. Buck, M. Garland, K. Skadron, Scalable parallel programming withCUDA, Queue 6 (2) (2008) 40�53. doi:10.1145/1365490.1365500.

[46] C. K. Law, Combustion Physics, Cambridge University Press, New York, 2006.

[47] J. Warnatz, U. Maas, R. W. Dibble, Combustion, 4th Edition, Physical and ChemicalFundamentals, Modeling and Simulation, Exeriments, Pollutant Formation, Springer,Berlin Heidelberg, 2006.

[48] I. Glassman, R. A. Yetter, Combustion, 4th Edition, Academic Press, Burlington, MA,2008.

[49] S. Gordon, B. J. McBride, Computer program for calculation of complex chemical equi-librium compositions, rocket performance, incident and re�ected shocks, and Chapman-Jouguet detonations, Tech. Rep. NASA-SP-273, NASA Lewis Research Center (Mar.1976).

[50] F. A. Lindemann, S. Arrhenius, I. Langmuir, N. R. Dhar, J. Perrin, W. C. McC Lewis,Discussion on �the radiation theory of chemical action�, Trans. Faraday Soc. 17 (1922)598�606. doi:10.1039/TF9221700598.

[51] R. G. Gilbert, K. Luther, J. Troe, Theory of thermal unimolecular reactions in the fall-o� range. II. Weak collision rate constants, Ber. Bunsenges. Phys. Chem. 87 (2) (1983)169�177. doi:10.1002/bbpc.19830870218.

[52] P. H. Stewart, C. W. Larson, D. M. Golden, Pressure and temperature dependenceof reactions proceeding via a bound complex. 2. Application to 2CH3 � C2H5 + H,Combust. Flame 75 (1) (1989) 25�31. doi:10.1016/0010-2180(89)90084-9.

[53] Reaction Design: San Diego, CHEMKIN-PRO 15113 (2012).URL http://www.ansys.com/Products/Fluids/ANSYS-Chemkin-Pro

[54] D. G. Goodwin, H. K. Mo�at, R. L. Speth, Cantera: An object-oriented software toolkitfor chemical kinetics, thermodynamics, and transport processes, http://www.cantera.org, version 2.3.0 (2017). doi:10.5281/zenodo.170284.

[55] P. K. Venkatesh, A. M. Dean, M. H. Cohen, R. W. Carr, Chebyshev expansions andsensitivity analysis for approximating the temperature- and pressure-dependence ofchemically-activated reactions, Rev. Chem. Eng. 13 (1) (1997) 1�67. doi:10.1515/

REVCE.1997.13.1.1.

[56] P. K. Venkatesh, A. Y. Chang, A. M. Dean, M. H. Cohen, R. W. Carr, Parameterizationof pressure- and temperature-dependent kinetics in multiple well reactions, AICHe J.43 (5) (1997) 1331�1340. doi:10.1002/aic.690430522.

[57] P. K. Venkatesh, Damped pseudospectral functional forms of the fallo� behavior ofunimolecular reactions, J. Phys. Chem. A 104 (2) (2000) 280�287. doi:10.1021/

jp991458u.

40

Page 41: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

[58] G. P. Smith, D. M. Golden, M. Frenklach, N. W. Moriarty, B. Eiteneer, M. Goldenberg,C. T. Bowman, R. K. Hanson, S. Song, W. C. Gardiner, V. V. Lissianski, Z. Qin,GRI-Mech 3.0, http://www.me.berkeley.edu/gri_mech/.

[59] Python Software Foundation, Python language reference, version 2.7.10, Available athttp://www.python.org (2015).

[60] K. E. Niemeyer, N. J. Curtis, pyJac v1.0.2 (Jan. 2017). doi:10.5281/zenodo.251144.

[61] S. van der Walt, S. C. Colbert, G. Varoquaux, The NumPy array: A structure fore�cient numerical computation, Comput. Sci. Eng. 13 (2011) 22�30. doi:10.1109/

MCSE.2011.37.

[62] S. Behnel, R. Bradshaw, C. Citro, L. Dalcin, D. S. Seljebotn, K. Smith, Cython: Thebest of both worlds, Comput. Sci. Eng. 13 (2011) 31�39. doi:10.1109/MCSE.2010.118.

[63] K. Simonov, PyYAML version 3.11, Available at http://pyyaml.org (Mar. 2014).

[64] R. J. Hogan, Adept v1.1, Available at https://github.com/rjhogan/Adept (Jun.2015).

[65] M. P. Burke, M. Chaos, Y. Ju, F. L. Dryer, S. J. Klippenstein, Comprehensive H2/O2

kinetic model for high-pressure combustion, Int. J. Chem. Kinet. 44 (7) (2011) 444�474.doi:10.1002/kin.20603.

[66] H. Wang, X. You, A. V. Joshi, S. G. Davis, A. Laskin, F. Egolfopoulos, C. K. Law,USC Mech Version II. High-temperature combustion reaction model of H2/CO/C1�C4

compounds, http://ignis.usc.edu/USC_Mech_II.htm (May 2007).

[67] S. M. Sarathy, S. Park, B. W. Weber, W. Wang, P. S. Veloo, A. C. Davis, C. Togbe,C. K. Westbrook, O. Park, G. Dayma, Z. Luo, M. A. Oehlschlaeger, F. N. Egolfopoulos,T. Lu, W. J. Pitz, C. J. Sung, P. Dagaut, A comprehensive experimental and modelingstudy of iso-pentanol combustion, Combust. Flame 160 (12) (2013) 2712�2728. doi:

10.1016/j.combustflame.2013.06.022.

[68] L. F. Shampine, Numerical Solution of Ordinary Di�erential Equations, Chapman &Hall, New York, 1994.

[69] S.-H. Lam, D. A. Goussis, Understanding complex chemical kinetics with computationalsingular perturbation, Symp. (Int.) Combust. 22 (1988) 931�941. doi:10.1016/S0082-0784(89)80102-X.

[70] S.-H. Lam, Using CSP to understand complex chemical kinetics, Combust. Sci. Technol.89 (5-6) (1993) 375�404. doi:10.1080/00102209308924120.

[71] S.-H. Lam, Reduced chemistry-di�usion coupling, Combust. Sci. Technol. 179 (4) (2007)767�786. doi:10.1080/00102200601093498.

41

Page 42: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

[72] T. Lu, C. S. Yoo, J. H. Chen, C. K. Law, Three-dimensional direct numerical simulationof a turbulent lifted hydrogen jet �ame in heated co�ow: a chemical explosive modeanalysis, J. Fluid Mech. 652 (2010) 45�64. doi:10.1017/S002211201000039X.

[73] Z. Luo, C. S. Yoo, E. S. Richardson, J. H. Chen, C. K. Law, T. Lu, Chemical explosivemode analysis for a turbulent lifted ethylene jet �ame in highly-heated co�ow, Combust.Flame 159 (1) (2012) 265�274. doi:10.1016/j.combustflame.2011.05.023.

[74] R. Shan, C. S. Yoo, J. H. Chen, T. Lu, Computational diagnostics for n-heptane �ameswith chemical explosive mode analysis, Combust. Flame 159 (10) (2012) 3119�3127.doi:10.1016/j.combustflame.2012.05.012.

[75] R. J. Hogan, Fast reverse-mode automatic di�erentiation using expression templates inC++, ACM Trans. Math. Software 40 (4) (2014) 26. doi:10.1145/2560359.

[76] L. F. Richardson, The approximate arithmetical solution by �nite di�erences of physicalproblems involving di�erential equations, with an application to the stresses in a ma-sonry dam, Phil. Trans. R. Soc. A 210 (1911) 307�357. doi:10.1098/rsta.1911.0009.

[77] J. N. Lyness, C. B. Moler, Van der Monde systems and numerical di�erentiation, Numer.Math. 8 (5) (1966) 458�464. doi:10.1007/BF02166671.

[78] J. N. Lyness, C. B. Moler, Generalized Romberg methods for integrals of derivatives,Numer. Math. 14 (1) (1969) 1�13. doi:10.1007/BF02165095.

[79] J. R. R. A. Martins, P. Sturdza, J. J. Alonso, The complex-step derivative approxima-tion, ACM Trans. Math. Software 29 (3) (2003) 245�262. doi:10.1145/838250.838251.

[80] L. F. Shampine, Accurate numerical derivatives in MATLAB, ACM T. Math. Software33 (4) (2007) 26. doi:10.1145/1268776.1268781.

[81] M. S. Ridout, Statistical applications of the complex-step method of numerical di�er-entiation, Am. Stat. 63 (1) (2009) 66�74. doi:10.1198/tast.2009.0013.

[82] E. Anderson, Z. Bai, C. Bischof, S. Blackford, J. Demmel, J. Dongarra, J. Du Croz,A. Greenbaum, S. Hammarling, A. McKenney, D. Sorensen, LAPACK Users' Guide,3rd Edition, SIAM, Philadelphia, PA, 1999.

[83] C. Safta, H. N. Najm, O. M. Knio, TChem v0.2, Available at http://www.sandia.gov/tchem/index.html (2011).

[84] Free Software Foundation, gcc-4.8.5, Available at https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/ (Jun. 2015).

[85] NVIDIA, CUDA Toolkit 7.5, Available at https://developer.nvidia.com/cuda-

downloads (Sep. 2015).

[86] K. E. Niemeyer, N. J. Curtis, C. J. Sung, Data, plotting scripts, and �gures for �pyJac:analytical Jacobian generator for chemical kinetics�, �gshare, CC-BY license (2017).doi:10.6084/m9.figshare.4578010.v1.

42

Page 43: pyJac : analytical Jacobian generator for chemical kinetics · Orgone State University, Corvallis, OR 97331, USA ... This section describes the theoretical background of the analytical

[87] S. M. Correa, Turbulence-chemistry interactions in the intermediate regime of premixedcombustion, Combust. Flame 93 (1�2) (1993) 41�60. doi:10.1016/0010-2180(93)

90083-F.

[88] J.-Y. Chen, Stochastic modeling of partially stirred reactors, Combust. Sci. Technol.122 (1�6) (1997) 63�94. doi:10.1080/00102209708935605.

[89] A. Bhave, M. Kraft, Partially stirred reactor model: Analytical solutions and numericalconvergence study of a PDF/Monte Carlo method, SIAM J. Sci. Comput. 25 (5) (2004)1798�1823. doi:10.1137/S1064827502411328.

[90] Z. Ren, S. B. Pope, An investigation of the performance of turbulent mixing models,Combust. Flame 136 (1-2) (2004) 208�216. doi:10.1016/j.combustflame.2003.09.

014.

[91] Z. Ren, Y. Liu, T. Lu, L. Lu, O. O. Oluwole, G. M. Goldin, The use of dynamic adaptivechemistry and tabulation in reactive �ow simulations, Combust. Flame 161 (1) (2014)127�137. doi:10.1016/j.combustflame.2013.08.018.

[92] N. J. Curtis, K. E. Niemeyer, Fileset for testing thread-safety of TChem, �gshare (Jan.2017). doi:10.6084/m9.figshare.4563982.v1.

43