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

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

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

revision 945 by johnpye, Sat Nov 25 10:46:13 2006 UTC revision 946 by johnpye, Sat Nov 25 15:28:56 2006 UTC
# Line 435  int integrator_analyse_dae(IntegratorSys Line 435  int integrator_analyse_dae(IntegratorSys
435      if(!integrator_check_indep_var(sys))return 0;      if(!integrator_check_indep_var(sys))return 0;
436    
437      gl_sort(sys->dynvars,(CmpFunc)Integ_CmpDynVars);      gl_sort(sys->dynvars,(CmpFunc)Integ_CmpDynVars);
438        /* !!! NOTE THAT dynvars IS NOW REARRANGED !!! *sigh* bug hunting(!) */
439    
440      fprintf(stderr,"\n\n\nSORTED VARS\n");      CONSOLE_DEBUG("Variables rearranged to increasing ODE ID & TYPE (varindx = matrix order)");
441      for(i=1; i<=gl_length(sys->dynvars); ++i){      for(i=1; i<=gl_length(sys->dynvars); ++i){
442          info = (struct Integ_var_t *)gl_fetch(sys->dynvars, i);          info = (struct Integ_var_t *)gl_fetch(sys->dynvars, i);
443          varname = var_make_name(sys->system,info->i);          varname = var_make_name(sys->system,info->i);
444          CONSOLE_DEBUG("var[%d] = \"%s\": ode_type = %ld (varindx = %d)",i,varname,info->type,info->varindx);          CONSOLE_DEBUG("var[%d] = \"%s\": ode_type = %ld (varindx = %d)",i-1,varname,info->type,info->varindx);
445          ASC_FREE(varname);          ASC_FREE(varname);
446      }      }
447    
# Line 504  int integrator_analyse_dae(IntegratorSys Line 505  int integrator_analyse_dae(IntegratorSys
505    
506      /* allocate storage for the 'y' and 'ydot' arrays */      /* allocate storage for the 'y' and 'ydot' arrays */
507      sys->y = ASC_NEW_ARRAY(struct var_variable *,numy);      sys->y = ASC_NEW_ARRAY(struct var_variable *,numy);
508      sys->ydot = ASC_NEW_ARRAY(struct var_variable *,numy);      sys->ydot = ASC_NEW_ARRAY_CLEAR(struct var_variable *,numy);
509      sys->y_id = ASC_NEW_ARRAY(int, slv_get_num_master_vars(sys->system));      sys->y_id = ASC_NEW_ARRAY(int, slv_get_num_master_vars(sys->system));
510    
511        for(i=0; i<numy; ++i){
512            asc_assert(sys->ydot[i]==NULL);
513        }
514    
515      /* now add variables and their derivatives to 'ydot' and 'y' */      /* now add variables and their derivatives to 'ydot' and 'y' */
516      yindex = 0;      yindex = 0;
517            
518        CONSOLE_DEBUG("VARS IN THEIR MATRIX ORDER");
519      for(i=1; i<=gl_length(sys->dynvars); ++i){      for(i=1; i<=gl_length(sys->dynvars); ++i){
520          info = (struct Integ_var_t *)gl_fetch(sys->dynvars, i);          info = (struct Integ_var_t *)gl_fetch(sys->dynvars, i);
521          if(info->derivative_of)continue;          if(info->derivative_of)continue;
# Line 518  int integrator_analyse_dae(IntegratorSys Line 524  int integrator_analyse_dae(IntegratorSys
524              assert(info->derivative);              assert(info->derivative);
525              sys->ydot[yindex] = info->derivative->i;              sys->ydot[yindex] = info->derivative->i;
526              if(info->varindx >= 0){              if(info->varindx >= 0){
527                  sys->y_id[info->varindx] = yindex;                  sys->y_id[info->varindx - 1] = yindex;
528                  CONSOLE_DEBUG("y_id[%d] = %d",info->varindx,yindex);                  CONSOLE_DEBUG("y_id[%d] = %d",info->varindx,yindex);
529              }              }
530              if(info->derivative->varindx >= 0){              if(info->derivative->varindx >= 0){
531                  sys->y_id[info->derivative->varindx] = -1-yindex;                  sys->y_id[info->derivative->varindx - 1] = -1-yindex;
532                  CONSOLE_DEBUG("y_id[%d] = %d",info->derivative->varindx,-1-yindex);                  CONSOLE_DEBUG("y_id[%d] = %d",info->derivative->varindx,-1-yindex);
533              }              }
534          }else{          }else{
535              sys->y[yindex] = info ->i;              sys->y[yindex] = info ->i;
536              sys->ydot[yindex] = NULL;              sys->ydot[yindex] = NULL;
537              if(info->varindx >= 0){              if(info->varindx >= 0){
538                  sys->y_id[info->varindx] = yindex;                  sys->y_id[info->varindx - 1] = yindex;
539                  CONSOLE_DEBUG("y_id[%d] = %d",info->varindx,yindex);                  CONSOLE_DEBUG("y_id[%d] = %d",info->varindx,yindex);
540              }              }
541          }          }

Legend:
Removed from v.945  
changed lines
  Added in v.946

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