Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State...

21
Cellular Automata

Transcript of Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State...

Page 1: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Cellular Automata

Page 2: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

CA Components

Transition Rule:

State of Neighbors/Self Last Time Step New State

Wolfram, S. 2002. A new kind of science. Wolfram Media, Inc. Champaign, IL. 1197+ pp.

Page 3: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Base 2 Binary Numbers

Digit position

8 7 6 5 4 3 2 1

Base 2 27 26 25 24 23 22 21 20

Value 128 64 32 16 8 4 2 1

Example 0 0 0 0 1 0 0 1

Value 8 1

Page 4: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Wolfram’s Binary Rule Numbers• 3 neighbor, 2 state CAs• General:

• Specific: Rule 2 + 4 + 8 + 16 = 30

Block diagram from http://mathworld.wolfram.com/ElementaryCellularAutomaton.html

7 6 5 4 3 2 1 0

27 26 25 24 23 22 21 20

4+2+1 4+2 4 + 1 4 2+1 2 1 0

http://atlas.wolfram.com/

Page 5: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Rule 18 Spreadsheet

• 18 = 0 0 0 1 0 0 1 0• 111 110 101 100 011 010 001 000

• =IF(OR(AND((A1=1),(B1=0),(C1=0)),AND((A1=0),(B1=0),(C1=1))),1,0)

• If • 1 0 0 or 0 0 1 • Then 1• Else 0

Page 6: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Rule 30 Spreadsheet• 30 = 0 0 0 1 1 1 1 0• 111 110 101 100 011 010 001 000

• =IF(OR(• AND((A1=1),(B1=0),(C1=0)),• AND((A1=0),(B1=1),(C1=1)),• AND((A1=0),(B1=1),(C1=0)),• AND((A1=0),(B1=0),(C1=1))),1,0)

• If • 1 0 0 or 0 1 1 or 0 1 0 or 0 0 1• Then 1• Else 0

Page 7: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Lattice Gas Cellular Automata

Page 8: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

FHP Lattice Gas Cellular AutomatonBit Value

128 64 32 16 8 4 2 1

A 0 0 0 0 0 0 0 1

B 0 0 0 0 0 0 1 0

C 0 0 0 0 0 1 0 0

D 0 0 0 0 1 0 0 0

E 0 0 0 1 0 0 0 0

F 0 0 1 0 0 0 0 0

S 0 1 0 0 0 0 0 0

R 1 0 0 0 0 0 0 0

• Fundamental basis is mass and momentum conservation

• All particles have the same mass and speed so that momentum conservation reduces to conservation of the vector sum of the velocities

• Maximum of 1 particle per direction

A

B

D

F E

C

S = Solid, R = RandomBoolean variables n = (n1, n2, …, n8)8 bits 256 possibilities

Page 9: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Zero net momentum, head-on, 2- and 3-particle collisions

Pre-collision Possible post-collision configurations

Pre-collision Post-collision

(Choose based on random bit R)

Page 10: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Unchangeable configurationsPre-collision Post-collision

All 5 and 6 particle collisions are similar; no configurations other than the original conserve momentum

No configurations other than the original conserve mass and momentum

Page 11: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Collision ‘Look up’ Table

• 256 Entries• Start with all

unchanged– ‘new configuration’ =

‘old configuration’

Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

0 0 0 0 0 0 0 0 0

1 0 0 0 0 0 0 0 1

2 0 0 0 0 0 0 1 0

3 0 0 0 0 0 0 1 1

255 1 1 1 1 1 1 1 1

Page 12: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Collision ‘Look up’ Table

• First 64 configurations (00000000 through 00111111) seventh bit (S) is 0

• Same is true for configurations 128 through 191 (10000000 through 10111111)

• Leave unchanged for the moment

Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

0 0 0 0 0 0 0 0 0

1 0 0 0 0 0 0 0 1

2 0 0 0 0 0 0 1 0

3 0 0 0 0 0 0 1 1

191 1 0 1 1 1 1 1 1

Page 13: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Collision ‘Look up’ Table

• Configurations 64 through 127 and 192 through 255 (01000000 through 01111111 and 11000000 through 11111111) are on solids

• Bounce back

In-State Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

64 0 1 0 0 0 0 0 0

65 0 1 0 0 0 0 0 1

66 0 1 0 0 0 0 1 0

127 0 1 1 1 1 1 1 1

Out-State Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

64 0 1 0 0 0 0 0 0

72 0 1 0 0 1 0 0 0

80 0 1 0 1 0 0 0 0

127 0 1 1 1 1 1 1 1

A

B

D

F E

C

Page 14: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Collision ‘Look up’ Table

• Two-particle head-on collisions

In-State Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

9 (AD)

0 0 0 0 1 0 0 1

137(AD)

1 0 0 0 1 0 0 1

A

B

D

F E

C

Out-State Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

18 (BE)

0 0 0 1 0 0 1 0

164(CF)

1 0 1 0 0 1 0 0

Page 15: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Collision ‘Look up’ Table

• Three-particle head-on collisions

In-State Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

21 (ACE)

0 0 0 1 0 1 0 1

42(BDF)

0 0 1 0 1 0 1 0

149 (ACE)

1 0 0 1 0 1 0 1

170(BDF)

1 0 1 0 1 0 1 0

A

B

D

F E

C

Out-State Bit Value

128R

64S

32F

16E

8D

4C

2B

1A

42 (BDF)

0 0 1 0 1 0 1 0

21(ACE)

0 0 0 1 0 1 0 1

170(BDF)

1 0 1 0 1 0 1 0

149 (ACE)

1 0 0 1 0 1 0 1

Page 16: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Remappings

Page 17: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Code• /* Put collisions */

• table[A + D] = B + E;• table[A + D + EPS] = C + F;• table[B + E) = C + F;• table[B + E + EPS] = A + D;• table[C + F] = A + D;• table[C + F + EPS] = B + E;

• table[A + C + E] = B + F + D;• table[B + D + F] = A + C + E;• table[A + C + E + EPS] = B + F + D;• table[B + D + F + EPS] = A + C + E;

Lgapack Version for the simulation of flow with lattice-gas automata. Copyright (C) 1997 D.H. Rothman and S. Zaleski.

http://www-ftp.lip6.fr/ftp/jussieu/labos/lmm/Lgapack/

In Unix/Linux:

Gunzip the .gz file

tar -xf the .tar file

In Windows:

Open archive or

Extract files

Page 18: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Matlab Script for Lgapack

• clear('all')• load x_mom• load y_mom• load mass• x_vel=x_mom./(2*mass)• y_vel=sqrt(3)*y_mom./(2*mass)• quiver(x_vel',y_vel')• axis equal

Page 19: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Exercise

• Theoretical viscosity (2 and 3-particle collisions only)

• Rearrange to solve for n from umax or umean

• Compare

2max 2

ag

u

8

1

)1(12

13

ff

Page 20: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,
Page 21: Cellular Automata. CA Components Transition Rule: State of Neighbors/Self Last Time Step New State Wolfram, S. 2002. A new kind of science. Wolfram Media,

Noise

• Need a lot of averaging• Real thermodynamics?