/[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 920 by johnpye, Thu Nov 2 21:34:59 2006 UTC revision 921 by johnpye, Mon Nov 6 07:49:06 2006 UTC
# Line 126  static void IntegInitSymbols(void); Line 126  static void IntegInitSymbols(void);
126  /**  /**
127      Create a new IntegratorSystem and assign a slv_system_t to it.      Create a new IntegratorSystem and assign a slv_system_t to it.
128  */  */
129  IntegratorSystem *integrator_new(slv_system_t sys, struct Instance *inst){  IntegratorSystem *integrator_new(slv_system_t slvsys, struct Instance *inst){
130      IntegratorSystem *intsys;      IntegratorSystem *sys;
131    
132      if (sys == NULL) {      if (slvsys == NULL) {
133          ERROR_REPORTER_HERE(ASC_PROG_ERR,"sys is NULL!");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"slvsys is NULL!");
134          return NULL;          return NULL;
135      }      }
136    
137      intsys = ASC_NEW_CLEAR(IntegratorSystem);      sys = ASC_NEW_CLEAR(IntegratorSystem);
138      intsys->system = sys;      sys->system = slvsys;
139      intsys->instance = inst;      sys->instance = inst;
140      return intsys;  
141        sys->states = NULL; sys->derivs = NULL;
142        sys->dynvars = NULL; sys->obslist = NULL; sys->indepvars = NULL;
143    
144        sys->y_id = NULL;
145        sys->obs_id = NULL;
146        sys->y = NULL;
147        sys->ydot = NULL;
148        sys->obs = NULL;
149        return sys;
150  }  }
151    
152  /**  /**
# Line 160  void integrator_free(IntegratorSystem *s Line 169  void integrator_free(IntegratorSystem *s
169      if(sys->obslist != NULL)gl_free_and_destroy(sys->obslist);    /* and obslist */      if(sys->obslist != NULL)gl_free_and_destroy(sys->obslist);    /* and obslist */
170      if (sys->indepvars != NULL)gl_free_and_destroy(sys->indepvars);  /* and indepvars */      if (sys->indepvars != NULL)gl_free_and_destroy(sys->indepvars);  /* and indepvars */
171    
172      if(sys->y_id != NULL)ascfree(sys->y_id);      /* if(sys->y_id != NULL)ASC_FREE(sys->y_id); */
173      if(sys->obs_id != NULL)ascfree(sys->obs_id);      if(sys->obs_id != NULL)ASC_FREE(sys->obs_id);
174    
175      if(sys->y != NULL && !sys->ycount)ascfree(sys->y);      if(sys->y != NULL && !sys->ycount)ASC_FREE(sys->y);
176      if(sys->ydot != NULL && !sys->ydotcount)ascfree(sys->ydot);      if(sys->ydot != NULL && !sys->ydotcount)ASC_FREE(sys->ydot);
177      if(sys->obs != NULL && !sys->obscount)ascfree(sys->obs);      if(sys->obs != NULL && !sys->obscount)ASC_FREE(sys->obs);
178    
179      ascfree(sys);      ascfree(sys);
180      sys=NULL;      sys=NULL;
# Line 534  int integrator_analyse_dae(IntegratorSys Line 543  int integrator_analyse_dae(IntegratorSys
543          There's something a bit fishy about fetching the varlist at this late stage...          There's something a bit fishy about fetching the varlist at this late stage...
544      */      */
545    
546      varlist = slv_get_master_var_list(sys->system);      varlist = slv_get_solvers_var_list(sys->system);
547      nvarlist = slv_get_num_master_vars(sys->system);      nvarlist = slv_get_num_solvers_vars(sys->system);
548    
549      CONSOLE_DEBUG("WORKING THROUGH THE MASTER VAR LIST %d",nvarlist);      CONSOLE_DEBUG("WORKING THROUGH THE SOLVER'S VAR LIST %d",nvarlist);
550    
551      sys->y_id = ASC_NEW_ARRAY(long, nvarlist);      sys->y_id = ASC_NEW_ARRAY(long, nvarlist);
552      for(i=0; i< nvarlist; ++i){      for(i=0; i< nvarlist; ++i){
# Line 560  int integrator_analyse_dae(IntegratorSys Line 569  int integrator_analyse_dae(IntegratorSys
569      for(i=0; i< nvarlist; ++i){      for(i=0; i< nvarlist; ++i){
570          if(sys->y_id[i] < 0){          if(sys->y_id[i] < 0){
571              varname = var_make_name(sys->system,varlist[i]);              varname = var_make_name(sys->system,varlist[i]);
572              CONSOLE_DEBUG("UNCONNECTED SOLVER VAR varlist[%d] = '%s' (probably fixed?)",i,varname);              CONSOLE_DEBUG("UNCONNECTED SOLVER VAR varlist[%d] = '%s' (%s)",i,varname,var_fixed(varlist[i])?"fixed":"not fixed");
573              ASC_FREE(varname);              ASC_FREE(varname);
574          }          }
575      }      }
# Line 866  void integrator_dae_classify_var(Integra Line 875  void integrator_dae_classify_var(Integra
875      assert(var != NULL && var_instance(var)!=NULL );      assert(var != NULL && var_instance(var)!=NULL );
876    
877      if( var_apply_filter(var,&vfilt) ) {      if( var_apply_filter(var,&vfilt) ) {
878            if(!var_active(var)){
879                CONSOLE_DEBUG("VARIABLE IS NOT ACTIVE");
880                return;
881            }
882    
883          if(!var_fixed(var)){          if(!var_fixed(var)){
884              /* get the ode_type and ode_id of this solver_var */              /* get the ode_type and ode_id of this solver_var */
# Line 879  void integrator_dae_classify_var(Integra Line 892  void integrator_dae_classify_var(Integra
892                  /* any other type of var is in the DAE system, at least for now */                  /* any other type of var is in the DAE system, at least for now */
893                  INTEG_ADD_TO_LIST(info,type,index,var,varindx,sys->dynvars);                  INTEG_ADD_TO_LIST(info,type,index,var,varindx,sys->dynvars);
894              }              }
895          }else{          }
896    #if 1
897    else{
898              /* fixed variable, only include it if ode_type == 1 */              /* fixed variable, only include it if ode_type == 1 */
899              type = DynamicVarInfo(var,&index);              type = DynamicVarInfo(var,&index);
900              if(type==INTEG_STATE_VAR){              if(type==INTEG_STATE_VAR){
901                  INTEG_ADD_TO_LIST(info,type,index,var,varindx,sys->dynvars);                  INTEG_ADD_TO_LIST(info,type,index,var,varindx,sys->dynvars);
902              }              }
903          }          }
904    #endif
905    
906          /* if the var's obs_id > 0, add it to the observation list */          /* if the var's obs_id > 0, add it to the observation list */
907          if(ObservationVar(var,&index) != NULL && index > 0L) {          if(ObservationVar(var,&index) != NULL && index > 0L) {

Legend:
Removed from v.920  
changed lines
  Added in v.921

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