Presentation is loading. Please wait.

Presentation is loading. Please wait.

Numerical Algorithm for the Integrating SDEs (include Euler method)

Similar presentations


Presentation on theme: "Numerical Algorithm for the Integrating SDEs (include Euler method)"— Presentation transcript:

1 Numerical Algorithm for the Integrating SDEs (include Euler method)
Eui-Sun Lee Department of Physics Kangwon National University Stochastic Differential Equation(SDE): q(x): deterministic part of SDE: g(x)ㆍ (t): stochastic part of SDE. Random numbers : (t): Gaussian random variable with properties: < (t) > = 0, < (t1) (t2) > = (t1-t2).

2 Integral Algorithm for SDE
Taylor expansion of q(x) and g(x) about x=x(t) Taking the lowest term in the Taylor expansion: u(t): Gaussian random variable with properties: < u(t) > = 0 – mean zero, < u(ti) u(tj) > = ij – unit variance.

3 Integral Algorithm for SDE
In the Taylor expansion of g(x(s)), next-order contribution to (1) is Double integral Milshtein method Euler method ;Additive noise case

4 Solving a Stochastic Parametrically Force Pendulum
Milshtein method Initial value: Step width a number of steps for( i=0,1,2…,N){ #include<stdio.h> #include<stdlib.h> #include<math.h> #include<time.h> #define c 32767 int TN,N,SN,driver,mode; long double A,W,Beta,gamma1,x0,y01,t0,x,y,t,h,h1,k1,q1,p1,p2,yi,xi; long double f,g; long double g1,g2,Dg1,Dg2; long double Ut1,Ut2; char FOUTN[20]; FILE *FOUT; void INITIAL(); /* A routine 1 to give the initial conditions */ void MAP(); /* A routine 2 to plot maps in the A-x plane */ void TRANS(); /* A routine 3 to eliminate transient behaviors*/ void P(); /* A routine 4 for Poincare maps of the system of twodifferential equations */ void P1(); /* A routine 5 for Poincare maps of the system of twodifferential equations */ void Q1(); /* A routine 6 to return the value of Q1(x,y,t) of the system */ void Q2(); /* A routine 7 to return the value of Q2(x,y,t) of the system */ void G1(); /* A routine 6 to return the value of G1(x,y,t) of the system */ void G2(); /* A routine 7 to return the value of G2(x,y,t) of the system */ long double GRand();/* A routine 7 to return the value of U(t) */ void main() { int i,n; long double Ai,Af,An; time_t t; srand((unsigned) time(&t)); p2=2.0*M_PI; W=0.5; gamma1=0.1; k1=p2*gamma1; p1=p2*pow(W,2.0); Ai=0.3520;Af=0.3586;n=2000; xi=0.1; yi=0.7; TN=1000; SN=100; N=1000; h=1.0/N; INITIAL(); An=(Af-Ai)/n; for(i=0; i<=n; i++) A=Ai+i*An; q1=p2*A; x=xi;y=yi; x0=x;y01=y;t0=0; t=t0; MAP();xi=x;yi=y; } printf("Process Termination\n"); fclose(FOUT); /* A routine 1 to give the initial conditions */ void INITIAL() printf("\n INPUT THE NAME OF THE OUTPUT FILE\n"); scanf("%s",FOUTN); if((FOUT = fopen(FOUTN,"w"))==NULL){ printf("FILE OPEN ERROR...\n");exit(-1); /* A routine 2 to plot maps in the A-x plane */ void MAP() int j; TRANS(); if(x>=0.5) x = x - floor(x+0.5); if(x<-0.5) x = x + floor(0.5-x); for(j=0; j<SN; j++) P(); P(); fprintf(FOUT,"%20.16Lf %20.16Lf %20.16Lf\n",A,x,y); t0=t; x0=x; y01=y; /* A routine 3 to eliminate transient behaviors*/ void TRANS() int i; for(i=0; i<TN; i++){ P(); /* A routine 4 for Poincare maps of the system of two differential equations */ void P() double K11,K12; for(i=1;i<=N;i++) Q1();Q2(); G1();G2(); K11=f; K12=g; Ut1=GRand(); Ut2=GRand(); x=x0+sqrt(h)*Ut1*g1+h*(K11+0.5*g1*Dg1*pow(Ut1,2.0)); y=y01+sqrt(h)*Ut2*g2+h*(K12+0.5*g2*Dg2*pow(Ut2,2.0)); t=t0+h;t0=t;x0=x;y01=y; /* A routine 6 to return the value of Q1(x,y,t) of the system*/ void Q1() { f=y; } /* A routine 7 to return the value of Q2(x,y,t) of the system*/ void Q2() { g=-k1*y-(p1-q1*cos(p2*t))*sin(p2*x); } /* A routine 8 to return the value of G1(x,y,t) of the system*/ void G1() { g1=0.0000; Dg1=0.000;} /* A routine 9 to return the value of G2(x,y,t) of the system*/ void G2() { g2=0.0000; Dg2=0.000;} /* A routine 10 to return the value of Gaussian RandomNumber*/ long double GRand() /*time_t t; srand((unsigned) time(&t));*/ long double v1,v2,fac,r1,r2,r[2]; v1=1.0*((long double)rand()+1.)/((long double)RAND_MAX+2.); v2=1.0*((long double)rand()+1.)/((long double)RAND_MAX+2.); fac=sqrt(-2.0*log(v1)); r1=cos(2.0*M_PI*v2)*fac; r[1]=r1;/*Guassina dist random numbers*/ return r[1]; }

5 Bifurcation Diagram in the Stochastic PFP

6 Summary 1. Through the Euler Method, SDEs are solved numerically.


Download ppt "Numerical Algorithm for the Integrating SDEs (include Euler method)"

Similar presentations


Ads by Google