215 |
#endif |
#endif |
216 |
asc_assert(ny1 == sys->n_y); |
asc_assert(ny1 == sys->n_y); |
217 |
|
|
218 |
|
ERROR_REPORTER_HERE(ASC_USER_NOTE,"moving derivs to start of remainder\n"); |
219 |
if(system_cut_vars(sys->system, ny1, &integrator_ida_deriv, &nydot)){ |
if(system_cut_vars(sys->system, ny1, &integrator_ida_deriv, &nydot)){ |
220 |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem cutting derivs"); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem cutting derivs"); |
221 |
return 1; |
return 1; |
351 |
asc_assert(system_vfilter_deriv.matchbits & VAR_DERIV); |
asc_assert(system_vfilter_deriv.matchbits & VAR_DERIV); |
352 |
asc_assert(system_vfilter_deriv.matchvalue & VAR_DERIV); |
asc_assert(system_vfilter_deriv.matchvalue & VAR_DERIV); |
353 |
|
|
354 |
|
CONSOLE_DEBUG("system has %d vars matching deriv filter",slv_count_solvers_vars(sys->system, &system_vfilter_deriv)); |
355 |
|
|
356 |
res = system_jacobian(sys->system |
res = system_jacobian(sys->system |
357 |
, &system_rfilter_diff |
, &system_rfilter_diff |
358 |
, &system_vfilter_deriv |
, &system_vfilter_deriv |
573 |
|
|
574 |
/* ...(1) FIX the derivatives */ |
/* ...(1) FIX the derivatives */ |
575 |
CONSOLE_DEBUG("Checking system with derivatives fixed..."); |
CONSOLE_DEBUG("Checking system with derivatives fixed..."); |
576 |
for(i=0;i<n_y;++i){ |
for(i=0;i<sys->n_y;++i){ |
577 |
if(sys->ydot[i])var_set_fixed(sys->ydot[i],1); |
if(sys->ydot[i])var_set_fixed(sys->ydot[i],1); |
578 |
} |
} |
579 |
|
|
583 |
|
|
584 |
/* ...(2) FREE the derivatives, FIX the diffvars */ |
/* ...(2) FREE the derivatives, FIX the diffvars */ |
585 |
CONSOLE_DEBUG("Checking system with differential variables fixed..."); |
CONSOLE_DEBUG("Checking system with differential variables fixed..."); |
586 |
for(i=0;i<n_y;++i){ |
for(i=0;i<sys->n_y;++i){ |
587 |
if(sys->ydot[i]){ |
if(sys->ydot[i]){ |
588 |
var_set_fixed(sys->ydot[i],0); |
var_set_fixed(sys->ydot[i],0); |
589 |
var_set_fixed(sys->y[i],1); |
var_set_fixed(sys->y[i],1); |
594 |
if(res)return 200 + res; |
if(res)return 200 + res; |
595 |
|
|
596 |
/* ...(3) restore as it was, FREE the diffvars */ |
/* ...(3) restore as it was, FREE the diffvars */ |
597 |
for(i=0;i<n_y;++i){ |
for(i=0;i<sys->n_y;++i){ |
598 |
if(sys->ydot[i]){ |
if(sys->ydot[i]){ |
599 |
var_set_fixed(sys->y[i],0); |
var_set_fixed(sys->y[i],0); |
600 |
} |
} |
924 |
return sys->y_id[var_sindex(deriv) - sys->n_y]; |
return sys->y_id[var_sindex(deriv) - sys->n_y]; |
925 |
} |
} |
926 |
|
|
927 |
|
/** |
928 |
|
A less assertive version of diffindex... |
929 |
|
*/ |
930 |
|
int integrator_ida_diffindex1(const IntegratorSystem *sys, const struct var_variable *deriv){ |
931 |
|
if(var_sindex(deriv) >= sys->n_y)return -1; |
932 |
|
if(var_sindex(deriv) < sys->n_y + sys->n_ydot)return -2; |
933 |
|
return sys->y_id[var_sindex(deriv) - sys->n_y]; |
934 |
|
} |
935 |
|
|
936 |
/** |
/** |
937 |
This function will output the data structures provided to use BY THE |
This function will output the data structures provided to use BY THE |
938 |
SYSTEM -- not the ones we're working with here IN THE SOLVER. |
SYSTEM -- not the ones we're working with here IN THE SOLVER. |