#include #include #include #include "shoot.h" /*#include #include */ #include #include "xpplim.h" #include "getvar.h" #define MAX_LEN_SBOX 25 #define ESCAPE 27 #define NOCHANGE 2 #define GOODSHOT 1 #define NUMICS -1 #define BADINT -4 #define ABORT -5 #define ABORT_ALL -6 #define TOOMANY -2 #define BADJAC -3 #define PARAM 1 #define IC 2 /* #define Set_ivar(a,b) variables[(a)]=(b) */ extern int DCURY; extern int RANGE_FLAG; int HOMOCLINIC_FLAG=0,Homo_n; extern int INFLAG; extern int NUPAR; extern int storind; extern float **storage; extern int *my_ode[]; extern int BVP_NL,BVP_NR,BVP_N,BVP_MAXIT; extern int FFT,HIST,DelayFlag,STORFLAG,POIMAP; extern int NCON,NCON_START,NSYM,NSYM_START; extern int BVP_FLAG,NODE,NEQ,NJMP,NMarkov,FIX_VAR,PrimeStart; extern double T0,TEND,DELTA_T; extern double BVP_TOL; extern double TRANS; extern double BVP_EPS; extern double variables[]; extern int NVAR; extern BC_STRUCT my_bc[MAXODE]; extern int color_line[11],MyStart; extern int NKernel; extern double MyData[MAXODE],MyTime; struct { char item[30]; int steps,side,cycle,movie; double plow,phigh; } shoot_range; extern char upar_names[MAXPAR][11]; extern char uvar_names[MAXODE][12]; double atof(); double evaluate(); typedef struct { int nunstab,nstab,n; /* dimension of unstable, stable, phasespace */ int eleft,eright; /* addresses of variables holding left and right equilibria */ int u0; /* address of first phase variable */ double cprev[1600],a[400]; int iflag[4]; double fb[400]; /* values of the boundary projections first nstab are proj to unstable mfld at left ane then the proj to the stabl mfld on the right */ } HOMOCLIN; extern HOMOCLIN my_hom; /* more general mixed boundary types */ do_bc(y__0,t0,y__1,t1,f,n) double *y__0,*y__1,*f; double t0,t1; int n; { int n0=PrimeStart; int i; if(HOMOCLINIC_FLAG) do_projection(y__0,t0,y__1,t1); SETVAR(0,t0); SETVAR(n0,t1); for(i=0;i-1) my_hom.eleft=i; else { err_msg("No such variable"); return 0; } i=find_user_name(IC,values[1]); if(i>-1) my_hom.eright=i; else { err_msg("No such variable"); return 0; } my_hom.nunstab=atoi(values[2]); my_hom.nstab=atoi(values[3]); my_hom.n=my_hom.nstab+my_hom.nunstab; Homo_n=my_hom.n; HOMOCLINIC_FLAG=1; for(i=0;i<4;i++) my_hom.iflag[i]=0; } return 1; } set_up_periodic(ipar,ivar,sect,ishow) int *ipar,*ivar,*ishow; double *sect; { static char *n[]={"Freq. Par.","*1Sect. Var","Section","Show(Y/N)"}; char values[4][MAX_LEN_SBOX]; int status,i; static char *yn[]={"N","Y"}; sprintf(values[0],"%s",upar_names[*ipar]); sprintf(values[1],"%s",uvar_names[*ivar]); sprintf(values[2],"%g",*sect); sprintf(values[3],"%s",yn[*ishow]); status=do_string_box(4,4,1,"Periodic BCs",n,values,45); if(status!=0){ i=find_user_name(PARAM,values[0]); if(i>-1) *ipar=i; else { err_msg("No such parameter"); return(0); } i=find_user_name(IC,values[1]); if(i>-1) *ivar=i; else { err_msg("No such variable"); return(0); } *sect=atof(values[2]); if(values[3][0]=='Y'||values[3][0]=='y')*ishow=1; else *ishow=0; return(1); } return(0); } find_bvp_com(int com) { int i,ierr,ishow=0,iret; int iper=0,ivar=0,ipar=0,pflag; double sect=0.0; double oldpar; double ystart[MAXODE],oldtrans; double yend[MAXODE]; /* Window temp=main_win; */ if(NMarkov>0||NKernel>0){ err_msg("Can't do BVP with integral or markov eqns"); return; } wipe_rep(); data_back(); compile_bvp(); if(FFT||HIST||DelayFlag||BVP_FLAG==0)return; STORFLAG=0; RANGE_FLAG=1; POIMAP=0; oldtrans=TRANS; TRANS=0.0; get_ic(1,ystart); switch(com){ case 0: do_sh_range(ystart,yend); return; case 4: set_up_homoclinic(); return; case 3: if(NUPAR==0)goto bye; pflag=set_up_periodic(&ipar,&ivar,§,&ishow); if(pflag==0)goto bye; iper=1; get_val(upar_names[ipar],&oldpar); break; case 2: ishow=1; iper=0; break; case 1: default: iper=0; break; } if(iper) bvshoot(ystart,yend,BVP_TOL,BVP_EPS,BVP_MAXIT,&iret,NODE,ishow, iper,ipar,ivar,sect); else bvshoot(ystart,yend,BVP_TOL,BVP_EPS,BVP_MAXIT,&iret,NODE,ishow,0,0,0,0.0 ); bad_shoot(iret); if(iret==1||iret==2) { get_ic(0,ystart); redraw_ics(); if(ishow){ reset_graphics(); } last_shot(1); INFLAG=1; refresh_browser(storind); auto_freeze_it(); ping(); } else if(iper)set_val(upar_names[ipar],oldpar); bye: TRANS=oldtrans; } last_shot(flag) int flag; { int i; double *x; x=&MyData[0]; MyStart=1; get_ic(2,x); STORFLAG=flag; MyTime=T0; if(flag){ storage[0][0]=(float)T0; extra(x,T0,NODE,NEQ); for(i=0;imaxit){ *iret=-2; goto bye; } /* Too many iterates */ /* create the Jacobian matrix ... */ for(j=0;j