Kamil Ondrousek
/
Brusselator
Brusselator chemical oscillator
main.cpp@0:7db0029f15d6, 2010-12-31 (annotated)
- Committer:
- JLS
- Date:
- Fri Dec 31 16:54:57 2010 +0000
- Revision:
- 0:7db0029f15d6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JLS | 0:7db0029f15d6 | 1 | #include "TFT_4DGL.h" |
JLS | 0:7db0029f15d6 | 2 | |
JLS | 0:7db0029f15d6 | 3 | TFT_4DGL lcd(p9,p10,p11); |
JLS | 0:7db0029f15d6 | 4 | |
JLS | 0:7db0029f15d6 | 5 | int main() { |
JLS | 0:7db0029f15d6 | 6 | |
JLS | 0:7db0029f15d6 | 7 | double x1,y1,z1,x,y,z,t,dt; |
JLS | 0:7db0029f15d6 | 8 | int xp,yp; |
JLS | 0:7db0029f15d6 | 9 | |
JLS | 0:7db0029f15d6 | 10 | float a = 0.4; |
JLS | 0:7db0029f15d6 | 11 | float A = 0.05; |
JLS | 0:7db0029f15d6 | 12 | float b = 1.2; |
JLS | 0:7db0029f15d6 | 13 | float c = 0.9; |
JLS | 0:7db0029f15d6 | 14 | |
JLS | 0:7db0029f15d6 | 15 | x1 = 0.3; |
JLS | 0:7db0029f15d6 | 16 | y1 = 2; |
JLS | 0:7db0029f15d6 | 17 | z1 = 0; |
JLS | 0:7db0029f15d6 | 18 | |
JLS | 0:7db0029f15d6 | 19 | dt = 0.02; |
JLS | 0:7db0029f15d6 | 20 | |
JLS | 0:7db0029f15d6 | 21 | while(1) |
JLS | 0:7db0029f15d6 | 22 | |
JLS | 0:7db0029f15d6 | 23 | { |
JLS | 0:7db0029f15d6 | 24 | |
JLS | 0:7db0029f15d6 | 25 | x = x1+(pow(x1,2)*y1-(b+1)*x1+a+A*sin(c*z1))*dt; |
JLS | 0:7db0029f15d6 | 26 | y = y1+(-pow(x1,2)*y1+b*x1)*dt; |
JLS | 0:7db0029f15d6 | 27 | z = z1+(c)*dt; |
JLS | 0:7db0029f15d6 | 28 | t = t+dt; |
JLS | 0:7db0029f15d6 | 29 | |
JLS | 0:7db0029f15d6 | 30 | xp = -70+(int)floor(395*x); |
JLS | 0:7db0029f15d6 | 31 | yp = -190+floor(125*y); |
JLS | 0:7db0029f15d6 | 32 | |
JLS | 0:7db0029f15d6 | 33 | lcd.pixel(yp,xp,WHITE); |
JLS | 0:7db0029f15d6 | 34 | |
JLS | 0:7db0029f15d6 | 35 | x1 = x; |
JLS | 0:7db0029f15d6 | 36 | y1 = y; |
JLS | 0:7db0029f15d6 | 37 | z1 = z; |
JLS | 0:7db0029f15d6 | 38 | |
JLS | 0:7db0029f15d6 | 39 | } |
JLS | 0:7db0029f15d6 | 40 | |
JLS | 0:7db0029f15d6 | 41 | } |