source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp/util/dJac_dRcoeff.f @ 4901

Last change on this file since 4901 was 2696, checked in by kanani, 6 years ago

Merge of branch palm4u into trunk

File size: 2.3 KB
Line 
1C ------------------------------------------------------------------------------
2C Subroutine for the derivative of Jac with respect to rate coefficients
3C Times a user vector
4C -----------------------------------------------------------------------------
5
6      SUBROUTINE  dJac_dRcoeff( V, F, U, NCOEFF, JCOEFF, DJDR )
7       
8      IMPLICIT NONE
9      INCLUDE 'KPP_ROOT_Parameters.h'
10      INCLUDE 'KPP_ROOT_Sparse.h'
11
12C V - Concentrations of variable/radical/fixed species           
13      KPP_REAL V(NVAR), F(NFIX)
14C U - User-supplied Vector           
15      KPP_REAL U(NVAR)
16C NCOEFF - the number of rate coefficients with respect to which we differentiate
17      INTEGER NCOEFF       
18C JCOEFF - a vector of integers containing the indices of reactions (rate
19C          coefficients) with respect to which we differentiate
20      INTEGER JCOEFF(NCOEFF)       
21C DFDR  - a matrix containg derivative values; specifically, 
22C         column j contains d Jac(1:NVAR) / d RCT( JCOEFF(j) ) * U
23C                     for each 1 <= j <= NCOEFF
24C         This matrix is stored in a column-wise linearized format
25      KPP_REAL DJDR(NVAR*NCOEFF)
26
27C Local vector for Jacobian of reactant products
28      KPP_REAL JV_RPROD(NJVRP)
29      KPP_REAL aj
30      INTEGER i,j,k
31     
32C Compute the Jacobian of all reactant products   
33      CALL JacReactantProd( V, F, JV_RPROD )
34
35C Compute the derivatives by multiplying column JCOEFF(j) of the stoichiometric matrix with A_PROD       
36      DO j=1,NCOEFF
37C                  Initialize the j-th column of derivative matrix to zero       
38         DO i=1,NVAR
39           DJDR(i+NVAR*(j-1)) = 0.0D0
40         END DO
41C                  Column JCOEFF(j) in the stoichiometric matrix times the
42C                  ( Gradient of reactant product of the JCOEFF(j)-th reaction X user vector )   
43C                  give the j-th column of the derivative matrix   
44C
45C          Row JCOEFF(j) of JV_RPROD times the user vector
46         aj = 0.d0
47         DO k=CROW_JVRP(JCOEFF(j)),CROW_JVRP(JCOEFF(j)+1)-1
48            aj = aj + JV_RPROD(k)*U(ICOL_JVRP(k))
49         END DO
50C          Column JCOEFF(j) of Stoichiom. matrix times aj         
51         DO k=CCOL_STOICM(JCOEFF(j)),CCOL_STOICM(JCOEFF(j)+1)-1
52           DJDR(IROW_STOICM(k)+NVAR*(j-1)) = STOICM(k)*aj
53         END DO
54      END DO
55     
56      RETURN
57      END
Note: See TracBrowser for help on using the repository browser.