单参数Lyapunov指数.c ( File view )

  • By kezairenjian 2014-04-25
  • View(s):14
  • Download(s):0
  • Point(s): 1
			#include "stdio.h"
#include "math.h"
/*单参数最大Lyapunov指数程序*/
/*可以修改的部分包括五部分*/
/*1.函数function*/
/*2.划分的网格个数nx和ny*/
/*3.考察范围star 和 end*/
/*4.划分的步长个数 h*/
/*5.迭代的初值数组y[],个数需要和function对应*/
/****************************************/
/*******1离散系统的表达式function*******/ 
/***************在此修改***************/ 
#define nn 2 
void  function(y,wh)
double y[nn];
double wh;
{

 double yy[nn];
 
 /**/   
    	    
    yy[0] = y[0];
    yy[1] = y[1];
    y[0]=yy[0]+0.15*yy[0]*(129.0/10.0-(64.0*yy[1])/105.0-(148.0*yy[0])/105.0);                        
    y[1]=yy[1]+wh*yy[1]*(127.0/10.0-(148.0*yy[1])/105.0-(64.0*yy[0])/105.0);   	
 /**/
 

};

/*主函数*/
int  main(void)
  {

  int i,j,k,bj;
  double dis;
  double d0=1e-6; 
  double top_exp=0.0; 
  double flag1=0.0; 
  double y[nn],x[nn];
  double wh,star,end;
  int nx; 
  /*分岔参数的计算范围,起点和终点*/
  //////////////*******************************//////////////////////// 
                    star=0.0;
                     end=1.0;
                     nx=2000;
  //////////////*******************************//////////////////////// 
  double h=(end-star)/nx; 
  
  
  /*存储数据的文件*/
  FILE *fp1 = fopen("one_lyapunov.txt", "w");
  
  for(wh=star; wh<end; wh=wh+h)
  {
  
    if(flag1==1)
    {

	   printf("发散了 %f\n"); 
	   break;
    
};
    top_exp=0.0; 
    dis=0.0;
     /*初值在这里修改*/ 
       //////////////*******************************//////////////////////// 
	                     y[0]=1.0;
                         y[1]=1.0;             
       //////////////*******************************//////////////////////// 
    
	for(i=0;i<nn;i++)
	   {

		 x[i]=y[i];
	   
};
	x[0]=y[0]+d0;
	
    for(j=-100;j<=500;j++)
    {

	   for(k=1;k<=100;k++)
       {

       	 function(y,wh);		    
  	     function(x,wh);
  	     for(i=0;i<nn;i++)
	     {

   	      if(fabs(y[i])>1e5||fabs(x[i])>1e5)
   	      {

			flag1=1;
			break;
		  
}; 
	     
};
       
};
	   
	   if(flag1==1)
	   {

		  printf("发散了 %f\n");
		  break;
  	   
};	
		 		  
	   dis=0.0;			
	   for(i=0;i<nn;i++)
	   {

		  dis=dis+(x[i]-y[i])*(x[i]-y[i]);
	   
} 
	   dis=sqrt(dis);
       if(dis<1e-16)dis=1e-16;
       if(dis>1e16)dis=1e16; 
	   for(i=0;i<nn;i++)
	   {

		  x[i]=y[i]+(y[i]-x[i])*(sqrt(nn)*d0/dis);
	   
}
       if(j>0)
       {

		top_exp=top_exp+log10(dis/(sqrt(nn)*d0));
       
}
     
};
    top_exp= top_exp/(100*500); 
    fprintf(fp1, "%f  %f\n",wh,top_exp); 
    printf("wh=%f  %f\n ",wh,top_exp);
 
};
 return;

};
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
单参数Lyapunov指数.c2.58 kB09-04-14 08:31
单参数分岔3.c1.90 kB09-04-14 08:40
...
Sponsored links

单参数Lyapunov指数.c (2.10 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D