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

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

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

revision 1067 by johnpye, Sun Jan 7 07:10:16 2007 UTC revision 1068 by johnpye, Mon Jan 8 04:45:47 2007 UTC
# Line 20  Line 20 
20      Access to the IDA integrator for ASCEND. IDA is a DAE solver that comes      Access to the IDA integrator for ASCEND. IDA is a DAE solver that comes
21      as part of the GPL-licensed SUNDIALS solver package from LLNL.      as part of the GPL-licensed SUNDIALS solver package from LLNL.
22    
23      IDA provides dense, banded and sparse solvers. At present this module only      IDA provides the non-linear parts, as well as a number of pluggable linear
24      implements access to the dense and sparse solvers, using the *serial*      solvers: dense, banded and krylov types.
25      vector methods.  
26        We also implement here an EXPERIMENTAL direct sparse linear solver for IDA
27        using the ASCEND linsolqr routines.
28    
29      @see http://www.llnl.gov/casc/sundials/      @see http://www.llnl.gov/casc/sundials/
30  *//*  *//*
# Line 95  Line 97 
97  #define STATS_DEBUG  #define STATS_DEBUG
98  #define PREC_DEBUG  #define PREC_DEBUG
99    
100    /* #define IDA_NEW_ANALYSE */
101    
102  /**  /**
103      Everthing that the outside world needs to know about IDA      Everthing that the outside world needs to know about IDA
104  */  */
105  const IntegratorInternals integrator_ida_internals = {  const IntegratorInternals integrator_ida_internals = {
106      integrator_ida_create      integrator_ida_create
107      ,integrator_ida_params_default      ,integrator_ida_params_default
108    #ifdef IDA_NEW_ANALYSE
109        ,integrator_ida_analyse
110    #else
111      ,integrator_analyse_dae /* note, this routine is back in integrator.c */      ,integrator_analyse_dae /* note, this routine is back in integrator.c */
112    #endif
113      ,integrator_ida_solve      ,integrator_ida_solve
114      ,integrator_ida_free      ,integrator_ida_free
115      ,INTEG_IDA      ,INTEG_IDA
# Line 413  int integrator_ida_params_default(Integr Line 421  int integrator_ida_params_default(Integr
421      return 0;      return 0;
422  }  }
423    
424    /*------------------------------------------------------------------------------
425      ANALYSIS ROUTINE (new implementation)
426    */
427    
428    int integrator_ida_analyse(struct IntegratorSystemStruct *sys){
429        struct gl_list_t *solversvars;
430        unsigned long nsolversvars, i, j, nderivs;
431        struct var_variable *v;
432        struct var_variable **derivs, **derivs2;
433        
434        asc_assert(sys->engine==INTEG_IDA);
435        
436        /* identify our independent variable, throw errors if count()!=1 */
437        if(!sys->indepvars || !gl_length(sys->indepvars)){
438            if(!integrator_find_indep_var(sys)){
439                ERROR_REPORTER_HERE(ASC_PROG_ERR,"No independent variable found: abandoning integration");
440                return 0;
441            }
442        }
443    
444        /* get our list of derivative variables */
445        derivs = ASC_NEW_ARRAY(struct var_variable *,nsolversvars);
446        if(derivs==NULL){
447            ERROR_REPORTER_HERE(ASC_PROG_ERR,"insufficient memory");
448            return -1;
449        }
450        j = 0;
451        solversvars = slv_get_solvers_var_list(sys->system);
452        for(i=1; i<=nsolversvars; ++i){
453            v = (struct var_variable *)gl_fetch(solversvars,i);
454            /* the solver has marked derivs already, so just test */
455            if(var_deriv(v)){
456                CONSOLE_DEBUG("Found derivative var %p",v);
457                derivs[j++] = v;
458            }
459        }
460        nderivs = j;
461        if(nderivs==0){
462            ERROR_REPORTER_HERE(ASC_USER_ERROR,"System is not a dynamic problem: contains no derivatives");
463            return 1;
464        }
465        
466        /* shrink the list down to size */
467        derivs2 = derivs;
468        derivs = ASC_NEW_ARRAY(struct var_variable *,nderivs);
469        memcpy(derivs,derivs2,nderivs*sizeof(struct var_variable *));
470        ASC_FREE(derivs2);
471    
472        CONSOLE_DEBUG("FOUND %lu DERIV VARS",nderivs);
473            
474    
475        /* partition into static, dynamic and output problems */
476    
477        /* raise error if any of the above are non-square */
478    
479        /* get our list of differential variables */
480    
481        /* get our list of algebraic varibles */
482    
483        /* set up the static problem */
484        /*   - rel, var (etc) lists */
485        /*   - block decomposition */
486    
487        /* set up the output problem */
488        /*   - rel, var (etc) lists */
489        /*   - block decomposition */
490    
491        /* set up the dynamic problem */
492        /*   - 'y' list as [ya|yd] */
493        /*   - sparsity pattern for dF/dy and dF/dy' */
494        /*   - sparsity pattern for union of above */
495        /*   - block decomposition based on above */
496        /*   - block decomposition results in reordering of y and y' */
497        /*   - boundaries (optional) */
498    
499        ERROR_REPORTER_HERE(ASC_PROG_ERR,"Not implemented");
500        return 1;
501    }
502    
503  /*-------------------------------------------------------------  /*-------------------------------------------------------------
504    MAIN IDA SOLVER ROUTINE, see IDA manual, sec 5.4, p. 27 ff.    MAIN IDA SOLVER ROUTINE, see IDA manual, sec 5.4, p. 27 ff.
505  */  */

Legend:
Removed from v.1067  
changed lines
  Added in v.1068

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