Brusselator chemical oscillator

Dependencies:   mbed

main.cpp

Committer:
JLS
Date:
2010-12-31
Revision:
0:7db0029f15d6

File content as of revision 0:7db0029f15d6:

#include "TFT_4DGL.h"

TFT_4DGL lcd(p9,p10,p11);

int main() {

    double x1,y1,z1,x,y,z,t,dt;
    int   xp,yp;
   
    float a = 0.4;
    float A = 0.05;
    float b = 1.2;
    float c = 0.9;

    x1 = 0.3;
    y1 = 2;
    z1 = 0;
    
    dt = 0.02;

    while(1)
    
    {
    
        x = x1+(pow(x1,2)*y1-(b+1)*x1+a+A*sin(c*z1))*dt;
        y = y1+(-pow(x1,2)*y1+b*x1)*dt;
        z = z1+(c)*dt;
        t = t+dt;

        xp = -70+(int)floor(395*x);
        yp = -190+floor(125*y);

        lcd.pixel(yp,xp,WHITE);
      
        x1 = x;
        y1 = y;
        z1 = z;

    }
 
}