Wednesday, September 25, 2013

SIMULATION OF A SERVO SYSTEM USING VAN DER POL NON-LINEAR EQUATION

A servo system can be  described by the following second order differential equation:

                 (d2y/dt2) = P (1-y2)*(dy/dt) – Qy 

            Where P and Q are positive constants,  y is the  position coordinate which is a function of the time t.

This differential equation is the well-known Van der Pol non-linear equation.  To simulate this system , this second order differential equation is to be written as a set of two simultaneous equations of first order as follows:

By using the variable y1 in place of y, we get

                  dy1/dt = y2
                  dy2/dt = P(1- y12)* y2 - Qy1

Assuming constants P to be 0.1 and Q =1.0 and the initial conditions to be y1(0)=1.0 and y2(0)=0, our equation becomes:
                                   
                  dy1/dt = y2
                  dy2/dt = 0.1(1- y12)*y2- y1

The system has been simulated for 20 seconds with a step size of 0.001 seconds.  That is, 20000 computations have been done. The output is printed once for every  100 integration steps and the same has been plotted on graph.
-----------------------------------------------------------------------------------------------

#include < stdio.h >
#include < conio.h >
#include < math.h >
#include < stdlib.h >

void main()
 {
     clrscr();
     float t=0,y1=1,y2=0,h=0.001,u11,u12,u21,u22,u31,u32,u41,u42;
     long i;
     for(i=1;i<=20000;i++)
       {
        u11=h*y2;
        u12=h*(0.1*(1-y1*y1)*y2-y1);
        u21=h*(y2+0.5*u12);
        u22=h*(0.1*(1-(y1+0.5*u11)*(y1+0.5*u11))*(y2+0.5*u12)-(y1+0.5*u11));
        u31=h*(y2+0.5*u22);
  u32=h*(0.1*(1-(y1+0.5*u21)*(y1+0.5*u21))*(y2+0.5*u22)-(y1+0.5*u21));
        u41=h*(y2+u32);
u42=h*(0.1*(1-(y1+u31)*(y1+u31))*(y2+u32)-(y1+u31));
        y1=y1+(u11+2*u21+2*u31+u41)/6;
        y2=y2+(u12+2*u22+2*u32+u42)/6;
        t=t+h;
if(i%100==0)
        printf("%f     %f     %f \n", t,y1,y2)
     }
   getch();
}




  t     y1       y2     t      y1      y2  t       y1       y2
     t      y1      y2
0.1 0.995 -0.09984
3.7 -0.94681 0.59661
7.3 0.64308 -1.06776
10.901 -0.10418 1.40049
0.2 0.98007 -0.19871
3.8 -0.88247 0.6892
7.4 0.53293 -1.13381
11.001 0.03686 1.41794
0.3 0.95532 -0.29572
3.9 -0.80916 0.77593
7.5 0.41664 -1.19033
11.101 0.17893 1.42117
0.4 0.92101 -0.39002
4 -0.7275 0.85618
7.6 0.2952 -1.23656
11.201 0.32059 1.40944
0.5 0.87744 -0.48085
4.1 -0.63817 0.92928
7.7 0.1697 -1.27169
11.301 0.4603 1.38219
0.6 0.82498 -0.56749
4.2 -0.5419 0.99461
7.8 0.04126 -1.29494
11.401 0.5965 1.33911
0.7 0.7641 -0.64926
4.3 -0.43953 1.05149
7.9 -0.08887 -1.30555
11.501 0.7276 1.2802
0.8 0.69531 -0.7255
4.4 -0.33191 1.09925
8 -0.2194 -1.30286
11.601 0.85203 1.20582
0.9 0.6192 -0.79561
4.5 -0.22 1.13721
8.1 -0.34898 -1.28632
11.701 0.96827 1.11672
1 0.53642 -0.85895
4.6 -0.10482 1.16467
8.2 -0.47619 -1.25557
11.801 1.07492 1.014
1.1 0.44766 -0.91492
4.7 0.01256 1.181
8.3 -0.59962 -1.2105
11.901 1.17067 0.89912
1.2 0.3537 -0.96291
4.8 0.13099 1.18559
8.4 -0.71782 -1.15126
12.001 1.25439 0.77382
1.3 0.25536 -1.00231
4.9 0.24927 1.17796
8.5 -0.82941 -1.0783
12.101 1.32515 0.64003
1.4 0.15354 -1.03253
5 0.36616 1.15774
8.6 -0.93305 -0.99242
12.201 1.38218 0.4998
1.5 0.04918 -1.053
5.1 0.48039 1.12475
8.7 -1.0275 -0.89467
12.301 1.42496 0.35517
1.6 -0.05672 -1.06321
5.2 0.59068 1.07901
8.8 -1.11163 -0.78641
12.401 1.45314 0.20813
1.7 -0.1631 -1.06272
5.3 0.69578 1.02079
8.9 -1.18448 -0.66918
12.501 1.46657 0.0605
1.8 -0.26889 -1.05119
5.4 0.79444 0.9506
9 -1.24523 -0.5447
12.601 1.46527 -0.08607
1.9 -0.37297 -1.0284
5.5 0.88552 0.86921
9.1 -1.29324 -0.41473
12.702 1.44944 -0.23014
2 -0.4742 -0.99432
5.6 0.96795 0.77762
9.2 -1.32805 -0.28106
12.802 1.41937 -0.37052
2.1 -0.57146 -0.94905
5.7 1.04075 0.67704
9.3 -1.34938 -0.14538
12.902 1.37549 -0.50619
2.2 -0.66365 -0.89295
5.8 1.1031 0.56882
9.4 -1.35712 -0.0093
13.002 1.31831 -0.63634
2.3 -0.7497 -0.82653
5.9 1.15431 0.45445
9.5 -1.35128 0.12574
13.102 1.24843 -0.76025
2.4 -0.82863 -0.75052
6 1.19383 0.33545
9.6 -1.33204 0.25848
13.202 1.16649 -0.87734
2.5 -0.89952 -0.66584
6.1 1.22129 0.21333
9.7 -1.2997 0.38781
13.302 1.07321 -0.98704
2.6 -0.96155 -0.57354
6.2 1.23645 0.08957
9.8 -1.25463 0.51278
13.402 0.96935 -1.08879
2.7 -1.01401 -0.4748
6.3 1.2392 -0.03446
9.9 -1.19731 0.6326
13.502 0.85574 -1.18201
2.8 -1.05633 -0.3709
6.4 1.22959 -0.1575
10 -1.1283 0.74654
13.602 0.73325 -1.26603
2.9 -1.08806 -0.26311
6.5 1.20777 -0.27841
10.1 -1.04822 0.85397
13.702 0.60286 -1.3401
3 -1.10887 -0.15274
6.6 1.17401 -0.39619
10.2 -0.95774 0.9543
13.802 0.46559 -1.40337
3.1 -1.11856 -0.04105
6.7 1.12867 -0.50994
10.301 -0.85762 1.0469
13.902 0.32258 -1.45487
3.2 -1.11707 0.07079
6.8 1.07218 -0.61888
10.401 -0.74864 1.13114
14.002 0.17504 -1.4936
3.3 -1.10444 0.18166
6.9 1.00507 -0.7223
10.501 -0.63169 1.20633
14.102 0.02432 -1.51848
3.4 -1.08081 0.29056
7 0.92793 -0.81953
10.601 -0.50771 1.27171
14.202 -0.12816 -1.52848
3.5 -1.04642 0.39656
7.1 0.84139 -0.90995
10.701 -0.3777 1.32646
14.302 -0.28085 -1.52262
3.6 -1.00162 0.49883
7.2 0.74619 -0.99291
10.801 -0.2428 1.3697
14.402 -0.43213 -1.50013




























































     t          y1        y2              t      y1      y2







14.502 -0.5803 -1.46047
18.402 1.51587 0.68195







14.602 -0.72364 -1.40344
18.501 1.57595 0.51887







14.702 -0.86042 -1.32926
18.601 1.61952 0.3522







14.802 -0.98894 -1.23856
18.701 1.64635 0.18429







14.902 -1.10761 -1.13245
18.801 1.65641 0.01728







15.002 -1.21497 -1.01247
18.901 1.64989 -0.14705







15.102 -1.30971 -0.8805
19.001 1.62714 -0.3072







15.203 -1.39074 -0.73868
19.101 1.58863 -0.46201







15.303 -1.45719 -0.58933
19.201 1.53495 -0.61059







15.403 -1.50843 -0.43478
19.301 1.46675 -0.75224







15.503 -1.54405 -0.27729
19.401 1.38475 -0.88646







15.603 -1.56386 -0.11896
19.501 1.28972 -1.01279







15.703 -1.56788 0.03834
19.601 1.18247 -1.13082







15.803 -1.55628 0.19301
19.701 1.06384 -1.24011







15.903 -1.52941 0.34371
19.801 0.93475 -1.34013







16.003 -1.48771 0.48937
19.901 0.79615 -1.4302







16.103 -1.43173 0.62913
20.001 0.64907 -1.50953







16.203 -1.3621 0.7623











16.303 -1.27951 0.88833











16.403 -1.18469 1.00672











16.503 -1.07844 1.11698











16.603 -0.96158 1.21858











16.702 -0.83503 1.31091











16.802 -0.69973 1.39326











16.902 -0.55674 1.46478











17.002 -0.40717 1.52448











17.102 -0.25227 1.57126











17.202 -0.09339 1.60395











17.302 0.06801 1.62134











17.402 0.23033 1.62226











17.502 0.39188 1.60569











17.602 0.55086 1.57086











17.702 0.70542 1.51733











17.802 0.8537 1.4451











17.902 0.99384 1.35468











18.002 1.12406 1.24709











18.102 1.24274 1.12389











18.202 1.34839 0.98704











18.302 1.43977 0.83888















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































No comments: