1 % ------------------------------------------------------------------------------
2 % Subroutine for the derivative of Jac with respect to rate coefficients
4 % -----------------------------------------------------------------------------
6 DJDR = function dJac_dRcoeff( V, F, U, NCOEFF, JCOEFF )
8 % V - Concentrations of variable/fixed species
9 % KPP_REAL V(KPP_NVAR), F(NFIX)
10 % U - User-supplied Vector
11 % KPP_REAL U(KPP_NVAR)
12 % NCOEFF - the number of rate coefficients with respect to which we differentiate
14 % JCOEFF - a vector of integers containing the indices of reactions (rate
15 % coefficients) with respect to which we differentiate
16 % INTEGER JCOEFF(NCOEFF)
17 % DFDR - a matrix containg derivative values; specifiy,
18 % column j contains d Jac(1:KPP_NVAR) / d RCT( JCOEFF(j) ) * U
19 % for each 1 <= j <= NCOEFF
20 % This matrix is stored in a column-wise linearized format
21 % KPP_REAL DJDR(KPP_NVAR*NCOEFF)
23 % Local vector for Jacobian of reactant products
24 % KPP_REAL JV_RPROD(NJVRP)
25 % Compute the Jacobian of all reactant products
26 JV_RPROD = JacReactantProd( V, F );
28 % Compute the derivatives by multiplying column JCOEFF(j) of the stoichiometric matrix with A_PROD
30 % Initialize the j-th column of derivative matrix to zero
32 DJDR(i+KPP_NVAR*(j-1)) = 0.0;
34 % Column JCOEFF(j) in the stoichiometric matrix times the
35 % ( Gradient of reactant product of the JCOEFF(j)-th reaction X user vector )
36 % give the j-th column of the derivative matrix
38 % Row JCOEFF(j) of JV_RPROD times the user vector
40 for k=CROW_JVRP(JCOEFF(j)):CROW_JVRP(JCOEFF(j)+1)-1
41 aj = aj + JV_RPROD(k)*U(ICOL_JVRP(k));
43 % Column JCOEFF(j) of Stoichiom. matrix times aj
44 for k=CCOL_STOICM(JCOEFF(j)):CCOL_STOICM(JCOEFF(j)+1)-1
45 DJDR(IROW_STOICM(k)+KPP_NVAR*(j-1)) = STOICM(k)*aj;