/[ascend]/branches/ksenija2/solvers/ida/idaanalyse.c
ViewVC logotype

Diff of /branches/ksenija2/solvers/ida/idaanalyse.c

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

revision 2858 by jpye, Sat Mar 21 13:13:27 2015 UTC revision 2859 by jpye, Sun Mar 22 01:40:44 2015 UTC
# Line 80  static int integrator_ida_check_vars(Int Line 80  static int integrator_ida_check_vars(Int
80  static int integrator_ida_flag_rels(IntegratorSystem *integ);  static int integrator_ida_flag_rels(IntegratorSystem *integ);
81  static int integrator_ida_sort_rels_and_vars(IntegratorSystem *integ);  static int integrator_ida_sort_rels_and_vars(IntegratorSystem *integ);
82  static int integrator_ida_create_lists(IntegratorSystem *integ);  static int integrator_ida_create_lists(IntegratorSystem *integ);
 static int integrator_ida_vars_debug(IntegratorSystem *integ);  
83  static int integrator_ida_check_index(IntegratorSystem *integ);  static int integrator_ida_check_index(IntegratorSystem *integ);
84    
85    static int integrator_ida_vars_debug(IntegratorSystem *integ);
86    static int integrator_ida_rels_debug(IntegratorSystem *integ);
87    
88  /*------------------------------------------------------------------------------  /*------------------------------------------------------------------------------
89    ANALYSIS ROUTINE (new implementation)    ANALYSIS ROUTINE (new implementation)
90  */  */
# Line 318  int integrator_ida_analyse(IntegratorSys Line 320  int integrator_ida_analyse(IntegratorSys
320      CONSOLE_DEBUG("rels matchbits:  0x%x",integrator_ida_rel.matchbits);      CONSOLE_DEBUG("rels matchbits:  0x%x",integrator_ida_rel.matchbits);
321      CONSOLE_DEBUG("rels matchvalue: 0x%x",integrator_ida_rel.matchvalue);      CONSOLE_DEBUG("rels matchvalue: 0x%x",integrator_ida_rel.matchvalue);
322    
323        integrator_ida_rels_debug(integ);
324    
325      CONSOLE_DEBUG("At the end of ida_analyse, there are %d rels active"      CONSOLE_DEBUG("At the end of ida_analyse, there are %d rels active"
326          ,slv_count_solvers_rels(integ->system, &integrator_ida_rel)          ,slv_count_solvers_rels(integ->system, &integrator_ida_rel)
327      );      );
# Line 550  static int integrator_ida_sort_rels_and_ Line 554  static int integrator_ida_sort_rels_and_
554          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem cutting derivs");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem cutting derivs");
555          return 1;          return 1;
556      }      }
557    #ifdef ANALYSE_DEBUG
558        CONSOLE_DEBUG("Cut %d derivatives to just after the non-derivatives",nydot);
559    #endif
560    
561      if(system_cut_rels(integ->system, 0, &integrator_ida_rel, &nr)){      if(system_cut_rels(integ->system, 0, &integrator_ida_rel, &nr)){
562          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem cutting derivs");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem cutting derivs");
563          return 1;          return 1;
564      }      }
565    
566    #if 0
567        /* TODO we need to work out if it's reasonable to return an error now, or not... */
568      if(ny1 != nr){      if(ny1 != nr){
569          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem is not square (ny = %d, nr = %d)",ny1,nr);          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Problem is not square (ny = %d, nr = %d)",ny1,nr);
570          return 2;          return 2;
571      }      }
572    #endif
573    
574      return 0;      return 0;
575  }  }
# Line 1067  int integrator_ida_block_check(Integrato Line 1077  int integrator_ida_block_check(Integrato
1077  #endif /* disused code */  #endif /* disused code */
1078    
1079  /*------------------------------------------------------------------------------  /*------------------------------------------------------------------------------
1080    DEBUGGING/OUTPUT ROUTINES    DEBUGGING/OUTPUT ROUTINES (should be moved to idaio.c)
1081  */  */
1082    
1083  /**  /**
# Line 1092  static int integrator_ida_vars_debug(Int Line 1102  static int integrator_ida_vars_debug(Int
1102    
1103  #define FSTRING " %-10s %-*s %6s %6s %6s %6s %6s"  #define FSTRING " %-10s %-*s %6s %6s %6s %6s %6s"
1104  #define AST(F) ((var_##F(v))?"*":"")  #define AST(F) ((var_##F(v))?"*":"")
1105      fprintf(stderr,"%4s" FSTRING "\n","","",lmax,"","incid","active","fixed","deriv","indep");      fprintf(stderr,"%6s" FSTRING "\n","sindex","",lmax,"","incid","active","fixed","deriv","indep");
1106      fprintf(stderr,"%4s" FSTRING "\n","","",lmax,"","-----","------","-----","-----","-----");      fprintf(stderr,"%6s" FSTRING "\n","------","",lmax,"","-----","------","-----","-----","-----");
1107      struct var_variable *v;      struct var_variable *v;
1108      for(i=0;i<integ->n_y;++i){      for(i=0;i<integ->n_y;++i){
1109          v = list[i];          v = list[i];
1110          fprintf(stderr,"%4d" FSTRING "\n",i,(integ->ydot?(integ->ydot[i]?"diff":"algeb"):"?"),lmax,name[i]          fprintf(stderr,"%6d" FSTRING "\n",i,(integ->ydot?(integ->ydot[i]?"diff":"algeb"):"?"),lmax,name[i]
1111              ,AST(incident),AST(active),AST(fixed),AST(deriv),AST(nonbasic)              ,AST(incident),AST(active),AST(fixed),AST(deriv),AST(nonbasic)
1112          );          );
1113      }      }
1114      fprintf(stderr,"-------\n");      fprintf(stderr,"%6s %-10s\n","","-------");
1115      for(i=integ->n_y;i<integ->n_y+integ->n_ydot;++i){      for(i=integ->n_y;i<integ->n_y+integ->n_ydot;++i){
1116          v = list[i];          v = list[i];
1117          fprintf(stderr,"%4d" FSTRING " (of %s)\n",i,"deriv",lmax,name[i]          fprintf(stderr,"%6d" FSTRING " (of %s)\n",i,"deriv",lmax,name[i]
1118              ,AST(incident),AST(active),AST(fixed),AST(deriv),AST(nonbasic)              ,AST(incident),AST(active),AST(fixed),AST(deriv),AST(nonbasic)
1119              ,integ->y_id?(name[integ->y_id[i - integ->n_y]]):"?"              ,integ->y_id?(name[integ->y_id[i - integ->n_y]]):"?"
1120          );          );
1121      }      }
1122      fprintf(stderr,"-------\n");      fprintf(stderr,"%6s %-10s\n","","-------");
1123      for(i=integ->n_y+integ->n_ydot;i<n;++i){      for(i=integ->n_y+integ->n_ydot;i<n;++i){
1124          v = list[i];          v = list[i];
1125          fprintf(stderr,"%4d" FSTRING "\n",i,"other",lmax,name[i]          fprintf(stderr,"%6d" FSTRING "\n",i,"other",lmax,name[i]
1126              ,AST(incident),AST(active),AST(fixed),AST(deriv),AST(nonbasic)              ,AST(incident),AST(active),AST(fixed),AST(deriv),AST(nonbasic)
1127          );          );
1128      }      }
1129      fprintf(stderr,"=======\n");      fprintf(stderr,"%6s %-10s\n","","=======");
1130  #undef FSTRING  #undef FSTRING
1131  #undef AST  #undef AST
1132      for(i=0;i<n;++i){      for(i=0;i<n;++i){
# Line 1127  static int integrator_ida_vars_debug(Int Line 1137  static int integrator_ida_vars_debug(Int
1137  }  }
1138    
1139    
1140    static int integrator_ida_rels_debug(IntegratorSystem *integ){
1141        struct rel_relation **list;
1142        int n, i;
1143        /* get all the rel names, get the length of the longest one */
1144        n = slv_get_num_solvers_rels(integ->system);
1145        list = slv_get_solvers_rel_list(integ->system);
1146        char *name[n]; // we'll need to free all these pointers later
1147        int lmax = 0;
1148        for(i=0;i<n;++i){
1149            name[i] = rel_make_name(integ->system,list[i]);
1150            int l = strlen(name[i]);
1151            if(l>lmax)lmax=l;
1152        }
1153    
1154    #define FSTRING " %-10s %-*s %4s %6s %4s %5s %4s %4s %4s"
1155    #define AST(F) ((rel_##F(r))?"*":"")
1156        fprintf(stderr,"%6s" FSTRING "\n","sindex","",lmax,"","incl","active","diff","cond","event","when","bbox");
1157        fprintf(stderr,"%6s" FSTRING "\n","------","",lmax,"","----","------","----","----","-----","----","----");
1158        struct rel_relation *r;
1159        for(i=0;i<n;++i){
1160            r = list[i];
1161            fprintf(stderr,"%6d" FSTRING "\n",i,(rel_differential(r)?"diff":"algeb")
1162                ,lmax,name[i]
1163                ,AST(included),AST(active),AST(differential),AST(conditional),AST(in_when),AST(in_event),AST(blackbox)
1164            );
1165        }
1166        fprintf(stderr,"%6s %-10s\n","","=======");
1167    #undef FSTRING
1168    #undef AST
1169        for(i=0;i<n;++i){
1170            ASC_FREE(name[i]);
1171        }
1172    }
1173    
1174    /*------------------------------------------------------------------------------
1175      UTILITY FUNCTIONS (used elsewhere, not only in this file)
1176    */
1177    
1178  /**  /**
1179      Given a derivative variable, return the index of its corresponding differential      Given a derivative variable, return the index of its corresponding differential
1180      variable in the y vector (and equivalently the var_sindex of the diff var)      variable in the y vector (and equivalently the var_sindex of the diff var)

Legend:
Removed from v.2858  
changed lines
  Added in v.2859

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