Skip to content

Commit ee8a1f3

Browse files
Adjust Jacobian generation for integrators.
1 parent 2b5bc4c commit ee8a1f3

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

src/engine/classic/classic_cvode_integrator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void CVODE_integrate(SIM_simulator simulate)
218218
flag = CVodeRootInit(cvode_mem, clcData->events, CVODE_events);
219219
if (check_flag(&flag, "CVodeRootInit", 1, simulator)) return;
220220

221-
if (simulator->data->params->jacobian == 0) {
221+
if (simulator->data->params->jacobian == 1) {
222222
nnz = 0;
223223
for (i = 0; i < size; i++) {
224224
nnz += clcData->nSD[i];

src/engine/classic/classic_ida_integrator.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
/* Header files with a description of contents used */
2121

22-
//#define USE_JACOBIAN
23-
//#ifdef USE_JACOBIAN
22+
// #define USE_JACOBIAN
23+
// #ifdef USE_JACOBIAN
2424
#include <ida/ida_klu.h> /* prototype for CVSUPERLUMT */
2525
#include <sundials/sundials_sparse.h> /* definitions SlsMat */
26-
//#endif
26+
// #endif
2727

2828
#include <ida/ida.h>
2929
#include <ida/ida_dense.h>
@@ -52,7 +52,7 @@ static CLC_model clcModel = NULL;
5252

5353
static SD_output simOutput = NULL;
5454

55-
//#ifdef USE_JACOBIAN
55+
// #ifdef USE_JACOBIAN
5656
/* Test jacobian */
5757
static int IDA_Jac(realtype t, realtype cj, N_Vector y, N_Vector fy, N_Vector resvec, SlsMat JacMat, void *user_data, N_Vector tmp1,
5858
N_Vector tmp2, N_Vector tmp3)
@@ -81,7 +81,7 @@ static int IDA_Jac(realtype t, realtype cj, N_Vector y, N_Vector fy, N_Vector re
8181

8282
return 0;
8383
}
84-
//#endif
84+
// #endif
8585

8686
/* Test jacobian */
8787
static int check_flag(void *flagvalue, const char *funcname, int opt, CLC_simulator simulator)
@@ -200,11 +200,7 @@ void IDA_integrate(SIM_simulator simulate)
200200
flag = IDARootInit(mem, clcData->events, IDA_events);
201201
if (check_flag(&flag, "IDARootInit", 1, simulator)) return;
202202

203-
//#ifndef USE_JACOBIAN
204203
if (simulator->data->params->jacobian == 1) {
205-
flag = IDADense(mem, size);
206-
if (check_flag(&flag, "IDADense", 1, simulator)) return;
207-
} else {
208204
nnz = 0;
209205
for (i = 0; i < size; i++) {
210206
nnz += clcData->nSD[i];
@@ -217,9 +213,11 @@ void IDA_integrate(SIM_simulator simulate)
217213

218214
flag = IDASlsSetSparseJacFn(mem, IDA_Jac);
219215
if (check_flag(&flag, "IDASlsSetSparseJacFn", 1, simulator)) return;
216+
} else {
217+
flag = IDADense(mem, size);
218+
if (check_flag(&flag, "IDADense", 1, simulator)) return;
220219
}
221220

222-
//#endif
223221
double *res = malloc(sizeof(double) * size);
224222
IDASetUserData(mem, res);
225223
getTime(simulator->stats->sTime);

src/engine/qss/qss_hyb_integrator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ void QSS_HYB_integrate(SIM_simulator simulate)
423423
flag = CVodeSVtolerances(cvode_mem, reltol, abstol);
424424
if (check_flag(&flag, "CVodeInit", 1, simulator)) return;
425425

426-
if (simulator->data->params->jacobian == 0) {
426+
if (simulator->data->params->jacobian == 1) {
427427
int nnz = 0;
428428
for (i = 0; i < nBDF; i++) {
429429
int row = BDFMap[i];

0 commit comments

Comments
 (0)