/[ascend]/trunk/base/generic/integrator/ida.c
ViewVC logotype

Diff of /trunk/base/generic/integrator/ida.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1222 by johnpye, Wed Jan 24 13:46:44 2007 UTC revision 1223 by johnpye, Wed Jan 24 14:25:15 2007 UTC
# Line 440  static int integrator_ida_check_partitio Line 440  static int integrator_ida_check_partitio
440      struct var_variable **vlist, *v;      struct var_variable **vlist, *v;
441      nv = slv_get_num_solvers_vars(sys->system);      nv = slv_get_num_solvers_vars(sys->system);
442      vlist = slv_get_solvers_var_list(sys->system);      vlist = slv_get_solvers_var_list(sys->system);
443        var_filter_t vf = {VAR_SVAR|VAR_ACTIVE|VAR_INCIDENT|VAR_FIXED
444                          ,VAR_SVAR|VAR_ACTIVE|VAR_INCIDENT|0 };
445      for(i=0;i<nv;++i){      for(i=0;i<nv;++i){
446          v=vlist[i];          v=vlist[i];
447            if(!var_apply_filter(v,&vf))continue;
448          varname = var_make_name(sys->system,v);          varname = var_make_name(sys->system,v);
449          if(!var_deriv(v)){          if(!var_deriv(v)){
450              fprintf(stderr,"vlist[%ld] = '%s' (nonderiv)\n",i,varname);              fprintf(stderr,"vlist[%ld] = '%s' (nonderiv)\n",i,varname);
# Line 600  int integrator_ida_analyse(IntegratorSys Line 603  int integrator_ida_analyse(IntegratorSys
603      const SolverDiffVarCollection *diffvars;      const SolverDiffVarCollection *diffvars;
604      SolverDiffVarSequence seq;      SolverDiffVarSequence seq;
605      long i, j, n_y, n_ydot, n_skipped_diff, n_skipped_alg, n_skipped_deriv;      long i, j, n_y, n_ydot, n_skipped_diff, n_skipped_alg, n_skipped_deriv;
606      int res;      /* int res; */
607    
608      struct var_variable *v;      struct var_variable *v;
609      char *varname;      char *varname;
# Line 1423  int integrator_ida_djex(long int Neq, re Line 1426  int integrator_ida_djex(long int Neq, re
1426      /* print vars */      /* print vars */
1427      for(i=0; i < blsys->n_y; ++i){      for(i=0; i < blsys->n_y; ++i){
1428          varname = var_make_name(blsys->system, blsys->y[i]);          varname = var_make_name(blsys->system, blsys->y[i]);
1429          CONSOLE_DEBUG("%s = %f = %f",varname,NV_Ith_S(yy,i),var_value(blsys->y[i]));          CONSOLE_DEBUG("%s = %f = %f",varname,NV_Ith_S(yy,i));
1430            asc_assert(NV_Ith_S(yy,i) == var_value(blsys->y[i]));
1431          ASC_FREE(varname);          ASC_FREE(varname);
1432      }      }
1433    
# Line 1431  int integrator_ida_djex(long int Neq, re Line 1435  int integrator_ida_djex(long int Neq, re
1435      for(i=0; i < blsys->n_y; ++i){      for(i=0; i < blsys->n_y; ++i){
1436          if(blsys->ydot[i]){          if(blsys->ydot[i]){
1437              varname = var_make_name(blsys->system, blsys->ydot[i]);              varname = var_make_name(blsys->system, blsys->ydot[i]);
1438              CONSOLE_DEBUG("%s = %f =%f",varname,NV_Ith_S(yp,i),var_value(blsys->ydot[i]));              CONSOLE_DEBUG("%s = %f =%g",varname,NV_Ith_S(yp,i),var_value(blsys->ydot[i]));
1439              ASC_FREE(varname);              ASC_FREE(varname);
1440          }else{          }else{
1441              varname = var_make_name(blsys->system, blsys->y[i]);              varname = var_make_name(blsys->system, blsys->y[i]);
1442              CONSOLE_DEBUG("diff(%s) = %f",varname,NV_Ith_S(yp,i));              CONSOLE_DEBUG("diff(%s) = %g",varname,NV_Ith_S(yp,i));
1443              ASC_FREE(varname);              ASC_FREE(varname);
1444          }          }
1445      }      }
1446    
1447      /* print step size */      /* print step size */
1448      CONSOLE_DEBUG("<c_j> = %f",c_j);      CONSOLE_DEBUG("<c_j> = %g",c_j);
1449  #endif  #endif
1450    
     integrator_ida_check_partitioning(blsys);  
   
1451      /* build up the dense jacobian matrix... */      /* build up the dense jacobian matrix... */
1452      status = 0;      status = 0;
1453      for(i=0, relptr = enginedata->rellist;      for(i=0, relptr = enginedata->rellist;
# Line 1465  int integrator_ida_djex(long int Neq, re Line 1467  int integrator_ida_djex(long int Neq, re
1467          /* output what's going on here ... */          /* output what's going on here ... */
1468  #ifdef DJEX_DEBUG  #ifdef DJEX_DEBUG
1469          relname = rel_make_name(blsys->system, *relptr);          relname = rel_make_name(blsys->system, *relptr);
         CONSOLE_DEBUG("RELATION %d '%s'",i,relname);  
1470          fprintf(stderr,"%d: '%s': ",i,relname);          fprintf(stderr,"%d: '%s': ",i,relname);
1471          ASC_FREE(relname);          ASC_FREE(relname);
1472          for(j=0;j<count;++j){          for(j=0;j<count;++j){
# Line 1484  int integrator_ida_djex(long int Neq, re Line 1485  int integrator_ida_djex(long int Neq, re
1485          /* insert values into the Jacobian row in appropriate spots (can assume Jac starts with zeros -- IDA manual) */          /* insert values into the Jacobian row in appropriate spots (can assume Jac starts with zeros -- IDA manual) */
1486          for(j=0; j < count; ++j){          for(j=0; j < count; ++j){
1487              if(!var_deriv(variables[j])){              if(!var_deriv(variables[j])){
1488    #ifdef DJEX_DEBUG1
1489                  CONSOLE_DEBUG("Jac = %p, i = %d, j = %d, variables[j] = %p, sindex = %d, deriv = %f"                  CONSOLE_DEBUG("Jac = %p, i = %d, j = %d, variables[j] = %p, sindex = %d, deriv = %f"
1490                      ,Jac, i, j,  variables[j], var_sindex(variables[j]),derivatives[j]                      ,Jac, i, j,  variables[j], var_sindex(variables[j]),derivatives[j]
1491                  );                  );
1492                  CONSOLE_DEBUG("var flags = 0x%o",var_flags(variables[j]));                  CONSOLE_DEBUG("var flags = 0x%o",var_flags(variables[j]));
1493                  var_make_name(blsys->system,variables[j]);                  varname = var_make_name(blsys->system,variables[j]);
1494                  CONSOLE_DEBUG("var name '%s'",varname);                  CONSOLE_DEBUG("var name '%s'",varname);
1495                  ASC_FREE(varname);                  ASC_FREE(varname);
1496                  asc_assert(var_sindex(variables[j]) >= 0);                  asc_assert(var_sindex(variables[j]) >= 0);
1497                  ASC_ASSERT_LT(var_sindex(variables[j]) , Neq);                  ASC_ASSERT_LT(var_sindex(variables[j]) , Neq);
1498    #endif
1499                  DENSE_ELEM(Jac,i,var_sindex(variables[j])) += derivatives[j];                  DENSE_ELEM(Jac,i,var_sindex(variables[j])) += derivatives[j];
1500              }else{              }else{
1501                  DENSE_ELEM(Jac,i,integrator_ida_diffindex(blsys,variables[j])) += derivatives[j] * c_j;                  DENSE_ELEM(Jac,i,integrator_ida_diffindex(blsys,variables[j])) += derivatives[j] * c_j;

Legend:
Removed from v.1222  
changed lines
  Added in v.1223

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22