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

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

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

revision 1240 by johnpye, Fri Jan 26 11:12:20 2007 UTC revision 1241 by johnpye, Fri Jan 26 11:59:45 2007 UTC
# Line 40  static int integrator_ida_check_vars(Int Line 40  static int integrator_ida_check_vars(Int
40      int n_y = 0;      int n_y = 0;
41      int i, j;      int i, j;
42      struct var_variable *v;      struct var_variable *v;
   
43      SolverDiffVarSequence seq;      SolverDiffVarSequence seq;
44    
45        CONSOLE_DEBUG("BEFORE CHECKING VARS");
46        integrator_ida_analyse_debug(sys,stderr);
47    
48      /* we shouldn't have allocated these yet: just be sure */      /* we shouldn't have allocated these yet: just be sure */
49      asc_assert(sys->y==NULL);      asc_assert(sys->y==NULL);
50      asc_assert(sys->ydot==NULL);      asc_assert(sys->ydot==NULL);
# Line 57  static int integrator_ida_check_vars(Int Line 59  static int integrator_ida_check_vars(Int
59            
60      /* add the variables from the derivative chains */      /* add the variables from the derivative chains */
61      for(i=0; i<diffvars->nseqs; ++i){      for(i=0; i<diffvars->nseqs; ++i){
62    
63    
64            CONSOLE_DEBUG("BEFORE CHAIN %d",i);
65            integrator_ida_analyse_debug(sys,stderr);
66    
67          seq = diffvars->seqs[i];          seq = diffvars->seqs[i];
68          asc_assert(seq.n >= 1);          asc_assert(seq.n >= 1);
69          v = seq.vars[0];          v = seq.vars[0];
# Line 70  static int integrator_ida_check_vars(Int Line 77  static int integrator_ida_check_vars(Int
77                  var_set_value(v,0);                  var_set_value(v,0);
78                  varname = var_make_name(sys->system,v);                              varname = var_make_name(sys->system,v);            
79                  CONSOLE_DEBUG("Derivative '%s' SET ZERO AND INACTIVE",varname);                  CONSOLE_DEBUG("Derivative '%s' SET ZERO AND INACTIVE",varname);
80                  ASC_FREE(v);                  ASC_FREE(varname);
81              }              }
82              continue;              continue;
83          }          }
# Line 114  static int integrator_ida_check_vars(Int Line 121  static int integrator_ida_check_vars(Int
121    
122      CONSOLE_DEBUG("Found %d good non-derivative vars", n_y);      CONSOLE_DEBUG("Found %d good non-derivative vars", n_y);
123      sys->n_y = n_y;      sys->n_y = n_y;
124    
125        CONSOLE_DEBUG("AFTER CHECKING VARS");
126        integrator_ida_analyse_debug(sys,stderr);
127    
128      return 0;      return 0;
129  }  }
130    
# Line 125  static int integrator_ida_check_vars(Int Line 136  static int integrator_ida_check_vars(Int
136  static int integrator_ida_sort_rels_and_vars(IntegratorSystem *sys){  static int integrator_ida_sort_rels_and_vars(IntegratorSystem *sys){
137      int ny1, nydot, nr;      int ny1, nydot, nr;
138    
139    
140        CONSOLE_DEBUG("BEFORE SORTING RELS AND VARS");
141        integrator_ida_analyse_debug(sys,stderr);
142    
143      /* we should not have allocated y or ydot yet */      /* we should not have allocated y or ydot yet */
144      asc_assert(sys->y==NULL && sys->ydot==NULL);      asc_assert(sys->y==NULL && sys->ydot==NULL);
145    
# Line 176  static int integrator_ida_create_lists(I Line 191  static int integrator_ida_create_lists(I
191      const SolverDiffVarCollection *diffvars;      const SolverDiffVarCollection *diffvars;
192      int i, j;      int i, j;
193      struct var_variable *v;      struct var_variable *v;
194        char *varname;
195    
196      SolverDiffVarSequence seq;      SolverDiffVarSequence seq;
197    
# Line 183  static int integrator_ida_create_lists(I Line 199  static int integrator_ida_create_lists(I
199      asc_assert(sys->ydot==NULL);      asc_assert(sys->ydot==NULL);
200      asc_assert(sys->y_id== NULL);      asc_assert(sys->y_id== NULL);
201    
202        CONSOLE_DEBUG("BEFORE MAKING LISTS");
203        integrator_ida_analyse_debug(sys,stderr);
204    
205      /* get the the dervative chains from the system */      /* get the the dervative chains from the system */
206      diffvars = slv_get_diffvars(sys->system);      diffvars = slv_get_diffvars(sys->system);
207      if(diffvars==NULL){      if(diffvars==NULL){
# Line 196  static int integrator_ida_create_lists(I Line 215  static int integrator_ida_create_lists(I
215      sys->ydot = ASC_NEW_ARRAY_CLEAR(struct var_variable *,sys->n_y);      sys->ydot = ASC_NEW_ARRAY_CLEAR(struct var_variable *,sys->n_y);
216      j = 0;      j = 0;
217    
218        CONSOLE_DEBUG("Passing through chains...");
219    
220      /* add the variables from the derivative chains */      /* add the variables from the derivative chains */
221      for(i=0; i<diffvars->nseqs; ++i){      for(i=0; i<diffvars->nseqs; ++i){
222    
223            CONSOLE_DEBUG("i = %d",i);
224                
225          seq = diffvars->seqs[i];          seq = diffvars->seqs[i];
226          asc_assert(seq.n >= 1);          asc_assert(seq.n >= 1);
227          v = seq.vars[0];          v = seq.vars[0];
228    
229            varname = var_make_name(sys->system, v);
230            CONSOLE_DEBUG("alg '%s'",varname);
231            ASC_FREE(varname);
232    
233    
234          if(!var_apply_filter(v,&integrator_ida_nonderiv)){          if(!var_apply_filter(v,&integrator_ida_nonderiv)){
235              continue;              continue;
236          }          }
237    
238            varname = var_make_name(sys->system, v);
239            CONSOLE_DEBUG("alg '%s' is GOOD",varname);
240            ASC_FREE(varname);
241    
242          if(seq.n > 1 && var_apply_filter(seq.vars[1],&integrator_ida_deriv)){          if(seq.n > 1 && var_apply_filter(seq.vars[1],&integrator_ida_deriv)){
243              asc_assert(var_sindex(seq.vars[1])-sys->n_y >= 0);              asc_assert(var_sindex(seq.vars[1]) >= sys->n_y);
244              asc_assert(var_sindex(seq.vars[1])-sys->n_y < sys->n_y);              asc_assert(var_sindex(seq.vars[1])-sys->n_y < sys->n_y);
245              sys->y_id[var_sindex(seq.vars[1])-sys->n_y] = j;  
246                varname = var_make_name(sys->system, seq.vars[1]);
247                CONSOLE_DEBUG("diff '%s' IS GOOD",varname);
248                ASC_FREE(varname);
249    
250                sys->y_id[var_sindex(seq.vars[1]) - sys->n_y] = j;
251              sys->ydot[j] = seq.vars[1];              sys->ydot[j] = seq.vars[1];
252          }else{          }else{
253              asc_assert(sys->ydot[j]==NULL);              asc_assert(sys->ydot[j]==NULL);
# Line 218  static int integrator_ida_create_lists(I Line 257  static int integrator_ida_create_lists(I
257          j++;          j++;
258      }      }
259    
260        CONSOLE_DEBUG("AFTER MAKING LISTS");
261        integrator_ida_analyse_debug(sys,stderr);
262    
263      return 0;      return 0;
264  }  }
265    
# Line 545  int integrator_ida_diffindex(const Integ Line 587  int integrator_ida_diffindex(const Integ
587  }  }
588    
589    
590    /**
591        This function will output the data structures provided to use BY THE
592        SYSTEM -- not the ones we're working with here IN THE SOLVER.
593    */
594  int integrator_ida_analyse_debug(const IntegratorSystem *sys,FILE *fp){  int integrator_ida_analyse_debug(const IntegratorSystem *sys,FILE *fp){
595      return analyse_diffvars_debug(sys->system,fp);      return analyse_diffvars_debug(sys->system,fp);
596  }  }

Legend:
Removed from v.1240  
changed lines
  Added in v.1241

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