1 SUBROUTINE INTEGRATE
( NSENSIT
, Y
, TIN
, TOUT
)
3 INCLUDE
'KPP_ROOT_params.h'
4 INCLUDE
'KPP_ROOT_global.h'
12 KPP_REAL Y
( NVAR*
(NSENSIT
+1) )
13 C --- Note: Y contains: (1:NVAR) concentrations, followed by
14 C --- (1:NVAR) sensitivities w.r.t. first parameter, followed by
15 C --- etc., followed by
16 C --- (1:NVAR) sensitivities w.r.t. NSENSIT's parameter
20 EXTERNAL FUNC_CHEM
, JAC_CHEM
, HESS_CHEM
24 CALL ROS1_DDM
(NVAR
,NSENSIT
,TIN
,TOUT
,STEPMIN
,Y
,
25 + Info
,FUNC_CHEM
,JAC_CHEM
,HESS_CHEM
)
34 SUBROUTINE ROS1_DDM
(N
,NSENSIT
,T
,Tnext
,Hstart
,
35 + y
,Info
,FUNC_CHEM
,JAC_CHEM
,HESS_CHEM
)
37 INCLUDE
'KPP_ROOT_params.h'
38 INCLUDE
'KPP_ROOT_sparse.h'
39 INCLUDE
'KPP_ROOT_global.h'
41 C Linearly Implicit Euler with direct-decoupled calculation of sensitivities
42 C A method of theoretical interest but of no practical value
44 C The global variable DDMTYPE distinguishes between:
45 C DDMTYPE = 0 : sensitivities w.r.t. initial values
46 C DDMTYPE = 1 : sensitivities w.r.t. parameters
49 C y = Vector of: (1:NVAR) concentrations, followed by
50 C (1:NVAR) sensitivities w.r.t. first parameter, followed by
52 C (1:NVAR) sensitivities w.r.t. NSENSIT's parameter
53 C (y contains initial values at input, final values at output)
54 C [T, Tnext] = the integration interval
55 C Hmin, Hmax = lower and upper bounds for the selected step-size.
56 C Note that for Step = Hmin the current computed
57 C solution is unconditionally accepted by the error
59 C AbsTol, RelTol = (NVAR) dimensional vectors of
60 C componentwise absolute and relative tolerances.
61 C FUNC_CHEM = name of routine of derivatives. KPP syntax.
62 C See the header below.
63 C JAC_CHEM = name of routine that computes the Jacobian, in
64 C sparse format. KPP syntax. See the header below.
65 C Info(1) = 1 for Autonomous system
66 C = 0 for nonAutonomous system
69 C y = the values of concentrations at Tend.
70 C T = equals TENDon output.
71 C Info(2) = # of FUNC_CHEM CALLs.
72 C Info(3) = # of JAC_CHEM CALLs.
73 C Info(4) = # of accepted steps.
74 C Info(5) = # of rejected steps.
75 C Hstart = The last accepted stepsize
77 C Adrian Sandu, December 2001
80 KPP_REAL Fv
(NVAR*
(NSENSIT
+1)), Hv
(NVAR
)
81 KPP_REAL DFDP
(NVAR*NSENSIT
)
82 KPP_REAL JAC
(LU_NONZERO
), AJAC
(LU_NONZERO
)
84 KPP_REAL DJDP
(NVAR*NSENSIT
)
86 KPP_REAL y
(NVAR*
(NSENSIT
+1))
87 KPP_REAL T
, Tnext
, Tplus
88 KPP_REAL elo
,ghinv
,uround
90 INTEGER n
,nfcn
,njac
,Naccept
,Nreject
,i
,j
,ier
92 LOGICAL IsReject
, Autonomous
93 EXTERNAL FUNC_CHEM
, JAC_CHEM
, HESS_CHEM
101 C === Starting the time loop ===
105 IF ( Tplus
.gt
. Tnext
) THEN
110 C Initial Function and Jacobian values
111 CALL FUNC_CHEM
(NVAR
, T
, y
, Fv
)
113 CALL JAC_CHEM
(NVAR
, T
, y
, JAC
)
115 CALL HESS_CHEM
( NVAR
, T
, y
, HESS
)
116 IF (DDMTYPE
.EQ
. 1) THEN
117 CALL DFUNDPAR
(NVAR
, NSENSIT
, T
, y
, DFDP
)
120 C Form the Prediction matrix and compute its LU factorization
125 AJAC
(LU_DIAG
(j
)) = AJAC
(LU_DIAG
(j
)) + 1.0d0
/H
127 CALL KppDecomp
(AJAC
, ier
)
130 PRINT
*,'ROS1: Singular factorization at T=',T
,'; H=',H
134 C ------------ STAGE 1-------------------------
135 CALL KppSolve
(AJAC
, Fv
)
136 C --- If derivative w.r.t. parameters
137 IF (DDMTYPE
.EQ
. 1) THEN
138 CALL DJACDPAR
(NVAR
, NSENSIT
, T
, y
, Fv
(1), DJDP
)
140 C --- End of derivative w.r.t. parameters
143 CALL Jac_SP_Vec
(JAC
, y
(i*NVAR
+1), Fv
(i*NVAR
+1))
144 CALL Hess_Vec
( HESS
, y
(i*NVAR
+1), Fv
(1), Hv
)
145 IF (DDMTYPE
.EQ
. 0) THEN
147 Fv
(i*NVAR
+j
) = Fv
(i*NVAR
+j
) + Hv
(j
)
151 Fv
(i*NVAR
+j
) = Fv
(i*NVAR
+j
) + Hv
(j
)
152 & + DFDP
(i*NVAR
+j
)+ DJDP
((i
-1)*NVAR
+j
)
155 CALL KppSolve
(AJAC
, Fv
(i*NVAR
+1))
158 C ---- The Solution ---
159 DO 160 j
= 1,NVAR*
(NSENSIT
+1)
164 C ======= End of the time loop ===============================
165 IF ( T
.lt
. Tnext
) THEN
169 C ======= Output Information =================================
181 SUBROUTINE FUNC_CHEM
(N
, T
, Y
, P
)
182 INCLUDE
'KPP_ROOT_params.h'
183 INCLUDE
'KPP_ROOT_global.h'
186 KPP_REAL Y
(NVAR
), P
(NVAR
)
191 CALL Fun
( Y
, FIX
, RCONST
, P
)
197 SUBROUTINE DFUNDPAR
(N
, NSENSIT
, T
, Y
, P
)
198 C --- Computes the partial derivatives of FUNC_CHEM w.r.t. parameters
199 INCLUDE
'KPP_ROOT_params.h'
200 INCLUDE
'KPP_ROOT_global.h'
201 C --- NCOEFF, JCOEFF useful for derivatives w.r.t. rate coefficients
202 INTEGER NCOEFF
, JCOEFF
(NREACT
)
203 COMMON /DDMRCOEFF
/ NCOEFF
, JCOEFF
207 KPP_REAL Y
(NVAR
), P
(NVAR*NSENSIT
)
213 IF (DDMTYPE
.EQ
. 0) THEN
214 C --- Note: the values below are for sensitivities w.r.t. initial values;
215 C --- they may have to be changed for other applications
218 P
(i
+NVAR*
(j
-1)) = 0.0D0
222 C --- Example: the call below is for sensitivities w.r.t. rate coefficients;
223 C --- JCOEFF(1:NSENSIT) are the indices of the NSENSIT rate coefficients
224 C --- w.r.t. which one differentiates
225 CALL dFun_dRcoeff
( Y
, FIX
, NCOEFF
, JCOEFF
, P
)
231 SUBROUTINE JAC_CHEM
(N
, T
, Y
, J
)
232 INCLUDE
'KPP_ROOT_params.h'
233 INCLUDE
'KPP_ROOT_global.h'
236 KPP_REAL Y
(NVAR
), J
(LU_NONZERO
)
241 CALL Jac_SP
( Y
, FIX
, RCONST
, J
)
247 SUBROUTINE DJACDPAR
(N
, NSENSIT
, T
, Y
, U
, P
)
248 C --- Computes the partial derivatives of JAC w.r.t. parameters times user vector U
249 INCLUDE
'KPP_ROOT_params.h'
250 INCLUDE
'KPP_ROOT_global.h'
251 C --- NCOEFF, JCOEFF useful for derivatives w.r.t. rate coefficients
252 INTEGER NCOEFF
, JCOEFF
(NREACT
)
253 COMMON /DDMRCOEFF
/ NCOEFF
, JCOEFF
257 KPP_REAL Y
(NVAR
), U
(NVAR
)
258 KPP_REAL P
(NVAR*NSENSIT
)
264 IF (DDMTYPE
.EQ
. 0) THEN
265 C --- Note: the values below are for sensitivities w.r.t. initial values;
266 C --- they may have to be changed for other applications
269 P
(i
+NVAR*
(j
-1)) = 0.0D0
273 C --- Example: the call below is for sensitivities w.r.t. rate coefficients;
274 C --- JCOEFF(1:NSENSIT) are the indices of the NSENSIT rate coefficients
275 C --- w.r.t. which one differentiates
276 CALL dJac_dRcoeff
( Y
, FIX
, U
, NCOEFF
, JCOEFF
, P
)
283 SUBROUTINE HESS_CHEM
(N
, T
, Y
, HESS
)
284 INCLUDE
'KPP_ROOT_params.h'
285 INCLUDE
'KPP_ROOT_global.h'
288 KPP_REAL Y
(NVAR
), HESS
(NHESS
)
293 CALL Hessian
( Y
, FIX
, RCONST
, HESS
)