source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp/util/dFun_dRcoeff.m @ 3529

Last change on this file since 3529 was 2696, checked in by kanani, 7 years ago

Merge of branch palm4u into trunk

File size: 1.7 KB
Line 
1% ------------------------------------------------------------------------------
2% Subroutine for the derivative of Fun with respect to rate coefficients
3% -----------------------------------------------------------------------------
4
5DFDR = function dFun_dRcoeff( V, F, NCOEFF, JCOEFF )
6
7% V/F - Concentrations of variable/fixed species           
8% NCOEFF - the number of rate coefficients with respect to which we differentiate
9% JCOEFF - a vector of integers containing the indices of reactions (rate
10%          coefficients) with respect to which we differentiate
11%      INTEGER JCOEFF(NCOEFF)       
12% DFDR  - a matrix containg derivative values; specifically,
13%         column j contains d Fun(1:KPP_NVAR) / d RCT( JCOEFF(j) )
14%         for each 1 <= j <= NCOEFF
15%         This matrix is stored in a column-wise linearized format
16%      KPP_REAL DFDR(KPP_NVAR*NCOEFF)
17
18% A_RPROD - Local vector with reactant products     
19% Compute the reactant products of all reactions     
20      A_RPROD = ReactantProd ( V, F );
21
22% Compute the derivatives by multiplying column JCOEFF(j) of the stoichiometric matrix with A_RPROD       
23      for j=1:NCOEFF
24%                  Initialize the j-th column of derivative matrix to zero       
25         for i=1:KPP_NVAR
26           DFDR(i+KPP_NVAR*(j-1)) = 0.0;
27         end
28%                  Column JCOEFF(j) in the stoichiometric matrix times the
29%                  reactant product  of the JCOEFF(j)-th reaction     
30%                  give the j-th column of the derivative matrix   
31         aj = A_RPROD(JCOEFF(j));
32         for k=CCOL_STOICM(JCOEFF(j)):CCOL_STOICM(JCOEFF(j)+1)-1
33           DFDR(IROW_STOICM(k)+KPP_NVAR*(j-1)) = STOICM(k)*aj;
34         end
35      end
36     
37return % dFun_dRcoeff
Note: See TracBrowser for help on using the repository browser.