/[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 941 by johnpye, Fri Nov 24 10:46:32 2006 UTC revision 942 by johnpye, Sat Nov 25 05:26:47 2006 UTC
# Line 25  Line 25 
25      integration engines.      integration engines.
26  */  */
27  #include <time.h>  #include <time.h>
28    #include <string.h>
29  #include "integrator.h"  #include "integrator.h"
30  #include "lsode.h"  #include "lsode.h"
31  #include "ida.h"  #include "ida.h"
32    #include "slv_common.h"
33    #include <utilities/ascPanic.h>
34    
35  #include "samplelist.h"  #include "samplelist.h"
36    
# Line 176  void integrator_free(IntegratorSystem *s Line 179  void integrator_free(IntegratorSystem *s
179      if(sys->ydot != NULL && !sys->ydotcount)ASC_FREE(sys->ydot);      if(sys->ydot != NULL && !sys->ydotcount)ASC_FREE(sys->ydot);
180      if(sys->obs != NULL && !sys->obscount)ASC_FREE(sys->obs);      if(sys->obs != NULL && !sys->obscount)ASC_FREE(sys->obs);
181    
182      ascfree(sys);      slv_destroy_parms(&(sys->params));
183    
184        ASC_FREE(sys);
185        CONSOLE_DEBUG("Destroyed IntegratorSystem");
186      sys=NULL;      sys=NULL;
187  }  }
188    
# Line 258  void integrator_create_engine(Integrator Line 264  void integrator_create_engine(Integrator
264  }  }
265    
266  /*------------------------------------------------------------------------------  /*------------------------------------------------------------------------------
267      PARAMETERS
268    */
269    
270    /**
271        Reset the parameters in this IntegratorSystem to the default ones for this
272        Integrator.
273    
274        @return 0 on success, 1 on error
275    */
276    static int integrator_params_default(IntegratorSystem *sys){
277        switch(sys->engine){
278            case INTEG_LSODE: return integrator_lsode_params_default(sys);
279    #ifdef ASC_WITH_IDA
280            case INTEG_IDA: return integrator_ida_params_default(sys);
281    #endif
282            default: return 0;
283        }
284    }
285    
286    int integrator_params_get(const IntegratorSystem *sys, slv_parameters_t *parameters){
287        asc_assert(sys!=NULL);
288        asc_assert(sys->params.num_parms > 0);
289        memcpy(parameters,&(sys->params),sizeof(slv_parameters_t));
290        return 0;
291    }
292    
293    int integrator_params_set(IntegratorSystem *sys, const slv_parameters_t *parameters){
294        asc_assert(sys!=NULL);
295        asc_assert(parameters!=NULL);
296        memcpy(&(sys->params),parameters,sizeof(slv_parameters_t));
297        return 0;
298    }
299    
300    /*------------------------------------------------------------------------------
301    ANALYSIS    ANALYSIS
302    
303    Provide two modes in order to provide analysis suitable for solution of both    Provide two modes in order to provide analysis suitable for solution of both
# Line 476  int integrator_analyse_dae(IntegratorSys Line 516  int integrator_analyse_dae(IntegratorSys
516          if(info->derivative_of)continue;          if(info->derivative_of)continue;
517          if(info->derivative){          if(info->derivative){
518              sys->y[yindex] = info->i;              sys->y[yindex] = info->i;
519                assert(info->derivative);
520              sys->ydot[yindex] = info->derivative->i;              sys->ydot[yindex] = info->derivative->i;
521              if(info->varindx >= 0){              if(info->varindx >= 0){
522                  sys->y_id[info->varindx] = yindex;                  sys->y_id[info->varindx] = yindex;
# Line 771  static int integrator_check_indep_var(In Line 812  static int integrator_check_indep_var(In
812      info->type=TYPE; \      info->type=TYPE; \
813      info->index=INDEX; \      info->index=INDEX; \
814      info->i=VAR; \      info->i=VAR; \
815        info->derivative=NULL; \
816        info->derivative_of=NULL; \
817      if(VARINDX==NULL){ \      if(VARINDX==NULL){ \
818          info->varindx = -1; \          info->varindx = -1; \
819      }else{ \      }else{ \

Legend:
Removed from v.941  
changed lines
  Added in v.942

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