#include #include #include #include #include "xpplim.h" #include "getvar.h" #define MAXDAE 400 extern double variables[]; extern int NVAR; extern int DelayErr; extern double EVEC_ERR,NEWT_ERR,BOUND; extern int EVEC_ITER; double evaluate(); extern int NODE,FIX_VAR; extern int *my_ode[]; double sdot(); /* will have more stuff someday */ typedef struct { double *work; int *iwork; int status; } DAEWORK; DAEWORK dae_work; typedef struct { char name[12],*rhs; int *form; int index; double value,last; }SOL_VAR; typedef struct { char *rhs; int *form; } DAE_EQN; SOL_VAR svar[MAXDAE]; DAE_EQN aeqn[MAXDAE]; int nsvar=0,naeqn=0; /* this adds an algebraically defined variable and a formula for the first guess */ add_svar(name,rhs) char *name,*rhs; { if(nsvar>=MAXDAE){ printf(" Too many variables\n"); return 1; } strcpy(svar[nsvar].name,name); svar[nsvar].rhs=(char *) malloc(80); strcpy(svar[nsvar].rhs,rhs); printf(" Added sol-var[%d] %s = %s \n", nsvar,svar[nsvar].name,svar[nsvar].rhs); nsvar++; return 0; } /* adds algebraically define name to name list */ add_svar_names() { int i; for(i=0;i=MAXDAE){ printf(" Too many equations\n"); return 1; } aeqn[naeqn].rhs=(char *) malloc(strlen(rhs)+5); strcpy(aeqn[naeqn].rhs,rhs); naeqn++; return 0; } /* this compiles formulas to set to zero */ compile_svars() { int i,f[256],n,k; if(nsvar!=naeqn){ printf(" #SOL_VAR(%d) must equal #ALG_EQN(%d) ! \n",nsvar,naeqn); return 1; } for(i=0;i(n*BOUND)){ for(i=0;imaxit){ /* printf(" Too many iterates ... \n"); */ for(i=0;i